Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Phil Muldoon <pmuldoon@redhat.com>
Cc: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [patch][python] Add breakpoint support.
Date: Mon, 05 Apr 2010 16:27:00 -0000	[thread overview]
Message-ID: <20100405162648.GD19194@adacore.com> (raw)
In-Reply-To: <4BB0B063.6000600@redhat.com>

General question: How come the python error strings are not i18n'ed?
For instance: 

> +      PyErr_SetString (PyExc_TypeError, "cannot delete `silent' attribute");

This is definitely the standard, currently. Is that normal?

> 2010-03-29  Phil Muldoon  <pmuldoon@redhat.com>
> 	    Thiago Jung Bauermann  <bauerman@br.ibm.com>
>    	    Tom Tromey  <tromey@redhat.com>
> 
> 	* breakpoint.c (condition_command): Simplify.  Move condition
> 	setting code too ...
> 	(set_breakpoint_condition): ... here.  New function.
> 	* breakpoint.h  (set_breakpoint_condition): Declare.
> 	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-breakpoint.
> 	(SUBDIR_PYTHON_SRCS): Likewise.
> 	(py-breakpoint.o): New rule.
> 	* python/py-breakpoint.c: New file.
> 	* python/python-internal.h (gdbpy_breakpoints)
> 	(gdbpy_get_hook_function, gdbpy_initialize_breakpoints): Declare.
> 	(GDB_PY_SET_HANDLE_EXCEPTION) Define.
> 	* python/python.c (gdbpy_get_hook_function): New function.

Overall, it looks fine to me. Just a few comments...

> +/* From breakpoint.c.  */
> +extern struct breakpoint *breakpoint_chain;

This shouldn't be needed.  The only use I found was:

> +  for (bp = breakpoint_chain; bp; bp = bp->next)
> +    if (bp->number == num)
> +      break;

But there is a public function that should return the breakpoint you
are looking for: get_breakpoint.

> +/* Evaluate to true if the breakpoint NUM is valid, false otherwise.  */
> +#define BPPY_VALID_P(Num)			\
> +    ((Num) >= 0					\
> +     && (Num) < bppy_slots			\
> +     && bppy_breakpoints[Num] != NULL)

Personally (and I litterally mean it, it's a personal preference),
I'd rather we did not use macros, but a real function... Being a static
function, I'm sure the compiler will be capable of performing whatever
is best for performance (and that way, we can avoid the parens around
"Num", and the "do/while(0)" dance in the macro that follows).

> +  breakpoint_object *self_bp = (breakpoint_object *) self;
> +  if (self_bp->bp)

Can you add an empty line after the declaration(s)?

> +/* Python function to set the thread of a breakpoint.  */
> +static int
> +bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)

Small request: Can we have the same for tasks (Ada tasks)? The function
that allows you to verify that a given task number is valid is:

        extern int valid_task_id (int);

Similarly, we can also have a getter for the breakpoint task ID?

> +  if (bp->type != bp_breakpoint && bp->type != bp_watchpoint
> +      && bp->type != bp_hardware_watchpoint  
> +      && bp->type != bp_read_watchpoint
> +      && bp->type != bp_access_watchpoint)

Small nit-pick? Since we're aligning all conditions, can we split the
first line in two?

     if (bp->type != bp_breakpoint
         && bp->type != bp_watchpoint
         && bp->type != bp_hardware_watchpoint  
         && bp->type != bp_read_watchpoint
         && bp->type != bp_access_watchpoint)

I think it'll be easier to not miss the "!= bp_watchpoint" condition.

> +PyObject *
> +gdbpy_get_hook_function (const char *name)

This function needs to be documented...

> +set testfile "py-breakpoint"
> +set srcfile ${testfile}.c
> +set binfile ${objdir}/${subdir}/${testfile}
> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
> +    untested "Couldn't compile ${srcfile}"
> +    return -1
> +}

> +# Start with a fresh gdb.
> +gdb_exit
> +gdb_start
> +gdb_reinitialize_dir $srcdir/$subdir
> +gdb_load ${binfile}

All the above can be simplified into:

    set testfile "py-breakpoint"
    set srcfile ${testfile}.c
    if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
        return -1
    }

I mention this, because people rarely seem to know about this...

> +gdb_test "python print blist\[0\].location" "main." "Check breakpoint location"
                                                   ^^^
   Can you check whether you might need to escape the period, here?

> +# Start with a fresh gdb.
> +gdb_exit
> +gdb_start
> +gdb_reinitialize_dir $srcdir/$subdir
> +gdb_load ${binfile}

You can replace this with a call to clean_restart.

-- 
Joel


  parent reply	other threads:[~2010-04-05 16:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-29 13:52 Phil Muldoon
2010-03-29 14:28 ` Eli Zaretskii
2010-03-29 14:53   ` Phil Muldoon
2010-03-29 15:15     ` Eli Zaretskii
2010-04-05 16:27 ` Joel Brobecker [this message]
2010-04-06 13:47   ` Phil Muldoon
2010-04-06 18:21     ` Eli Zaretskii
2010-04-07 21:09     ` Tom Tromey
2010-04-08 12:42       ` Phil Muldoon
2010-04-08 15:29         ` Joel Brobecker
2010-04-08 19:48           ` Phil Muldoon
2010-04-08 20:41             ` Tom Tromey
2010-04-08 21:27               ` Phil Muldoon
2010-04-08 21:45                 ` Joel Brobecker
2010-04-08 22:21                   ` Pedro Alves
2010-04-08 23:26                     ` Joel Brobecker
2010-04-08 23:40                       ` Pedro Alves
2010-04-09 15:35                       ` Tom Tromey
2010-04-09 15:32                   ` Tom Tromey
2010-04-08 19:57         ` Tom Tromey
2010-04-09 10:11           ` Phil Muldoon
2010-04-07 21:19     ` Joel Brobecker
2010-06-11 17:41     ` Ulrich Weigand
2010-06-11 20:28       ` Phil Muldoon

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=20100405162648.GD19194@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@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