From 68dadef54c216f7ec75c27d74193897b18c5f9ab Mon Sep 17 00:00:00 2001 From: Markus Metzger Date: Mon, 20 Jun 2016 11:12:14 +0200 Subject: [PATCH] python: accept address and explicit locations in gdb.decode_line The gdb.decode_line python function is documented to support the same location expressions as the "break" command. It currently expects a linespec location. Instead of creating a linespec location directly, create the location via string_to_event_location_basic. --- gdb/ChangeLog | 5 +++++ gdb/python/python.c | 2 +- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.python/python.exp | 7 +++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 95f2b92..65ed6b3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-10-07 Markus Metzger + + * python/python.c (gdbpy_decode_line): Call + string_to_event_location_basic instead of new_linespec_location. + 2016-10-06 Sergio Durigan Junior * target.c (target_supports_multi_process): New function, moved diff --git a/gdb/python/python.c b/gdb/python/python.c index b00b70b..7e34d26 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -740,7 +740,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) if (arg != NULL) { - location = new_linespec_location (&arg); + location = string_to_event_location_basic (&arg, python_language); make_cleanup_delete_event_location (location); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4722c34..74091ee 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-10-07 Markus Metzger + + * gdb.python/python.exp: Test decode_line("*0"). + 2016-10-06 Doug Evans * gdb.python/py-value.exp (test_value_creation): Add test for large diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 3f8c46f..4072fa3 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -251,6 +251,13 @@ gdb_py_test_silent_cmd {python symtab = gdb.decode_line ("func1,func2")} \ "test decode_line func1,func2" 1 gdb_test {python print (symtab[0])} ",func2" "stop at comma in linespec" +gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"*0\")" "Test decode_line *0" 1 +gdb_test "python print (len(symtab))" "2" "Test decode_line *0 result length" +gdb_test "python print (symtab\[0\])" "None" "Test decode_line *0 unparsed" +gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line *0 locations length" +gdb_test "python print (symtab\[1\]\[0\].symtab)" "None" "Test decode_line *0 filename" +gdb_test "python print (symtab\[1\]\[0\].pc)" "0" "Test decode_line *0 pc" + # gdb.write gdb_test "python print (sys.stderr)" ".*gdb.GdbOutputErrorFile (instance|object) at.*" "Test stderr location" gdb_test "python print (sys.stdout)" ".*gdb.GdbOutputFile (instance|object) at.*" "Test stdout location" -- 2.7.4