From patchwork Wed Aug 23 15:20:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 22332 Received: (qmail 72730 invoked by alias); 23 Aug 2017 15:20:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 72441 invoked by uid 89); 23 Aug 2017 15:20:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Aug 2017 15:20:22 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F1B5882FB for ; Wed, 23 Aug 2017 15:20:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1F1B5882FB Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=sergiodj@redhat.com Received: from psique.yyz.redhat.com (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3EA96F104; Wed, 23 Aug 2017 15:20:15 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Sergio Durigan Junior , Jan Kratochvil Subject: [PUSHED 1/2] compile: set debug compile: Display GCC driver filename Date: Wed, 23 Aug 2017 11:20:06 -0400 Message-Id: <20170823152007.5553-1-sergiodj@redhat.com> X-IsSubscribed: yes From: Jan Kratochvil Pushed as per: https://sourceware.org/ml/gdb-patches/2015-05/msg00711.html As discussed in How to use compile & execute function in GDB https://sourceware.org/ml/gdb/2015-04/msg00026.html GDB currently searches for compilers on /usr/bin/ARCH-OS-gcc and chooses a match from there. However, it is not currently possible for the user to display which compiler was selected. Up until now, GDB's compiler interface was not up-to-date with GCC's one, which means that it wasn't possible to obtain this information. This patch implements the mechanisms necessary for that. gdb/ChangeLog 2017-08-23 Jan Kratochvil * compile/compile.c (compile_to_object): Conditionally call set_verbose. Conditionally call compile or compile_v0. include/ChangeLog 2017-08-23 Jan Kratochvil * gcc-interface.h (enum gcc_base_api_version): Add GCC_FE_VERSION_1. (struct gcc_base_vtable): Rename compile to compile_v0. Update comment for compile. New methods set_verbose and compile. --- gdb/ChangeLog | 5 +++++ gdb/compile/compile.c | 11 +++++++++-- include/ChangeLog | 7 +++++++ include/gcc-interface.h | 36 ++++++++++++++++++++++++++++-------- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 77a19c2ff0..d7466d0578 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-08-23 Jan Kratochvil + + * compile/compile.c (compile_to_object): Conditionally call + set_verbose. Conditionally call compile or compile_v0. + 2017-08-07 Weimin Pan * sparc64-tdep.h: (adi_normalize_address): New export. diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 91e084f89f..36baab3ede 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -516,6 +516,9 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, get_args (compiler, gdbarch, &argc, &argv); gdb_argv argv_holder (argv); + if (compiler->fe->ops->version >= GCC_FE_VERSION_1) + compiler->fe->ops->set_verbose (compiler->fe, compile_debug); + error_message = compiler->fe->ops->set_arguments (compiler->fe, triplet_rx, argc, argv); if (error_message != NULL) @@ -556,8 +559,12 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, /* Call the compiler and start the compilation process. */ compiler->fe->ops->set_source_file (compiler->fe, fnames.source_file ()); - if (!compiler->fe->ops->compile (compiler->fe, fnames.object_file (), - compile_debug)) + if (compiler->fe->ops->version >= GCC_FE_VERSION_1) + ok = compiler->fe->ops->compile (compiler->fe, fnames.object_file ()); + else + ok = compiler->fe->ops->compile_v0 (compiler->fe, fnames.object_file (), + compile_debug); + if (!ok) error (_("Compilation failed.")); if (compile_debug) diff --git a/include/ChangeLog b/include/ChangeLog index db500dce93..02ee554b90 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,10 @@ +2017-08-23 Jan Kratochvil + + * gcc-interface.h (enum gcc_base_api_version): Add + GCC_FE_VERSION_1. + (struct gcc_base_vtable): Rename compile to compile_v0. Update + comment for compile. New methods set_verbose and compile. + 2017-08-21 Alexander Fedotov Edmar Wienskoski diff --git a/include/gcc-interface.h b/include/gcc-interface.h index d4c4ec6997..c98f078454 100644 --- a/include/gcc-interface.h +++ b/include/gcc-interface.h @@ -44,7 +44,10 @@ struct gcc_base_context; enum gcc_base_api_version { - GCC_FE_VERSION_0 = 0 + GCC_FE_VERSION_0 = 0, + + /* Deprecated method compile_v0. Added method set_verbose and compile. */ + GCC_FE_VERSION_1 = 1, }; /* The operations defined by the GCC base API. This is the vtable for @@ -93,18 +96,35 @@ struct gcc_base_vtable const char *message), 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. */ + /* Deprecated GCC_FE_VERSION_0 variant of the GCC_FE_VERSION_1 + compile method. GCC_FE_VERSION_0 version verbose parameter has + been replaced by the set_verbose method. */ - int /* bool */ (*compile) (struct gcc_base_context *self, - const char *filename, - int /* bool */ verbose); + int /* bool */ (*compile_v0) (struct gcc_base_context *self, + const char *filename, + int /* bool */ verbose); /* Destroy this object. */ void (*destroy) (struct gcc_base_context *self); + + /* VERBOSE can be set to non-zero to cause GCC to print some + information as it works. Calling this method overrides its + possible previous calls. + + This method is only available since GCC_FE_VERSION_1. */ + + void (*set_verbose) (struct gcc_base_context *self, + int /* bool */ verbose); + + /* Perform the compilation. FILENAME is the name of the resulting + object file. Either set_triplet_regexp or set_driver_filename must + be called before. Returns true on success, false on error. + + This method is only available since GCC_FE_VERSION_1. */ + + int /* bool */ (*compile) (struct gcc_base_context *self, + const char *filename); }; /* The GCC object. */