2009-05-28 00:47:20 +00:00
|
|
|
|
/* Python interface to types.
|
|
|
|
|
|
2015-01-01 09:32:14 +00:00
|
|
|
|
Copyright (C) 2008-2015 Free Software Foundation, Inc.
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "python-internal.h"
|
|
|
|
|
#include "charset.h"
|
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
|
#include "cp-support.h"
|
|
|
|
|
#include "demangle.h"
|
|
|
|
|
#include "objfiles.h"
|
2009-06-17 18:46:26 +00:00
|
|
|
|
#include "language.h"
|
2010-08-23 20:26:10 +00:00
|
|
|
|
#include "vec.h"
|
* NEWS: Update.
* c-typeprint.c (c_type_print_base): Handle print_method and
print_typedefs flags.
* gdbcmd.h (setprinttypelist, showprinttypelist): Declare.
* python/py-type.c (typy_str): Use LA_PRINT_TYPE and raw
options.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new field.s
(whatis_exp): Parse flags. Use LA_PRINT_TYPE.
(setprinttypelist, showprinttypelist, print_methods,
print_typedefs): New globals.
(set_print_type, show_print_type, set_print_type_methods,
show_print_type_methods, set_print_type_typedefs,
show_print_type_typedefs): New functions.
(_initialize_typeprint): Update documentation. Add "print
type methods" and "print type typedefs" parameters.
* typeprint.h (struct type_print_options) <print_methods,
print_typedefs>: New fields.
doc
* gdb.texinfo (Symbols): Document "set print type methods",
"set print type typedefs", and flags to ptype and whatis.
2012-11-12 17:26:21 +00:00
|
|
|
|
#include "typeprint.h"
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
typedef struct pyty_type_object
|
|
|
|
|
{
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
struct type *type;
|
|
|
|
|
|
|
|
|
|
/* If a Type object is associated with an objfile, it is kept on a
|
|
|
|
|
doubly-linked list, rooted in the objfile. This lets us copy the
|
|
|
|
|
underlying struct type when the objfile is deleted. */
|
|
|
|
|
struct pyty_type_object *prev;
|
|
|
|
|
struct pyty_type_object *next;
|
|
|
|
|
} type_object;
|
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
extern PyTypeObject type_object_type
|
2013-05-20 20:09:01 +00:00
|
|
|
|
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("type_object");
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
/* A Field object. */
|
|
|
|
|
typedef struct pyty_field_object
|
|
|
|
|
{
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
|
|
|
|
|
/* Dictionary holding our attributes. */
|
|
|
|
|
PyObject *dict;
|
|
|
|
|
} field_object;
|
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
extern PyTypeObject field_object_type
|
2013-05-20 20:09:01 +00:00
|
|
|
|
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("field_object");
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
/* A type iterator object. */
|
|
|
|
|
typedef struct {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
/* The current field index. */
|
|
|
|
|
int field;
|
|
|
|
|
/* What to return. */
|
|
|
|
|
enum gdbpy_iter_kind kind;
|
|
|
|
|
/* Pointer back to the original source type object. */
|
|
|
|
|
struct pyty_type_object *source;
|
|
|
|
|
} typy_iterator_object;
|
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
extern PyTypeObject type_iterator_object_type
|
2013-05-20 20:09:01 +00:00
|
|
|
|
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("typy_iterator_object");
|
2011-09-28 20:04:52 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
/* This is used to initialize various gdb.TYPE_ constants. */
|
|
|
|
|
struct pyty_code
|
|
|
|
|
{
|
|
|
|
|
/* The code. */
|
|
|
|
|
enum type_code code;
|
|
|
|
|
/* The name. */
|
|
|
|
|
const char *name;
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-04 16:20:03 +00:00
|
|
|
|
/* Forward declarations. */
|
|
|
|
|
static PyObject *typy_make_iter (PyObject *self, enum gdbpy_iter_kind kind);
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
#define ENTRY(X) { X, #X }
|
|
|
|
|
|
|
|
|
|
static struct pyty_code pyty_codes[] =
|
|
|
|
|
{
|
2012-08-16 07:36:28 +00:00
|
|
|
|
ENTRY (TYPE_CODE_BITSTRING),
|
2009-05-28 00:47:20 +00:00
|
|
|
|
ENTRY (TYPE_CODE_PTR),
|
|
|
|
|
ENTRY (TYPE_CODE_ARRAY),
|
|
|
|
|
ENTRY (TYPE_CODE_STRUCT),
|
|
|
|
|
ENTRY (TYPE_CODE_UNION),
|
|
|
|
|
ENTRY (TYPE_CODE_ENUM),
|
|
|
|
|
ENTRY (TYPE_CODE_FLAGS),
|
|
|
|
|
ENTRY (TYPE_CODE_FUNC),
|
|
|
|
|
ENTRY (TYPE_CODE_INT),
|
|
|
|
|
ENTRY (TYPE_CODE_FLT),
|
|
|
|
|
ENTRY (TYPE_CODE_VOID),
|
|
|
|
|
ENTRY (TYPE_CODE_SET),
|
|
|
|
|
ENTRY (TYPE_CODE_RANGE),
|
|
|
|
|
ENTRY (TYPE_CODE_STRING),
|
|
|
|
|
ENTRY (TYPE_CODE_ERROR),
|
|
|
|
|
ENTRY (TYPE_CODE_METHOD),
|
|
|
|
|
ENTRY (TYPE_CODE_METHODPTR),
|
|
|
|
|
ENTRY (TYPE_CODE_MEMBERPTR),
|
|
|
|
|
ENTRY (TYPE_CODE_REF),
|
|
|
|
|
ENTRY (TYPE_CODE_CHAR),
|
|
|
|
|
ENTRY (TYPE_CODE_BOOL),
|
|
|
|
|
ENTRY (TYPE_CODE_COMPLEX),
|
|
|
|
|
ENTRY (TYPE_CODE_TYPEDEF),
|
|
|
|
|
ENTRY (TYPE_CODE_NAMESPACE),
|
|
|
|
|
ENTRY (TYPE_CODE_DECFLOAT),
|
|
|
|
|
ENTRY (TYPE_CODE_INTERNAL_FUNCTION),
|
|
|
|
|
{ TYPE_CODE_UNDEF, NULL }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
field_dealloc (PyObject *obj)
|
|
|
|
|
{
|
|
|
|
|
field_object *f = (field_object *) obj;
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
Py_XDECREF (f->dict);
|
2012-12-12 16:47:30 +00:00
|
|
|
|
Py_TYPE (obj)->tp_free (obj);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
field_new (void)
|
|
|
|
|
{
|
|
|
|
|
field_object *result = PyObject_New (field_object, &field_object_type);
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
result->dict = PyDict_New ();
|
|
|
|
|
if (!result->dict)
|
|
|
|
|
{
|
|
|
|
|
Py_DECREF (result);
|
|
|
|
|
result = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (PyObject *) result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-12 23:18:27 +00:00
|
|
|
|
/* Return true if OBJ is of type gdb.Field, false otherwise. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
gdbpy_is_field (PyObject *obj)
|
|
|
|
|
{
|
|
|
|
|
return PyObject_TypeCheck (obj, &field_object_type);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
/* Return the code for this type. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_get_code (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
return PyInt_FromLong (TYPE_CODE (type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for typy_fields which converts a single field to a
|
2011-09-28 20:04:52 +00:00
|
|
|
|
gdb.Field object. Returns NULL on error. */
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
static PyObject *
|
|
|
|
|
convert_field (struct type *type, int field)
|
|
|
|
|
{
|
|
|
|
|
PyObject *result = field_new ();
|
|
|
|
|
PyObject *arg;
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2013-12-12 23:18:27 +00:00
|
|
|
|
arg = type_to_type_object (type);
|
|
|
|
|
if (arg == NULL)
|
|
|
|
|
goto fail;
|
|
|
|
|
if (PyObject_SetAttrString (result, "parent_type", arg) < 0)
|
|
|
|
|
goto failarg;
|
|
|
|
|
Py_DECREF (arg);
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (!field_is_static (&TYPE_FIELD (type, field)))
|
|
|
|
|
{
|
2012-04-18 06:46:47 +00:00
|
|
|
|
const char *attrstring;
|
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_ENUM)
|
|
|
|
|
{
|
|
|
|
|
arg = gdb_py_long_from_longest (TYPE_FIELD_ENUMVAL (type, field));
|
|
|
|
|
attrstring = "enumval";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-08-10 18:55:18 +00:00
|
|
|
|
arg = gdb_py_long_from_longest (TYPE_FIELD_BITPOS (type, field));
|
2012-04-18 06:46:47 +00:00
|
|
|
|
attrstring = "bitpos";
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (!arg)
|
|
|
|
|
goto fail;
|
|
|
|
|
|
2012-04-20 07:17:58 +00:00
|
|
|
|
/* At least python-2.4 had the second parameter non-const. */
|
|
|
|
|
if (PyObject_SetAttrString (result, (char *) attrstring, arg) < 0)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
goto failarg;
|
2012-08-15 14:22:02 +00:00
|
|
|
|
Py_DECREF (arg);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 20:20:59 +00:00
|
|
|
|
arg = NULL;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (TYPE_FIELD_NAME (type, field))
|
2013-12-27 20:20:59 +00:00
|
|
|
|
{
|
|
|
|
|
const char *field_name = TYPE_FIELD_NAME (type, field);
|
2014-01-15 12:28:08 +00:00
|
|
|
|
|
2013-12-27 20:20:59 +00:00
|
|
|
|
if (field_name[0] != '\0')
|
|
|
|
|
{
|
|
|
|
|
arg = PyString_FromString (TYPE_FIELD_NAME (type, field));
|
|
|
|
|
if (arg == NULL)
|
|
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (arg == NULL)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
|
|
|
|
arg = Py_None;
|
|
|
|
|
Py_INCREF (arg);
|
|
|
|
|
}
|
|
|
|
|
if (PyObject_SetAttrString (result, "name", arg) < 0)
|
|
|
|
|
goto failarg;
|
2012-08-15 14:22:02 +00:00
|
|
|
|
Py_DECREF (arg);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
arg = TYPE_FIELD_ARTIFICIAL (type, field) ? Py_True : Py_False;
|
|
|
|
|
Py_INCREF (arg);
|
|
|
|
|
if (PyObject_SetAttrString (result, "artificial", arg) < 0)
|
|
|
|
|
goto failarg;
|
2012-08-15 14:22:02 +00:00
|
|
|
|
Py_DECREF (arg);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
2014-11-07 01:19:06 +00:00
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
|
2009-12-03 21:19:49 +00:00
|
|
|
|
arg = field < TYPE_N_BASECLASSES (type) ? Py_True : Py_False;
|
|
|
|
|
else
|
|
|
|
|
arg = Py_False;
|
|
|
|
|
Py_INCREF (arg);
|
|
|
|
|
if (PyObject_SetAttrString (result, "is_base_class", arg) < 0)
|
|
|
|
|
goto failarg;
|
2012-08-15 14:22:02 +00:00
|
|
|
|
Py_DECREF (arg);
|
2009-12-03 21:19:49 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field));
|
|
|
|
|
if (!arg)
|
|
|
|
|
goto fail;
|
|
|
|
|
if (PyObject_SetAttrString (result, "bitsize", arg) < 0)
|
|
|
|
|
goto failarg;
|
2012-08-15 14:22:02 +00:00
|
|
|
|
Py_DECREF (arg);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
/* A field can have a NULL type in some situations. */
|
|
|
|
|
if (TYPE_FIELD_TYPE (type, field) == NULL)
|
|
|
|
|
{
|
|
|
|
|
arg = Py_None;
|
|
|
|
|
Py_INCREF (arg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
arg = type_to_type_object (TYPE_FIELD_TYPE (type, field));
|
|
|
|
|
if (!arg)
|
|
|
|
|
goto fail;
|
|
|
|
|
if (PyObject_SetAttrString (result, "type", arg) < 0)
|
|
|
|
|
goto failarg;
|
2012-08-15 14:22:02 +00:00
|
|
|
|
Py_DECREF (arg);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
failarg:
|
|
|
|
|
Py_DECREF (arg);
|
|
|
|
|
fail:
|
|
|
|
|
Py_DECREF (result);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
/* Helper function to return the name of a field, as a gdb.Field object.
|
|
|
|
|
If the field doesn't have a name, None is returned. */
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
static PyObject *
|
2011-09-28 20:04:52 +00:00
|
|
|
|
field_name (struct type *type, int field)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
|
|
|
|
PyObject *result;
|
2011-09-28 20:04:52 +00:00
|
|
|
|
|
|
|
|
|
if (TYPE_FIELD_NAME (type, field))
|
|
|
|
|
result = PyString_FromString (TYPE_FIELD_NAME (type, field));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = Py_None;
|
|
|
|
|
Py_INCREF (result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for Type standard mapping methods. Returns a
|
|
|
|
|
Python object for field i of the type. "kind" specifies what to
|
|
|
|
|
return: the name of the field, a gdb.Field object corresponding to
|
|
|
|
|
the field, or a tuple consisting of field name and gdb.Field
|
|
|
|
|
object. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
make_fielditem (struct type *type, int i, enum gdbpy_iter_kind kind)
|
|
|
|
|
{
|
|
|
|
|
PyObject *item = NULL, *key = NULL, *value = NULL;
|
|
|
|
|
|
|
|
|
|
switch (kind)
|
|
|
|
|
{
|
|
|
|
|
case iter_items:
|
|
|
|
|
key = field_name (type, i);
|
|
|
|
|
if (key == NULL)
|
|
|
|
|
goto fail;
|
|
|
|
|
value = convert_field (type, i);
|
|
|
|
|
if (value == NULL)
|
|
|
|
|
goto fail;
|
|
|
|
|
item = PyTuple_New (2);
|
|
|
|
|
if (item == NULL)
|
|
|
|
|
goto fail;
|
|
|
|
|
PyTuple_SET_ITEM (item, 0, key);
|
|
|
|
|
PyTuple_SET_ITEM (item, 1, value);
|
|
|
|
|
break;
|
|
|
|
|
case iter_keys:
|
|
|
|
|
item = field_name (type, i);
|
|
|
|
|
break;
|
|
|
|
|
case iter_values:
|
|
|
|
|
item = convert_field (type, i);
|
|
|
|
|
break;
|
2013-05-20 20:25:40 +00:00
|
|
|
|
default:
|
|
|
|
|
gdb_assert_not_reached ("invalid gdbpy_iter_kind");
|
2011-09-28 20:04:52 +00:00
|
|
|
|
}
|
|
|
|
|
return item;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
fail:
|
|
|
|
|
Py_XDECREF (key);
|
|
|
|
|
Py_XDECREF (value);
|
|
|
|
|
Py_XDECREF (item);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a sequence of all field names, fields, or (name, field) pairs.
|
|
|
|
|
Each field is a gdb.Field object. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind)
|
|
|
|
|
{
|
2011-11-10 19:15:10 +00:00
|
|
|
|
PyObject *py_type = self;
|
2011-10-04 16:20:03 +00:00
|
|
|
|
PyObject *result = NULL, *iter = NULL;
|
2011-11-10 19:15:10 +00:00
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
struct type *type = ((type_object *) py_type)->type;
|
|
|
|
|
struct type *checked_type = type;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
CHECK_TYPEDEF (checked_type);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
if (checked_type != type)
|
|
|
|
|
py_type = type_to_type_object (checked_type);
|
|
|
|
|
iter = typy_make_iter (py_type, kind);
|
|
|
|
|
if (checked_type != type)
|
|
|
|
|
{
|
|
|
|
|
/* Need to wrap this in braces because Py_DECREF isn't wrapped
|
|
|
|
|
in a do{}while(0). */
|
|
|
|
|
Py_DECREF (py_type);
|
|
|
|
|
}
|
|
|
|
|
if (iter != NULL)
|
|
|
|
|
{
|
|
|
|
|
result = PySequence_List (iter);
|
|
|
|
|
Py_DECREF (iter);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
return result;
|
2011-09-28 20:04:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a sequence of all fields. Each field is a gdb.Field object. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
2011-11-15 21:17:04 +00:00
|
|
|
|
typy_values (PyObject *self, PyObject *args)
|
2011-09-28 20:04:52 +00:00
|
|
|
|
{
|
|
|
|
|
return typy_fields_items (self, iter_values);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
/* Return a sequence of all fields. Each field is a gdb.Field object.
|
2013-11-29 20:00:47 +00:00
|
|
|
|
This method is similar to typy_values, except where the supplied
|
2011-11-15 21:17:04 +00:00
|
|
|
|
gdb.Type is an array, in which case it returns a list of one entry
|
|
|
|
|
which is a gdb.Field object for a range (the array bounds). */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_fields (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
PyObject *r, *rl;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
|
|
|
|
|
return typy_fields_items (self, iter_values);
|
|
|
|
|
|
|
|
|
|
/* Array type. Handle this as a special case because the common
|
|
|
|
|
machinery wants struct or union or enum types. Build a list of
|
|
|
|
|
one entry which is the range for the array. */
|
|
|
|
|
r = convert_field (type, 0);
|
|
|
|
|
if (r == NULL)
|
|
|
|
|
return NULL;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
rl = Py_BuildValue ("[O]", r);
|
2013-05-20 20:37:48 +00:00
|
|
|
|
Py_DECREF (r);
|
2011-11-15 21:17:04 +00:00
|
|
|
|
|
|
|
|
|
return rl;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
/* Return a sequence of all field names. Each field is a gdb.Field object. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_field_names (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
return typy_fields_items (self, iter_keys);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-29 20:00:47 +00:00
|
|
|
|
/* Return a sequence of all (name, fields) pairs. Each field is a
|
2011-09-28 20:04:52 +00:00
|
|
|
|
gdb.Field object. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_items (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
return typy_fields_items (self, iter_items);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-23 03:18:51 +00:00
|
|
|
|
/* Return the type's name, or None. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_get_name (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
|
|
|
|
|
if (TYPE_NAME (type) == NULL)
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
return PyString_FromString (TYPE_NAME (type));
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
/* Return the type's tag, or None. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_get_tag (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (!TYPE_TAG_NAME (type))
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
return PyString_FromString (TYPE_TAG_NAME (type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the type, stripped of typedefs. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_strip_typedefs (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
2011-11-28 15:49:43 +00:00
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
type = check_typedef (type);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
2013-02-06 17:05:22 +00:00
|
|
|
|
return type_to_type_object (type);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
/* Strip typedefs and pointers/reference from a type. Then check that
|
|
|
|
|
it is a struct, union, or enum type. If not, raise TypeError. */
|
|
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
|
typy_get_composite (struct type *type)
|
|
|
|
|
{
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
CHECK_TYPEDEF (type);
|
|
|
|
|
}
|
2013-05-20 20:19:03 +00:00
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2011-11-15 21:17:04 +00:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (type) != TYPE_CODE_PTR
|
|
|
|
|
&& TYPE_CODE (type) != TYPE_CODE_REF)
|
|
|
|
|
break;
|
|
|
|
|
type = TYPE_TARGET_TYPE (type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If this is not a struct, union, or enum type, raise TypeError
|
|
|
|
|
exception. */
|
2013-11-29 20:00:47 +00:00
|
|
|
|
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
|
2011-11-15 21:17:04 +00:00
|
|
|
|
&& TYPE_CODE (type) != TYPE_CODE_UNION
|
|
|
|
|
&& TYPE_CODE (type) != TYPE_CODE_ENUM)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"Type is not a structure, union, or enum type.");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-10 20:26:00 +00:00
|
|
|
|
/* Helper for typy_array and typy_vector. */
|
2010-08-23 20:21:28 +00:00
|
|
|
|
|
|
|
|
|
static PyObject *
|
2012-08-10 20:26:00 +00:00
|
|
|
|
typy_array_1 (PyObject *self, PyObject *args, int is_vector)
|
2010-08-23 20:21:28 +00:00
|
|
|
|
{
|
2011-01-26 20:53:45 +00:00
|
|
|
|
long n1, n2;
|
2010-08-23 20:21:28 +00:00
|
|
|
|
PyObject *n2_obj = NULL;
|
|
|
|
|
struct type *array = NULL;
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
2011-01-26 20:53:45 +00:00
|
|
|
|
if (! PyArg_ParseTuple (args, "l|O", &n1, &n2_obj))
|
2010-08-23 20:21:28 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (n2_obj)
|
|
|
|
|
{
|
|
|
|
|
if (!PyInt_Check (n2_obj))
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Array bound must be an integer"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2011-01-26 20:53:45 +00:00
|
|
|
|
|
|
|
|
|
if (! gdb_py_int_as_long (n2_obj, &n2))
|
2010-08-23 20:21:28 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
n2 = n1;
|
|
|
|
|
n1 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 03:34:29 +00:00
|
|
|
|
if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1. */
|
2010-08-23 20:21:28 +00:00
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_ValueError,
|
|
|
|
|
_("Array length must not be negative"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
array = lookup_array_range_type (type, n1, n2);
|
2012-08-10 20:26:00 +00:00
|
|
|
|
if (is_vector)
|
|
|
|
|
make_vector_type (array);
|
2010-08-23 20:21:28 +00:00
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (array);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-10 20:26:00 +00:00
|
|
|
|
/* Return an array type. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_array (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
return typy_array_1 (self, args, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a vector type. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_vector (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
return typy_array_1 (self, args, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
/* Return a Type object which represents a pointer to SELF. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_pointer (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
type = lookup_pointer_type (type);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (type);
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 14:06:04 +00:00
|
|
|
|
/* Return the range of a type represented by SELF. The return type is
|
|
|
|
|
a tuple. The first element of the tuple contains the low bound,
|
|
|
|
|
while the second element of the tuple contains the high bound. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_range (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
PyObject *result;
|
|
|
|
|
PyObject *low_bound = NULL, *high_bound = NULL;
|
2009-12-09 07:49:31 +00:00
|
|
|
|
/* Initialize these to appease GCC warnings. */
|
|
|
|
|
LONGEST low = 0, high = 0;
|
2009-12-08 14:06:04 +00:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
|
|
|
|
|
&& TYPE_CODE (type) != TYPE_CODE_STRING
|
|
|
|
|
&& TYPE_CODE (type) != TYPE_CODE_RANGE)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-14 13:18:55 +00:00
|
|
|
|
_("This type does not have a range."));
|
2009-12-08 14:06:04 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
case TYPE_CODE_STRING:
|
|
|
|
|
low = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
|
|
|
|
|
high = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type));
|
|
|
|
|
break;
|
|
|
|
|
case TYPE_CODE_RANGE:
|
|
|
|
|
low = TYPE_LOW_BOUND (type);
|
|
|
|
|
high = TYPE_HIGH_BOUND (type);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
low_bound = PyLong_FromLong (low);
|
|
|
|
|
if (!low_bound)
|
|
|
|
|
goto failarg;
|
|
|
|
|
|
|
|
|
|
high_bound = PyLong_FromLong (high);
|
|
|
|
|
if (!high_bound)
|
|
|
|
|
goto failarg;
|
|
|
|
|
|
|
|
|
|
result = PyTuple_New (2);
|
|
|
|
|
if (!result)
|
|
|
|
|
goto failarg;
|
|
|
|
|
|
|
|
|
|
if (PyTuple_SetItem (result, 0, low_bound) != 0)
|
|
|
|
|
{
|
|
|
|
|
Py_DECREF (result);
|
|
|
|
|
goto failarg;
|
|
|
|
|
}
|
|
|
|
|
if (PyTuple_SetItem (result, 1, high_bound) != 0)
|
|
|
|
|
{
|
|
|
|
|
Py_DECREF (high_bound);
|
|
|
|
|
Py_DECREF (result);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2009-12-08 14:06:04 +00:00
|
|
|
|
failarg:
|
|
|
|
|
Py_XDECREF (high_bound);
|
|
|
|
|
Py_XDECREF (low_bound);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
/* Return a Type object which represents a reference to SELF. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_reference (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
type = lookup_reference_type (type);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a Type object which represents the target type of SELF. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_target (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
|
|
|
|
|
if (!TYPE_TARGET_TYPE (type))
|
|
|
|
|
{
|
2013-11-29 20:00:47 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
2010-04-14 13:18:55 +00:00
|
|
|
|
_("Type does not have a target."));
|
2009-05-28 00:47:20 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (TYPE_TARGET_TYPE (type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a const-qualified type variant. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_const (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
type = make_cv_type (1, 0, type, NULL);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a volatile-qualified type variant. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_volatile (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
type = make_cv_type (0, 1, type, NULL);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return an unqualified type variant. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_unqualified (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
type = make_cv_type (0, 0, type, NULL);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the size of the type represented by SELF, in bytes. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_get_sizeof (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
check_typedef (type);
|
|
|
|
|
}
|
|
|
|
|
/* Ignore exceptions. */
|
|
|
|
|
|
2012-08-10 18:55:18 +00:00
|
|
|
|
return gdb_py_long_from_longest (TYPE_LENGTH (type));
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct type *
|
2011-10-20 12:31:30 +00:00
|
|
|
|
typy_lookup_typename (const char *type_name, const struct block *block)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
|
|
|
|
struct type *type = NULL;
|
|
|
|
|
volatile struct gdb_exception except;
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
if (!strncmp (type_name, "struct ", 7))
|
|
|
|
|
type = lookup_struct (type_name + 7, NULL);
|
|
|
|
|
else if (!strncmp (type_name, "union ", 6))
|
|
|
|
|
type = lookup_union (type_name + 6, NULL);
|
|
|
|
|
else if (!strncmp (type_name, "enum ", 5))
|
|
|
|
|
type = lookup_enum (type_name + 5, NULL);
|
|
|
|
|
else
|
* python/python-internal.h (struct language_defn): Declare.
(python_gdbarch, python_language): Likewise.
(ensure_python_env): Add prototype.
(make_cleanup_py_restore_gil): Remove prototype.
* python/python.c: Include "arch-utils.h", "value.h" and "language.h".
(python_gdbarch, python_language): New global variables.
(struct python_env): New data type.
(ensure_python_env, restore_python_env): New functions.
(eval_python_from_control_command): Call ensure_python_env to
install current architecture and language.
(python_command, gdbpy_new_objfile): Likewise.
* python/python-cmd.c: Include "arch-utils.h" and "language.h".
(cmdpy_destroyer, cmdpy_function, cmdpy_completer): Call
ensure_python_env.
* python/python-type.c (clean_up_objfile_types): Likewise.
* python/python-objfile.c: Include "language.h".
(clean_up_objfile): Call ensure_python_env.
* python/python-prettyprint.c (apply_val_pretty_printer): Likewise.
(apply_varobj_pretty_printer): Do not call PyGILState_Ensure.
* varobj.c (varobj_ensure_python_env): New helper function.
(varobj_get_display_hint, update_dynamic_varobj_children,
install_default_visualizer, varobj_set_visualizer, free_variable,
value_get_print_value): Call it.
(value_get_print_value): Add varobj argument instead of pretty
printer argument. Update all callers.
* python/python-utils.c (py_gil_restore, make_cleanup_py_restore_gil):
Remove.
* value.h (internal_function_fn): Add GDBARCH and LANGUAGE argument.
(call_internal_function): Likewise.
* value.c (call_internal_function): Likewise. Pass to handler.
* eval.c (evaluate_subexp_standard): Update call.
* python/python-function.c: Include "language.h".
(fnpy_call): Add GDBARCH and LANGAUAGE arguments and call
make_cleanup_python_env.
* python/python-value.c (builtin_type_pyint, builtin_type_pyfloat,
builtin_type_pylong, builtin_type_pybool, builtin_type_pychar,
valpy_str): Use python_gdbarch and python_language instead of
current_gdbarch and current_language.
* python/python-type.c (typy_lookup_typename): Likewise.
2009-07-02 17:04:23 +00:00
|
|
|
|
type = lookup_typename (python_language, python_gdbarch,
|
2010-02-26 09:08:10 +00:00
|
|
|
|
type_name, block, 0);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
2013-05-20 20:19:03 +00:00
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct type *
|
2010-02-26 09:08:10 +00:00
|
|
|
|
typy_lookup_type (struct demangle_component *demangled,
|
2011-10-20 12:31:30 +00:00
|
|
|
|
const struct block *block)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
2011-11-04 11:57:04 +00:00
|
|
|
|
struct type *type, *rtype = NULL;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
char *type_name = NULL;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
enum demangle_component_type demangled_type;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
volatile struct gdb_exception except;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
/* Save the type: typy_lookup_type() may (indirectly) overwrite
|
|
|
|
|
memory pointed by demangled. */
|
|
|
|
|
demangled_type = demangled->type;
|
|
|
|
|
|
|
|
|
|
if (demangled_type == DEMANGLE_COMPONENT_POINTER
|
|
|
|
|
|| demangled_type == DEMANGLE_COMPONENT_REFERENCE
|
|
|
|
|
|| demangled_type == DEMANGLE_COMPONENT_CONST
|
|
|
|
|
|| demangled_type == DEMANGLE_COMPONENT_VOLATILE)
|
|
|
|
|
{
|
2010-02-26 09:08:10 +00:00
|
|
|
|
type = typy_lookup_type (demangled->u.s_binary.left, block);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (! type)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2011-10-27 09:14:27 +00:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
2011-11-04 11:57:04 +00:00
|
|
|
|
/* If the demangled_type matches with one of the types
|
|
|
|
|
below, run the corresponding function and save the type
|
|
|
|
|
to return later. We cannot just return here as we are in
|
|
|
|
|
an exception handler. */
|
2011-10-27 09:14:27 +00:00
|
|
|
|
switch (demangled_type)
|
|
|
|
|
{
|
|
|
|
|
case DEMANGLE_COMPONENT_REFERENCE:
|
2011-11-04 11:57:04 +00:00
|
|
|
|
rtype = lookup_reference_type (type);
|
|
|
|
|
break;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
case DEMANGLE_COMPONENT_POINTER:
|
2011-11-04 11:57:04 +00:00
|
|
|
|
rtype = lookup_pointer_type (type);
|
|
|
|
|
break;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
case DEMANGLE_COMPONENT_CONST:
|
2011-11-04 11:57:04 +00:00
|
|
|
|
rtype = make_cv_type (1, 0, type, NULL);
|
|
|
|
|
break;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
case DEMANGLE_COMPONENT_VOLATILE:
|
2011-11-04 11:57:04 +00:00
|
|
|
|
rtype = make_cv_type (0, 1, type, NULL);
|
|
|
|
|
break;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-20 20:19:03 +00:00
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-11-04 11:57:04 +00:00
|
|
|
|
/* If we have a type from the switch statement above, just return
|
|
|
|
|
that. */
|
|
|
|
|
if (rtype)
|
|
|
|
|
return rtype;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-11-04 11:57:04 +00:00
|
|
|
|
/* We don't have a type, so lookup the type. */
|
|
|
|
|
type_name = cp_comp_to_string (demangled, 10);
|
2010-02-26 09:08:10 +00:00
|
|
|
|
type = typy_lookup_typename (type_name, block);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
xfree (type_name);
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-28 20:50:17 +00:00
|
|
|
|
/* This is a helper function for typy_template_argument that is used
|
|
|
|
|
when the type does not have template symbols attached. It works by
|
|
|
|
|
parsing the type name. This happens with compilers, like older
|
|
|
|
|
versions of GCC, that do not emit DW_TAG_template_*. */
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
static PyObject *
|
2011-10-20 12:31:30 +00:00
|
|
|
|
typy_legacy_template_argument (struct type *type, const struct block *block,
|
2010-07-28 20:50:17 +00:00
|
|
|
|
int argno)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
2010-07-28 20:50:17 +00:00
|
|
|
|
int i;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
struct demangle_component *demangled;
|
2011-11-28 15:49:43 +00:00
|
|
|
|
struct demangle_parse_info *info = NULL;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
const char *err;
|
|
|
|
|
struct type *argtype;
|
2011-08-18 16:17:39 +00:00
|
|
|
|
struct cleanup *cleanup;
|
2011-11-28 15:49:43 +00:00
|
|
|
|
volatile struct gdb_exception except;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
if (TYPE_NAME (type) == NULL)
|
|
|
|
|
{
|
2010-02-26 09:08:10 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError, _("Null type name."));
|
2009-05-28 00:47:20 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-28 15:49:43 +00:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
/* Note -- this is not thread-safe. */
|
|
|
|
|
info = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
2011-08-18 16:17:39 +00:00
|
|
|
|
if (! info)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError, err);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2011-08-18 16:17:39 +00:00
|
|
|
|
demangled = info->tree;
|
|
|
|
|
cleanup = make_cleanup_cp_demangled_name_parse_free (info);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
/* Strip off component names. */
|
|
|
|
|
while (demangled->type == DEMANGLE_COMPONENT_QUAL_NAME
|
|
|
|
|
|| demangled->type == DEMANGLE_COMPONENT_LOCAL_NAME)
|
|
|
|
|
demangled = demangled->u.s_binary.right;
|
|
|
|
|
|
|
|
|
|
if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
|
|
|
|
|
{
|
2011-08-18 16:17:39 +00:00
|
|
|
|
do_cleanups (cleanup);
|
2010-02-26 09:08:10 +00:00
|
|
|
|
PyErr_SetString (PyExc_RuntimeError, _("Type is not a template."));
|
2009-05-28 00:47:20 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Skip from the template to the arguments. */
|
|
|
|
|
demangled = demangled->u.s_binary.right;
|
|
|
|
|
|
|
|
|
|
for (i = 0; demangled && i < argno; ++i)
|
|
|
|
|
demangled = demangled->u.s_binary.right;
|
|
|
|
|
|
|
|
|
|
if (! demangled)
|
|
|
|
|
{
|
2011-08-18 16:17:39 +00:00
|
|
|
|
do_cleanups (cleanup);
|
2010-02-26 09:08:10 +00:00
|
|
|
|
PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
|
2009-05-28 00:47:20 +00:00
|
|
|
|
argno);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-26 09:08:10 +00:00
|
|
|
|
argtype = typy_lookup_type (demangled->u.s_binary.left, block);
|
2011-08-18 16:17:39 +00:00
|
|
|
|
do_cleanups (cleanup);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (! argtype)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (argtype);
|
2010-07-28 20:50:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_template_argument (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
int argno;
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
2011-10-20 12:31:30 +00:00
|
|
|
|
const struct block *block = NULL;
|
2010-07-28 20:50:17 +00:00
|
|
|
|
PyObject *block_obj = NULL;
|
|
|
|
|
struct symbol *sym;
|
|
|
|
|
struct value *val = NULL;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (block_obj)
|
|
|
|
|
{
|
|
|
|
|
block = block_object_to_block (block_obj);
|
|
|
|
|
if (! block)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Second argument must be block."));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-23 20:23:55 +00:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
type = check_typedef (type);
|
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_REF)
|
|
|
|
|
type = check_typedef (TYPE_TARGET_TYPE (type));
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2010-07-28 20:50:17 +00:00
|
|
|
|
|
|
|
|
|
/* We might not have DW_TAG_template_*, so try to parse the type's
|
|
|
|
|
name. This is inefficient if we do not have a template type --
|
|
|
|
|
but that is going to wind up as an error anyhow. */
|
|
|
|
|
if (! TYPE_N_TEMPLATE_ARGUMENTS (type))
|
|
|
|
|
return typy_legacy_template_argument (type, block, argno);
|
|
|
|
|
|
|
|
|
|
if (argno >= TYPE_N_TEMPLATE_ARGUMENTS (type))
|
|
|
|
|
{
|
|
|
|
|
PyErr_Format (PyExc_RuntimeError, _("No argument %d in template."),
|
|
|
|
|
argno);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sym = TYPE_TEMPLATE_ARGUMENT (type, argno);
|
|
|
|
|
if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
|
|
|
|
|
return type_to_type_object (SYMBOL_TYPE (sym));
|
|
|
|
|
else if (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT)
|
|
|
|
|
{
|
|
|
|
|
PyErr_Format (PyExc_RuntimeError,
|
|
|
|
|
_("Template argument is optimized out"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
val = value_of_variable (sym, block);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return value_to_value_object (val);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_str (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
char *thetype = NULL;
|
2009-08-14 00:32:33 +00:00
|
|
|
|
long length = 0;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
PyObject *result;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
struct cleanup *old_chain;
|
|
|
|
|
struct ui_file *stb;
|
|
|
|
|
|
|
|
|
|
stb = mem_fileopen ();
|
|
|
|
|
old_chain = make_cleanup_ui_file_delete (stb);
|
|
|
|
|
|
* NEWS: Update.
* c-typeprint.c (c_type_print_base): Handle print_method and
print_typedefs flags.
* gdbcmd.h (setprinttypelist, showprinttypelist): Declare.
* python/py-type.c (typy_str): Use LA_PRINT_TYPE and raw
options.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new field.s
(whatis_exp): Parse flags. Use LA_PRINT_TYPE.
(setprinttypelist, showprinttypelist, print_methods,
print_typedefs): New globals.
(set_print_type, show_print_type, set_print_type_methods,
show_print_type_methods, set_print_type_typedefs,
show_print_type_typedefs): New functions.
(_initialize_typeprint): Update documentation. Add "print
type methods" and "print type typedefs" parameters.
* typeprint.h (struct type_print_options) <print_methods,
print_typedefs>: New fields.
doc
* gdb.texinfo (Symbols): Document "set print type methods",
"set print type typedefs", and flags to ptype and whatis.
2012-11-12 17:26:21 +00:00
|
|
|
|
LA_PRINT_TYPE (type_object_to_type (self), "", stb, -1, 0,
|
|
|
|
|
&type_print_raw_options);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
thetype = ui_file_xstrdup (stb, &length);
|
|
|
|
|
do_cleanups (old_chain);
|
|
|
|
|
}
|
|
|
|
|
if (except.reason < 0)
|
|
|
|
|
{
|
|
|
|
|
xfree (thetype);
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-14 00:32:33 +00:00
|
|
|
|
result = PyUnicode_Decode (thetype, length, host_charset (), NULL);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
xfree (thetype);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-23 20:26:10 +00:00
|
|
|
|
/* Implement the richcompare method. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_richcompare (PyObject *self, PyObject *other, int op)
|
|
|
|
|
{
|
|
|
|
|
int result = Py_NE;
|
|
|
|
|
struct type *type1 = type_object_to_type (self);
|
|
|
|
|
struct type *type2 = type_object_to_type (other);
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
/* We can only compare ourselves to another Type object, and only
|
|
|
|
|
for equality or inequality. */
|
|
|
|
|
if (type2 == NULL || (op != Py_EQ && op != Py_NE))
|
|
|
|
|
{
|
|
|
|
|
Py_INCREF (Py_NotImplemented);
|
|
|
|
|
return Py_NotImplemented;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type1 == type2)
|
|
|
|
|
result = Py_EQ;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
2013-11-22 04:28:35 +00:00
|
|
|
|
result = types_deeply_equal (type1, type2);
|
2010-08-23 20:26:10 +00:00
|
|
|
|
}
|
2013-11-22 04:28:35 +00:00
|
|
|
|
/* If there is a GDB exception, a comparison is not capable
|
|
|
|
|
(or trusted), so exit. */
|
2011-10-27 09:14:27 +00:00
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2010-08-23 20:26:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-22 04:28:35 +00:00
|
|
|
|
if (op == (result ? Py_EQ : Py_NE))
|
2010-08-23 20:26:10 +00:00
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const struct objfile_data *typy_objfile_data_key;
|
|
|
|
|
|
|
|
|
|
static void
|
2009-09-11 18:51:31 +00:00
|
|
|
|
save_objfile_types (struct objfile *objfile, void *datum)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
|
|
|
|
type_object *obj = datum;
|
|
|
|
|
htab_t copied_types;
|
|
|
|
|
struct cleanup *cleanup;
|
|
|
|
|
|
2013-05-20 20:29:44 +00:00
|
|
|
|
if (!gdb_python_initialized)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
/* This prevents another thread from freeing the objects we're
|
|
|
|
|
operating on. */
|
* python/python-internal.h (struct language_defn): Declare.
(python_gdbarch, python_language): Likewise.
(ensure_python_env): Add prototype.
(make_cleanup_py_restore_gil): Remove prototype.
* python/python.c: Include "arch-utils.h", "value.h" and "language.h".
(python_gdbarch, python_language): New global variables.
(struct python_env): New data type.
(ensure_python_env, restore_python_env): New functions.
(eval_python_from_control_command): Call ensure_python_env to
install current architecture and language.
(python_command, gdbpy_new_objfile): Likewise.
* python/python-cmd.c: Include "arch-utils.h" and "language.h".
(cmdpy_destroyer, cmdpy_function, cmdpy_completer): Call
ensure_python_env.
* python/python-type.c (clean_up_objfile_types): Likewise.
* python/python-objfile.c: Include "language.h".
(clean_up_objfile): Call ensure_python_env.
* python/python-prettyprint.c (apply_val_pretty_printer): Likewise.
(apply_varobj_pretty_printer): Do not call PyGILState_Ensure.
* varobj.c (varobj_ensure_python_env): New helper function.
(varobj_get_display_hint, update_dynamic_varobj_children,
install_default_visualizer, varobj_set_visualizer, free_variable,
value_get_print_value): Call it.
(value_get_print_value): Add varobj argument instead of pretty
printer argument. Update all callers.
* python/python-utils.c (py_gil_restore, make_cleanup_py_restore_gil):
Remove.
* value.h (internal_function_fn): Add GDBARCH and LANGUAGE argument.
(call_internal_function): Likewise.
* value.c (call_internal_function): Likewise. Pass to handler.
* eval.c (evaluate_subexp_standard): Update call.
* python/python-function.c: Include "language.h".
(fnpy_call): Add GDBARCH and LANGAUAGE arguments and call
make_cleanup_python_env.
* python/python-value.c (builtin_type_pyint, builtin_type_pyfloat,
builtin_type_pylong, builtin_type_pybool, builtin_type_pychar,
valpy_str): Use python_gdbarch and python_language instead of
current_gdbarch and current_language.
* python/python-type.c (typy_lookup_typename): Likewise.
2009-07-02 17:04:23 +00:00
|
|
|
|
cleanup = ensure_python_env (get_objfile_arch (objfile), current_language);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
copied_types = create_copied_types_hash (objfile);
|
|
|
|
|
|
|
|
|
|
while (obj)
|
|
|
|
|
{
|
|
|
|
|
type_object *next = obj->next;
|
|
|
|
|
|
|
|
|
|
htab_empty (copied_types);
|
|
|
|
|
|
|
|
|
|
obj->type = copy_type_recursive (objfile, obj->type, copied_types);
|
|
|
|
|
|
|
|
|
|
obj->next = NULL;
|
|
|
|
|
obj->prev = NULL;
|
|
|
|
|
|
|
|
|
|
obj = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
htab_delete (copied_types);
|
|
|
|
|
|
|
|
|
|
do_cleanups (cleanup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_type (type_object *obj, struct type *type)
|
|
|
|
|
{
|
|
|
|
|
obj->type = type;
|
|
|
|
|
obj->prev = NULL;
|
|
|
|
|
if (type && TYPE_OBJFILE (type))
|
|
|
|
|
{
|
|
|
|
|
struct objfile *objfile = TYPE_OBJFILE (type);
|
|
|
|
|
|
|
|
|
|
obj->next = objfile_data (objfile, typy_objfile_data_key);
|
|
|
|
|
if (obj->next)
|
|
|
|
|
obj->next->prev = obj;
|
|
|
|
|
set_objfile_data (objfile, typy_objfile_data_key, obj);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
obj->next = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
typy_dealloc (PyObject *obj)
|
|
|
|
|
{
|
|
|
|
|
type_object *type = (type_object *) obj;
|
|
|
|
|
|
|
|
|
|
if (type->prev)
|
|
|
|
|
type->prev->next = type->next;
|
|
|
|
|
else if (type->type && TYPE_OBJFILE (type->type))
|
|
|
|
|
{
|
|
|
|
|
/* Must reset head of list. */
|
|
|
|
|
struct objfile *objfile = TYPE_OBJFILE (type->type);
|
2010-05-17 21:23:25 +00:00
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (objfile)
|
|
|
|
|
set_objfile_data (objfile, typy_objfile_data_key, type->next);
|
|
|
|
|
}
|
|
|
|
|
if (type->next)
|
|
|
|
|
type->next->prev = type->prev;
|
|
|
|
|
|
2012-12-12 16:47:30 +00:00
|
|
|
|
Py_TYPE (type)->tp_free (type);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
/* Return number of fields ("length" of the field dictionary). */
|
|
|
|
|
|
|
|
|
|
static Py_ssize_t
|
|
|
|
|
typy_length (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
type = typy_get_composite (type);
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
return TYPE_NFIELDS (type);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
/* Implements boolean evaluation of gdb.Type. Handle this like other
|
2013-11-29 20:00:47 +00:00
|
|
|
|
Python objects that don't have a meaningful truth value -- all
|
2011-11-15 21:17:04 +00:00
|
|
|
|
values are true. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
typy_nonzero (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
/* Return a gdb.Field object for the field named by the argument. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_getitem (PyObject *self, PyObject *key)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
|
|
|
|
char *field;
|
|
|
|
|
int i;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
field = python_string_to_host_string (key);
|
|
|
|
|
if (field == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2013-11-29 20:00:47 +00:00
|
|
|
|
/* We want just fields of this type, not of base types, so instead of
|
2011-09-28 20:04:52 +00:00
|
|
|
|
using lookup_struct_elt_type, portions of that function are
|
|
|
|
|
copied here. */
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
type = typy_get_composite (type);
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
return NULL;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
for (i = 0; i < TYPE_NFIELDS (type); i++)
|
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 04:48:23 +00:00
|
|
|
|
const char *t_field_name = TYPE_FIELD_NAME (type, i);
|
2011-09-28 20:04:52 +00:00
|
|
|
|
|
|
|
|
|
if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
|
|
|
|
|
{
|
|
|
|
|
return convert_field (type, i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PyErr_SetObject (PyExc_KeyError, key);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-29 20:00:47 +00:00
|
|
|
|
/* Implement the "get" method on the type object. This is the
|
2011-09-28 20:04:52 +00:00
|
|
|
|
same as getitem if the key is present, but returns the supplied
|
|
|
|
|
default value or None if the key is not found. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_get (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
PyObject *key, *defval = Py_None, *result;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
if (!PyArg_UnpackTuple (args, "get", 1, 2, &key, &defval))
|
|
|
|
|
return NULL;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
result = typy_getitem (self, key);
|
|
|
|
|
if (result != NULL)
|
|
|
|
|
return result;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
/* typy_getitem returned error status. If the exception is
|
|
|
|
|
KeyError, clear the exception status and return the defval
|
|
|
|
|
instead. Otherwise return the exception unchanged. */
|
|
|
|
|
if (!PyErr_ExceptionMatches (PyExc_KeyError))
|
|
|
|
|
return NULL;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
PyErr_Clear ();
|
|
|
|
|
Py_INCREF (defval);
|
|
|
|
|
return defval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implement the "has_key" method on the type object. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_has_key (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct type *type = ((type_object *) self)->type;
|
2011-10-13 13:55:30 +00:00
|
|
|
|
const char *field;
|
2011-09-28 20:04:52 +00:00
|
|
|
|
int i;
|
2011-10-27 09:14:27 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
if (!PyArg_ParseTuple (args, "s", &field))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2013-11-29 20:00:47 +00:00
|
|
|
|
/* We want just fields of this type, not of base types, so instead of
|
2011-09-28 20:04:52 +00:00
|
|
|
|
using lookup_struct_elt_type, portions of that function are
|
|
|
|
|
copied here. */
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
type = typy_get_composite (type);
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
return NULL;
|
2011-09-28 20:04:52 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < TYPE_NFIELDS (type); i++)
|
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 04:48:23 +00:00
|
|
|
|
const char *t_field_name = TYPE_FIELD_NAME (type, i);
|
2011-09-28 20:04:52 +00:00
|
|
|
|
|
|
|
|
|
if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
}
|
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make an iterator object to iterate over keys, values, or items. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_make_iter (PyObject *self, enum gdbpy_iter_kind kind)
|
|
|
|
|
{
|
|
|
|
|
typy_iterator_object *typy_iter_obj;
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
/* Check that "self" is a structure or union type. */
|
|
|
|
|
if (typy_get_composite (((type_object *) self)->type) == NULL)
|
|
|
|
|
return NULL;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
typy_iter_obj = PyObject_New (typy_iterator_object,
|
|
|
|
|
&type_iterator_object_type);
|
|
|
|
|
if (typy_iter_obj == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
typy_iter_obj->field = 0;
|
|
|
|
|
typy_iter_obj->kind = kind;
|
|
|
|
|
Py_INCREF (self);
|
|
|
|
|
typy_iter_obj->source = (type_object *) self;
|
|
|
|
|
|
|
|
|
|
return (PyObject *) typy_iter_obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* iteritems() method. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_iteritems (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
return typy_make_iter (self, iter_items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* iterkeys() method. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_iterkeys (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
return typy_make_iter (self, iter_keys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Iterating over the class, same as iterkeys except for the function
|
|
|
|
|
signature. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_iter (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
return typy_make_iter (self, iter_keys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* itervalues() method. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_itervalues (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
return typy_make_iter (self, iter_values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return a reference to the type iterator. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_iterator_iter (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
Py_INCREF (self);
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the next field in the iteration through the list of fields
|
|
|
|
|
of the type. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
typy_iterator_iternext (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
typy_iterator_object *iter_obj = (typy_iterator_object *) self;
|
|
|
|
|
struct type *type = iter_obj->source->type;
|
|
|
|
|
PyObject *result;
|
2013-11-29 20:00:47 +00:00
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
if (iter_obj->field < TYPE_NFIELDS (type))
|
|
|
|
|
{
|
|
|
|
|
result = make_fielditem (type, iter_obj->field, iter_obj->kind);
|
|
|
|
|
if (result != NULL)
|
|
|
|
|
iter_obj->field++;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
typy_iterator_dealloc (PyObject *obj)
|
|
|
|
|
{
|
|
|
|
|
typy_iterator_object *iter_obj = (typy_iterator_object *) obj;
|
|
|
|
|
|
|
|
|
|
Py_DECREF (iter_obj->source);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 00:47:20 +00:00
|
|
|
|
/* Create a new Type referring to TYPE. */
|
|
|
|
|
PyObject *
|
|
|
|
|
type_to_type_object (struct type *type)
|
|
|
|
|
{
|
|
|
|
|
type_object *type_obj;
|
|
|
|
|
|
|
|
|
|
type_obj = PyObject_New (type_object, &type_object_type);
|
|
|
|
|
if (type_obj)
|
|
|
|
|
set_type (type_obj, type);
|
|
|
|
|
|
|
|
|
|
return (PyObject *) type_obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct type *
|
|
|
|
|
type_object_to_type (PyObject *obj)
|
|
|
|
|
{
|
|
|
|
|
if (! PyObject_TypeCheck (obj, &type_object_type))
|
|
|
|
|
return NULL;
|
|
|
|
|
return ((type_object *) obj)->type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Implementation of gdb.lookup_type. */
|
|
|
|
|
PyObject *
|
|
|
|
|
gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
|
|
|
|
|
{
|
2010-02-26 09:08:10 +00:00
|
|
|
|
static char *keywords[] = { "name", "block", NULL };
|
2011-06-24 19:47:37 +00:00
|
|
|
|
const char *type_name = NULL;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
struct type *type = NULL;
|
2010-02-26 09:08:10 +00:00
|
|
|
|
PyObject *block_obj = NULL;
|
2011-10-20 12:31:30 +00:00
|
|
|
|
const struct block *block = NULL;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
2010-02-26 09:08:10 +00:00
|
|
|
|
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O", keywords,
|
|
|
|
|
&type_name, &block_obj))
|
2009-05-28 00:47:20 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2010-02-26 09:08:10 +00:00
|
|
|
|
if (block_obj)
|
|
|
|
|
{
|
|
|
|
|
block = block_object_to_block (block_obj);
|
|
|
|
|
if (! block)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("'block' argument must be a Block."));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type = typy_lookup_typename (type_name, block);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (! type)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return (PyObject *) type_to_type_object (type);
|
|
|
|
|
}
|
|
|
|
|
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
int
|
2009-05-28 00:47:20 +00:00
|
|
|
|
gdbpy_initialize_types (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
typy_objfile_data_key
|
2009-09-11 18:51:31 +00:00
|
|
|
|
= register_objfile_data_with_cleanup (save_objfile_types, NULL);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
if (PyType_Ready (&type_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
if (PyType_Ready (&field_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2011-09-28 20:04:52 +00:00
|
|
|
|
if (PyType_Ready (&type_iterator_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; pyty_codes[i].name; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (PyModule_AddIntConstant (gdb_module,
|
|
|
|
|
/* Cast needed for Python 2.4. */
|
|
|
|
|
(char *) pyty_codes[i].name,
|
|
|
|
|
pyty_codes[i].code) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-20 20:36:19 +00:00
|
|
|
|
if (gdb_pymodule_addobject (gdb_module, "Type",
|
|
|
|
|
(PyObject *) &type_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2009-05-28 00:47:20 +00:00
|
|
|
|
|
2013-05-20 20:36:19 +00:00
|
|
|
|
if (gdb_pymodule_addobject (gdb_module, "TypeIterator",
|
|
|
|
|
(PyObject *) &type_iterator_object_type) < 0)
|
* python/py-arch.c (gdbpy_initialize_arch): Return 'int'.
Check errors.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Return 'int'.
* python/py-block.c (gdbpy_initialize_blocks): Return 'int'.
Check errors.
* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Return 'int'.
Check errors.
* python/py-cmd.c (gdbpy_initialize_commands): Return 'int'.
Check errors.
* python/py-event.c (gdbpy_initialize_event): Return 'int'.
Check errors.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Change generated
init function to return 'int'.
* python/py-evtregistry.c (gdbpy_initialize_eventregistry):
Return 'int'. Check errors.
* python/py-evts.c (gdbpy_initialize_py_events): Return 'int'.
Check errors.
* python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints):
Return 'int'. Check errors.
* python/py-frame.c (gdbpy_initialize_frames): Return 'int'.
Check errors.
* python/py-function.c (gdbpy_initialize_functions): Return 'int'.
Check errors.
* python/py-gdb-readline.c (gdbpy_initialize_gdb_readline):
Check errors.
* python/py-inferior.c (gdbpy_initialize_inferior): Return 'int'.
Check errors.
* python/py-infthread.c (gdbpy_initialize_thread): Return 'int'.
Check errors.
* python/py-lazy-string.c (gdbpy_initialize_lazy_string): Return 'int'.
Check errors.
* python/py-objfile.c (gdbpy_initialize_objfile): Return 'int'.
Check errors.
* python/py-param.c (gdbpy_initialize_parameters): Return 'int'.
Check errors.
* python/py-progspace.c (gdbpy_initialize_pspace): Return 'int'.
Check errors.
* python/py-symbol.c (gdbpy_initialize_symbols): Return 'int'.
Check errors.
* python/py-symtab.c (gdbpy_initialize_symtabs): Return 'int'.
Check errors.
* python/py-type.c (gdbpy_initialize_types): Return 'int'.
Check errors.
* python/py-value.c (gdbpy_initialize_values): Return 'int'.
Check errors.
* python/python-internal.h (gdbpy_initialize_auto_load,
gdbpy_initialize_values, gdbpy_initialize_frames,
gdbpy_initialize_symtabs, gdbpy_initialize_commands,
gdbpy_initialize_symbols, gdbpy_initialize_symtabs,
gdbpy_initialize_blocks, gdbpy_initialize_types,
gdbpy_initialize_functions, gdbpy_initialize_pspace,
gdbpy_initialize_objfile, gdbpy_initialize_breakpoints,
gdbpy_initialize_finishbreakpoints,
gdbpy_initialize_lazy_string, gdbpy_initialize_parameters,
gdbpy_initialize_thread, gdbpy_initialize_inferior,
gdbpy_initialize_eventregistry, gdbpy_initialize_event,
gdbpy_initialize_py_events, gdbpy_initialize_stop_event,
gdbpy_initialize_signal_event,
gdbpy_initialize_breakpoint_event,
gdbpy_initialize_continue_event,
gdbpy_initialize_exited_event, gdbpy_initialize_thread_event,
gdbpy_initialize_new_objfile_event, gdbpy_initialize_arch):
Update. Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION.
* python/python.c (gdb_python_initialized): New global.
(gdbpy_initialize_events): Return 'int'. Check errors.
(_initialize_python): Check errors. Set
gdb_python_initialized.
2013-05-20 20:28:52 +00:00
|
|
|
|
return -1;
|
2011-09-28 20:04:52 +00:00
|
|
|
|
|
2013-05-20 20:36:19 +00:00
|
|
|
|
return gdb_pymodule_addobject (gdb_module, "Field",
|
|
|
|
|
(PyObject *) &field_object_type);
|
2009-05-28 00:47:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static PyGetSetDef type_object_getset[] =
|
|
|
|
|
{
|
|
|
|
|
{ "code", typy_get_code, NULL,
|
|
|
|
|
"The code for this type.", NULL },
|
2013-12-23 03:18:51 +00:00
|
|
|
|
{ "name", typy_get_name, NULL,
|
|
|
|
|
"The name for this type, or None.", NULL },
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{ "sizeof", typy_get_sizeof, NULL,
|
|
|
|
|
"The size of this type, in bytes.", NULL },
|
|
|
|
|
{ "tag", typy_get_tag, NULL,
|
|
|
|
|
"The tag name for this type, or None.", NULL },
|
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PyMethodDef type_object_methods[] =
|
|
|
|
|
{
|
2010-08-23 20:21:28 +00:00
|
|
|
|
{ "array", typy_array, METH_VARARGS,
|
2011-12-02 00:27:48 +00:00
|
|
|
|
"array ([LOW_BOUND,] HIGH_BOUND) -> Type\n\
|
|
|
|
|
Return a type which represents an array of objects of this type.\n\
|
|
|
|
|
The bounds of the array are [LOW_BOUND, HIGH_BOUND] inclusive.\n\
|
|
|
|
|
If LOW_BOUND is omitted, a value of zero is used." },
|
2012-08-10 20:26:00 +00:00
|
|
|
|
{ "vector", typy_vector, METH_VARARGS,
|
|
|
|
|
"vector ([LOW_BOUND,] HIGH_BOUND) -> Type\n\
|
|
|
|
|
Return a type which represents a vector of objects of this type.\n\
|
|
|
|
|
The bounds of the array are [LOW_BOUND, HIGH_BOUND] inclusive.\n\
|
|
|
|
|
If LOW_BOUND is omitted, a value of zero is used.\n\
|
|
|
|
|
Vectors differ from arrays in that if the current language has C-style\n\
|
|
|
|
|
arrays, vectors don't decay to a pointer to the first element.\n\
|
|
|
|
|
They are first class values." },
|
2011-09-28 20:04:52 +00:00
|
|
|
|
{ "__contains__", typy_has_key, METH_VARARGS,
|
|
|
|
|
"T.__contains__(k) -> True if T has a field named k, else False" },
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{ "const", typy_const, METH_NOARGS,
|
|
|
|
|
"const () -> Type\n\
|
|
|
|
|
Return a const variant of this type." },
|
|
|
|
|
{ "fields", typy_fields, METH_NOARGS,
|
2011-09-28 20:04:52 +00:00
|
|
|
|
"fields () -> list\n\
|
|
|
|
|
Return a list holding all the fields of this type.\n\
|
|
|
|
|
Each field is a gdb.Field object." },
|
|
|
|
|
{ "get", typy_get, METH_VARARGS,
|
|
|
|
|
"T.get(k[,default]) -> returns field named k in T, if it exists;\n\
|
|
|
|
|
otherwise returns default, if supplied, or None if not." },
|
|
|
|
|
{ "has_key", typy_has_key, METH_VARARGS,
|
|
|
|
|
"T.has_key(k) -> True if T has a field named k, else False" },
|
|
|
|
|
{ "items", typy_items, METH_NOARGS,
|
|
|
|
|
"items () -> list\n\
|
|
|
|
|
Return a list of (name, field) pairs of this type.\n\
|
|
|
|
|
Each field is a gdb.Field object." },
|
|
|
|
|
{ "iteritems", typy_iteritems, METH_NOARGS,
|
|
|
|
|
"iteritems () -> an iterator over the (name, field)\n\
|
|
|
|
|
pairs of this type. Each field is a gdb.Field object." },
|
|
|
|
|
{ "iterkeys", typy_iterkeys, METH_NOARGS,
|
|
|
|
|
"iterkeys () -> an iterator over the field names of this type." },
|
|
|
|
|
{ "itervalues", typy_itervalues, METH_NOARGS,
|
|
|
|
|
"itervalues () -> an iterator over the fields of this type.\n\
|
|
|
|
|
Each field is a gdb.Field object." },
|
|
|
|
|
{ "keys", typy_field_names, METH_NOARGS,
|
|
|
|
|
"keys () -> list\n\
|
|
|
|
|
Return a list holding all the fields names of this type." },
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{ "pointer", typy_pointer, METH_NOARGS,
|
|
|
|
|
"pointer () -> Type\n\
|
|
|
|
|
Return a type of pointer to this type." },
|
2009-12-08 14:06:04 +00:00
|
|
|
|
{ "range", typy_range, METH_NOARGS,
|
|
|
|
|
"range () -> tuple\n\
|
|
|
|
|
Return a tuple containing the lower and upper range for this type."},
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{ "reference", typy_reference, METH_NOARGS,
|
|
|
|
|
"reference () -> Type\n\
|
|
|
|
|
Return a type of reference to this type." },
|
|
|
|
|
{ "strip_typedefs", typy_strip_typedefs, METH_NOARGS,
|
|
|
|
|
"strip_typedefs () -> Type\n\
|
|
|
|
|
Return a type formed by stripping this type of all typedefs."},
|
|
|
|
|
{ "target", typy_target, METH_NOARGS,
|
|
|
|
|
"target () -> Type\n\
|
|
|
|
|
Return the target type of this type." },
|
|
|
|
|
{ "template_argument", typy_template_argument, METH_VARARGS,
|
2010-02-26 09:08:10 +00:00
|
|
|
|
"template_argument (arg, [block]) -> Type\n\
|
2009-05-28 00:47:20 +00:00
|
|
|
|
Return the type of a template argument." },
|
|
|
|
|
{ "unqualified", typy_unqualified, METH_NOARGS,
|
|
|
|
|
"unqualified () -> Type\n\
|
|
|
|
|
Return a variant of this type without const or volatile attributes." },
|
2011-11-15 21:17:04 +00:00
|
|
|
|
{ "values", typy_values, METH_NOARGS,
|
2011-09-28 20:04:52 +00:00
|
|
|
|
"values () -> list\n\
|
|
|
|
|
Return a list holding all the fields of this type.\n\
|
|
|
|
|
Each field is a gdb.Field object." },
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{ "volatile", typy_volatile, METH_NOARGS,
|
|
|
|
|
"volatile () -> Type\n\
|
|
|
|
|
Return a volatile variant of this type" },
|
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-15 21:17:04 +00:00
|
|
|
|
static PyNumberMethods type_object_as_number = {
|
|
|
|
|
NULL, /* nb_add */
|
|
|
|
|
NULL, /* nb_subtract */
|
|
|
|
|
NULL, /* nb_multiply */
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#ifndef IS_PY3K
|
2011-11-15 21:17:04 +00:00
|
|
|
|
NULL, /* nb_divide */
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#endif
|
2011-11-15 21:17:04 +00:00
|
|
|
|
NULL, /* nb_remainder */
|
|
|
|
|
NULL, /* nb_divmod */
|
|
|
|
|
NULL, /* nb_power */
|
|
|
|
|
NULL, /* nb_negative */
|
|
|
|
|
NULL, /* nb_positive */
|
|
|
|
|
NULL, /* nb_absolute */
|
|
|
|
|
typy_nonzero, /* nb_nonzero */
|
|
|
|
|
NULL, /* nb_invert */
|
|
|
|
|
NULL, /* nb_lshift */
|
|
|
|
|
NULL, /* nb_rshift */
|
|
|
|
|
NULL, /* nb_and */
|
|
|
|
|
NULL, /* nb_xor */
|
|
|
|
|
NULL, /* nb_or */
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#ifdef IS_PY3K
|
|
|
|
|
NULL, /* nb_int */
|
|
|
|
|
NULL, /* reserved */
|
|
|
|
|
#else
|
2011-11-15 21:17:04 +00:00
|
|
|
|
NULL, /* nb_coerce */
|
|
|
|
|
NULL, /* nb_int */
|
|
|
|
|
NULL, /* nb_long */
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#endif
|
2011-11-15 21:17:04 +00:00
|
|
|
|
NULL, /* nb_float */
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#ifndef IS_PY3K
|
2011-11-15 21:17:04 +00:00
|
|
|
|
NULL, /* nb_oct */
|
|
|
|
|
NULL /* nb_hex */
|
2012-12-12 16:47:30 +00:00
|
|
|
|
#endif
|
2011-11-15 21:17:04 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-09-28 20:04:52 +00:00
|
|
|
|
static PyMappingMethods typy_mapping = {
|
|
|
|
|
typy_length,
|
|
|
|
|
typy_getitem,
|
|
|
|
|
NULL /* no "set" method */
|
|
|
|
|
};
|
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
PyTypeObject type_object_type =
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
2012-12-12 16:47:30 +00:00
|
|
|
|
PyVarObject_HEAD_INIT (NULL, 0)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
"gdb.Type", /*tp_name*/
|
|
|
|
|
sizeof (type_object), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
typy_dealloc, /*tp_dealloc*/
|
|
|
|
|
0, /*tp_print*/
|
|
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
|
|
|
|
0, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
2011-11-15 21:17:04 +00:00
|
|
|
|
&type_object_as_number, /*tp_as_number*/
|
2009-05-28 00:47:20 +00:00
|
|
|
|
0, /*tp_as_sequence*/
|
2011-09-28 20:04:52 +00:00
|
|
|
|
&typy_mapping, /*tp_as_mapping*/
|
2009-05-28 00:47:20 +00:00
|
|
|
|
0, /*tp_hash */
|
|
|
|
|
0, /*tp_call*/
|
|
|
|
|
typy_str, /*tp_str*/
|
|
|
|
|
0, /*tp_getattro*/
|
|
|
|
|
0, /*tp_setattro*/
|
|
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
|
|
|
|
|
"GDB type object", /* tp_doc */
|
|
|
|
|
0, /* tp_traverse */
|
|
|
|
|
0, /* tp_clear */
|
2010-08-23 20:26:10 +00:00
|
|
|
|
typy_richcompare, /* tp_richcompare */
|
2009-05-28 00:47:20 +00:00
|
|
|
|
0, /* tp_weaklistoffset */
|
2011-09-28 20:04:52 +00:00
|
|
|
|
typy_iter, /* tp_iter */
|
2009-05-28 00:47:20 +00:00
|
|
|
|
0, /* tp_iternext */
|
|
|
|
|
type_object_methods, /* tp_methods */
|
|
|
|
|
0, /* tp_members */
|
|
|
|
|
type_object_getset, /* tp_getset */
|
|
|
|
|
0, /* tp_base */
|
|
|
|
|
0, /* tp_dict */
|
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
|
0, /* tp_dictoffset */
|
|
|
|
|
0, /* tp_init */
|
|
|
|
|
0, /* tp_alloc */
|
|
|
|
|
0, /* tp_new */
|
|
|
|
|
};
|
|
|
|
|
|
2012-02-17 19:24:27 +00:00
|
|
|
|
static PyGetSetDef field_object_getset[] =
|
|
|
|
|
{
|
|
|
|
|
{ "__dict__", gdb_py_generic_dict, NULL,
|
|
|
|
|
"The __dict__ for this field.", &field_object_type },
|
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
PyTypeObject field_object_type =
|
2009-05-28 00:47:20 +00:00
|
|
|
|
{
|
2012-12-12 16:47:30 +00:00
|
|
|
|
PyVarObject_HEAD_INIT (NULL, 0)
|
2009-05-28 00:47:20 +00:00
|
|
|
|
"gdb.Field", /*tp_name*/
|
|
|
|
|
sizeof (field_object), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
field_dealloc, /*tp_dealloc*/
|
|
|
|
|
0, /*tp_print*/
|
|
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
|
|
|
|
0, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash */
|
|
|
|
|
0, /*tp_call*/
|
|
|
|
|
0, /*tp_str*/
|
|
|
|
|
0, /*tp_getattro*/
|
|
|
|
|
0, /*tp_setattro*/
|
|
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
|
|
|
|
|
"GDB field object", /* tp_doc */
|
|
|
|
|
0, /* tp_traverse */
|
|
|
|
|
0, /* tp_clear */
|
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
|
0, /* tp_iter */
|
|
|
|
|
0, /* tp_iternext */
|
|
|
|
|
0, /* tp_methods */
|
|
|
|
|
0, /* tp_members */
|
2012-02-17 19:24:27 +00:00
|
|
|
|
field_object_getset, /* tp_getset */
|
2009-05-28 00:47:20 +00:00
|
|
|
|
0, /* tp_base */
|
|
|
|
|
0, /* tp_dict */
|
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
|
offsetof (field_object, dict), /* tp_dictoffset */
|
|
|
|
|
0, /* tp_init */
|
|
|
|
|
0, /* tp_alloc */
|
|
|
|
|
0, /* tp_new */
|
|
|
|
|
};
|
2011-09-28 20:04:52 +00:00
|
|
|
|
|
Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances. That doesn't
work in C++ though. C++ treats these as definitions. So then the
compiler complains about symbol redefinition, like:
src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
The intent of static here is naturally to avoid making these objects
visible outside the compilation unit. The equivalent in C++ would be
to instead define the objects in the anonymous namespace. But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.
(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)
gdb/ChangeLog:
2015-02-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* breakpoint.c (base_breakpoint_ops): Delete.
* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
* python/py-arch.c (arch_object_type): Make extern.
* python/py-block.c (block_syms_iterator_object_type): Make extern.
* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
* python/py-cmd.c (cmdpy_object_type): Make extern.
* python/py-continueevent.c (continue_event_object_type)
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
parameter. Update all callers.
* python/py-evtregistry.c (eventregistry_object_type): Make extern.
* python/py-exitedevent.c (exited_event_object_type): Make extern.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
* python/py-function.c (fnpy_object_type): Make extern.
* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
* python/py-infevents.c (call_pre_event_object_type)
(inferior_call_post_event_object_type).
(memory_changed_event_object_type): Make extern.
* python/py-infthread.c (thread_object_type): Make extern.
* python/py-lazy-string.c (lazy_string_object_type): Make extern.
* python/py-linetable.c (linetable_entry_object_type)
(linetable_object_type, ltpy_iterator_object_type): Make extern.
* python/py-newobjfileevent.c (new_objfile_event_object_type)
(clear_objfiles_event_object_type): Make extern.
* python/py-objfile.c (objfile_object_type): Make extern.
* python/py-param.c (parmpy_object_type): Make extern.
* python/py-progspace.c (pspace_object_type): Make extern.
* python/py-signalevent.c (signal_event_object_type): Make extern.
* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Make extern.
* python/python.c (python_extension_script_ops)
(python_extension_ops): Make extern.
* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
|
|
|
|
PyTypeObject type_iterator_object_type = {
|
2012-12-12 16:47:30 +00:00
|
|
|
|
PyVarObject_HEAD_INIT (NULL, 0)
|
2011-09-28 20:04:52 +00:00
|
|
|
|
"gdb.TypeIterator", /*tp_name*/
|
|
|
|
|
sizeof (typy_iterator_object), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
typy_iterator_dealloc, /*tp_dealloc*/
|
|
|
|
|
0, /*tp_print*/
|
|
|
|
|
0, /*tp_getattr*/
|
|
|
|
|
0, /*tp_setattr*/
|
|
|
|
|
0, /*tp_compare*/
|
|
|
|
|
0, /*tp_repr*/
|
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
|
0, /*tp_hash */
|
|
|
|
|
0, /*tp_call*/
|
|
|
|
|
0, /*tp_str*/
|
|
|
|
|
0, /*tp_getattro*/
|
|
|
|
|
0, /*tp_setattro*/
|
|
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
|
|
|
|
|
"GDB type iterator object", /*tp_doc */
|
|
|
|
|
0, /*tp_traverse */
|
|
|
|
|
0, /*tp_clear */
|
|
|
|
|
0, /*tp_richcompare */
|
|
|
|
|
0, /*tp_weaklistoffset */
|
|
|
|
|
typy_iterator_iter, /*tp_iter */
|
|
|
|
|
typy_iterator_iternext, /*tp_iternext */
|
|
|
|
|
0 /*tp_methods */
|
|
|
|
|
};
|