47 #define TMP_PREFIX "/tmp/gdbobj-"
99 error (
_(
"You must provide a filename for this command."));
111 error (
_(
"You must provide a filename with the raw option set."));
114 error (
_(
"Unknown argument specified."));
119 buffer =
xstrprintf (
"#include \"%s\"\n", arg);
150 error (
_(
"Unknown argument specified."));
185 const char *arg = arg_param;
217 const char *dir = arg;
222 zap = concat (
"rm -rf ", dir, (
char *) NULL);
223 wstat = system (zap);
225 warning (
_(
"Could not remove temporary directory %s"), dir);
235 static char *tempdir_name;
237 #define TEMPLATE TMP_PREFIX "XXXXXX"
240 if (tempdir_name != NULL)
246 tempdir_name = mkdtemp (tname);
248 error (
_(
"Command not supported on this host."));
250 if (tempdir_name == NULL)
253 tempdir_name = xstrdup (tempdir_name);
274 static const struct block *
303 *argcp = countargv (*argvp);
341 *argvp =
xrealloc (*argvp, (*argcp + argc + 1) *
sizeof (**argvp));
343 for (argi = 0; argi < argc; argi++)
344 (*argvp)[(*argcp)++] = xstrdup (argv[argi]);
345 (*argvp)[(*argcp)] = NULL;
361 if (symtab == NULL || symtab->
producer == NULL
366 while (*cs != 0 && *cs !=
'-')
380 for (destv = argv; *argv != NULL; argv++)
383 if (strcmp (*argv,
"-fpreprocessed") == 0)
400 int *argcp,
char ***argvp)
402 const char *cs_producer_options;
404 char **argv_compiler;
410 if (cs_producer_options != NULL)
413 char **argv_producer;
417 append_args (argcp, argvp, argc_producer, argv_producer);
418 freeargv (argv_producer);
422 &argc_compiler, &argv_compiler);
423 append_args (argcp, argvp, argc_compiler, argv_compiler);
424 freeargv (argv_compiler);
444 const char *filename = arg;
470 char *source_file, *object_file;
473 const struct block *expr_block;
486 error (
_(
"The program must be running for the compile command to "\
494 error (
_(
"No compiler support for this language."));
500 compiler->
scope = scope;
501 compiler->
block = expr_block;
522 else if (cmd_string != NULL)
525 error (
_(
"Neither a simple expression, or a multi-line specified."));
528 expr_block, expr_pc);
537 triplet_rx = concat (arch_rx,
"(-[^-]*)?-", os_rx, (
char *) NULL);
541 get_args (compiler, gdbarch, &argc, &argv);
544 error_message = compiler->
fe->ops->set_arguments (compiler->
fe, triplet_rx,
546 if (error_message != NULL)
549 error (
"%s", error_message);
557 for (argi = 0; argi < argc; argi++)
570 if (fputs (code, src) == EOF)
579 compiler->
fe->ops->set_source_file (compiler->
fe, source_file);
581 if (!compiler->
fe->ops->compile (compiler->
fe, object_file,
583 error (
_(
"Compilation failed."));
591 *source_filep = source_file;
611 char *object_file, *source_file;
614 if (object_file != NULL)
616 struct cleanup *cleanup_xfree, *cleanup_unlink;
625 if (compile_module == NULL)
657 if (regname[0] !=
'_' || regname[1] !=
'_')
658 error (
_(
"Invalid register name \"%s\"."), regname);
665 error (
_(
"Cannot find gdbarch register \"%s\"."), regname);
677 Command to compile source code and inject it into the inferior."),
678 &compile_command_list,
"compile ", 1, &
cmdlist);
683 Compile, inject, and execute code.\n\
685 Usage: compile code [-r|-raw] [--] [CODE]\n\
686 -r|-raw: Suppress automatic 'void _gdb_expr () { CODE }' wrapping.\n\
687 --: Do not parse any options beyond this delimiter. All text to the\n\
688 right will be treated as source code.\n\
690 The source code may be specified as a simple one line expression, e.g.:\n\
692 compile code printf(\"Hello world\\n\");\n\
694 Alternatively, you can type a multiline expression by invoking\n\
695 this command with no argument. GDB will then prompt for the\n\
696 expression interactively; type a line containing \"end\" to\n\
697 indicate the end of the expression."),
698 &compile_command_list);
702 Evaluate a file containing source code.\n\
704 Usage: compile file [-r|-raw] [filename]\n\
705 -r|-raw: Suppress automatic 'void _gdb_expr () { CODE }' wrapping."),
706 &compile_command_list);
711 Evaluate EXPR by using the compiler and print result.\n\
713 Usage: compile print[/FMT] [EXPR]\n\
715 The expression may be specified on the same line as the command, e.g.:\n\
719 Alternatively, you can type a multiline expression by invoking\n\
720 this command with no argument. GDB will then prompt for the\n\
721 expression interactively; type a line containing \"end\" to\n\
722 indicate the end of the expression.\n\
724 EXPR may be preceded with /FMT, where FMT is a format letter\n\
725 but no count or size letter (see \"x\" command)."),
726 &compile_command_list);
729 Set compile command debugging."),
_(
"\
730 Show compile command debugging."),
_(
"\
731 When on, compile command debugging is enabled."),
737 _(
"Set compile command GCC command-line arguments"),
738 _(
"Show compile command GCC command-line arguments"),
740 Use options like -I (include file directory) or ABI settings.\n\
741 String quoting is parsed like in shell, for example:\n\
742 -mno-align-double \"-I/dir with a space/include\""),
756 " -Wno-implicit-function-declaration"
757 " -Wno-unused-but-set-variable"
758 " -Wno-unused-variable"
760 " -fno-stack-protector"
struct cleanup * make_cleanup_freeargv(char **arg)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
CORE_ADDR get_frame_address_in_block(struct frame_info *this_frame)
static int check_raw_argument(char **arg)
void eval_compile_command(struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, void *scope_data)
struct frame_info * get_selected_frame(const char *message)
struct command_line::@48::@49 compile
union command_line::@48 control_u
char * gdb_abspath(const char *path)
CORE_ADDR get_frame_pc(struct frame_info *frame)
static void compile_print_command(char *arg_param, int from_tty)
enum command_control_type execute_control_command_untraced(struct command_line *cmd)
char *(* la_compute_program)(struct compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc)
void fputs_unfiltered(const char *buf, struct ui_file *file)
struct compile_module * compile_object_load(const char *object_file, const char *source_file, enum compile_i_scope_types scope, void *scope_data)
const char * gcc_target_options
const char * gdbarch_gnu_triplet_regexp(struct gdbarch *gdbarch)
static void do_rmdir(void *arg)
void warning(const char *fmt,...)
char * ui_file_xstrdup(struct ui_file *file, long *length)
const char * skip_to_space_const(const char *chp)
struct symtab_and_line get_current_source_symtab_and_line(void)
const char * osabi_triplet_regexp(enum gdb_osabi osabi)
int compile_register_name_demangle(struct gdbarch *gdbarch, const char *regname)
static const char * get_selected_pc_producer_options(void)
#define BLOCKVECTOR_BLOCK(blocklist, n)
struct cmd_list_element * cmdlist
FILE * gdb_fopen_cloexec(const char *filename, const char *opentype)
int gdbarch_num_regs(struct gdbarch *gdbarch)
static char ** compile_args_argv
char * skip_spaces(char *chp)
static char * compile_args
static char * compile_to_object(struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, char **source_filep)
char * compile_register_name_mangled(struct gdbarch *gdbarch, int regnum)
static void cleanup_compile_instance(void *arg)
static void append_args(int *argcp, char ***argvp, int argc, char **argv)
enum gdb_osabi gdbarch_osabi(struct gdbarch *gdbarch)
struct compunit_symtab * find_pc_compunit_symtab(CORE_ADDR pc)
struct command_line * get_command_line(enum command_control_type type, char *arg)
struct cmd_list_element * setlist
#define SYMTAB_BLOCKVECTOR(symtab)
int check_for_argument(char **str, char *arg, int arg_len)
struct cleanup * make_cleanup_restore_integer(int *variable)
void print_value(struct value *val, const struct format_data *fmtp)
void initialize_file_ftype(void)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
const char * skip_spaces_const(const char *chp)
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
static void build_argc_argv(const char *s, int *argcp, char ***argvp)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct compile_instance *(* la_get_compile_instance)(void)
struct cmd_list_element * showlist
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
enum compile_i_scope_types scope
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
static void set_compile_args(char *args, int from_tty, struct cmd_list_element *c)
void add_setshow_string_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct gdbarch * get_current_arch(void)
initialize_file_ftype _initialize_compile
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
static void show_compile_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static int startswith(const char *string, const char *pattern)
static int compile_args_argc
#define target_has_execution
char * xstrprintf(const char *format,...)
static void filter_args(int *argcp, char **argv)
struct cmd_list_element * setdebuglist
static void compile_file_command(char *arg, int from_tty)
struct ui_file * gdb_stdlog
struct ui_file * mem_fileopen(void)
static void print_callback(void *ignore, const char *message)
void(* destroy)(struct compile_instance *)
static void get_new_file_names(char **source_file, char **object_file)
PTR xrealloc(PTR ptr, size_t size)
struct command_line * next
static void cleanup_unlink_file(void *arg)
void discard_cleanups(struct cleanup *old_chain)
const struct language_defn * current_language
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
struct cleanup * make_cleanup_ui_file_delete(struct ui_file *arg)
enum compile_i_scope_types scope
void print_command_parse_format(const char **expp, const char *cmdname, struct format_data *fmtp)
struct gcc_base_context * fe
struct ui_file * gdb_stderr
static const char * get_compile_file_tempdir(void)
void compile_print_value(struct value *val, void *data_voidp)
static void show_compile_args(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void compile_code_command(char *arg, int from_tty)
char ** gdb_buildargv(const char *s)
static void compile_command(char *args, int from_tty)
struct cleanup * make_cleanup_free_command_lines(struct command_line **arg)
struct cleanup * make_final_cleanup(make_cleanup_ftype *function, void *arg)
const struct block * get_selected_block(CORE_ADDR *addr_in_block)
static struct cmd_list_element * compile_command_list
void compile_object_run(struct compile_module *module)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
const struct block * block
static const struct block * get_expr_block_and_pc(CORE_ADDR *pc)
struct cmd_list_element * showdebuglist
struct command_line ** body_list
void error(const char *fmt,...)
char * gdbarch_gcc_target_options(struct gdbarch *gdbarch)
void do_cleanups(struct cleanup *old_chain)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void get_args(const struct compile_instance *compiler, struct gdbarch *gdbarch, int *argcp, char ***argvp)