Introduce gdb.FinishBreakpoint in Python
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-finishbreakpoint.o. (SUBDIR_PYTHON_SRCS): Add python/py-finishbreakpoint.c. Add build rule for this file. * infcmd.c (print_return_value): Split to create get_return_value. (get_return_value): New function based on print_return_value. Handle case where stop_registers are not set. * inferior.h (get_return_value): New prototype. * python/py-breakpoint.c (bppy_pending_object): Make non-static. (gdbpy_breakpoint_created): Set is_py_finish_bp is necessary. (struct breakpoint_object): Move to python-internal.h (BPPY_REQUIRE_VALID): Likewise. (BPPY_SET_REQUIRE_VALID): Likewise. (gdbpy_breakpoint_created): Initialize is_finish_bp. (gdbpy_should_stop): Add pre/post hooks before/after calling stop method. * python/python-internal.h (breakpoint_object_type): Add as extern. (bppy_pending_object): Likewise. (typedef struct breakpoint_object) Removed. (struct breakpoint_object): Moved from py-breakpoint.c. Add field is_finish_bp. (BPPY_REQUIRE_VALID): Moved from py-breakpoint.c. (BPPY_SET_REQUIRE_VALID): Likewise. (frame_object_to_frame_info): New prototype. (gdbpy_initialize_finishbreakpoints): New prototype. (bpfinishpy_is_finish_bp): Likewise. (bpfinishpy_pre_stop_hook): Likewise. (bpfinishpy_post_stop_hook): Likewise. * python/py-finishbreakpoint.c: New file. * python/py-frame.c(frame_object_to_frame_info): Make non-static and accept PyObject instead of frame_object. (frapy_is_valid): Don't cast to frame_object. (frapy_name): Likewise. (frapy_type): Likewise. (frapy_unwind_stop_reason): Likewise. (frapy_pc): Likewise. (frapy_block): Likewise. (frapy_function): Likewise. (frapy_older): Likewise. (frapy_newer): Likewise. (frapy_find_sal): Likewise. (frapy_read_var): Likewise. (frapy_select): Likewise. * python/python.c (gdbpy_is_stopped_at_finish_bp): New noop function. (_initialize_python): Add gdbpy_initialize_finishbreakpoints. * python/python.h: Include breakpoint.h (gdbpy_is_stopped_at_finish_bp): New prototype. doc/ * gdb.texinfo (Finish Breakpoints in Python): New subsection. (Python API): Add menu entry for Finish Breakpoints. testsuite/ * Makefile.in (EXECUTABLES): Add py-finish-breakpoint and py-finish-breakpoint2 (MISCALLANEOUS): Add py-events-shlib.so and py-events-shlib-nodebug.so * gdb.python/py-breakpoint.exp (mult_line): Define and use variable instead of line number. * gdb.python/py-finish-breakpoint.c: New file. * gdb.python/py-finish-breakpoint.exp: New file. * gdb.python/py-finish-breakpoint.py: New file. * gdb.python/py-finish-breakpoint2.cc: New file. * gdb.python/py-finish-breakpoint2.exp: New file. * gdb.python/py-finish-breakpoint2.py: New file.
This commit is contained in:
parent
6538471c25
commit
cc72b2a2da
23 changed files with 1329 additions and 69 deletions
100
gdb/testsuite/gdb.python/py-finish-breakpoint.c
Normal file
100
gdb/testsuite/gdb.python/py-finish-breakpoint.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* This testcase is part of GDB, the GNU debugger.
|
||||
|
||||
Copyright 2011 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Defined in py-events-shlib.h. */
|
||||
extern void do_nothing (void);
|
||||
|
||||
int increase_1 (int *a)
|
||||
{
|
||||
*a += 1;
|
||||
return -5;
|
||||
}
|
||||
|
||||
void increase (int *a)
|
||||
{
|
||||
increase_1 (a);
|
||||
}
|
||||
|
||||
int
|
||||
test_1 (int i, int j)
|
||||
{
|
||||
return i == j;
|
||||
}
|
||||
|
||||
int
|
||||
test (int i, int j)
|
||||
{
|
||||
return test_1 (i, j);
|
||||
}
|
||||
|
||||
int
|
||||
call_longjmp_1 (jmp_buf *buf)
|
||||
{
|
||||
longjmp (*buf, 1);
|
||||
}
|
||||
|
||||
int
|
||||
call_longjmp (jmp_buf *buf)
|
||||
{
|
||||
call_longjmp_1 (buf);
|
||||
}
|
||||
|
||||
void
|
||||
test_exec_exit (int do_exit)
|
||||
{
|
||||
if (do_exit)
|
||||
exit (0);
|
||||
else
|
||||
execl ("/bin/echo", "echo", "-1", (char *)0);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
jmp_buf env;
|
||||
int foo = 5;
|
||||
int bar = 42;
|
||||
int i, j;
|
||||
|
||||
do_nothing ();
|
||||
|
||||
i = 0;
|
||||
/* Break at increase. */
|
||||
increase (&i);
|
||||
increase (&i);
|
||||
increase (&i);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
j += 1; /* Condition Break. */
|
||||
}
|
||||
|
||||
if (setjmp (env) == 0) /* longjmp caught */
|
||||
{
|
||||
call_longjmp (&env);
|
||||
}
|
||||
else
|
||||
j += 1; /* after longjmp. */
|
||||
|
||||
test_exec_exit (1);
|
||||
|
||||
return j; /* Break at end. */
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue