Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org, tromey@redhat.com
Subject: Re: [PATCH v2 14/14] the "compile" command
Date: Fri, 20 Jun 2014 19:17:00 -0000	[thread overview]
Message-ID: <83fvizqtlq.fsf@gnu.org> (raw)
In-Reply-To: <1403279874-23781-15-git-send-email-tromey@redhat.com>

> From: Tom Tromey <tromey@redhat.com>
> Cc: Tom Tromey <tromey@redhat.com>
> 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.


  reply	other threads:[~2014-06-20 19:17 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 15:58 [PATCH v2 00/15] let gdb reuse gcc's C compiler Tom Tromey
2014-06-20 15:58 ` [PATCH v2 11/14] export dwarf2_reg_to_regnum_or_error Tom Tromey
2014-06-20 15:58 ` [PATCH v2 04/14] add make_unqualified_type Tom Tromey
2014-06-20 15:58 ` [PATCH v2 03/14] add some missing ops to DWARF assembler Tom Tromey
2014-06-20 15:58 ` [PATCH v2 09/14] split dwarf2_fetch_cfa_info from dwarf2_compile_expr_to_ax Tom Tromey
2014-06-20 15:58 ` [PATCH v2 02/14] add gcc/gdb interface files Tom Tromey
2014-06-20 15:58 ` [PATCH v2 01/14] introduce ui_file_write_for_put Tom Tromey
2014-06-20 15:58 ` [PATCH v2 14/14] the "compile" command Tom Tromey
2014-06-20 19:17   ` Eli Zaretskii [this message]
2014-10-08 17:45     ` Jan Kratochvil
2014-10-08 18:42       ` Eli Zaretskii
2014-10-08 19:42         ` Jan Kratochvil
2014-06-20 16:26 ` [PATCH v2 13/14] add s390_gcc_target_options Tom Tromey
2014-06-20 16:32 ` [PATCH v2 12/14] add linux_infcall_mmap Tom Tromey
2014-06-20 16:32 ` [PATCH v2 05/14] add dummy frame destructor Tom Tromey
2014-06-20 16:32 ` [PATCH v2 07/14] add gnu_triplet_regexp gdbarch method Tom Tromey
2014-06-20 16:33 ` [PATCH v2 10/14] make dwarf_expr_frame_base_1 public Tom Tromey
2014-06-20 20:05   ` Doug Evans
2014-06-23  8:18     ` Gary Benson
2014-06-23 14:57       ` Eli Zaretskii
2014-06-24 10:18         ` Gary Benson
2014-06-24 13:04           ` Pedro Alves
2014-10-08 16:57             ` Jan Kratochvil
2014-06-20 16:39 ` [PATCH v2 08/14] introduce call_function_by_hand_dummy Tom Tromey
2014-06-20 16:51 ` [PATCH v2 06/14] add infcall_mmap and gcc_target_options gdbarch methods Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83fvizqtlq.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox