GNU Binutils with patches for OS216
修订版 | d246674d8cd0262e7587925b06040a8347d4ed55 (tree) |
---|---|
时间 | 2017-02-22 06:32:56 |
作者 | Keith Seitz <keiths@redh...> |
Commiter | Keith Seitz |
compile: Add 'set compile-gcc'
gdb/ChangeLog
2015-05-24 Jan Kratochvil <jan.kratochvil@redhat.com>
gdb/doc/ChangeLog
2015-05-24 Jan Kratochvil <jan.kratochvil@redhat.com>
include/ChangeLog
2015-05-24 Jan Kratochvil <jan.kratochvil@redhat.com>
@@ -1,3 +1,7 @@ | ||
1 | +set|show compile-gcc | |
2 | + Set and show compilation command used for compiling and injecting code | |
3 | + with the 'compile' commands. | |
4 | + | |
1 | 5 | What has changed in GDB? |
2 | 6 | (Organized release by release) |
3 | 7 |
@@ -340,6 +340,19 @@ append_args (int *argcp, char ***argvp, int argc, char **argv) | ||
340 | 340 | (*argvp)[(*argcp)] = NULL; |
341 | 341 | } |
342 | 342 | |
343 | +/* String for 'set compile-gcc' and 'show compile-gcc'. */ | |
344 | +static char *compile_gcc; | |
345 | + | |
346 | +/* Implement 'show compile-gcc'. */ | |
347 | + | |
348 | +static void | |
349 | +show_compile_gcc (struct ui_file *file, int from_tty, | |
350 | + struct cmd_list_element *c, const char *value) | |
351 | +{ | |
352 | + fprintf_filtered (file, _("Compile command GCC driver filename is \"%s\".\n"), | |
353 | + value); | |
354 | +} | |
355 | + | |
343 | 356 | /* Return DW_AT_producer parsed for get_selected_frame () (if any). |
344 | 357 | Return NULL otherwise. |
345 | 358 |
@@ -467,8 +480,6 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, | ||
467 | 480 | int ok; |
468 | 481 | FILE *src; |
469 | 482 | struct gdbarch *gdbarch = get_current_arch (); |
470 | - const char *os_rx; | |
471 | - const char *arch_rx; | |
472 | 483 | char *triplet_rx; |
473 | 484 | char *error_message; |
474 | 485 |
@@ -520,22 +531,39 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, | ||
520 | 531 | if (compile_debug) |
521 | 532 | fprintf_unfiltered (gdb_stdlog, "debug output:\n\n%s", code.c_str ()); |
522 | 533 | |
523 | - os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch)); | |
524 | - arch_rx = gdbarch_gnu_triplet_regexp (gdbarch); | |
534 | + if (compiler->fe->ops->version >= GCC_FE_VERSION_1) | |
535 | + compiler->fe->ops->set_verbose (compiler->fe, compile_debug); | |
525 | 536 | |
526 | - /* Allow triplets with or without vendor set. */ | |
527 | - triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL); | |
528 | - make_cleanup (xfree, triplet_rx); | |
537 | + if (compile_gcc[0] != 0) | |
538 | + { | |
539 | + if (compiler->fe->ops->version < GCC_FE_VERSION_1) | |
540 | + error (_("Command 'set compile-gcc' requires GCC version 6 or higher " | |
541 | + "(libcc1 interface version 1 or higher)")); | |
542 | + | |
543 | + compiler->fe->ops->set_driver_filename (compiler->fe, compile_gcc); | |
544 | + } | |
545 | + else | |
546 | + { | |
547 | + const char *os_rx = osabi_triplet_regexp (gdbarch_osabi (gdbarch)); | |
548 | + const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch); | |
549 | + | |
550 | + /* Allow triplets with or without vendor set. */ | |
551 | + triplet_rx = concat (arch_rx, "(-[^-]*)?-", os_rx, (char *) NULL); | |
552 | + make_cleanup (xfree, triplet_rx); | |
553 | + | |
554 | + if (compiler->fe->ops->version >= GCC_FE_VERSION_1) | |
555 | + compiler->fe->ops->set_triplet_regexp (compiler->fe, triplet_rx); | |
556 | + } | |
529 | 557 | |
530 | 558 | /* Set compiler command-line arguments. */ |
531 | 559 | get_args (compiler, gdbarch, &argc, &argv); |
532 | 560 | make_cleanup_freeargv (argv); |
533 | 561 | |
534 | 562 | if (compiler->fe->ops->version >= GCC_FE_VERSION_1) |
535 | - compiler->fe->ops->set_verbose (compiler->fe, compile_debug); | |
536 | - | |
537 | - error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx, | |
538 | - argc, argv); | |
563 | + error_message = compiler->fe->ops->set_arguments (compiler->fe, argc, argv); | |
564 | + else | |
565 | + error_message = compiler->fe->ops->set_arguments_v0 (compiler->fe, triplet_rx, | |
566 | + argc, argv); | |
539 | 567 | if (error_message != NULL) |
540 | 568 | { |
541 | 569 | make_cleanup (xfree, error_message); |
@@ -748,4 +776,17 @@ String quoting is parsed like in shell, for example:\n\ | ||
748 | 776 | " -fno-stack-protector" |
749 | 777 | ); |
750 | 778 | set_compile_args (compile_args, 0, NULL); |
779 | + | |
780 | + add_setshow_optional_filename_cmd ("compile-gcc", class_support, | |
781 | + &compile_gcc, | |
782 | + _("Set compile command " | |
783 | + "GCC driver filename"), | |
784 | + _("Show compile command " | |
785 | + "GCC driver filename"), | |
786 | + _("\ | |
787 | +It should be absolute filename of the gcc executable.\n\ | |
788 | +If empty the default target triplet will be searched in $PATH."), | |
789 | + NULL, show_compile_gcc, &setlist, | |
790 | + &showlist); | |
791 | + compile_gcc = xstrdup (""); | |
751 | 792 | } |
@@ -18132,13 +18132,15 @@ will print to the console. | ||
18132 | 18132 | |
18133 | 18133 | @subsection Compiler search for the @code{compile} command |
18134 | 18134 | |
18135 | -@value{GDBN} needs to find @value{NGCC} for the inferior being debugged which | |
18136 | -may not be obvious for remote targets of different architecture than where | |
18137 | -@value{GDBN} is running. Environment variable @code{PATH} (@code{PATH} from | |
18138 | -shell that executed @value{GDBN}, not the one set by @value{GDBN} | |
18139 | -command @code{set environment}). @xref{Environment}. @code{PATH} on | |
18135 | +@value{GDBN} needs to find @value{NGCC} for the inferior being debugged | |
18136 | +which may not be obvious for remote targets of different architecture | |
18137 | +than where @value{GDBN} is running. Environment variable @code{PATH} on | |
18140 | 18138 | @value{GDBN} host is searched for @value{NGCC} binary matching the |
18141 | -target architecture and operating system. | |
18139 | +target architecture and operating system. This search can be overriden | |
18140 | +by @code{set compile-gcc} @value{GDBN} command below. @code{PATH} is | |
18141 | +taken from shell that executed @value{GDBN}, it is not the value set by | |
18142 | +@value{GDBN} command @code{set environment}). @xref{Environment}. | |
18143 | + | |
18142 | 18144 | |
18143 | 18145 | Specifically @code{PATH} is searched for binaries matching regular expression |
18144 | 18146 | @code{@var{arch}(-[^-]*)?-@var{os}-gcc} according to the inferior target being |
@@ -18148,6 +18150,28 @@ example both @code{i386} and @code{x86_64} targets look for pattern | ||
18148 | 18150 | for pattern @code{s390x?}. @var{os} is currently supported only for |
18149 | 18151 | pattern @code{linux(-gnu)?}. |
18150 | 18152 | |
18153 | +On Posix hosts the compiler driver @value{GDBN} needs to find also | |
18154 | +shared library @file{libcc1.so} from the compiler. It is searched in | |
18155 | +default shared library search path (overridable with usual environment | |
18156 | +variable @code{LD_LIBRARY_PATH}), unrelated to @code{PATH} or @code{set | |
18157 | +compile-gcc} settings. Contrary to it @file{libcc1plugin.so} is found | |
18158 | +according to the installation of the found compiler --- as possibly | |
18159 | +specified by the @code{set compile-gcc} command. | |
18160 | + | |
18161 | +@table @code | |
18162 | +@item set compile-gcc | |
18163 | +@cindex compile command driver filename override | |
18164 | +Set compilation command used for compiling and injecting code with the | |
18165 | +@code{compile} commands. If this option is not set (it is set to | |
18166 | +an empty string), the search described above will occur --- that is the | |
18167 | +default. | |
18168 | + | |
18169 | +@item show compile-gcc | |
18170 | +Displays the current compile command @value{NGCC} driver filename. | |
18171 | +If set, it is the main command @command{gcc}, found usually for example | |
18172 | +under name @file{x86_64-linux-gnu-gcc}. | |
18173 | +@end table | |
18174 | + | |
18151 | 18175 | @node GDB Files |
18152 | 18176 | @chapter @value{GDBN} Files |
18153 | 18177 |
@@ -46,7 +46,9 @@ enum gcc_base_api_version | ||
46 | 46 | { |
47 | 47 | GCC_FE_VERSION_0 = 0, |
48 | 48 | |
49 | - /* Deprecated method compile_v0. Added method set_verbose and compile. */ | |
49 | + /* Deprecated methods set_arguments_v0 and compile_v0. Added methods | |
50 | + set_arguments, set_triplet_regexp, set_driver_filename, set_verbose and | |
51 | + compile. */ | |
50 | 52 | GCC_FE_VERSION_1 = 1, |
51 | 53 | }; |
52 | 54 |
@@ -67,20 +69,12 @@ struct gcc_base_vtable | ||
67 | 69 | |
68 | 70 | unsigned int version; |
69 | 71 | |
70 | - /* Set the compiler's command-line options for the next compilation. | |
71 | - TRIPLET_REGEXP is a regular expression that is used to match the | |
72 | - configury triplet prefix to the compiler. | |
73 | - The arguments are copied by GCC. ARGV need not be | |
74 | - NULL-terminated. The arguments must be set separately for each | |
75 | - compilation; that is, after a compile is requested, the | |
76 | - previously-set arguments cannot be reused. | |
77 | - | |
78 | - This returns NULL on success. On failure, returns a malloc()d | |
79 | - error message. The caller is responsible for freeing it. */ | |
72 | + /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1 | |
73 | + methods set_triplet_regexp and set_arguments. */ | |
80 | 74 | |
81 | - char *(*set_arguments) (struct gcc_base_context *self, | |
82 | - const char *triplet_regexp, | |
83 | - int argc, char **argv); | |
75 | + char *(*set_arguments_v0) (struct gcc_base_context *self, | |
76 | + const char *triplet_regexp, | |
77 | + int argc, char **argv); | |
84 | 78 | |
85 | 79 | /* Set the file name of the program to compile. The string is |
86 | 80 | copied by the method implementation, but the caller must |
@@ -125,6 +119,45 @@ struct gcc_base_vtable | ||
125 | 119 | |
126 | 120 | int /* bool */ (*compile) (struct gcc_base_context *self, |
127 | 121 | const char *filename); |
122 | + | |
123 | + /* Set the compiler's command-line options for the next compilation. | |
124 | + The arguments are copied by GCC. ARGV need not be | |
125 | + NULL-terminated. The arguments must be set separately for each | |
126 | + compilation; that is, after a compile is requested, the | |
127 | + previously-set arguments cannot be reused. | |
128 | + | |
129 | + This returns NULL on success. On failure, returns a malloc()d | |
130 | + error message. The caller is responsible for freeing it. | |
131 | + | |
132 | + This method is only available since GCC_FE_VERSION_1. */ | |
133 | + | |
134 | + char *(*set_arguments) (struct gcc_base_context *self, | |
135 | + int argc, char **argv); | |
136 | + | |
137 | + /* Set TRIPLET_REGEXP as a regular expression that is used to match | |
138 | + the configury triplet prefix to the compiler. Calling this method | |
139 | + overrides possible previous call of itself or set_driver_filename. | |
140 | + | |
141 | + This returns NULL on success. On failure, returns a malloc()d | |
142 | + error message. The caller is responsible for freeing it. | |
143 | + | |
144 | + This method is only available since GCC_FE_VERSION_1. */ | |
145 | + | |
146 | + char *(*set_triplet_regexp) (struct gcc_base_context *self, | |
147 | + const char *triplet_regexp); | |
148 | + | |
149 | + /* DRIVER_FILENAME should be filename of the gcc compiler driver | |
150 | + program. It will be searched in PATH components like | |
151 | + TRIPLET_REGEXP. Calling this method overrides possible previous | |
152 | + call of itself or set_triplet_regexp. | |
153 | + | |
154 | + This returns NULL on success. On failure, returns a malloc()d | |
155 | + error message. The caller is responsible for freeing it. | |
156 | + | |
157 | + This method is only available since GCC_FE_VERSION_1. */ | |
158 | + | |
159 | + char *(*set_driver_filename) (struct gcc_base_context *self, | |
160 | + const char *driver_filename); | |
128 | 161 | }; |
129 | 162 | |
130 | 163 | /* The GCC object. */ |