diff options
author | Keith Seitz <keiths@redhat.com> | 2016-02-09 10:02:53 -0800 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2016-02-09 14:27:50 -0800 |
commit | 9f61929fd82fb632ee7c3be883d7086afc5c65d0 (patch) | |
tree | 3f79fb369acd0eee4807b678ba92f9cc13f37f23 /gdb/testsuite | |
parent | eeb1af437c6f1ca111bc31b63eefc5344b553681 (diff) | |
download | gdb-9f61929fd82fb632ee7c3be883d7086afc5c65d0.zip gdb-9f61929fd82fb632ee7c3be883d7086afc5c65d0.tar.gz gdb-9f61929fd82fb632ee7c3be883d7086afc5c65d0.tar.bz2 |
python/19506 -- gdb.Breakpoint address location regression
Now that "legacy" linespecs benefit from consolidated support in
string_to_event_location_basic, python's Breakpoint command should use this
function to turn strings into event locations.
As a result, this patch fixes python/19506. Before:
(gdb) python gdb.Breakpoint("*main")
Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: Function "*main" not defined.
Error while executing Python code.
After:
(gdb) python gdb.Breakpoint("*main")
Breakpoint 1 at 0x4005fb: file ../../../src/gdb/testsuite/gdb.python/py-breakpoint.c, line 32.
gdb/ChangeLog
PR python/19506
* python/py-breakpoint.c (bppy_init): Use
string_to_event_location_basic instead of new_linespec_location.
gdb/testsuite/ChangeLog
PR python/19506
* gdb.python/py-breakpoint.exp (test_bkpt_address): New procedure.
(toplevel): Call test_bkpt_address.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-breakpoint.exp | 33 |
2 files changed, 39 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 68b4e42..38f1fc5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-02-09 Keith Seitz <keiths@redhat.com> + + PR python/19506 + * gdb.python/py-breakpoint.exp (test_bkpt_address): New procedure. + (toplevel): Call test_bkpt_address. + 2016-02-09 Simon Marchi <simon.marchi@ericsson.com> * configure.ac: Use AC_CONFIG_FILES instead of passing arguments diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index af6c5fc..d1d1b22 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -462,6 +462,38 @@ proc test_bkpt_temporary { } { } } +# Test address locations. + +proc test_bkpt_address {} { + global gdb_prompt decimal srcfile + + # Delete all breakpoints + delete_breakpoints + + gdb_test "python gdb.Breakpoint(\"*main\")" \ + ".*Breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." + + gdb_py_test_silent_cmd \ + "python main_loc = gdb.parse_and_eval(\"main\").address" \ + "eval address of main" 0 + + # Python 2 vs 3 ... Check `int' first. If that fails, try `long'. + gdb_test_multiple "python main_addr = int(main_loc)" "int value of main" { + -re "Traceback.*$gdb_prompt $" { + gdb_test_no_output "python main_addr = long(main_loc)" \ + "long value of main" + } + -re "$gdb_prompt $" { + pass "int value of main" + } + } + + # Include whitespace in the linespec to double-check proper + # grokking of argument to gdb.Breakpoint. + gdb_test "python gdb.Breakpoint(\" *{}\".format(str(main_addr)))" \ + ".*Breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\." +} + test_bkpt_basic test_bkpt_deletion test_bkpt_cond_and_cmds @@ -470,3 +502,4 @@ test_watchpoints test_bkpt_internal test_bkpt_eval_funcs test_bkpt_temporary +test_bkpt_address |