2011-09-15 Kevin Pouget <kevin.pouget@st.com>

Handle multiple breakpoint hits in Python interface:
	* python/py-bpevent.c (create_breakpoint_event_object): Rename C/Python
	variable to breakpoints.
	* python/py-stopevent.c (emit_stop_event): Return a Python tuple of
	bps instead of single breakpoint. Fix some space typos.
	* python/py-stopevent.c (create_breakpoint_event_object): Rename
	variable to breakpoints.

testsuite:
	* gdb.python/py-events.exp: Set a duplicate breakpoint and check its
	presence.
	* gdb.python/py-events.py (breakpoint_stop_handler): Browse all the
	breakpoint hits.

doc:
	* gdb.texinfo (Events In Python): New function documentation:
	gdb.BreakpointEvent.breakpoints. Indicate that
	gdb.BreakpointEvent.breakpoint is now deprecated.
This commit is contained in:
Kevin Pouget 2011-09-15 12:27:20 +00:00
parent 672f9b6009
commit 6839b47f2b
10 changed files with 85 additions and 17 deletions

View file

@ -1,3 +1,13 @@
2011-09-15 Kevin Pouget <kevin.pouget@st.com>
Handle multiple breakpoint hits in Python interface:
* python/py-bpevent.c (create_breakpoint_event_object): Rename C/Python
variable to breakpoints.
* python/py-stopevent.c (emit_stop_event): Return a Python tuple of
bps instead of single breakpoint. Fix some space typos.
* python/py-stopevent.c (create_breakpoint_event_object): Rename
variable to breakpoints.
2011-09-15 Kevin Pouget <kevin.pouget@st.com>
* breakpoint.c (describe_other_breakpoints): Do not write 'duplicate'

View file

@ -38,6 +38,9 @@
** Symbols now provide the "type" attribute, the type of the symbol.
** The "gdb.breakpoint" function has been deprecated in favor of
"gdb.breakpoints".
* libthread-db-search-path now supports two special values: $sdir and $pdir.
$sdir specifies the default system locations of shared libraries.
$pdir specifies the directory where the libpthread used by the application

View file

@ -1,3 +1,10 @@
2011-09-15 Kevin Pouget <kevin.pouget@st.com>
Handle multiple breakpoint hits in Python interface:
* gdb.texinfo (Events In Python): New function documentation:
gdb.BreakpointEvent.breakpoints. Indicate that
gdb.BreakpointEvent.breakpoint is now deprecated.
2011-09-04 Joel Brobecker <brobecker@adacore.com>
* gdb.texinfo: Set EDITION to "Tenth" and change ISBN.

View file

@ -22317,14 +22317,19 @@ the @value{GDBN} command prompt.
Also emits @code{gdb.BreakpointEvent} which extends @code{gdb.StopEvent}.
@code{gdb.BreakpointEvent} event indicates that a breakpoint has been hit, and
has the following attributes:
@code{gdb.BreakpointEvent} event indicates that one or more breakpoints have
been hit, and has the following attributes:
@table @code
@defivar BreakpointEvent breakpoint
A reference to the breakpoint that was hit of type @code{gdb.Breakpoint}.
@defivar BreakpointEvent breakpoints
A sequence containing references to all the breakpoints (type
@code{gdb.Breakpoint}) that were hit.
@xref{Breakpoints In Python}, for details of the @code{gdb.Breakpoint} object.
@end defivar
@defivar BreakpointEvent breakpoint
A reference to the first breakpoint that was hit.
This function is maintained for backward compatibility and is now deprecated
in favor of the @code{gdb.BreakpointEvent.breakpoints} function.
@end table
@end table

View file

@ -24,7 +24,7 @@ static PyTypeObject breakpoint_event_object_type;
/* Create and initialize a BreakpointEvent object. */
PyObject *
create_breakpoint_event_object (PyObject *breakpoint)
create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp)
{
PyObject *breakpoint_event_obj =
create_stop_event_object (&breakpoint_event_object_type);
@ -34,7 +34,11 @@ create_breakpoint_event_object (PyObject *breakpoint)
if (evpy_add_attribute (breakpoint_event_obj,
"breakpoint",
breakpoint) < 0)
first_bp) < 0)
goto fail;
if (evpy_add_attribute (breakpoint_event_obj,
"breakpoints",
breakpoint_list) < 0)
goto fail;
return breakpoint_event_obj;

View file

@ -45,18 +45,42 @@ int
emit_stop_event (struct bpstats *bs, enum target_signal stop_signal)
{
PyObject *stop_event_obj = NULL; /* Appease GCC warning. */
PyObject *list = NULL;
PyObject *first_bp = NULL;
struct bpstats *current_bs;
if (evregpy_no_listeners_p (gdb_py_events.stop))
return 0;
if (bs && bs->breakpoint_at
&& bs->breakpoint_at->py_bp_object)
/* Add any breakpoint set at this location to the list. */
for (current_bs = bs; current_bs != NULL; current_bs = current_bs->next)
{
stop_event_obj = create_breakpoint_event_object ((PyObject *) bs
->breakpoint_at
->py_bp_object);
if (current_bs->breakpoint_at
&& current_bs->breakpoint_at->py_bp_object)
{
PyObject *current_py_bp =
(PyObject *) current_bs->breakpoint_at->py_bp_object;
if (list == NULL)
{
list = PyList_New (0);
if (!list)
goto fail;
}
if (PyList_Append (list, current_py_bp))
goto fail;
if (first_bp == NULL)
first_bp = current_py_bp;
}
}
if (list != NULL)
{
stop_event_obj = create_breakpoint_event_object (list, first_bp);
if (!stop_event_obj)
goto fail;
goto fail;
}
/* Check if the signal is "Signal 0" or "Trace/breakpoint trap". */
@ -75,13 +99,14 @@ emit_stop_event (struct bpstats *bs, enum target_signal stop_signal)
{
stop_event_obj = create_stop_event_object (&stop_event_object_type);
if (!stop_event_obj)
goto fail;
goto fail;
}
return evpy_emit_event (stop_event_obj, gdb_py_events.stop);
fail:
return -1;
fail:
Py_XDECREF (list);
return -1;
}
GDBPY_NEW_EVENT_TYPE (stop,

View file

@ -28,7 +28,8 @@ extern void stop_evpy_dealloc (PyObject *self);
extern int emit_stop_event (struct bpstats *bs,
enum target_signal stop_signal);
extern PyObject *create_breakpoint_event_object (PyObject *breakpoint);
extern PyObject *create_breakpoint_event_object (PyObject *breakpoint_list,
PyObject *first_bp);
extern PyObject *create_signal_event_object (enum target_signal stop_signal);

View file

@ -1,3 +1,11 @@
2011-04-30 Kevin Pouget <kevin.pouget@st.com>
Handle multiple breakpoint hits in Python interface:
* gdb.python/py-events.exp: Set a duplicate breakpoint and check its
presence.
* gdb.python/py-events.py (breakpoint_stop_handler): Browse all the
breakpoint hits.
2011-09-13 Sami Wagiaalla <swagiaal@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>

View file

@ -39,13 +39,16 @@ if ![runto_main ] then {
gdb_test "Test_Events" "Event testers registered."
gdb_breakpoint "first"
gdb_breakpoint "first"
# Test continue event and breakpoint stop event
gdb_test "continue" ".*event type: continue.*
.*event type: stop.*
.*stop reason: breakpoint.*
.*first breakpoint number: 2.*
.*breakpoint number: 2.*
.*breakpoint number: 3.*
all threads stopped"
#test exited event.

View file

@ -31,7 +31,9 @@ def breakpoint_stop_handler (event):
print "event type: stop"
if (isinstance (event, gdb.BreakpointEvent)):
print "stop reason: breakpoint"
print "breakpoint number: %s" % (event.breakpoint.number)
print "first breakpoint number: %s" % (event.breakpoint.number)
for bp in event.breakpoints:
print "breakpoint number: %s" % (bp.number)
if ( event.inferior_thread is not None) :
print "thread num: %s" % (event.inferior_thread.num);
else: