Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Thiago Jung Bauermann <bauerman@br.ibm.com>
Cc: Tom Tromey <tromey@redhat.com>,
		gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [RFA] Re: [RFC][patch 1/9] initial Python support
Date: Fri, 18 Jul 2008 19:50:00 -0000	[thread overview]
Message-ID: <20080718195010.GA14356@caradoc.them.org> (raw)
In-Reply-To: <1216245620.12209.18.camel@localhost.localdomain>

On Wed, Jul 16, 2008 at 07:00:20PM -0300, Thiago Jung Bauermann wrote:
> +#
> +# python sub directory definitons
> +#
> +SUBDIR_PYTHON_OBS = \
> +	python-utils.o
> +SUBDIR_PYTHON_SRCS = \
> +	python/python.c \
> +	python/utils.c

Can we call it python-utils.c or something else, instead?  IMO having
different naming for the source file and object is very confusing.

> @@ -1283,7 +1303,11 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
>  # duplicates.  Files in the gdb/ directory can end up appearing in
>  # COMMON_OBS (as a .o file) and CONFIG_SRCS (as a .c file).
>  
> -INIT_FILES = $(COMMON_OBS) $(TSOBS) $(CONFIG_SRCS)
> +# NOTE: bauermann/2008-06-15: python.c needs to be explicitly included
> +# because the generation of init.c does not work for .c files which
> +# result in differently named objects (i.e., python/python -> python.o).
> +
> +INIT_FILES = $(COMMON_OBS) $(TSOBS) $(CONFIG_SRCS) python/python.c

This comment doesn't make sense.  python/python.c is already included
in INIT_FILES, because of CONFIG_SRCS.

> +# Flags needed to compile Python code (taken from python-config --cflags)
> +PYTHON_CFLAGS=-fno-strict-aliasing -DNDEBUG -fwrapv

The output of python-config will vary by platform (that's the point of
having a helper program).  So, I'm afraid we have to run python-config
if we need the cflags.  Or else we could add these flags
unconditionally, if they work with the current compiler.  Consider
non-GCC.

> @@ -538,6 +560,17 @@ execute_control_command (struct command_line *cmd)
>    return ret;
>  }
>  
> +/* Like execute_control_command, but first set
> +   suppress_next_print_command_trace.   */
> +
> +enum command_control_type
> +execute_control_command_suppressed (struct command_line *cmd)
> +{
> +  suppress_next_print_command_trace = 1;
> +  return execute_control_command (cmd);
> +}
> +
> +
>  /* "while" command support.  Executes a body of statements while the
>     loop condition is nonzero.  */
>  

This is an unclear name - suppressed what?  Maybe
execute_control_command_untraced is more accurate.

> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 2920179..b1419a7 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -165,6 +165,7 @@ software in general.  We will miss him.
>  * Emacs::                       Using @value{GDBN} under @sc{gnu} Emacs
>  * GDB/MI::                      @value{GDBN}'s Machine Interface.
>  * Annotations::                 @value{GDBN}'s annotation interface.
> +* Python::                      Scripting @value{GDBN} using Python.
>  
>  * GDB Bugs::                    Reporting bugs in @value{GDBN}
>  

We should ask Eli to look at the manual.

> +@kindex set python-stack
> +By default, @value{GDBN} will print a stack trace when an error occurs
> +in a Python script.  This can be controlled using @code{set python-stack}.

Please expand this; see e.g. Print Settings for the usual way we
document commands.  In particular it should say what the values
are/mean.

Also, perhaps this should use a prefix command, like "set python
print-stack"?

There should probably be an explicit table item for the "python"
command, too.

> +/* Python 2.4 doesn't include stdint.h soon enough to get {u,}intptr_t
> +   needed by pyport.h.  */
> +#ifdef HAVE_STDINT_H
> +#include <stdint.h>
> +#endif

You can include stdint.h unconditionally now; gnulib provides it.

> +/* /usr/include/features.h on linux systems will define _POSIX_C_SOURCE
> +   if it sees _GNU_SOURCE (which config.h will define).
> +   pyconfig.h defines _POSIX_C_SOURCE to a different value than
> +   /usr/include/features.h does causing compilation to fail.
> +   To work around this, undef _POSIX_C_SOURCE before we include Python.h.  */
> +#undef _POSIX_C_SOURCE

