summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPhil Muldoon <pmuldoon@redhat.com>2017-12-07 16:47:33 +0000
committerPhil Muldoon <pmuldoon@redhat.com>2017-12-07 16:47:33 +0000
commit824cc835aa9a4d585d955db4ab2a5dd4c17cc22c (patch)
tree8f0ee6f88956328aea665e4016ea7ae09274c6bd /gdb/testsuite
parent9c226a8689db8bced43b94f551e118551219ce54 (diff)
Implement explicit locations for Python breakpoints.
This introduces several new keywords to the bppy_init constructor. The spec parameter is now optional but mutually exclusive to the explicit keywords source, label, function and line. gdb/ChangeLog 2017-12-07 Phil Muldoon <pmuldoon@redhat.com> * python/py-breakpoint.c (bppy_init): Use string_to_event_location over basic location code. Implement explicit location keywords. (bppy_init_validate_args): New function. * NEWS: Document Python explicit breakpoint locations. doc/ChangeLog 2017-12-07 Phil Muldoon <pmuldoon@redhat.com> * python.texi (Breakpoints In Python): Add text relating to allowed explicit locations and keywords in gdb.Breakpoints. testsuite/ChangeLog 2017-12-07 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/py-breakpoint.exp (test_bkpt_explicit_loc): Add new tests for explicit locations.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint.c2
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint.exp80
3 files changed, 86 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 326af54ace..87547cbe13 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-07 Phil Muldoon <pmuldoon@redhat.com>
+
+ * gdb.python/py-breakpoint.exp (test_bkpt_explicit_loc): Add new
+ tests for explicit locations.
+
2017-12-06 Pedro Alves <palves@redhat.com>
* gdb.arch/i386-avx.exp: If testing with a RSP target, check
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.c b/gdb/testsuite/gdb.python/py-breakpoint.c
index df6163e53a..562cab35f7 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.c
+++ b/gdb/testsuite/gdb.python/py-breakpoint.c
@@ -24,7 +24,7 @@ int multiply (int i)
int add (int i)
{
- return i + i;
+ return i + i; /* Break at function add. */
}
diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp
index 6c39f13696..e89b9b8446 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint.exp
@@ -531,6 +531,85 @@ proc_with_prefix test_bkpt_events {} {
check_last_event breakpoint_deleted
}
+proc test_bkpt_explicit_loc {} {
+ global srcfile testfile
+
+ with_test_prefix test_bkpt_invisible {
+ # Start with a fresh gdb.
+ clean_restart ${testfile}
+
+ if ![runto_main] then {
+ fail "cannot run to main."
+ return 0
+ }
+
+ delete_breakpoints
+
+ set bp_location1 [gdb_get_line_number "Break at multiply."]
+ set bp_location2 [gdb_get_line_number "Break at add."]
+
+ gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=$bp_location1)" \
+ "set explicit breakpoint by line" 0
+ gdb_continue_to_breakpoint "break at multiply for explicit line" \
+ ".*Break at multiply.*"
+
+ gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=\"+1\")" \
+ "set explicit breakpoint by relative line" 0
+ gdb_continue_to_breakpoint "break at add for relative line" \
+ ".*Break at add.*"
+
+ delete_breakpoints
+ gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (line=\"-1\")" \
+ "set explicit breakpoint by relative negative line" 0
+ gdb_continue_to_breakpoint "break at multiply for negative line" \
+ ".*Break at multiply.*"
+
+ delete_breakpoints
+ gdb_test "python bp1 = gdb.Breakpoint (line=bp1)" \
+ "RuntimeError: Line keyword should be an integer or a string.*" \
+ "set explicit breakpoint by invalid line type"
+
+ delete_breakpoints
+ gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (function=\"add\")" \
+ "set explicit breakpoint by function" 0
+ gdb_continue_to_breakpoint "break at function add for function" \
+ ".*Break at function add.*"
+
+ delete_breakpoints
+ gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (source=\"$srcfile\", function=\"add\")" \
+ "set explicit breakpoint by source file and function" 0
+ gdb_continue_to_breakpoint "break at function add for source and function" \
+ ".*Break at function add.*"
+
+ delete_breakpoints
+ gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (source=\"$srcfile\", line=\"$bp_location2\")" \
+ "set explicit breakpoint by source file and line number" 0
+ gdb_continue_to_breakpoint "break at add for source and line" \
+ ".*Break at add.*"
+
+ delete_breakpoints
+ gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (\"-source $srcfile -line $bp_location2\")" \
+ "set explicit breakpoint by source file and line number in spec" 0
+ gdb_continue_to_breakpoint "break at add for source and line in spec" \
+ ".*Break at add.*"
+
+ delete_breakpoints
+ gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\")" \
+ "RuntimeError: Specifying a source must also include a line, label or function.*" \
+ "set invalid explicit breakpoint by source only"
+
+ gdb_test "python bp1 = gdb.Breakpoint (source=\"foo.c\", line=\"5\")" \
+ "No source file named foo.*" \
+ "set invalid explicit breakpoint by missing source and line"
+ gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\", line=\"900\")" \
+ "No line 900 in file \"$srcfile\".*" \
+ "set invalid explicit breakpoint by source and invalid line"
+ gdb_test "python bp1 = gdb.Breakpoint (function=\"blah\")" \
+ "Function \"blah\" not defined.*" \
+ "set invalid explicit breakpoint by missing function"
+ }
+}
+
test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
@@ -542,3 +621,4 @@ test_bkpt_temporary
test_bkpt_address
test_bkpt_pending
test_bkpt_events
+test_bkpt_explicit_loc