This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] - Exposing find_pc_line through Python API


On Wed, May 9, 2012 at 12:35 AM, Siva Chandra <sivachandra@google.com> wrote:
> The more I think about your comments, the more I feel that exposing
> this 'actual' argument is not a good idea. ?I am now of the opinion
> that the 'notcurrent' argument to the internal function find_pc_line
> caters to a internal usage which depends on much more than just what
> the user feels. ?Hence, I have modified the patch to remove the
> 'actual' argument. ?The new version of the patch is attached.
>
> 2012-05-07 ?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.

+@findex gdb.find_pc_line
+@defun gdb.find_pc_line (pc)
+Return the @code{gdb.Symtab_and_line} object corresponding to the
+@var{pc} value.  @xref{Symbol Tables In Python}.
+@end defun

I think we need to specify what the result is if there is no sal for
the specified pc.

+/* 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;
+  PyObject *actual = NULL;
+
+  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);
+}

"actual" can be deleted now.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]