gdb: use caller objfile in dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value
[deliverable/binutils-gdb.git] / gdb / python / py-progspace.c
index c55c432bb8801cb8e856a9b193fb3c8bed29648c..34baa87502789161fb323da2073520655c5a5bb8 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to program spaces.
 
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,7 +24,6 @@
 #include "objfiles.h"
 #include "language.h"
 #include "arch-utils.h"
-#include "py-ref.h"
 #include "solib.h"
 #include "block.h"
 
@@ -164,7 +163,6 @@ pspy_get_printers (PyObject *o, void *ignore)
 static int
 pspy_set_printers (PyObject *o, PyObject *value, void *ignore)
 {
-  PyObject *tmp;
   pspace_object *self = (pspace_object *) o;
 
   if (! value)
@@ -182,10 +180,9 @@ pspy_set_printers (PyObject *o, PyObject *value, void *ignore)
     }
 
   /* Take care in case the LHS and RHS are related somehow.  */
-  tmp = self->printers;
+  gdbpy_ref<> tmp (self->printers);
   Py_INCREF (value);
   self->printers = value;
-  Py_XDECREF (tmp);
 
   return 0;
 }
@@ -205,7 +202,6 @@ pspy_get_frame_filters (PyObject *o, void *ignore)
 static int
 pspy_set_frame_filters (PyObject *o, PyObject *frame, void *ignore)
 {
-  PyObject *tmp;
   pspace_object *self = (pspace_object *) o;
 
   if (! frame)
@@ -223,10 +219,9 @@ pspy_set_frame_filters (PyObject *o, PyObject *frame, void *ignore)
     }
 
   /* Take care in case the LHS and RHS are related somehow.  */
-  tmp = self->frame_filters;
+  gdbpy_ref<> tmp (self->frame_filters);
   Py_INCREF (frame);
   self->frame_filters = frame;
-  Py_XDECREF (tmp);
 
   return 0;
 }
@@ -247,7 +242,6 @@ pspy_get_frame_unwinders (PyObject *o, void *ignore)
 static int
 pspy_set_frame_unwinders (PyObject *o, PyObject *unwinders, void *ignore)
 {
-  PyObject *tmp;
   pspace_object *self = (pspace_object *) o;
 
   if (!unwinders)
@@ -265,10 +259,9 @@ pspy_set_frame_unwinders (PyObject *o, PyObject *unwinders, void *ignore)
     }
 
   /* Take care in case the LHS and RHS are related somehow.  */
-  tmp = self->frame_unwinders;
+  gdbpy_ref<> tmp (self->frame_unwinders);
   Py_INCREF (unwinders);
   self->frame_unwinders = unwinders;
-  Py_XDECREF (tmp);
 
   return 0;
 }
@@ -300,7 +293,6 @@ pspy_get_xmethods (PyObject *o, void *ignore)
 static int
 pspy_set_type_printers (PyObject *o, PyObject *value, void *ignore)
 {
-  PyObject *tmp;
   pspace_object *self = (pspace_object *) o;
 
   if (! value)
@@ -318,10 +310,9 @@ pspy_set_type_printers (PyObject *o, PyObject *value, void *ignore)
     }
 
   /* Take care in case the LHS and RHS are related somehow.  */
-  tmp = self->type_printers;
+  gdbpy_ref<> tmp (self->type_printers);
   Py_INCREF (value);
   self->type_printers = value;
-  Py_XDECREF (tmp);
 
   return 0;
 }
@@ -341,9 +332,7 @@ pspy_get_objfiles (PyObject *self_, PyObject *args)
 
   if (self->pspace != NULL)
     {
-      struct objfile *objf;
-
-      ALL_PSPACE_OBJFILES (self->pspace, objf)
+      for (objfile *objf : self->pspace->objfiles ())
        {
          gdbpy_ref<> item = objfile_to_objfile_object (objf);
 
@@ -392,7 +381,7 @@ pspy_block_for_pc (PyObject *o, PyObject *args)
   if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
     return NULL;
 
-  TRY
+  try
     {
       scoped_restore_current_program_space saver;
 
@@ -402,18 +391,13 @@ pspy_block_for_pc (PyObject *o, PyObject *args)
       if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
        block = block_for_pc (pc);
     }
-  CATCH (except, RETURN_MASK_ALL)
+  catch (const gdb_exception &except)
     {
       GDB_PY_HANDLE_EXCEPTION (except);
     }
-  END_CATCH
 
   if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
-    {
-      PyErr_SetString (PyExc_RuntimeError,
-                      _("Cannot locate object file for block."));
-      return NULL;
-    }
+    Py_RETURN_NONE;
 
   if (block)
     return block_to_block_object (block, COMPUNIT_OBJFILE (cust));
@@ -436,7 +420,7 @@ pspy_find_pc_line (PyObject *o, PyObject *args)
   if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu))
     return NULL;
 
-  TRY
+  try
     {
       struct symtab_and_line sal;
       CORE_ADDR pc;
@@ -448,11 +432,10 @@ pspy_find_pc_line (PyObject *o, PyObject *args)
       sal = find_pc_line (pc, 0);
       result = symtab_and_line_to_sal_object (sal);
     }
-  CATCH (except, RETURN_MASK_ALL)
+  catch (const gdb_exception &except)
     {
       GDB_PY_HANDLE_EXCEPTION (except);
     }
-  END_CATCH
 
   return result;
 }
This page took 0.025516 seconds and 4 git commands to generate.