[3/4] compile: set debug compile: Display GCC driver filename
Commit Message
Hi,
as discussed in
How to use compile & execute function in GDB
https://sourceware.org/ml/gdb/2015-04/msg00026.html
GDB currently searches for /usr/bin/ARCH-OS-gcc and chooses one but it does not
display which one. It cannot, GCC method set_arguments() does not yet know
whether 'set debug compile' is enabled or not.
Unfortunately this changes libcc1 API in an incompatible way. There is
a possibility of a hack to keep the API the same - one could pass "-v" option
explicitly to set_arguments(), set_arguments() could compare the "-v" string
and print the GCC filename accordingly. Then the 'verbose' parameter of
compile() would lose its meaning. But I will see what GCC upstream says.
Jan
gdb/ChangeLog
2015-04-21 Jan Kratochvil <jan.kratochvil@redhat.com>
* compile/compile.c (compile_to_object): Pass compile_debug to GCC's
set_arguments instead of compile.
include/ChangeLog
2015-04-21 Jan Kratochvil <jan.kratochvil@redhat.com>
* gcc-interface.h (enum gcc_base_api_version): Add comment to
GCC_FE_VERSION_1.
(struct gcc_base_vtable): Move parameter verbose from compile to
set_arguments.
---
gdb/compile/compile.c | 5 ++---
include/gcc-interface.h | 14 +++++++-------
2 files changed, 9 insertions(+), 10 deletions(-)
Comments
obsoleted by:
[PATCH v2 1/2] compile: set debug compile: Display GCC driver filename
https://sourceware.org/ml/gdb-patches/2015-04/msg00909.html
[PATCH v2 2/2] compile: Add 'set compile-gcc'
https://sourceware.org/ml/gdb-patches/2015-04/msg00910.html
@@ -493,7 +493,7 @@ compile_to_object (struct command_line *cmd, char *cmd_string,
make_cleanup_freeargv (argv);
error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx,
- argc, argv);
+ argc, argv, compile_debug);
if (error_message != NULL)
{
make_cleanup (xfree, error_message);
@@ -529,8 +529,7 @@ compile_to_object (struct command_line *cmd, char *cmd_string,
/* Call the compiler and start the compilation process. */
compiler->fe->ops->set_source_file (compiler->fe, source_file);
- if (!compiler->fe->ops->compile (compiler->fe, object_file,
- compile_debug))
+ if (!compiler->fe->ops->compile (compiler->fe, object_file))
error (_("Compilation failed."));
if (compile_debug)
@@ -45,6 +45,8 @@ struct gcc_base_context;
enum gcc_base_api_version
{
GCC_FE_VERSION_0 = 0,
+
+ /* Parameter verbose has been moved from compile to set_arguments. */
GCC_FE_VERSION_1 = 1,
};
@@ -71,14 +73,15 @@ struct gcc_base_vtable
The arguments are copied by GCC. ARGV need not be
NULL-terminated. The arguments must be set separately for each
compilation; that is, after a compile is requested, the
- previously-set arguments cannot be reused.
+ previously-set arguments cannot be reused. VERBOSE can be set
+ to cause GCC to print some information as it works.
This returns NULL on success. On failure, returns a malloc()d
error message. The caller is responsible for freeing it. */
char *(*set_arguments) (struct gcc_base_context *self,
const char *triplet_regexp,
- int argc, char **argv);
+ int argc, char **argv, int /* bool */ verbose);
/* Set the file name of the program to compile. The string is
copied by the method implementation, but the caller must
@@ -95,13 +98,10 @@ struct gcc_base_vtable
void *datum);
/* Perform the compilation. FILENAME is the name of the resulting
- object file. VERBOSE can be set to cause GCC to print some
- information as it works. Returns true on success, false on
- error. */
+ object file. Returns true on success, false on error. */
int /* bool */ (*compile) (struct gcc_base_context *self,
- const char *filename,
- int /* bool */ verbose);
+ const char *filename);
/* Destroy this object. */