Odd.  For me, pyconfig.h and features.h define it to the same thing.
Anyway, this is gross but acceptable.

> +static PyMethodDef GdbMethods[] =
> +{
> +  { "execute", execute_gdb_command, METH_VARARGS,
> +    "Execute a gdb command" },
> +  { "show", get_show_variable, METH_VARARGS,
> +    "Return a gdb setting's value" },
> +
> +  { "write", gdbpy_write, METH_VARARGS,
> +    "Write a string using gdb's filtered stream." },
> +  { "flush", gdbpy_flush, METH_NOARGS,
> +    "Flush gdb's filtered stdout stream." },
> +
> +  {NULL, NULL, 0, NULL}
> +};

I think that these are now "gdb commands", effectively.  So, sorry,
but there's a bit more documentation you get to write :-)  No new
undocumented public interfaces.

> +  /* Create a couple objects which are used for Python's stdout and
> +     stderr.  */
> +  PyRun_SimpleString ("\
> +import sys\n\
> +class GdbOutputFile:\n\
> +  def close(self):\n\
> +    # Do nothing.\n\
> +    return None\n\
> +\n\
> +  def isatty(self):\n\
> +    return False\n\
> +\n\
> +  def write(self, s):\n\
> +    gdb.write(s)\n\
> +\n\
> +  def writelines(self, iterable):\n\
> +    for line in iterable:\n\
> +      self.write(line)\n\
> +\n\
> +  def flush(self):\n\
> +    gdb.flush()\n\
> +\n\
> +sys.stderr = GdbOutputFile()\n\
> +sys.stdout = GdbOutputFile()\n\

This is OK for now, but it is likely to grow.  There's code to convert
a text file into a C string, in features/ (used for XML files); maybe
we should internalize a couple of Python source files that way?
Alternatively we could install Python source files to a known path in
the build / install directories; that lets vendors precompile the
files for faster startup.

Anyway, that's a future note, not a current problem.

> +/* Initialize dummy Python code.  */
> +
> +void
> +_initialize_python (void)
> +{
> +  add_com ("python", class_obscure, python_command, _("\
> +Evaluate a Python command.\n\
> +\n\
> +Python scripting is not supported in this copy of GDB.\n\
> +This command is only a placeholder."));
> +
> +  add_setshow_boolean_cmd ("python-stack", class_maintenance,
> +			   &gdbpy_should_print_stack, _("\
> +Set Python stack printing."), _("\
> +Show Python stack printing."), _("\
> +Enables printing of Python stack traces."),
> +			   NULL, NULL,
> +			   &maintenance_set_cmdlist,
> +			   &maintenance_show_cmdlist);
> +
> +}

If the list of python configuration variables grows, this will get out
of hand; I suggest sharing the init code regardless of HAVE_PYTHON.

This patch is enough for a first NEWS entry.

Otherwise OK :-)

-- 
Daniel Jacobowitz
CodeSourcery


  reply	other threads:[~2008-07-18 19:50 UTC|newest]

