aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@sourceware.org>2012-05-13 11:33:44 +0000
committerSiva Chandra Reddy <sivachandra@sourceware.org>2012-05-13 11:33:44 +0000
commit7efc75aaf903ab9bf93b8411260740d5a5ee6056 (patch)
treeae3797c876f883109200007bace80d3755f9bf5b /gdb/python
parent02277eae005e94859bd208e7814f1ac66c8b2433 (diff)
downloadbinutils-7efc75aaf903ab9bf93b8411260740d5a5ee6056.zip
binutils-7efc75aaf903ab9bf93b8411260740d5a5ee6056.tar.gz
binutils-7efc75aaf903ab9bf93b8411260740d5a5ee6056.tar.bz2
2012-05-13 Siva Chandra Reddy <sivachandra@google.com>
Add a new function gdb.find_pc_line to the Python API. * NEWS (Python Scripting): Add entry about the new function. * python/python.c (gdbpy_find_pc_line): New function which implements gdb.find_pc_line. (GdbMethods): Add entry for the new function. doc/ * gdb.texinfo (Basic Python): Add description about the function gdb.find_pc_line testsuite/ * gdb.python/python.c: Add a new breakpoint comment. * gdb.python/python.exp: Add tests to test gdb.find_pc_line.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/python.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 938275a..5e5f980 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -631,6 +631,24 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args)
return value_to_value_object (result);
}
+/* Implementation of gdb.find_pc_line function.
+ Returns the gdb.Symtab_and_line object corresponding to a PC value. */
+
+static PyObject *
+gdbpy_find_pc_line (PyObject *self, PyObject *args)
+{
+ struct symtab_and_line sal;
+ CORE_ADDR pc;
+ unsigned long long pc_llu;
+
+ if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu))
+ return NULL;
+
+ pc = (CORE_ADDR) pc_llu;
+ sal = find_pc_line (pc, 0);
+ return symtab_and_line_to_sal_object (sal);
+}
+
/* Read a file as Python code.
FILE is the file to run. FILENAME is name of the file FILE.
This does not throw any errors. If an exception occurs python will print
@@ -1458,6 +1476,9 @@ gdb.Symtab_and_line objects (or None)."},
"parse_and_eval (String) -> Value.\n\
Parse String as an expression, evaluate it, and return the result as a Value."
},
+ { "find_pc_line", gdbpy_find_pc_line, METH_VARARGS,
+ "find_pc_line (pc) -> Symtab_and_line.\n\
+Return the gdb.Symtab_and_line object corresponding to the pc value." },
{ "post_event", gdbpy_post_event, METH_VARARGS,
"Post an event into gdb's event loop." },