/* Python interface to symbol tables.
- Copyright (C) 2008-2016 Free Software Foundation, Inc.
+ Copyright (C) 2008-2017 Free Software Foundation, Inc.
This file is part of GDB.
#include "python-internal.h"
#include "objfiles.h"
#include "block.h"
+#include "py-ref.h"
typedef struct stpy_symtab_object {
PyObject_HEAD
STPY_REQUIRE_VALID (self, symtab);
filename = symtab_to_filename_for_display (symtab);
- str_obj = PyString_Decode (filename, strlen (filename),
- host_charset (), NULL);
+ str_obj = host_string_to_python_string (filename);
return str_obj;
}
{
const char *producer = COMPUNIT_PRODUCER (cust);
- return PyString_Decode (producer, strlen (producer),
- host_charset (), NULL);
+ return host_string_to_python_string (producer);
}
Py_RETURN_NONE;
fullname = symtab_to_fullname (symtab);
- return PyString_Decode (fullname, strlen (fullname), host_charset (), NULL);
+ return host_string_to_python_string (fullname);
}
/* Implementation of gdb.Symtab.is_valid (self) -> Boolean.
PyObject *
symtab_and_line_to_sal_object (struct symtab_and_line sal)
{
- sal_object *sal_obj;
- int success = 0;
-
- sal_obj = PyObject_New (sal_object, &sal_object_type);
- if (sal_obj)
+ gdbpy_ref<sal_object> sal_obj (PyObject_New (sal_object, &sal_object_type));
+ if (sal_obj != NULL)
{
- if (set_sal (sal_obj, sal) < 0)
- {
- Py_DECREF (sal_obj);
- return NULL;
- }
+ if (set_sal (sal_obj.get (), sal) < 0)
+ return NULL;
}
- return (PyObject *) sal_obj;
+ return (PyObject *) sal_obj.release ();
}
/* Return struct symtab_and_line reference that is wrapped by this