Thread overview: 147+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-29 15:59 [RFC][patch 0/9] Python support in GDB Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 5/9] permit GDB commands implemented in Python Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 9/9] export threads to Python Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 6/9] export frames " Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 8/9] export symtab mechanism " Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 3/9] export hooks " Thiago Jung Bauermann
2008-04-29 21:29   ` Tom Tromey
2008-04-30 18:27     ` Joel Brobecker
2008-04-30 21:30       ` Tom Tromey
2008-05-27 18:22         ` Tom Tromey
2008-04-30 18:29     ` Daniel Jacobowitz
2008-04-30 23:00       ` Tom Tromey
2008-05-29  7:55   ` Daniel Jacobowitz
2008-05-30 14:59     ` Tom Tromey
2008-06-15 22:53       ` Thiago Jung Bauermann
2008-06-15 22:58         ` Tom Tromey
2008-06-16  3:22           ` Daniel Jacobowitz
2008-06-17 18:13             ` Thiago Jung Bauermann
2008-06-17 22:20               ` Joel Brobecker
2008-06-23 17:58                 ` Tom Tromey
2008-04-29 16:08 ` [RFC][patch 7/9] export block and symbol " Thiago Jung Bauermann
2008-04-29 18:11 ` [RFC][patch 4/9] export breakpoints " Thiago Jung Bauermann
2008-04-29 18:15 ` [RFC][patch 1/9] initial Python support Thiago Jung Bauermann
2008-05-05  8:12   ` Thiago Jung Bauermann
2008-05-05 14:39     ` Daniel Jacobowitz
2008-05-05 14:46       ` Thiago Jung Bauermann
2008-05-05 16:50         ` Daniel Jacobowitz
2008-05-06  2:38           ` Thiago Jung Bauermann
2008-05-11 22:24           ` Thiago Jung Bauermann
2008-05-11 22:26             ` Daniel Jacobowitz
2008-05-12 20:33               ` Thiago Jung Bauermann
2008-05-12 20:39                 ` Daniel Jacobowitz
2008-05-12 21:00                   ` Thiago Jung Bauermann
2008-05-29  0:29   ` Daniel Jacobowitz
2008-05-30 13:07     ` Function syntax (Was: [RFC][patch 1/9] initial Python support) Tom Tromey
2008-06-08 15:24       ` Doug Evans
2008-06-08 15:32         ` Function syntax Tom Tromey
2008-06-08 18:21       ` Function syntax (Was: [RFC][patch 1/9] initial Python support) Daniel Jacobowitz
2008-06-09 13:48         ` Thiago Jung Bauermann
2008-06-09 18:43           ` Daniel Jacobowitz
2008-06-10  0:24             ` Function syntax Tom Tromey
2008-06-10  0:04           ` Tom Tromey
2008-06-11  0:04             ` Thiago Jung Bauermann
2008-06-10  0:00         ` Tom Tromey
2008-05-30 14:47     ` [RFC][patch 1/9] initial Python support Tom Tromey
2008-06-15 22:35     ` thiagoju
2008-06-23 17:36       ` Tom Tromey
2008-07-06 17:28         ` Tom Tromey
2008-07-08  4:12           ` Thiago Jung Bauermann
2008-07-15  7:38       ` [RFA] " Thiago Jung Bauermann
2008-07-15 17:19         ` Tom Tromey
2008-07-15 18:33           ` Thiago Jung Bauermann
2008-07-15 19:03             ` Tom Tromey
2008-07-16  7:14               ` Thiago Jung Bauermann
2008-07-16 14:39           ` Tom Tromey
2008-07-16 22:02             ` Thiago Jung Bauermann
2008-07-18 19:50               ` Daniel Jacobowitz [this message]
2008-07-18 23:24                 ` Tom Tromey
2008-07-19  0:45                   ` Daniel Jacobowitz
2008-07-19 19:50                 ` [RFA] iRe: " Thiago Jung Bauermann
2008-07-19 21:13                   ` Daniel Jacobowitz
2008-07-19 22:13                     ` Thiago Jung Bauermann
2008-07-20 23:47                   ` Thiago Jung Bauermann
2008-07-21  2:03                     ` Daniel Jacobowitz
2008-07-23 17:46                       ` [obvious] Wipe out CONFIG_INITS Thiago Jung Bauermann
2008-07-20 22:43                 ` [RFA] Re: [RFC][patch 1/9] initial Python support Tom Tromey
2008-07-21  1:59                   ` Daniel Jacobowitz
2008-07-21 15:29                 ` [RFA][patch 1/9] Yet another respin of the patch with " Thiago Jung Bauermann
2008-07-21 16:47                   ` Thiago Jung Bauermann
2008-07-26 13:07                   ` Eli Zaretskii
2008-07-26 13:43                     ` Daniel Jacobowitz
2008-07-26 14:02                       ` Eli Zaretskii
2008-07-26 14:42                         ` Daniel Jacobowitz
2008-07-26 17:06                           ` Eli Zaretskii
2008-07-26 17:26                             ` Tom Tromey
2008-07-26 19:21                               ` Eli Zaretskii
2008-07-26 17:40                             ` Daniel Jacobowitz
2008-07-26 17:10                           ` Tom Tromey
2008-07-26 17:40                             ` Eli Zaretskii
2008-07-26 18:00                               ` Tom Tromey
2008-07-26 18:29                                 ` Eli Zaretskii
2008-07-26 18:45                                   ` Tom Tromey
2008-07-26 19:34                                     ` Eli Zaretskii
2008-07-30 14:59                                       ` Thiago Jung Bauermann
2008-07-30 17:57                                         ` Eli Zaretskii
2008-08-04  4:44                                           ` Thiago Jung Bauermann
2008-08-04 19:18                                             ` Eli Zaretskii
2008-08-05  3:42                                               ` Thiago Jung Bauermann
2008-07-26 17:04                     ` Tom Tromey
2008-07-26 17:35                       ` Daniel Jacobowitz
2008-07-26 17:42                         ` Tom Tromey
2008-07-26 19:18                           ` Eli Zaretskii
2008-08-04  2:52                             ` Thiago Jung Bauermann
2008-08-04  3:22                               ` Eli Zaretskii
2008-08-04 12:15                                 ` Daniel Jacobowitz
2008-08-04 19:50                                   ` Eli Zaretskii
2008-08-05  2:08                                     ` Daniel Jacobowitz
2008-08-05  2:41                                       ` Thiago Jung Bauermann
2008-08-05  3:32                                       ` Eli Zaretskii
2008-08-05 12:19                                         ` Daniel Jacobowitz
2008-08-05 18:10                                           ` Eli Zaretskii
2008-08-05 18:23                                             ` Daniel Jacobowitz
2008-08-05 18:50                                               ` Eli Zaretskii
2008-08-05 18:58                                                 ` Daniel Jacobowitz
2008-07-26 19:20                         ` Eli Zaretskii
2008-07-26 18:11                       ` Eli Zaretskii
2008-07-26 18:30                         ` Daniel Jacobowitz
2008-07-26 19:26                           ` Eli Zaretskii
2008-08-01 20:04                           ` Tom Tromey
2008-08-02 17:38                             ` Daniel Jacobowitz
2008-08-02 17:50                               ` Tom Tromey
2008-08-02 19:00                               ` Eli Zaretskii
2008-08-05  4:19                         ` Thiago Jung Bauermann
2008-08-05 18:14                           ` Eli Zaretskii
2008-08-06  5:35                             ` [RFA][patch 1/9] Initial Python support, patch du jour Thiago Jung Bauermann
2008-08-06 18:24                               ` Eli Zaretskii
2008-08-06 19:53                                 ` Thiago Jung Bauermann
2008-08-04  4:44                     ` [RFA][patch 1/9] Yet another respin of the patch with initial Python support Thiago Jung Bauermann
2008-08-04 19:22                       ` Eli Zaretskii
2008-08-05  1:24                         ` Thiago Jung Bauermann
2008-08-02 17:41                   ` Daniel Jacobowitz
2008-08-02 19:02                     ` Eli Zaretskii
2008-08-02 19:07                       ` Daniel Jacobowitz
2008-07-15 18:01         ` [RFA] Re: [RFC][patch 1/9] " Thiago Jung Bauermann
2008-04-29 18:17 ` [RFC][patch 2/9] export values mechanism to Python Thiago Jung Bauermann
2008-05-29  1:23   ` Daniel Jacobowitz
2008-06-03  0:19     ` Tom Tromey
2008-06-03 13:04       ` Daniel Jacobowitz
2008-06-03 14:52         ` Tom Tromey
2008-07-07  6:03       ` Thiago Jung Bauermann
2008-07-07 23:44         ` Tom Tromey
2008-07-26  2:55           ` Daniel Jacobowitz
2008-07-26 17:17             ` Tom Tromey
2008-07-26 17:41               ` Daniel Jacobowitz
2008-07-30  3:01                 ` Tom Tromey
2008-07-30 14:26                   ` Thiago Jung Bauermann
2008-08-13  6:45         ` [python] acessing struct elements Thiago Jung Bauermann
2008-08-13 12:38           ` Daniel Jacobowitz
2008-08-13 20:38             ` Thiago Jung Bauermann
2008-08-17 20:16           ` Tom Tromey
2008-04-29 18:38 ` [RFC][patch 0/9] Python support in GDB Eli Zaretskii
2008-04-29 20:37   ` Thiago Jung Bauermann
2008-04-29 21:22     ` Tom Tromey
2008-04-30  7:54       ` Eli Zaretskii
2008-04-30 19:38         ` Thiago Jung Bauermann
2008-04-30 19:52           ` Eli Zaretskii
2008-05-02 18:30 ` Vladimir Prus

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=20080718195010.GA14356@caradoc.them.org \
    --to=drow@false.org \
    --cc=bauerman@br.ibm.com \
    --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