From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26376 invoked by alias); 20 Jun 2014 19:17:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26360 invoked by uid 89); 20 Jun 2014 19:17:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout22.012.net.il Received: from mtaout22.012.net.il (HELO mtaout22.012.net.il) (80.179.55.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Jun 2014 19:17:03 +0000 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0N7H00600E5FDX00@a-mtaout22.012.net.il> for gdb-patches@sourceware.org; Fri, 20 Jun 2014 22:17:01 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N7H006ZOEWC59A0@a-mtaout22.012.net.il>; Fri, 20 Jun 2014 22:17:01 +0300 (IDT) Date: Fri, 20 Jun 2014 19:17:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH v2 14/14] the "compile" command In-reply-to: <1403279874-23781-15-git-send-email-tromey@redhat.com> To: Tom Tromey Cc: gdb-patches@sourceware.org, tromey@redhat.com Reply-to: Eli Zaretskii Message-id: <83fvizqtlq.fsf@gnu.org> References: <1403279874-23781-1-git-send-email-tromey@redhat.com> <1403279874-23781-15-git-send-email-tromey@redhat.com> X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00780.txt.bz2 > From: Tom Tromey > Cc: Tom Tromey > Date: Fri, 20 Jun 2014 09:57:54 -0600 > > +* GDB now supports the compilation and injection of source code into > + the inferior. GDB will use a feature-capable compiler to compile > + the source code to object code, and if successful, inject and > + execute that code within the current context of the inferior. Like I said, we should at least mention GCC and likely also the name of the plugin needed to support this feature. users should be able to quickly discover whether their compiler supports this. > + Currently the C language is supported. The commands used to > + interface with this new feature are: > + > + compile code [-raw|-r] [--] [source code] > + compile file [-raw|-r] filename > + > * GDB supports printing and modifying of variable length automatic arrays > as specified in ISO C99. > > @@ -33,6 +43,15 @@ guile-repl > gr > Start a Guile interactive prompt (or "repl" for "read-eval-print loop"). > > +compile code [-r|-raw] [--] [source code] > + Compile and inject into the inferior the executable object code > + produced by compiling the provided source code. "Compile, inject, and execute", I think. > +Evaluate a block of source code.\n\ > +\n\ > +Usage: code [-r|-raw] [--] [CODE]\n\ "compile code", I think. > +The source code may be specified as a simple one line expression, e.g:\n\ ^^^ Period missing. > +Usage: file [-r|-raw] [filename]\n\ "compile file" > + /* Override flags possibly coming from DW_AT_producer. */ > + compile_args = xstrdup ("-O0 -gdwarf-4" This cannot be a fixed setting, I think. E.g., MinGW compilers barf when they see -gdwarf-4. > + /* We use -fPIC to ensure that we can reference properly. Otherwise > + on x86-64 a string constant's address might be truncated when gdb > + loads the object; another approach would be -mcmodel=large, but > + -fPIC seems more portable across back ends. */ > + " -fPIC" > + /* We don't want warnings. */ > + " -w" > + /* Override CU's possible -fstack-protector-strong. */ > + " -fno-stack-protector" Likewise: these are architecture dependent switches, they cannot be fixed constants, I think. > +@value{GDBN} supports on-demand compilation and code injection into > +programs running under @value{GDBN}. A suitable compiler must be > +installed for this functionality to be enabled. This functionality is > +implemented with the following commands. My request still stands to mention GCC and perhaps its version or some other attribute that would make it easy to determine that the feature is supported. > +language in @value{GDBN} (@pxref{Languages}). If compilation and > +injection is not supported with the current language specified in > +@value{GDBN}, or the compiler does not support this feature, an error > +message will be printed and the command will exit. If @var{source} The "and the command will exit" part is misleading, suggest to remove it (it doesn't add anything useful to the description). > +Specifying @samp{-@var{raw}}, prohibits @value{GDBN} from wrapping the Please remove the @var part and the braces (here and elsewhere), it is incorrect here, since "raw" is a literal string. > +provided @var{source} in a callable scope. In this case, you must > +specify the entry point of the code by defining a function named > +@code{_gdb_expr_}. The @samp{-@var{raw}} code does not automatically > +access variables of the inferior, for their import you must use the > +@samp{#pragma} line first: > + > +@smallexample > +#pragma GCC user_expression > +@end smallexample > + > +@samp{#include} lines are better to be placed before the @samp{#pragma} > +line. The use of @var{raw} is considered to be expert usage, and care ^^^^^^^^^ @code{-raw} Thanks.