GDB (xrefs)
compile.c
Go to the documentation of this file.
1 /* General Compile and inject code
2 
3  Copyright (C) 2014-2015 Free Software Foundation, Inc.
4 
5  This file is part of GDB.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #include "defs.h"
21 #include "interps.h"
22 #include "ui-out.h"
23 #include "command.h"
24 #include "cli/cli-script.h"
25 #include "cli/cli-utils.h"
26 #include "completer.h"
27 #include "gdbcmd.h"
28 #include "compile.h"
29 #include "compile-internal.h"
30 #include "compile-object-load.h"
31 #include "compile-object-run.h"
32 #include "language.h"
33 #include "frame.h"
34 #include "source.h"
35 #include "block.h"
36 #include "arch-utils.h"
37 #include "filestuff.h"
38 #include "target.h"
39 #include "osabi.h"
40 #include "gdb_wait.h"
41 #include "valprint.h"
42 
43 
44 
45 /* Initial filename for temporary files. */
46 
47 #define TMP_PREFIX "/tmp/gdbobj-"
48 
49 /* Hold "compile" commands. */
50 
52 
53 /* Debug flag for "compile" commands. */
54 
56 
57 /* Implement "show debug compile". */
58 
59 static void
60 show_compile_debug (struct ui_file *file, int from_tty,
61  struct cmd_list_element *c, const char *value)
62 {
63  fprintf_filtered (file, _("Compile debugging is %s.\n"), value);
64 }
65 
66 
67 
68 /* Check *ARG for a "-raw" or "-r" argument. Return 0 if not seen.
69  Return 1 if seen and update *ARG. */
70 
71 static int
72 check_raw_argument (char **arg)
73 {
74  *arg = skip_spaces (*arg);
75 
76  if (arg != NULL
77  && (check_for_argument (arg, "-raw", sizeof ("-raw") - 1)
78  || check_for_argument (arg, "-r", sizeof ("-r") - 1)))
79  return 1;
80  return 0;
81 }
82 
83 /* Handle the input from the 'compile file' command. The "compile
84  file" command is used to evaluate an expression contained in a file
85  that may contain calls to the GCC compiler. */
86 
87 static void
88 compile_file_command (char *arg, int from_tty)
89 {
91  char *buffer;
92  struct cleanup *cleanup;
93 
96 
97  /* Check the user did not just <enter> after command. */
98  if (arg == NULL)
99  error (_("You must provide a filename for this command."));
100 
101  /* Check if a raw (-r|-raw) argument is provided. */
102  if (arg != NULL && check_raw_argument (&arg))
103  {
104  scope = COMPILE_I_RAW_SCOPE;
105  arg = skip_spaces (arg);
106  }
107 
108  /* After processing arguments, check there is a filename at the end
109  of the command. */
110  if (arg[0] == '\0')
111  error (_("You must provide a filename with the raw option set."));
112 
113  if (arg[0] == '-')
114  error (_("Unknown argument specified."));
115 
116  arg = skip_spaces (arg);
117  arg = gdb_abspath (arg);
118  make_cleanup (xfree, arg);
119  buffer = xstrprintf ("#include \"%s\"\n", arg);
120  make_cleanup (xfree, buffer);
121  eval_compile_command (NULL, buffer, scope, NULL);
122  do_cleanups (cleanup);
123 }
124 
125 /* Handle the input from the 'compile code' command. The
126  "compile code" command is used to evaluate an expression that may
127  contain calls to the GCC compiler. The language expected in this
128  compile command is the language currently set in GDB. */
129 
130 static void
131 compile_code_command (char *arg, int from_tty)
132 {
133  struct cleanup *cleanup;
135 
137  interpreter_async = 0;
138 
139  if (arg != NULL && check_raw_argument (&arg))
140  {
141  scope = COMPILE_I_RAW_SCOPE;
142  arg = skip_spaces (arg);
143  }
144 
145  arg = skip_spaces (arg);
146 
147  if (arg != NULL && !check_for_argument (&arg, "--", sizeof ("--") - 1))
148  {
149  if (arg[0] == '-')
150  error (_("Unknown argument specified."));
151  }
152 
153  if (arg && *arg)
154  eval_compile_command (NULL, arg, scope, NULL);
155  else
156  {
158 
160  l->control_u.compile.scope = scope;
162  }
163 
164  do_cleanups (cleanup);
165 }
166 
167 /* Callback for compile_print_command. */
168 
169 void
170 compile_print_value (struct value *val, void *data_voidp)
171 {
172  const struct format_data *fmtp = data_voidp;
173 
174  print_value (val, fmtp);
175 }
176 
177 /* Handle the input from the 'compile print' command. The "compile
178  print" command is used to evaluate and print an expression that may
179  contain calls to the GCC compiler. The language expected in this
180  compile command is the language currently set in GDB. */
181 
182 static void
183 compile_print_command (char *arg_param, int from_tty)
184 {
185  const char *arg = arg_param;
186  struct cleanup *cleanup;
188  struct format_data fmt;
189 
191  interpreter_async = 0;
192 
193  /* Passing &FMT as SCOPE_DATA is safe as do_module_cleanup will not
194  touch the stale pointer if compile_object_run has already quit. */
195  print_command_parse_format (&arg, "compile print", &fmt);
196 
197  if (arg && *arg)
198  eval_compile_command (NULL, arg, scope, &fmt);
199  else
200  {
202 
204  l->control_u.compile.scope = scope;
205  l->control_u.compile.scope_data = &fmt;
207  }
208 
209  do_cleanups (cleanup);
210 }
211 
212 /* A cleanup function to remove a directory and all its contents. */
213 
214 static void
215 do_rmdir (void *arg)
216 {
217  const char *dir = arg;
218  char *zap;
219  int wstat;
220 
222  zap = concat ("rm -rf ", dir, (char *) NULL);
223  wstat = system (zap);
224  if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
225  warning (_("Could not remove temporary directory %s"), dir);
226  XDELETEVEC (zap);
227 }
228 
229 /* Return the name of the temporary directory to use for .o files, and
230  arrange for the directory to be removed at shutdown. */
231 
232 static const char *
234 {
235  static char *tempdir_name;
236 
237 #define TEMPLATE TMP_PREFIX "XXXXXX"
238  char tname[sizeof (TEMPLATE)];
239 
240  if (tempdir_name != NULL)
241  return tempdir_name;
242 
243  strcpy (tname, TEMPLATE);
244 #undef TEMPLATE
245 #ifdef HAVE_MKDTEMP
246  tempdir_name = mkdtemp (tname);
247 #else
248  error (_("Command not supported on this host."));
249 #endif
250  if (tempdir_name == NULL)
251  perror_with_name (_("Could not make temporary directory"));
252 
253  tempdir_name = xstrdup (tempdir_name);
254  make_final_cleanup (do_rmdir, tempdir_name);
255  return tempdir_name;
256 }
257 
258 /* Compute the names of source and object files to use. The names are
259  allocated by malloc and should be freed by the caller. */
260 
261 static void
262 get_new_file_names (char **source_file, char **object_file)
263 {
264  static int seq;
265  const char *dir = get_compile_file_tempdir ();
266 
267  ++seq;
268  *source_file = xstrprintf ("%s%sout%d.c", dir, SLASH_STRING, seq);
269  *object_file = xstrprintf ("%s%sout%d.o", dir, SLASH_STRING, seq);
270 }
271 
272 /* Get the block and PC at which to evaluate an expression. */
273 
274 static const struct block *
276 {
277  const struct block *block = get_selected_block (pc);
278 
279  if (block == NULL)
280  {
282 
283  if (cursal.symtab)
284  block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
285  STATIC_BLOCK);
286  if (block != NULL)
287  *pc = BLOCK_START (block);
288  }
289  else
290  *pc = BLOCK_START (block);
291 
292  return block;
293 }
294 
295 /* Call gdb_buildargv, set its result for S into *ARGVP but calculate also the
296  number of parsed arguments into *ARGCP. If gdb_buildargv has returned NULL
297  then *ARGCP is set to zero. */
298 
299 static void
300 build_argc_argv (const char *s, int *argcp, char ***argvp)
301 {
302  *argvp = gdb_buildargv (s);
303  *argcp = countargv (*argvp);
304 }
305 
306 /* String for 'set compile-args' and 'show compile-args'. */
307 static char *compile_args;
308 
309 /* Parsed form of COMPILE_ARGS. COMPILE_ARGS_ARGV is NULL terminated. */
310 static int compile_args_argc;
311 static char **compile_args_argv;
312 
313 /* Implement 'set compile-args'. */
314 
315 static void
316 set_compile_args (char *args, int from_tty, struct cmd_list_element *c)
317 {
318  freeargv (compile_args_argv);
320 }
321 
322 /* Implement 'show compile-args'. */
323 
324 static void
325 show_compile_args (struct ui_file *file, int from_tty,
326  struct cmd_list_element *c, const char *value)
327 {
328  fprintf_filtered (file, _("Compile command command-line arguments "
329  "are \"%s\".\n"),
330  value);
331 }
332 
333 /* Append ARGC and ARGV (as parsed by build_argc_argv) to *ARGCP and *ARGVP.
334  ARGCP+ARGVP can be zero+NULL and also ARGC+ARGV can be zero+NULL. */
335 
336 static void
337 append_args (int *argcp, char ***argvp, int argc, char **argv)
338 {
339  int argi;
340 
341  *argvp = xrealloc (*argvp, (*argcp + argc + 1) * sizeof (**argvp));
342 
343  for (argi = 0; argi < argc; argi++)
344  (*argvp)[(*argcp)++] = xstrdup (argv[argi]);
345  (*argvp)[(*argcp)] = NULL;
346 }
347 
348 /* Return DW_AT_producer parsed for get_selected_frame () (if any).
349  Return NULL otherwise.
350 
351  GCC already filters its command-line arguments only for the suitable ones to
352  put into DW_AT_producer - see GCC function gen_producer_string. */
353 
354 static const char *
356 {
359  const char *cs;
360 
361  if (symtab == NULL || symtab->producer == NULL
362  || !startswith (symtab->producer, "GNU "))
363  return NULL;
364 
365  cs = symtab->producer;
366  while (*cs != 0 && *cs != '-')
368  if (*cs != '-')
369  return NULL;
370  return cs;
371 }
372 
373 /* Filter out unwanted options from *ARGCP and ARGV. */
374 
375 static void
376 filter_args (int *argcp, char **argv)
377 {
378  char **destv;
379 
380  for (destv = argv; *argv != NULL; argv++)
381  {
382  /* -fpreprocessed may get in commonly from ccache. */
383  if (strcmp (*argv, "-fpreprocessed") == 0)
384  {
385  xfree (*argv);
386  (*argcp)--;
387  continue;
388  }
389  *destv++ = *argv;
390  }
391  *destv = NULL;
392 }
393 
394 /* Produce final vector of GCC compilation options. First element is target
395  size ("-m64", "-m32" etc.), optionally followed by DW_AT_producer options
396  and then compile-args string GDB variable. */
397 
398 static void
399 get_args (const struct compile_instance *compiler, struct gdbarch *gdbarch,
400  int *argcp, char ***argvp)
401 {
402  const char *cs_producer_options;
403  int argc_compiler;
404  char **argv_compiler;
405 
407  argcp, argvp);
408 
409  cs_producer_options = get_selected_pc_producer_options ();
410  if (cs_producer_options != NULL)
411  {
412  int argc_producer;
413  char **argv_producer;
414 
415  build_argc_argv (cs_producer_options, &argc_producer, &argv_producer);
416  filter_args (&argc_producer, argv_producer);
417  append_args (argcp, argvp, argc_producer, argv_producer);
418  freeargv (argv_producer);
419  }
420 
422  &argc_compiler, &argv_compiler);
423  append_args (argcp, argvp, argc_compiler, argv_compiler);
424  freeargv (argv_compiler);
425 
427 }
428 
429 /* A cleanup function to destroy a gdb_gcc_instance. */
430 
431 static void
433 {
434  struct compile_instance *inst = arg;
435 
436  inst->destroy (inst);
437 }
438 
439 /* A cleanup function to unlink a file. */
440 
441 static void
443 {
444  const char *filename = arg;
445 
446  unlink (filename);
447 }
448 
449 /* A helper function suitable for use as the "print_callback" in the
450  compiler object. */
451 
452 static void
453 print_callback (void *ignore, const char *message)
454 {
455  fputs_filtered (message, gdb_stderr);
456 }
457 
458 /* Process the compilation request. On success it returns the object
459  file name and *SOURCE_FILEP is set to source file name. On an
460  error condition, error () is called. The caller is responsible for
461  freeing both strings. */
462 
463 static char *
464 compile_to_object (struct command_line *cmd, const char *cmd_string,
466  char **source_filep)
467 {
468  char *code;
469  const char *input;
470  char *source_file, *object_file;
471  struct compile_instance *compiler;
472  struct cleanup *cleanup, *inner_cleanup;
473  const struct block *expr_block;
474  CORE_ADDR trash_pc, expr_pc;
475  int argc;
476  char **argv;
477  int ok;
478  FILE *src;
479  struct gdbarch *gdbarch = get_current_arch ();
480  const char *os_rx;
481  const char *arch_rx;
482  char *triplet_rx;
483  char *error_message;
484 
486  error (_("The program must be running for the compile command to "\
487  "work."));
488 
489  expr_block = get_expr_block_and_pc (&trash_pc);
491 
492  /* Set up instance and context for the compiler. */
494  error (_("No compiler support for this language."));
496  cleanup = make_cleanup (cleanup_compile_instance, compiler);
497 
498  compiler->fe->ops->set_print_callback (compiler->fe, print_callback, NULL);
499 
500  compiler->scope = scope;
501  compiler->block = expr_block;
502 
503  /* From the provided expression, build a scope to pass to the
504  compiler. */
505  if (cmd != NULL)
506  {
507  struct ui_file *stream = mem_fileopen ();
508  struct command_line *iter;
509  char *stream_buf;
510 
512  for (iter = cmd->body_list[0]; iter; iter = iter->next)
513  {
514  fputs_unfiltered (iter->line, stream);
515  fputs_unfiltered ("\n", stream);
516  }
517 
518  stream_buf = ui_file_xstrdup (stream, NULL);
519  make_cleanup (xfree, stream_buf);
520  input = stream_buf;
521  }
522  else if (cmd_string != NULL)
523  input = cmd_string;
524  else
525  error (_("Neither a simple expression, or a multi-line specified."));
526 
527  code = current_language->la_compute_program (compiler, input, gdbarch,
528  expr_block, expr_pc);
529  make_cleanup (xfree, code);
530  if (compile_debug)
531  fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code);
532 
533  os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
534  arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
535 
536  /* Allow triplets with or without vendor set. */
537  triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL);
538  make_cleanup (xfree, triplet_rx);
539 
540  /* Set compiler command-line arguments. */
541  get_args (compiler, gdbarch, &argc, &argv);
542  make_cleanup_freeargv (argv);
543 
544  error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx,
545  argc, argv);
546  if (error_message != NULL)
547  {
548  make_cleanup (xfree, error_message);
549  error ("%s", error_message);
550  }
551 
552  if (compile_debug)
553  {
554  int argi;
555 
556  fprintf_unfiltered (gdb_stdlog, "Passing %d compiler options:\n", argc);
557  for (argi = 0; argi < argc; argi++)
558  fprintf_unfiltered (gdb_stdlog, "Compiler option %d: <%s>\n",
559  argi, argv[argi]);
560  }
561 
562  get_new_file_names (&source_file, &object_file);
563  inner_cleanup = make_cleanup (xfree, source_file);
564  make_cleanup (xfree, object_file);
565 
566  src = gdb_fopen_cloexec (source_file, "w");
567  if (src == NULL)
568  perror_with_name (_("Could not open source file for writing"));
569  make_cleanup (cleanup_unlink_file, source_file);
570  if (fputs (code, src) == EOF)
571  perror_with_name (_("Could not write to source file"));
572  fclose (src);
573 
574  if (compile_debug)
575  fprintf_unfiltered (gdb_stdlog, "source file produced: %s\n\n",
576  source_file);
577 
578  /* Call the compiler and start the compilation process. */
579  compiler->fe->ops->set_source_file (compiler->fe, source_file);
580 
581  if (!compiler->fe->ops->compile (compiler->fe, object_file,
582  compile_debug))
583  error (_("Compilation failed."));
584 
585  if (compile_debug)
586  fprintf_unfiltered (gdb_stdlog, "object file produced: %s\n\n",
587  object_file);
588 
589  discard_cleanups (inner_cleanup);
590  do_cleanups (cleanup);
591  *source_filep = source_file;
592  return object_file;
593 }
594 
595 /* The "compile" prefix command. */
596 
597 static void
598 compile_command (char *args, int from_tty)
599 {
600  /* If a sub-command is not specified to the compile prefix command,
601  assume it is a direct code compilation. */
602  compile_code_command (args, from_tty);
603 }
604 
605 /* See compile.h. */
606 
607 void
608 eval_compile_command (struct command_line *cmd, const char *cmd_string,
610 {
611  char *object_file, *source_file;
612 
613  object_file = compile_to_object (cmd, cmd_string, scope, &source_file);
614  if (object_file != NULL)
615  {
616  struct cleanup *cleanup_xfree, *cleanup_unlink;
618 
619  cleanup_xfree = make_cleanup (xfree, object_file);
620  make_cleanup (xfree, source_file);
621  cleanup_unlink = make_cleanup (cleanup_unlink_file, object_file);
622  make_cleanup (cleanup_unlink_file, source_file);
623  compile_module = compile_object_load (object_file, source_file,
624  scope, scope_data);
625  if (compile_module == NULL)
626  {
628  do_cleanups (cleanup_xfree);
629  eval_compile_command (cmd, cmd_string,
630  COMPILE_I_PRINT_VALUE_SCOPE, scope_data);
631  return;
632  }
633  discard_cleanups (cleanup_unlink);
634  do_cleanups (cleanup_xfree);
635  compile_object_run (compile_module);
636  }
637 }
638 
639 /* See compile/compile-internal.h. */
640 
641 char *
643 {
644  const char *regname = gdbarch_register_name (gdbarch, regnum);
645 
646  return xstrprintf ("__%s", regname);
647 }
648 
649 /* See compile/compile-internal.h. */
650 
651 int
653  const char *regname)
654 {
655  int regnum;
656 
657  if (regname[0] != '_' || regname[1] != '_')
658  error (_("Invalid register name \"%s\"."), regname);
659  regname += 2;
660 
661  for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++)
662  if (strcmp (regname, gdbarch_register_name (gdbarch, regnum)) == 0)
663  return regnum;
664 
665  error (_("Cannot find gdbarch register \"%s\"."), regname);
666 }
667 
669 
670 void
672 {
673  struct cmd_list_element *c = NULL;
674 
676  _("\
677 Command to compile source code and inject it into the inferior."),
678  &compile_command_list, "compile ", 1, &cmdlist);
679  add_com_alias ("expression", "compile", class_obscure, 0);
680 
682  _("\
683 Compile, inject, and execute code.\n\
684 \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\
689 \n\
690 The source code may be specified as a simple one line expression, e.g.:\n\
691 \n\
692  compile code printf(\"Hello world\\n\");\n\
693 \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);
699 
701  _("\
702 Evaluate a file containing source code.\n\
703 \n\
704 Usage: compile file [-r|-raw] [filename]\n\
705 -r|-raw: Suppress automatic 'void _gdb_expr () { CODE }' wrapping."),
706  &compile_command_list);
707  set_cmd_completer (c, filename_completer);
708 
710  _("\
711 Evaluate EXPR by using the compiler and print result.\n\
712 \n\
713 Usage: compile print[/FMT] [EXPR]\n\
714 \n\
715 The expression may be specified on the same line as the command, e.g.:\n\
716 \n\
717  compile print i\n\
718 \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\
723 \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);
727 
729 Set compile command debugging."), _("\
730 Show compile command debugging."), _("\
731 When on, compile command debugging is enabled."),
732  NULL, show_compile_debug,
734 
735  add_setshow_string_cmd ("compile-args", class_support,
736  &compile_args,
737  _("Set compile command GCC command-line arguments"),
738  _("Show compile command GCC command-line arguments"),
739  _("\
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\""),
744 
745  /* Override flags possibly coming from DW_AT_producer. */
746  compile_args = xstrdup ("-O0 -gdwarf-4"
747  /* We use -fPIE Otherwise GDB would need to reserve space large enough for
748  any object file in the inferior in advance to get the final address when
749  to link the object file to and additionally the default system linker
750  script would need to be modified so that one can specify there the
751  absolute target address.
752  -fPIC is not used at is would require from GDB to generate .got. */
753  " -fPIE"
754  /* We want warnings, except for some commonly happening for GDB commands. */
755  " -Wall "
756  " -Wno-implicit-function-declaration"
757  " -Wno-unused-but-set-variable"
758  " -Wno-unused-variable"
759  /* Override CU's possible -fstack-protector-strong. */
760  " -fno-stack-protector"
761  );
762  set_compile_args (compile_args, 0, NULL);
763 }
struct cleanup * make_cleanup_freeargv(char **arg)
Definition: utils.c:165
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)
Definition: cli-decode.c:338
CORE_ADDR get_frame_address_in_block(struct frame_info *this_frame)
Definition: frame.c:2248
static int check_raw_argument(char **arg)
Definition: compile.c:72
void eval_compile_command(struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, void *scope_data)
Definition: compile.c:608
struct frame_info * get_selected_frame(const char *message)
Definition: frame.c:1535
struct command_line::@48::@49 compile
union command_line::@48 control_u
char * gdb_abspath(const char *path)
Definition: utils.c:2945
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2217
static void compile_print_command(char *arg_param, int from_tty)
Definition: compile.c:183
enum command_control_type execute_control_command_untraced(struct command_line *cmd)
Definition: cli-script.c:645
bfd_vma CORE_ADDR
Definition: common-types.h:41
char *(* la_compute_program)(struct compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc)
Definition: language.h:389
void fputs_unfiltered(const char *buf, struct ui_file *file)
Definition: ui-file.c:252
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)
Definition: gdbarch.c:4723
void xfree(void *)
Definition: common-utils.c:97
static void do_rmdir(void *arg)
Definition: compile.c:215
void warning(const char *fmt,...)
Definition: errors.c:26
char * ui_file_xstrdup(struct ui_file *file, long *length)
Definition: ui-file.c:345
const char * skip_to_space_const(const char *chp)
Definition: common-utils.c:283
struct symtab_and_line get_current_source_symtab_and_line(void)
Definition: source.c:181
const char * osabi_triplet_regexp(enum gdb_osabi osabi)
Definition: osabi.c:103
int compile_register_name_demangle(struct gdbarch *gdbarch, const char *regname)
Definition: compile.c:652
compile_i_scope_types
Definition: defs.h:60
static const char * get_selected_pc_producer_options(void)
Definition: compile.c:355
#define BLOCKVECTOR_BLOCK(blocklist, n)
Definition: block.h:136
struct cmd_list_element * cmdlist
Definition: cli-cmds.c:103
FILE * gdb_fopen_cloexec(const char *filename, const char *opentype)
Definition: filestuff.c:304
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:1898
static char ** compile_args_argv
Definition: compile.c:311
char * skip_spaces(char *chp)
Definition: common-utils.c:259
const char * producer
Definition: symtab.h:1047
#define _(String)
Definition: gdb_locale.h:40
static char * compile_args
Definition: compile.c:307
#define BLOCK_START(bl)
Definition: block.h:116
static char * compile_to_object(struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, char **source_filep)
Definition: compile.c:464
char * compile_register_name_mangled(struct gdbarch *gdbarch, int regnum)
Definition: compile.c:642
static void cleanup_compile_instance(void *arg)
Definition: compile.c:432
static void append_args(int *argcp, char ***argvp, int argc, char **argv)
Definition: compile.c:337
enum gdb_osabi gdbarch_osabi(struct gdbarch *gdbarch)
Definition: gdbarch.c:1438
struct compunit_symtab * find_pc_compunit_symtab(CORE_ADDR pc)
Definition: symtab.c:3051
struct command_line * get_command_line(enum command_control_type type, char *arg)
Definition: cli-script.c:130
char * line
Definition: defs.h:400
struct cmd_list_element * setlist
Definition: cli-cmds.c:135
#define SYMTAB_BLOCKVECTOR(symtab)
Definition: symtab.h:968
int check_for_argument(char **str, char *arg, int arg_len)
Definition: cli-utils.c:277
#define SLASH_STRING
Definition: host-defs.h:58
struct cleanup * make_cleanup_restore_integer(int *variable)
Definition: utils.c:292
void print_value(struct value *val, const struct format_data *fmtp)
Definition: printcmd.c:962
void initialize_file_ftype(void)
Definition: defs.h:281
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2351
const char * skip_spaces_const(const char *chp)
Definition: common-utils.c:271
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition: cli-decode.c:159
static void build_argc_argv(const char *s, int *argcp, char ***argvp)
Definition: compile.c:300
#define WIFEXITED(w)
Definition: gdb_wait.h:44
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2361
struct compile_instance *(* la_get_compile_instance)(void)
Definition: language.h:373
struct cmd_list_element * showlist
Definition: cli-cmds.c:143
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
Definition: cli-decode.c:882
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
Definition: utils.c:2145
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)
Definition: cli-decode.c:192
enum compile_i_scope_types scope
Definition: defs.h:406
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:117
int interpreter_async
Definition: interps.c:46
static void set_compile_args(char *args, int from_tty, struct cmd_list_element *c)
Definition: compile.c:316
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)
Definition: cli-decode.c:585
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:781
#define gdb_assert(expr)
Definition: gdb_assert.h:33
initialize_file_ftype _initialize_compile
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
Definition: gdbarch.c:2117
static void show_compile_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: compile.c:60
static int startswith(const char *string, const char *pattern)
Definition: common-utils.h:75
static int compile_args_argc
Definition: compile.c:310
#define target_has_execution
Definition: target.h:1726
char * xstrprintf(const char *format,...)
Definition: common-utils.c:107
static void filter_args(int *argcp, char **argv)
Definition: compile.c:376
int regnum
Definition: aarch64-tdep.c:69
void * scope_data
Definition: defs.h:407
#define WEXITSTATUS(w)
Definition: gdb_wait.h:67
struct cmd_list_element * setdebuglist
Definition: cli-cmds.c:173
Definition: symtab.h:925
static void compile_file_command(char *arg, int from_tty)
Definition: compile.c:88
struct symtab * symtab
Definition: symtab.h:1369
struct ui_file * gdb_stdlog
Definition: main.c:73
struct ui_file * mem_fileopen(void)
Definition: ui-file.c:427
#define TMP_PREFIX
Definition: compile.c:47
Definition: block.h:60
Definition: value.c:172
static void print_callback(void *ignore, const char *message)
Definition: compile.c:453
void(* destroy)(struct compile_instance *)
static void get_new_file_names(char **source_file, char **object_file)
Definition: compile.c:262
PTR xrealloc(PTR ptr, size_t size)
Definition: common-utils.c:51
struct command_line * next
Definition: defs.h:399
static void cleanup_unlink_file(void *arg)
Definition: compile.c:442
#define TEMPLATE
void discard_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:213
const struct language_defn * current_language
Definition: language.c:85
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
Definition: utils.c:979
struct cleanup * make_cleanup_ui_file_delete(struct ui_file *arg)
Definition: utils.c:237
enum compile_i_scope_types scope
void print_command_parse_format(const char **expp, const char *cmdname, struct format_data *fmtp)
Definition: printcmd.c:935
struct gcc_base_context * fe
struct ui_file * gdb_stderr
Definition: main.c:72
static const char * get_compile_file_tempdir(void)
Definition: compile.c:233
void compile_print_value(struct value *val, void *data_voidp)
Definition: compile.c:170
static void show_compile_args(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: compile.c:325
int code
Definition: ser-unix.c:684
Definition: buffer.h:23
static void compile_code_command(char *arg, int from_tty)
Definition: compile.c:131
char ** gdb_buildargv(const char *s)
Definition: utils.c:3036
CORE_ADDR pc
Definition: symtab.h:1376
static void compile_command(char *args, int from_tty)
Definition: compile.c:598
struct cleanup * make_cleanup_free_command_lines(struct command_line **arg)
Definition: cli-script.c:1405
struct cleanup * make_final_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:136
const struct block * get_selected_block(CORE_ADDR *addr_in_block)
Definition: stack.c:2230
static struct cmd_list_element * compile_command_list
Definition: compile.c:51
void compile_object_run(struct compile_module *module)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: corelow.c:917
const struct block * block
static const struct block * get_expr_block_and_pc(CORE_ADDR *pc)
Definition: compile.c:275
struct cmd_list_element * showdebuglist
Definition: cli-cmds.c:175
void * arg
Definition: cleanups.c:43
struct command_line ** body_list
Definition: defs.h:417
void error(const char *fmt,...)
Definition: errors.c:38
char * gdbarch_gcc_target_options(struct gdbarch *gdbarch)
Definition: gdbarch.c:4706
void do_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:175
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)
Definition: cli-decode.c:541
int compile_debug
Definition: compile.c:55
static void get_args(const struct compile_instance *compiler, struct gdbarch *gdbarch, int *argcp, char ***argvp)
Definition: compile.c:399