From patchwork Fri Apr 10 08:09:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 6124 Received: (qmail 21733 invoked by alias); 10 Apr 2015 08:09:47 -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 20710 invoked by uid 89); 10 Apr 2015 08:09:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, 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; Fri, 10 Apr 2015 08:09:45 +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 t3A89daU018134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 Apr 2015 04:09:39 -0400 Received: from host1.jankratochvil.net (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3A89YhD014117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 10 Apr 2015 04:09:37 -0400 Date: Fri, 10 Apr 2015 10:09:33 +0200 From: Jan Kratochvil To: Eli Zaretskii Cc: Paul_Koning@dell.com, gdb-patches@sourceware.org, pmuldoon@redhat.com Subject: Re: [doc patch] compile: missing bits [Re: [PATCH v2 7/9] compile: New 'compile print'] Message-ID: <20150410080933.GA8497@host1.jankratochvil.net> References: <20150406172623.31404.58833.stgit@host1.jankratochvil.net> <20150406172716.31404.8551.stgit@host1.jankratochvil.net> <83bnj1jgsw.fsf@gnu.org> <021F612D-0E51-44ED-BA7F-894A8B51F5BF@dell.com> <20150406175250.GA314@host1.jankratochvil.net> <0484210C-BBE9-4C64-8F51-7DC74ACF8F86@dell.com> <20150408200315.GA6777@host1.jankratochvil.net> <83egntg37h.fsf@gnu.org> <20150409173950.GA3400@host1.jankratochvil.net> <83pp7ddvcq.fsf@gnu.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <83pp7ddvcq.fsf@gnu.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Thu, 09 Apr 2015 20:12:21 +0200, Eli Zaretskii wrote: > > +@value{NGCC} (since version 4.7) stores the options used for compilation > > +into @code{DW_AT_producer} part of DWARF debugging information according > > +to the @value{NGCC} option @code{-grecord-gcc-switches}. One has to > > +explicitly specify @code{-g} during inferior compilation otherwise > > +@value{NGCC} produces no DWARF. > > Hmm... Are you sure -g always produces DWARF? Maybe we should say > that for targets where DWARF is not the default, -gdwarf-N should be > used, and also that -gstabs etc. should _not_ be used? While you are technically right I do not think it is appropriate to mention it that way. When some platform is still using -gstabs by default (is there any?) there are probably some serious reasons for it - such as some old debugging / crash analysing tools incompatible with DWARF. Using -gdwarf-X may do more harm than good there IMO; unless one really knows what s/he is doing and then one does not need to read this doc. I have just added: This feature is only relevant for platforms where @code{-g} produces DWARF by default, otherwise one may try to enforce DWARF by using @code{-gdwarf-4}. > > +Specifically @code{PATH} is searched for binaries matching regular expression > > +@code{@var{ARCH}(-[^-]*)?-@var{OS}-gcc} according to the inferior target being > > +debugged. @code{@var{ARCH}} is processor name - multiarch is supported, [...] > > +for pattern @code{s390x?}. @code{OS} is currently supported only for > > ^^^^^^^^^ > > @var{os}. Not sure if @code{@var{os}} is the same as @var{os}, used only @var{os}. Thanks, Jan gdb/doc/ 2015-04-10 Jan Kratochvil Eli Zaretskii * gdb.texinfo (Compiling and Injecting Code): Describe set debug compile, show debug compile. New subsection Compilation options for the compile command. New subsection Compiler search for the compile command. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index d794893..419439a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -17223,6 +17223,66 @@ compile file /home/user/example.c @end smallexample @end table +@noindent +The process of compiling and injecting the code can be inspected using: + +@table @code +@anchor{set debug compile} +@item set debug compile +@cindex compile command debugging info +Turns on or off display of @value{GDBN} process of compiling and +injecting the code. The default is off. + +@item show debug compile +Displays the current state of displaying @value{GDBN} process of +compiling and injecting the code. +@end table + +@subsection Compilation options for the @code{compile} command + +@value{GDBN} needs to specify the right compilation options for the code +to be injected, in part to make its ABI compatible with the inferior +and in part to make the injected code compatible with @value{GDBN}'s +injecting process. + +@noindent +The options used, in increasing precedence: + +@table @asis +@item target architecture and OS options (@code{gdbarch}) +These options depend on target processor type and target operating +system, usually they specify at least 32-bit (@code{-m32}) or 64-bit +(@code{-m64}) compilation option. + +@item compilation options recorded in the target +@value{NGCC} (since version 4.7) stores the options used for compilation +into @code{DW_AT_producer} part of DWARF debugging information according +to the @value{NGCC} option @code{-grecord-gcc-switches}. One has to +explicitly specify @code{-g} during inferior compilation otherwise +@value{NGCC} produces no DWARF. This feature is only relevant for +platforms where @code{-g} produces DWARF by default, otherwise one may +try to enforce DWARF by using @code{-gdwarf-4}. + +@item compilation options set by @code{set compile-args} +@end table + +@noindent +You can override compilation options using the following command: + +@table @code +@item set compile-args +@cindex compile command options override +Set compilation options used for compiling and injecting code with the +@code{compile} commands. These options override any conflicting ones +from the target architecture and/or options stored during inferior +compilation. + +@item show compile-args +Displays the current state of compilation options override. +This does not show all the options actually used during compilation, +use @ref{set debug compile} for that. +@end table + @subsection Caveats when using the @code{compile} command There are a few caveats to keep in mind when using the @code{compile} @@ -17380,6 +17440,24 @@ Access to those variables will generate a compiler error which @value{GDBN} will print to the console. @end table +@subsection Compiler search for the @code{compile} command + +@value{GDBN} needs to find @value{NGCC} for the inferior being debugged which +may not be obvious for remote targets of different architecture than where +@value{GDBN} is running. Environment variable @code{PATH} (@code{PATH} from +shell that executed @value{GDBN}, not the one set by @value{GDBN} +command @code{set environment}). @xref{Environment}. @code{PATH} on +@value{GDBN} host is searched for @value{NGCC} binary matching the +target architecture and operating system. + +Specifically @code{PATH} is searched for binaries matching regular expression +@code{@var{arch}(-[^-]*)?-@var{os}-gcc} according to the inferior target being +debugged. @var{arch} is processor name --- multiarch is supported, so for +example both @code{i386} and @code{x86_64} targets look for pattern +@code{(x86_64|i.86)} and both @code{s390} and @code{s390x} targets look +for pattern @code{s390x?}. @var{os} is currently supported only for +pattern @code{linux(-gnu)?}. + @node GDB Files @chapter @value{GDBN} Files