diff mbox

[18/21] struct symtab split part 2: python/py-symtab.c

Message ID 5464aa47.e9a7420a.2e39.ffffa21b@mx.google.com
State New
Headers show

Commit Message

Doug Evans Nov. 13, 2014, 12:54 p.m. UTC
This patch contains the changes to the python support.

Full ChangeLog: https://sourceware.org/ml/gdb-patches/2014-11/msg00233.html

2014-11-12  Doug Evans  <xdje42@gmail.com>

	* python/py-symtab.c (stpy_get_producer): Fetch producer from compunit.
diff mbox

Patch

diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 7dee782..3741762 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -372,8 +372,7 @@  gdbpy_block_for_pc (PyObject *self, PyObject *args)
 {
   gdb_py_ulongest pc;
   const struct block *block = NULL;
-  struct obj_section *section = NULL;
-  struct symtab *symtab = NULL;
+  struct compunit_symtab *cust = NULL;
   volatile struct gdb_exception except;
 
   if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
@@ -381,15 +380,14 @@  gdbpy_block_for_pc (PyObject *self, PyObject *args)
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
-      section = find_pc_mapped_section (pc);
-      symtab = find_pc_sect_symtab (pc, section);
+      cust = find_pc_compunit_symtab (pc);
 
-      if (symtab != NULL && SYMTAB_OBJFILE (symtab) != NULL)
+      if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
 	block = block_for_pc (pc);
     }
   GDB_PY_HANDLE_EXCEPTION (except);
 
-  if (!symtab || SYMTAB_OBJFILE (symtab) == NULL)
+  if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
     {
       PyErr_SetString (PyExc_RuntimeError,
 		       _("Cannot locate object file for block."));
@@ -397,7 +395,7 @@  gdbpy_block_for_pc (PyObject *self, PyObject *args)
     }
 
   if (block)
-    return block_to_block_object (block, SYMTAB_OBJFILE (symtab));
+    return block_to_block_object (block, COMPUNIT_OBJFILE (cust));
 
   Py_RETURN_NONE;
 }
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 6f4070d..caa0998 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -132,11 +132,13 @@  static PyObject *
 stpy_get_producer (PyObject *self, void *closure)
 {
   struct symtab *symtab = NULL;
+  struct compunit_symtab *cust;
 
   STPY_REQUIRE_VALID (self, symtab);
-  if (symtab->producer != NULL)
+  cust = SYMTAB_COMPUNIT (symtab);
+  if (COMPUNIT_PRODUCER (cust) != NULL)
     {
-      const char *producer = symtab->producer;
+      const char *producer = COMPUNIT_PRODUCER (cust);
 
       return PyString_Decode (producer, strlen (producer),
 			      host_charset (), NULL);