Use RAII to save and restore scalars
[binutils-gdb.git] / gdb / compile / compile.c
1 /* General Compile and inject code
2
3 Copyright (C) 2014-2016 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 "top.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 \f
44
45 /* Initial filename for temporary files. */
46
47 #define TMP_PREFIX "/tmp/gdbobj-"
48
49 /* Hold "compile" commands. */
50
51 static struct cmd_list_element *compile_command_list;
52
53 /* Debug flag for "compile" commands. */
54
55 int compile_debug;
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 \f
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 {
90 enum compile_i_scope_types scope = COMPILE_I_SIMPLE_SCOPE;
91 char *buffer;
92 struct cleanup *cleanup;
93
94 scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
95
96 /* Check the user did not just <enter> after command. */
97 if (arg == NULL)
98 error (_("You must provide a filename for this command."));
99
100 /* Check if a raw (-r|-raw) argument is provided. */
101 if (arg != NULL && check_raw_argument (&arg))
102 {
103 scope = COMPILE_I_RAW_SCOPE;
104 arg = skip_spaces (arg);
105 }
106
107 /* After processing arguments, check there is a filename at the end
108 of the command. */
109 if (arg[0] == '\0')
110 error (_("You must provide a filename with the raw option set."));
111
112 if (arg[0] == '-')
113 error (_("Unknown argument specified."));
114
115 arg = skip_spaces (arg);
116 arg = gdb_abspath (arg);
117 cleanup = make_cleanup (xfree, arg);
118 buffer = xstrprintf ("#include \"%s\"\n", arg);
119 make_cleanup (xfree, buffer);
120 eval_compile_command (NULL, buffer, scope, NULL);
121 do_cleanups (cleanup);
122 }
123
124 /* Handle the input from the 'compile code' command. The
125 "compile code" command is used to evaluate an expression that may
126 contain calls to the GCC compiler. The language expected in this
127 compile command is the language currently set in GDB. */
128
129 static void
130 compile_code_command (char *arg, int from_tty)
131 {
132 enum compile_i_scope_types scope = COMPILE_I_SIMPLE_SCOPE;
133
134 scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
135
136 if (arg != NULL && check_raw_argument (&arg))
137 {
138 scope = COMPILE_I_RAW_SCOPE;
139 arg = skip_spaces (arg);
140 }
141
142 arg = skip_spaces (arg);
143
144 if (arg != NULL && !check_for_argument (&arg, "--", sizeof ("--") - 1))
145 {
146 if (arg[0] == '-')
147 error (_("Unknown argument specified."));
148 }
149
150 if (arg && *arg)
151 eval_compile_command (NULL, arg, scope, NULL);
152 else
153 {
154 struct command_line *l = get_command_line (compile_control, "");
155 struct cleanup *cleanup = make_cleanup_free_command_lines (&l);
156
157 l->control_u.compile.scope = scope;
158 execute_control_command_untraced (l);
159 do_cleanups (cleanup);
160 }
161 }
162
163 /* Callback for compile_print_command. */
164
165 void
166 compile_print_value (struct value *val, void *data_voidp)
167 {
168 const struct format_data *fmtp = (const struct format_data *) data_voidp;
169
170 print_value (val, fmtp);
171 }
172
173 /* Handle the input from the 'compile print' command. The "compile
174 print" command is used to evaluate and print an expression that may
175 contain calls to the GCC compiler. The language expected in this
176 compile command is the language currently set in GDB. */
177
178 static void
179 compile_print_command (char *arg_param, int from_tty)
180 {
181 const char *arg = arg_param;
182 enum compile_i_scope_types scope = COMPILE_I_PRINT_ADDRESS_SCOPE;
183 struct format_data fmt;
184
185 scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
186
187 /* Passing &FMT as SCOPE_DATA is safe as do_module_cleanup will not
188 touch the stale pointer if compile_object_run has already quit. */
189 print_command_parse_format (&arg, "compile print", &fmt);
190
191 if (arg && *arg)
192 eval_compile_command (NULL, arg, scope, &fmt);
193 else
194 {
195 struct command_line *l = get_command_line (compile_control, "");
196 struct cleanup *cleanup = make_cleanup_free_command_lines (&l);
197
198 l->control_u.compile.scope = scope;
199 l->control_u.compile.scope_data = &fmt;
200 execute_control_command_untraced (l);
201 do_cleanups (cleanup);
202 }
203 }
204
205 /* A cleanup function to remove a directory and all its contents. */
206
207 static void
208 do_rmdir (void *arg)
209 {
210 const char *dir = (const char *) arg;
211 char *zap;
212 int wstat;
213
214 gdb_assert (startswith (dir, TMP_PREFIX));
215 zap = concat ("rm -rf ", dir, (char *) NULL);
216 wstat = system (zap);
217 if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
218 warning (_("Could not remove temporary directory %s"), dir);
219 XDELETEVEC (zap);
220 }
221
222 /* Return the name of the temporary directory to use for .o files, and
223 arrange for the directory to be removed at shutdown. */
224
225 static const char *
226 get_compile_file_tempdir (void)
227 {
228 static char *tempdir_name;
229
230 #define TEMPLATE TMP_PREFIX "XXXXXX"
231 char tname[sizeof (TEMPLATE)];
232
233 if (tempdir_name != NULL)
234 return tempdir_name;
235
236 strcpy (tname, TEMPLATE);
237 #undef TEMPLATE
238 #ifdef HAVE_MKDTEMP
239 tempdir_name = mkdtemp (tname);
240 #else
241 error (_("Command not supported on this host."));
242 #endif
243 if (tempdir_name == NULL)
244 perror_with_name (_("Could not make temporary directory"));
245
246 tempdir_name = xstrdup (tempdir_name);
247 make_final_cleanup (do_rmdir, tempdir_name);
248 return tempdir_name;
249 }
250
251 /* Compute the names of source and object files to use. The names are
252 allocated by malloc and should be freed by the caller. */
253
254 static void
255 get_new_file_names (char **source_file, char **object_file)
256 {
257 static int seq;
258 const char *dir = get_compile_file_tempdir ();
259
260 ++seq;
261 *source_file = xstrprintf ("%s%sout%d.c", dir, SLASH_STRING, seq);
262 *object_file = xstrprintf ("%s%sout%d.o", dir, SLASH_STRING, seq);
263 }
264
265 /* Get the block and PC at which to evaluate an expression. */
266
267 static const struct block *
268 get_expr_block_and_pc (CORE_ADDR *pc)
269 {
270 const struct block *block = get_selected_block (pc);
271
272 if (block == NULL)
273 {
274 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
275
276 if (cursal.symtab)
277 block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
278 STATIC_BLOCK);
279 if (block != NULL)
280 *pc = BLOCK_START (block);
281 }
282 else
283 *pc = BLOCK_START (block);
284
285 return block;
286 }
287
288 /* Call gdb_buildargv, set its result for S into *ARGVP but calculate also the
289 number of parsed arguments into *ARGCP. If gdb_buildargv has returned NULL
290 then *ARGCP is set to zero. */
291
292 static void
293 build_argc_argv (const char *s, int *argcp, char ***argvp)
294 {
295 *argvp = gdb_buildargv (s);
296 *argcp = countargv (*argvp);
297 }
298
299 /* String for 'set compile-args' and 'show compile-args'. */
300 static char *compile_args;
301
302 /* Parsed form of COMPILE_ARGS. COMPILE_ARGS_ARGV is NULL terminated. */
303 static int compile_args_argc;
304 static char **compile_args_argv;
305
306 /* Implement 'set compile-args'. */
307
308 static void
309 set_compile_args (char *args, int from_tty, struct cmd_list_element *c)
310 {
311 freeargv (compile_args_argv);
312 build_argc_argv (compile_args, &compile_args_argc, &compile_args_argv);
313 }
314
315 /* Implement 'show compile-args'. */
316
317 static void
318 show_compile_args (struct ui_file *file, int from_tty,
319 struct cmd_list_element *c, const char *value)
320 {
321 fprintf_filtered (file, _("Compile command command-line arguments "
322 "are \"%s\".\n"),
323 value);
324 }
325
326 /* Append ARGC and ARGV (as parsed by build_argc_argv) to *ARGCP and *ARGVP.
327 ARGCP+ARGVP can be zero+NULL and also ARGC+ARGV can be zero+NULL. */
328
329 static void
330 append_args (int *argcp, char ***argvp, int argc, char **argv)
331 {
332 int argi;
333
334 *argvp = XRESIZEVEC (char *, *argvp, (*argcp + argc + 1));
335
336 for (argi = 0; argi < argc; argi++)
337 (*argvp)[(*argcp)++] = xstrdup (argv[argi]);
338 (*argvp)[(*argcp)] = NULL;
339 }
340
341 /* Return DW_AT_producer parsed for get_selected_frame () (if any).
342 Return NULL otherwise.
343
344 GCC already filters its command-line arguments only for the suitable ones to
345 put into DW_AT_producer - see GCC function gen_producer_string. */
346
347 static const char *
348 get_selected_pc_producer_options (void)
349 {
350 CORE_ADDR pc = get_frame_pc (get_selected_frame (NULL));
351 struct compunit_symtab *symtab = find_pc_compunit_symtab (pc);
352 const char *cs;
353
354 if (symtab == NULL || symtab->producer == NULL
355 || !startswith (symtab->producer, "GNU "))
356 return NULL;
357
358 cs = symtab->producer;
359 while (*cs != 0 && *cs != '-')
360 cs = skip_spaces_const (skip_to_space_const (cs));
361 if (*cs != '-')
362 return NULL;
363 return cs;
364 }
365
366 /* Filter out unwanted options from *ARGCP and ARGV. */
367
368 static void
369 filter_args (int *argcp, char **argv)
370 {
371 char **destv;
372
373 for (destv = argv; *argv != NULL; argv++)
374 {
375 /* -fpreprocessed may get in commonly from ccache. */
376 if (strcmp (*argv, "-fpreprocessed") == 0)
377 {
378 xfree (*argv);
379 (*argcp)--;
380 continue;
381 }
382 *destv++ = *argv;
383 }
384 *destv = NULL;
385 }
386
387 /* Produce final vector of GCC compilation options. First element is target
388 size ("-m64", "-m32" etc.), optionally followed by DW_AT_producer options
389 and then compile-args string GDB variable. */
390
391 static void
392 get_args (const struct compile_instance *compiler, struct gdbarch *gdbarch,
393 int *argcp, char ***argvp)
394 {
395 const char *cs_producer_options;
396 int argc_compiler;
397 char **argv_compiler;
398
399 build_argc_argv (gdbarch_gcc_target_options (gdbarch),
400 argcp, argvp);
401
402 cs_producer_options = get_selected_pc_producer_options ();
403 if (cs_producer_options != NULL)
404 {
405 int argc_producer;
406 char **argv_producer;
407
408 build_argc_argv (cs_producer_options, &argc_producer, &argv_producer);
409 filter_args (&argc_producer, argv_producer);
410 append_args (argcp, argvp, argc_producer, argv_producer);
411 freeargv (argv_producer);
412 }
413
414 build_argc_argv (compiler->gcc_target_options,
415 &argc_compiler, &argv_compiler);
416 append_args (argcp, argvp, argc_compiler, argv_compiler);
417 freeargv (argv_compiler);
418
419 append_args (argcp, argvp, compile_args_argc, compile_args_argv);
420 }
421
422 /* A cleanup function to destroy a gdb_gcc_instance. */
423
424 static void
425 cleanup_compile_instance (void *arg)
426 {
427 struct compile_instance *inst = (struct compile_instance *) arg;
428
429 inst->destroy (inst);
430 }
431
432 /* A cleanup function to unlink a file. */
433
434 static void
435 cleanup_unlink_file (void *arg)
436 {
437 const char *filename = (const char *) arg;
438
439 unlink (filename);
440 }
441
442 /* A helper function suitable for use as the "print_callback" in the
443 compiler object. */
444
445 static void
446 print_callback (void *ignore, const char *message)
447 {
448 fputs_filtered (message, gdb_stderr);
449 }
450
451 /* Process the compilation request. On success it returns the object
452 file name and *SOURCE_FILEP is set to source file name. On an
453 error condition, error () is called. The caller is responsible for
454 freeing both strings. */
455
456 static char *
457 compile_to_object (struct command_line *cmd, const char *cmd_string,
458 enum compile_i_scope_types scope,
459 char **source_filep)
460 {
461 char *code;
462 const char *input;
463 char *source_file, *object_file;
464 struct compile_instance *compiler;
465 struct cleanup *cleanup, *inner_cleanup;
466 const struct block *expr_block;
467 CORE_ADDR trash_pc, expr_pc;
468 int argc;
469 char **argv;
470 int ok;
471 FILE *src;
472 struct gdbarch *gdbarch = get_current_arch ();
473 const char *os_rx;
474 const char *arch_rx;
475 char *triplet_rx;
476 char *error_message;
477
478 if (!target_has_execution)
479 error (_("The program must be running for the compile command to "\
480 "work."));
481
482 expr_block = get_expr_block_and_pc (&trash_pc);
483 expr_pc = get_frame_address_in_block (get_selected_frame (NULL));
484
485 /* Set up instance and context for the compiler. */
486 if (current_language->la_get_compile_instance == NULL)
487 error (_("No compiler support for language %s."),
488 current_language->la_name);
489 compiler = current_language->la_get_compile_instance ();
490 cleanup = make_cleanup (cleanup_compile_instance, compiler);
491
492 compiler->fe->ops->set_print_callback (compiler->fe, print_callback, NULL);
493
494 compiler->scope = scope;
495 compiler->block = expr_block;
496
497 /* From the provided expression, build a scope to pass to the
498 compiler. */
499 if (cmd != NULL)
500 {
501 struct ui_file *stream = mem_fileopen ();
502 struct command_line *iter;
503 char *stream_buf;
504
505 make_cleanup_ui_file_delete (stream);
506 for (iter = cmd->body_list[0]; iter; iter = iter->next)
507 {
508 fputs_unfiltered (iter->line, stream);
509 fputs_unfiltered ("\n", stream);
510 }
511
512 stream_buf = ui_file_xstrdup (stream, NULL);
513 make_cleanup (xfree, stream_buf);
514 input = stream_buf;
515 }
516 else if (cmd_string != NULL)
517 input = cmd_string;
518 else
519 error (_("Neither a simple expression, or a multi-line specified."));
520
521 code = current_language->la_compute_program (compiler, input, gdbarch,
522 expr_block, expr_pc);
523 make_cleanup (xfree, code);
524 if (compile_debug)
525 fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code);
526
527 os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch));
528 arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
529
530 /* Allow triplets with or without vendor set. */
531 triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL);
532 make_cleanup (xfree, triplet_rx);
533
534 /* Set compiler command-line arguments. */
535 get_args (compiler, gdbarch, &argc, &argv);
536 make_cleanup_freeargv (argv);
537
538 error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx,
539 argc, argv);
540 if (error_message != NULL)
541 {
542 make_cleanup (xfree, error_message);
543 error ("%s", error_message);
544 }
545
546 if (compile_debug)
547 {
548 int argi;
549
550 fprintf_unfiltered (gdb_stdlog, "Passing %d compiler options:\n", argc);
551 for (argi = 0; argi < argc; argi++)
552 fprintf_unfiltered (gdb_stdlog, "Compiler option %d: <%s>\n",
553 argi, argv[argi]);
554 }
555
556 get_new_file_names (&source_file, &object_file);
557 inner_cleanup = make_cleanup (xfree, source_file);
558 make_cleanup (xfree, object_file);
559
560 src = gdb_fopen_cloexec (source_file, "w");
561 if (src == NULL)
562 perror_with_name (_("Could not open source file for writing"));
563 make_cleanup (cleanup_unlink_file, source_file);
564 if (fputs (code, src) == EOF)
565 perror_with_name (_("Could not write to source file"));
566 fclose (src);
567
568 if (compile_debug)
569 fprintf_unfiltered (gdb_stdlog, "source file produced: %s\n\n",
570 source_file);
571
572 /* Call the compiler and start the compilation process. */
573 compiler->fe->ops->set_source_file (compiler->fe, source_file);
574
575 if (!compiler->fe->ops->compile (compiler->fe, object_file,
576 compile_debug))
577 error (_("Compilation failed."));
578
579 if (compile_debug)
580 fprintf_unfiltered (gdb_stdlog, "object file produced: %s\n\n",
581 object_file);
582
583 discard_cleanups (inner_cleanup);
584 do_cleanups (cleanup);
585 *source_filep = source_file;
586 return object_file;
587 }
588
589 /* The "compile" prefix command. */
590
591 static void
592 compile_command (char *args, int from_tty)
593 {
594 /* If a sub-command is not specified to the compile prefix command,
595 assume it is a direct code compilation. */
596 compile_code_command (args, from_tty);
597 }
598
599 /* See compile.h. */
600
601 void
602 eval_compile_command (struct command_line *cmd, const char *cmd_string,
603 enum compile_i_scope_types scope, void *scope_data)
604 {
605 char *object_file, *source_file;
606
607 object_file = compile_to_object (cmd, cmd_string, scope, &source_file);
608 if (object_file != NULL)
609 {
610 struct cleanup *cleanup_xfree, *cleanup_unlink;
611 struct compile_module *compile_module;
612
613 cleanup_xfree = make_cleanup (xfree, object_file);
614 make_cleanup (xfree, source_file);
615 cleanup_unlink = make_cleanup (cleanup_unlink_file, object_file);
616 make_cleanup (cleanup_unlink_file, source_file);
617 compile_module = compile_object_load (object_file, source_file,
618 scope, scope_data);
619 if (compile_module == NULL)
620 {
621 gdb_assert (scope == COMPILE_I_PRINT_ADDRESS_SCOPE);
622 do_cleanups (cleanup_xfree);
623 eval_compile_command (cmd, cmd_string,
624 COMPILE_I_PRINT_VALUE_SCOPE, scope_data);
625 return;
626 }
627 discard_cleanups (cleanup_unlink);
628 do_cleanups (cleanup_xfree);
629 compile_object_run (compile_module);
630 }
631 }
632
633 /* See compile/compile-internal.h. */
634
635 char *
636 compile_register_name_mangled (struct gdbarch *gdbarch, int regnum)
637 {
638 const char *regname = gdbarch_register_name (gdbarch, regnum);
639
640 return xstrprintf ("__%s", regname);
641 }
642
643 /* See compile/compile-internal.h. */
644
645 int
646 compile_register_name_demangle (struct gdbarch *gdbarch,
647 const char *regname)
648 {
649 int regnum;
650
651 if (regname[0] != '_' || regname[1] != '_')
652 error (_("Invalid register name \"%s\"."), regname);
653 regname += 2;
654
655 for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++)
656 if (strcmp (regname, gdbarch_register_name (gdbarch, regnum)) == 0)
657 return regnum;
658
659 error (_("Cannot find gdbarch register \"%s\"."), regname);
660 }
661
662 extern initialize_file_ftype _initialize_compile;
663
664 void
665 _initialize_compile (void)
666 {
667 struct cmd_list_element *c = NULL;
668
669 add_prefix_cmd ("compile", class_obscure, compile_command,
670 _("\
671 Command to compile source code and inject it into the inferior."),
672 &compile_command_list, "compile ", 1, &cmdlist);
673 add_com_alias ("expression", "compile", class_obscure, 0);
674
675 add_cmd ("code", class_obscure, compile_code_command,
676 _("\
677 Compile, inject, and execute code.\n\
678 \n\
679 Usage: compile code [-r|-raw] [--] [CODE]\n\
680 -r|-raw: Suppress automatic 'void _gdb_expr () { CODE }' wrapping.\n\
681 --: Do not parse any options beyond this delimiter. All text to the\n\
682 right will be treated as source code.\n\
683 \n\
684 The source code may be specified as a simple one line expression, e.g.:\n\
685 \n\
686 compile code printf(\"Hello world\\n\");\n\
687 \n\
688 Alternatively, you can type a multiline expression by invoking\n\
689 this command with no argument. GDB will then prompt for the\n\
690 expression interactively; type a line containing \"end\" to\n\
691 indicate the end of the expression."),
692 &compile_command_list);
693
694 c = add_cmd ("file", class_obscure, compile_file_command,
695 _("\
696 Evaluate a file containing source code.\n\
697 \n\
698 Usage: compile file [-r|-raw] [filename]\n\
699 -r|-raw: Suppress automatic 'void _gdb_expr () { CODE }' wrapping."),
700 &compile_command_list);
701 set_cmd_completer (c, filename_completer);
702
703 add_cmd ("print", class_obscure, compile_print_command,
704 _("\
705 Evaluate EXPR by using the compiler and print result.\n\
706 \n\
707 Usage: compile print[/FMT] [EXPR]\n\
708 \n\
709 The expression may be specified on the same line as the command, e.g.:\n\
710 \n\
711 compile print i\n\
712 \n\
713 Alternatively, you can type a multiline expression by invoking\n\
714 this command with no argument. GDB will then prompt for the\n\
715 expression interactively; type a line containing \"end\" to\n\
716 indicate the end of the expression.\n\
717 \n\
718 EXPR may be preceded with /FMT, where FMT is a format letter\n\
719 but no count or size letter (see \"x\" command)."),
720 &compile_command_list);
721
722 add_setshow_boolean_cmd ("compile", class_maintenance, &compile_debug, _("\
723 Set compile command debugging."), _("\
724 Show compile command debugging."), _("\
725 When on, compile command debugging is enabled."),
726 NULL, show_compile_debug,
727 &setdebuglist, &showdebuglist);
728
729 add_setshow_string_cmd ("compile-args", class_support,
730 &compile_args,
731 _("Set compile command GCC command-line arguments"),
732 _("Show compile command GCC command-line arguments"),
733 _("\
734 Use options like -I (include file directory) or ABI settings.\n\
735 String quoting is parsed like in shell, for example:\n\
736 -mno-align-double \"-I/dir with a space/include\""),
737 set_compile_args, show_compile_args, &setlist, &showlist);
738
739 /* Override flags possibly coming from DW_AT_producer. */
740 compile_args = xstrdup ("-O0 -gdwarf-4"
741 /* We use -fPIE Otherwise GDB would need to reserve space large enough for
742 any object file in the inferior in advance to get the final address when
743 to link the object file to and additionally the default system linker
744 script would need to be modified so that one can specify there the
745 absolute target address.
746 -fPIC is not used at is would require from GDB to generate .got. */
747 " -fPIE"
748 /* We want warnings, except for some commonly happening for GDB commands. */
749 " -Wall "
750 " -Wno-implicit-function-declaration"
751 " -Wno-unused-but-set-variable"
752 " -Wno-unused-variable"
753 /* Override CU's possible -fstack-protector-strong. */
754 " -fno-stack-protector"
755 );
756 set_compile_args (compile_args, 0, NULL);
757 }