]> Git Repo - binutils.git/blobdiff - gdb/python/py-lazy-string.c
update copyright year range in GDB files
[binutils.git] / gdb / python / py-lazy-string.c
index 3a02a3b6367cc782cb97f148a24b63d911a7e12e..14575bff85ab9cb0b5c839d184e3a09fd74e1d7f 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to lazy strings.
 
-   Copyright (C) 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2010-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "python-internal.h"
 #include "charset.h"
 #include "value.h"
-#include "exceptions.h"
 #include "valprint.h"
 #include "language.h"
-#include "gdb_assert.h"
 
 typedef struct {
   PyObject_HEAD
@@ -47,7 +45,8 @@ typedef struct {
   struct type *type;
 } lazy_string_object;
 
-static PyTypeObject lazy_string_object_type;
+extern PyTypeObject lazy_string_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("lazy_string_object");
 
 static PyObject *
 stpy_get_address (PyObject *self, void *closure)
@@ -97,20 +96,23 @@ stpy_convert_to_value  (PyObject *self, PyObject *args)
 {
   lazy_string_object *self_string = (lazy_string_object *) self;
   struct value *val = NULL;
-  volatile struct gdb_exception except;
 
   if (self_string->address == 0)
     {
-      PyErr_SetString (PyExc_MemoryError,
+      PyErr_SetString (gdbpy_gdb_memory_error,
                       _("Cannot create a value from NULL."));
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       val = value_at_lazy (self_string->type, self_string->address);
     }
-  GDB_PY_HANDLE_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDB_PY_HANDLE_EXCEPTION (except);
+    }
+  END_CATCH
 
   return value_to_value_object (val);
 }
@@ -131,7 +133,7 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
 
   if (address == 0 && length != 0)
     {
-      PyErr_SetString (PyExc_MemoryError,
+      PyErr_SetString (gdbpy_gdb_memory_error,
                       _("Cannot create a lazy string with address 0x0, " \
                         "and a non-zero length."));
       return NULL;
@@ -159,13 +161,14 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
   return (PyObject *) str_obj;
 }
 
-void
+int
 gdbpy_initialize_lazy_string (void)
 {
   if (PyType_Ready (&lazy_string_object_type) < 0)
-    return;
+    return -1;
 
   Py_INCREF (&lazy_string_object_type);
+  return 0;
 }
 
 /* Determine whether the printer object pointed to by OBJ is a
@@ -215,7 +218,7 @@ static PyGetSetDef lazy_string_object_getset[] = {
   { NULL }  /* Sentinel */
 };
 
-static PyTypeObject lazy_string_object_type = {
+PyTypeObject lazy_string_object_type = {
   PyVarObject_HEAD_INIT (NULL, 0)
   "gdb.LazyString",              /*tp_name*/
   sizeof (lazy_string_object),   /*tp_basicsize*/
This page took 0.037147 seconds and 4 git commands to generate.