From patchwork Sun May 24 18:57:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 6910 Received: (qmail 30104 invoked by alias); 24 May 2015 18:58:07 -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 30065 invoked by uid 89); 24 May 2015 18:58:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 24 May 2015 18:57:56 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4OIvtMe002654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sun, 24 May 2015 14:57:55 -0400 Received: from host1.jankratochvil.net (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4OIvrF2022828; Sun, 24 May 2015 14:57:54 -0400 Subject: [PATCH v4 1/2] compile: set debug compile: Display GCC driver filename From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Phil Muldoon Date: Sun, 24 May 2015 20:57:52 +0200 Message-ID: <20150524185752.31862.62312.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes 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. Jan gdb/ChangeLog 2015-05-24 Jan Kratochvil * compile/compile.c (compile_to_object): Conditionally call set_verbose. Conditionally call compile or compile_v0. include/ChangeLog 2015-05-24 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/compile/compile.c | 11 +++++++++-- include/gcc-interface.h | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 499c530..7980153 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -541,6 +541,9 @@ compile_to_object (struct command_line *cmd, const char *cmd_string, get_args (compiler, gdbarch, &argc, &argv); make_cleanup_freeargv (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) @@ -578,8 +581,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, source_file); - if (!compiler->fe->ops->compile (compiler->fe, object_file, - compile_debug)) + if (compiler->fe->ops->version >= GCC_FE_VERSION_1) + ok = compiler->fe->ops->compile (compiler->fe, object_file); + else + ok = compiler->fe->ops->compile_v0 (compiler->fe, object_file, + compile_debug); + if (!ok) error (_("Compilation failed.")); if (compile_debug) diff --git a/include/gcc-interface.h b/include/gcc-interface.h index df7db6e..90be018 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. */