This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python] Add missing block and symbol pieces for in_scopeconvenience function.


Hi,

This patch adds some bits that are necessary for the in_scope
convenience function.
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


2008-11-22  Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* python/python-block.c (gdbpy_get_block_for_pc): New function.
	(block_object_methods): Fix function called for get_superblock method.
	* python/python-internal.h (gdbpy_get_block_for_pc): New prototype.
	* python/python-symbol.c (gdbpy_initialize_symbols): Add
	SYMBOL_LOC_REGPARM_ADDR constant.
	* python/python.c (GdbMethods): Add get_block_for_pc function.

diff --git a/gdb/python/python-block.c b/gdb/python/python-block.c
index 0629ffa..e41ad9b 100644
--- a/gdb/python/python-block.c
+++ b/gdb/python/python-block.c
@@ -153,6 +153,26 @@ blpy_block_syms_iternext (PyObject *self)
   return (sym == NULL)? NULL : symbol_to_symbol_object (sym);
 }
 
+/* Return the innermost lexical block containing the specified pc value,
+   or 0 if there is none.  */
+
+PyObject *
+gdbpy_get_block_for_pc (PyObject *self, PyObject *args)
+{
+  unsigned PY_LONG_LONG pc;
+  struct block *block;
+  PyObject *sym_obj;
+
+  if (!PyArg_ParseTuple (args, "K", &pc))
+    return NULL;
+
+  block = block_for_pc (pc);
+  if (block)
+    return block_to_block_object (block);
+
+  Py_RETURN_NONE;
+}
+
 void
 gdbpy_initialize_blocks (void)
 {
@@ -183,7 +203,7 @@ static PyMethodDef block_object_methods[] = {
     "Return the end address of this block." },
   { "get_function", blpy_get_function, METH_NOARGS,
     "Return the symbol that names this block, or None." },
-  { "get_superblock", blpy_get_end, METH_NOARGS,
+  { "get_superblock", blpy_get_superblock, METH_NOARGS,
     "Return the block containing this block, or None." },
   {NULL}  /* Sentinel */
 };
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index e85548e..4603b18 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -76,6 +76,7 @@ PyObject *gdbpy_get_current_frame (PyObject *, PyObject *);
 PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
 PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args);
 PyObject *gdbpy_get_selected_frame (PyObject *self, PyObject *args);
+PyObject *gdbpy_get_block_for_pc (PyObject *self, PyObject *args);
 
 PyObject *symtab_and_line_to_sal_object (struct symtab_and_line sal);
 PyObject *symtab_to_symtab_object (struct symtab *symtab);
diff --git a/gdb/python/python-symbol.c b/gdb/python/python-symbol.c
index 44a227a..99e92c7 100644
--- a/gdb/python/python-symbol.c
+++ b/gdb/python/python-symbol.c
@@ -218,6 +218,8 @@ gdbpy_initialize_symbols (void)
   PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_OPTIMIZED_OUT",
 			   LOC_OPTIMIZED_OUT);
   PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMPUTED", LOC_COMPUTED);
+  PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR",
+			   LOC_REGPARM_ADDR);
   PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN", UNDEF_DOMAIN);
   PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", VAR_DOMAIN);
   PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN", STRUCT_DOMAIN);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index d263b77..716d63f 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1354,6 +1354,9 @@ static PyMethodDef GdbMethods[] =
   { "find_pc_function", gdbpy_find_pc_function, METH_VARARGS,
     "Return the function containing the given pc value, or None." },
 
+  { "get_block_for_pc", gdbpy_get_block_for_pc, METH_VARARGS,
+    "Return the block containing the given pc value, or None." },
+
   { "decode_line", gdbpy_decode_line, METH_VARARGS,
     "Decode a string argument the way that 'break' or 'edit' does.\n\
 Return a tuple holding the file name (or None) and line number (or None).\n\
-- 
1.5.6.5



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