2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
/* Python interface to symbols.
|
|
|
|
|
|
2013-01-01 07:33:28 +01:00
|
|
|
|
Copyright (C) 2008-2013 Free Software Foundation, Inc.
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01: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 "block.h"
|
|
|
|
|
#include "exceptions.h"
|
|
|
|
|
#include "frame.h"
|
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "python-internal.h"
|
|
|
|
|
#include "objfiles.h"
|
|
|
|
|
|
|
|
|
|
typedef struct sympy_symbol_object {
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
/* The GDB symbol structure this object is wrapping. */
|
|
|
|
|
struct symbol *symbol;
|
|
|
|
|
/* A symbol object is associated with an objfile, so keep track with
|
|
|
|
|
doubly-linked list, rooted in the objfile. This lets us
|
|
|
|
|
invalidate the underlying struct symbol when the objfile is
|
|
|
|
|
deleted. */
|
|
|
|
|
struct sympy_symbol_object *prev;
|
|
|
|
|
struct sympy_symbol_object *next;
|
|
|
|
|
} symbol_object;
|
|
|
|
|
|
|
|
|
|
/* Require a valid symbol. All access to symbol_object->symbol should be
|
|
|
|
|
gated by this call. */
|
|
|
|
|
#define SYMPY_REQUIRE_VALID(symbol_obj, symbol) \
|
|
|
|
|
do { \
|
|
|
|
|
symbol = symbol_object_to_symbol (symbol_obj); \
|
|
|
|
|
if (symbol == NULL) \
|
|
|
|
|
{ \
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError, \
|
|
|
|
|
_("Symbol is invalid.")); \
|
|
|
|
|
return NULL; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
static const struct objfile_data *sympy_objfile_data_key;
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_str (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
PyObject *result;
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
result = PyString_FromString (SYMBOL_PRINT_NAME (symbol));
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-13 00:21:57 +02:00
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_get_type (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
if (SYMBOL_TYPE (symbol) == NULL)
|
|
|
|
|
{
|
|
|
|
|
Py_INCREF (Py_None);
|
|
|
|
|
return Py_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return type_to_type_object (SYMBOL_TYPE (symbol));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_get_symtab (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
return symtab_to_symtab_object (SYMBOL_SYMTAB (symbol));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_get_name (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
return PyString_FromString (SYMBOL_NATURAL_NAME (symbol));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_get_linkage_name (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
return PyString_FromString (SYMBOL_LINKAGE_NAME (symbol));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_get_print_name (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
return sympy_str (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_get_addr_class (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
return PyInt_FromLong (SYMBOL_CLASS (symbol));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_is_argument (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
return PyBool_FromLong (SYMBOL_IS_ARGUMENT (symbol));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_is_constant (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
enum address_class class;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
class = SYMBOL_CLASS (symbol);
|
|
|
|
|
|
|
|
|
|
return PyBool_FromLong (class == LOC_CONST || class == LOC_CONST_BYTES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_is_function (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
enum address_class class;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
class = SYMBOL_CLASS (symbol);
|
|
|
|
|
|
|
|
|
|
return PyBool_FromLong (class == LOC_BLOCK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_is_variable (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
enum address_class class;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
class = SYMBOL_CLASS (symbol);
|
|
|
|
|
|
|
|
|
|
return PyBool_FromLong (!SYMBOL_IS_ARGUMENT (symbol)
|
|
|
|
|
&& (class == LOC_LOCAL || class == LOC_REGISTER
|
|
|
|
|
|| class == LOC_STATIC || class == LOC_COMPUTED
|
|
|
|
|
|| class == LOC_OPTIMIZED_OUT));
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-07 20:47:16 +01:00
|
|
|
|
/* Implementation of gdb.Symbol.needs_frame -> Boolean.
|
|
|
|
|
Returns true iff the symbol needs a frame for evaluation. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_needs_frame (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
result = symbol_read_needs_frame (symbol);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-07 20:42:27 +01:00
|
|
|
|
/* Implementation of gdb.Symbol.line -> int.
|
|
|
|
|
Returns the line number at which the symbol was defined. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_line (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
|
|
|
|
|
return PyInt_FromLong (SYMBOL_LINE (symbol));
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 10:36:17 +01:00
|
|
|
|
/* Implementation of gdb.Symbol.is_valid (self) -> Boolean.
|
|
|
|
|
Returns True if this Symbol still exists in GDB. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_is_valid (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
|
|
|
|
|
symbol = symbol_object_to_symbol (self);
|
|
|
|
|
if (symbol == NULL)
|
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-07 20:47:16 +01:00
|
|
|
|
/* Implementation of gdb.Symbol.value (self[, frame]) -> gdb.Value. Returns
|
|
|
|
|
the value of the symbol, or an error in various circumstances. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
sympy_value (PyObject *self, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *symbol = NULL;
|
|
|
|
|
struct frame_info *frame_info = NULL;
|
|
|
|
|
PyObject *frame_obj = NULL;
|
|
|
|
|
struct value *value = NULL;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple (args, "|O", &frame_obj))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (frame_obj != NULL && !PyObject_TypeCheck (frame_obj, &frame_object_type))
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError, "argument is not a frame");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SYMPY_REQUIRE_VALID (self, symbol);
|
|
|
|
|
if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError, "cannot get the value of a typedef");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
if (frame_obj != NULL)
|
|
|
|
|
{
|
|
|
|
|
frame_info = frame_object_to_frame_info (frame_obj);
|
|
|
|
|
if (frame_info == NULL)
|
2012-02-15 18:51:04 +01:00
|
|
|
|
error (_("invalid frame"));
|
2012-02-07 20:47:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (symbol_read_needs_frame (symbol) && frame_info == NULL)
|
2012-02-15 18:51:04 +01:00
|
|
|
|
error (_("symbol requires a frame to compute its value"));
|
2012-02-07 20:47:16 +01:00
|
|
|
|
|
|
|
|
|
value = read_var_value (symbol, frame_info);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
|
|
|
|
|
return value_to_value_object (value);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
/* Given a symbol, and a symbol_object that has previously been
|
|
|
|
|
allocated and initialized, populate the symbol_object with the
|
|
|
|
|
struct symbol data. Also, register the symbol_object life-cycle
|
2011-02-26 03:07:10 +01:00
|
|
|
|
with the life-cycle of the object file associated with this
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
symbol, if needed. */
|
|
|
|
|
static void
|
|
|
|
|
set_symbol (symbol_object *obj, struct symbol *symbol)
|
|
|
|
|
{
|
|
|
|
|
obj->symbol = symbol;
|
|
|
|
|
obj->prev = NULL;
|
|
|
|
|
if (SYMBOL_SYMTAB (symbol))
|
|
|
|
|
{
|
|
|
|
|
obj->next = objfile_data (SYMBOL_SYMTAB (symbol)->objfile,
|
|
|
|
|
sympy_objfile_data_key);
|
|
|
|
|
|
|
|
|
|
if (obj->next)
|
|
|
|
|
obj->next->prev = obj;
|
|
|
|
|
set_objfile_data (SYMBOL_SYMTAB (symbol)->objfile,
|
|
|
|
|
sympy_objfile_data_key, obj);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
obj->next = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a new symbol object (gdb.Symbol) that encapsulates the struct
|
|
|
|
|
symbol object from GDB. */
|
|
|
|
|
PyObject *
|
|
|
|
|
symbol_to_symbol_object (struct symbol *sym)
|
|
|
|
|
{
|
|
|
|
|
symbol_object *sym_obj;
|
|
|
|
|
|
|
|
|
|
sym_obj = PyObject_New (symbol_object, &symbol_object_type);
|
|
|
|
|
if (sym_obj)
|
|
|
|
|
set_symbol (sym_obj, sym);
|
|
|
|
|
|
|
|
|
|
return (PyObject *) sym_obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the symbol that is wrapped by this symbol object. */
|
|
|
|
|
struct symbol *
|
|
|
|
|
symbol_object_to_symbol (PyObject *obj)
|
|
|
|
|
{
|
|
|
|
|
if (! PyObject_TypeCheck (obj, &symbol_object_type))
|
|
|
|
|
return NULL;
|
|
|
|
|
return ((symbol_object *) obj)->symbol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sympy_dealloc (PyObject *obj)
|
|
|
|
|
{
|
|
|
|
|
symbol_object *sym_obj = (symbol_object *) obj;
|
|
|
|
|
|
|
|
|
|
if (sym_obj->prev)
|
|
|
|
|
sym_obj->prev->next = sym_obj->next;
|
2012-10-15 17:20:27 +02:00
|
|
|
|
else if (sym_obj->symbol && SYMBOL_SYMTAB (sym_obj->symbol))
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
{
|
|
|
|
|
set_objfile_data (SYMBOL_SYMTAB (sym_obj->symbol)->objfile,
|
|
|
|
|
sympy_objfile_data_key, sym_obj->next);
|
|
|
|
|
}
|
|
|
|
|
if (sym_obj->next)
|
|
|
|
|
sym_obj->next->prev = sym_obj->prev;
|
|
|
|
|
sym_obj->symbol = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of
|
|
|
|
|
gdb.lookup_symbol (name [, block] [, domain]) -> (symbol, is_field_of_this)
|
|
|
|
|
A tuple with 2 elements is always returned. The first is the symbol
|
|
|
|
|
object or None, the second is a boolean with the value of
|
|
|
|
|
is_a_field_of_this (see comment in lookup_symbol_in_language). */
|
2011-02-22 23:48:12 +01:00
|
|
|
|
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
PyObject *
|
|
|
|
|
gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
|
|
|
|
|
{
|
2012-12-14 18:47:40 +01:00
|
|
|
|
int domain = VAR_DOMAIN;
|
|
|
|
|
struct field_of_this_result is_a_field_of_this;
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
const char *name;
|
|
|
|
|
static char *keywords[] = { "name", "block", "domain", NULL };
|
2011-10-27 11:14:27 +02:00
|
|
|
|
struct symbol *symbol = NULL;
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
PyObject *block_obj = NULL, *ret_tuple, *sym_obj, *bool_obj;
|
2011-10-20 14:31:30 +02:00
|
|
|
|
const struct block *block = NULL;
|
2011-10-27 11:14:27 +02:00
|
|
|
|
volatile struct gdb_exception except;
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
|
|
|
|
|
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
|
|
|
|
|
&block_object_type, &block_obj, &domain))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (block_obj)
|
|
|
|
|
block = block_object_to_block (block_obj);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
struct frame_info *selected_frame;
|
|
|
|
|
volatile struct gdb_exception except;
|
|
|
|
|
|
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
2011-04-17 16:14:23 +02:00
|
|
|
|
selected_frame = get_selected_frame (_("No frame selected."));
|
|
|
|
|
block = get_frame_block (selected_frame, NULL);
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-27 11:14:27 +02:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
|
|
|
|
|
ret_tuple = PyTuple_New (2);
|
|
|
|
|
if (!ret_tuple)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (symbol)
|
|
|
|
|
{
|
|
|
|
|
sym_obj = symbol_to_symbol_object (symbol);
|
|
|
|
|
if (!sym_obj)
|
|
|
|
|
{
|
|
|
|
|
Py_DECREF (ret_tuple);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sym_obj = Py_None;
|
|
|
|
|
Py_INCREF (Py_None);
|
|
|
|
|
}
|
|
|
|
|
PyTuple_SET_ITEM (ret_tuple, 0, sym_obj);
|
|
|
|
|
|
2012-12-14 18:47:40 +01:00
|
|
|
|
bool_obj = (is_a_field_of_this.type != NULL) ? Py_True : Py_False;
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
Py_INCREF (bool_obj);
|
|
|
|
|
PyTuple_SET_ITEM (ret_tuple, 1, bool_obj);
|
|
|
|
|
|
|
|
|
|
return ret_tuple;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-22 23:48:12 +01:00
|
|
|
|
/* Implementation of
|
|
|
|
|
gdb.lookup_global_symbol (name [, domain]) -> symbol or None. */
|
|
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
|
gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
|
|
|
|
|
{
|
|
|
|
|
int domain = VAR_DOMAIN;
|
|
|
|
|
const char *name;
|
|
|
|
|
static char *keywords[] = { "name", "domain", NULL };
|
2011-10-27 11:14:27 +02:00
|
|
|
|
struct symbol *symbol = NULL;
|
2011-02-22 23:48:12 +01:00
|
|
|
|
PyObject *sym_obj;
|
2011-10-27 11:14:27 +02:00
|
|
|
|
volatile struct gdb_exception except;
|
2011-02-22 23:48:12 +01:00
|
|
|
|
|
|
|
|
|
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &name,
|
|
|
|
|
&domain))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2011-10-27 11:14:27 +02:00
|
|
|
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
|
|
|
|
{
|
|
|
|
|
symbol = lookup_symbol_global (name, NULL, domain);
|
|
|
|
|
}
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
2011-02-22 23:48:12 +01:00
|
|
|
|
|
|
|
|
|
if (symbol)
|
|
|
|
|
{
|
|
|
|
|
sym_obj = symbol_to_symbol_object (symbol);
|
|
|
|
|
if (!sym_obj)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sym_obj = Py_None;
|
|
|
|
|
Py_INCREF (Py_None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sym_obj;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
/* This function is called when an objfile is about to be freed.
|
|
|
|
|
Invalidate the symbol as further actions on the symbol would result
|
|
|
|
|
in bad data. All access to obj->symbol should be gated by
|
|
|
|
|
SYMPY_REQUIRE_VALID which will raise an exception on invalid
|
|
|
|
|
symbols. */
|
|
|
|
|
static void
|
|
|
|
|
del_objfile_symbols (struct objfile *objfile, void *datum)
|
|
|
|
|
{
|
|
|
|
|
symbol_object *obj = datum;
|
|
|
|
|
while (obj)
|
|
|
|
|
{
|
|
|
|
|
symbol_object *next = obj->next;
|
|
|
|
|
|
|
|
|
|
obj->symbol = NULL;
|
|
|
|
|
obj->next = NULL;
|
|
|
|
|
obj->prev = NULL;
|
|
|
|
|
|
|
|
|
|
obj = next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gdbpy_initialize_symbols (void)
|
|
|
|
|
{
|
|
|
|
|
if (PyType_Ready (&symbol_object_type) < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Register an objfile "free" callback so we can properly
|
|
|
|
|
invalidate symbol when an object file that is about to be
|
|
|
|
|
deleted. */
|
|
|
|
|
sympy_objfile_data_key
|
|
|
|
|
= register_objfile_data_with_cleanup (NULL, del_objfile_symbols);
|
|
|
|
|
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNDEF", LOC_UNDEF);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST", LOC_CONST);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_STATIC", LOC_STATIC);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGISTER", LOC_REGISTER);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_ARG", LOC_ARG);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REF_ARG", LOC_REF_ARG);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LOCAL", LOC_LOCAL);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_TYPEDEF", LOC_TYPEDEF);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LABEL", LOC_LABEL);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_BLOCK", LOC_BLOCK);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST_BYTES",
|
|
|
|
|
LOC_CONST_BYTES);
|
2011-01-06 01:57:05 +01:00
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNRESOLVED",
|
|
|
|
|
LOC_UNRESOLVED);
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_OPTIMIZED_OUT",
|
|
|
|
|
LOC_OPTIMIZED_OUT);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMPUTED", LOC_COMPUTED);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR",
|
|
|
|
|
LOC_REGPARM_ADDR);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN", UNDEF_DOMAIN);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", VAR_DOMAIN);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN", STRUCT_DOMAIN);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN", LABEL_DOMAIN);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN",
|
|
|
|
|
VARIABLES_DOMAIN);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN",
|
|
|
|
|
FUNCTIONS_DOMAIN);
|
|
|
|
|
PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN", TYPES_DOMAIN);
|
|
|
|
|
|
|
|
|
|
Py_INCREF (&symbol_object_type);
|
|
|
|
|
PyModule_AddObject (gdb_module, "Symbol", (PyObject *) &symbol_object_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static PyGetSetDef symbol_object_getset[] = {
|
2011-08-13 00:21:57 +02:00
|
|
|
|
{ "type", sympy_get_type, NULL,
|
|
|
|
|
"Type of the symbol.", NULL },
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
{ "symtab", sympy_get_symtab, NULL,
|
|
|
|
|
"Symbol table in which the symbol appears.", NULL },
|
|
|
|
|
{ "name", sympy_get_name, NULL,
|
|
|
|
|
"Name of the symbol, as it appears in the source code.", NULL },
|
|
|
|
|
{ "linkage_name", sympy_get_linkage_name, NULL,
|
2011-01-06 01:57:05 +01:00
|
|
|
|
"Name of the symbol, as used by the linker (i.e., may be mangled).",
|
|
|
|
|
NULL },
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
{ "print_name", sympy_get_print_name, NULL,
|
|
|
|
|
"Name of the symbol in a form suitable for output.\n\
|
|
|
|
|
This is either name or linkage_name, depending on whether the user asked GDB\n\
|
|
|
|
|
to display demangled or mangled names.", NULL },
|
|
|
|
|
{ "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." },
|
|
|
|
|
{ "is_argument", sympy_is_argument, NULL,
|
|
|
|
|
"True if the symbol is an argument of a function." },
|
|
|
|
|
{ "is_constant", sympy_is_constant, NULL,
|
|
|
|
|
"True if the symbol is a constant." },
|
|
|
|
|
{ "is_function", sympy_is_function, NULL,
|
|
|
|
|
"True if the symbol is a function or method." },
|
|
|
|
|
{ "is_variable", sympy_is_variable, NULL,
|
|
|
|
|
"True if the symbol is a variable." },
|
2012-02-07 20:47:16 +01:00
|
|
|
|
{ "needs_frame", sympy_needs_frame, NULL,
|
|
|
|
|
"True if the symbol requires a frame for evaluation." },
|
2012-02-07 20:42:27 +01:00
|
|
|
|
{ "line", sympy_line, NULL,
|
|
|
|
|
"The source line number at which the symbol was defined." },
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
{ NULL } /* Sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
2011-03-17 10:36:17 +01:00
|
|
|
|
static PyMethodDef symbol_object_methods[] = {
|
|
|
|
|
{ "is_valid", sympy_is_valid, METH_NOARGS,
|
|
|
|
|
"is_valid () -> Boolean.\n\
|
|
|
|
|
Return true if this symbol is valid, false if not." },
|
2012-02-07 20:47:16 +01:00
|
|
|
|
{ "value", sympy_value, METH_VARARGS,
|
|
|
|
|
"value ([frame]) -> gdb.Value\n\
|
|
|
|
|
Return the value of the symbol." },
|
2011-03-17 10:36:17 +01:00
|
|
|
|
{NULL} /* Sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
PyTypeObject symbol_object_type = {
|
2012-12-12 17:47:30 +01:00
|
|
|
|
PyVarObject_HEAD_INIT (NULL, 0)
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
"gdb.Symbol", /*tp_name*/
|
|
|
|
|
sizeof (symbol_object), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
sympy_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*/
|
|
|
|
|
sympy_str, /*tp_str*/
|
|
|
|
|
0, /*tp_getattro*/
|
|
|
|
|
0, /*tp_setattro*/
|
|
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
|
Py_TPFLAGS_DEFAULT, /*tp_flags*/
|
|
|
|
|
"GDB symbol object", /*tp_doc */
|
|
|
|
|
0, /*tp_traverse */
|
|
|
|
|
0, /*tp_clear */
|
|
|
|
|
0, /*tp_richcompare */
|
|
|
|
|
0, /*tp_weaklistoffset */
|
|
|
|
|
0, /*tp_iter */
|
|
|
|
|
0, /*tp_iternext */
|
2011-03-17 10:36:17 +01:00
|
|
|
|
symbol_object_methods, /*tp_methods */
|
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
Tom Tromey <tromey@redhat.com>
Thiago Jung Bauermann <bauerman@br.ibm.com>
* python/python.c (_initialize_python): Call
gdbpy_initialize_symtabs, gdbpy_initialize_symbols and
gdbpy_initialize_blocks.
* python/python-internal.h: Declare struct symbol, block and
symtab_and_line. Declare block_object_type and
symbol_object_type
(gdbpy_lookup_symbol gdbpy_block_for_pc)
(symtab_and_line_to_sal_object, symtab_to_symtab_object)
(symbol_to_symbol_object, block_to_block_object)
(gdbpy_initialize_symtabs,gdbpy_initialize_symbols)
(gdbpy_initialize_blocks ): Declare.
* python/py-frame.c (frapy_block, frapy_function, frapy_find_sal)
(frapy_select): Add methods.
(frapy_read_var): Add symbol branch.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-symbol, py-symtab,
py-block.
(SUBDIR_PYTHON_SRCS): Likewise.
(py-symbol.o): New rule.
(py-symtab.o): Likewise.
(py-block.o): Likewise.
* python/py-symbol.c: New file.
* python/py-symtab.c: Likewise.
* python/py-block.c: Likewise.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* Makefile.in: Add py-block and py-symbol.
* gdb.python/py-symbol.exp: New File.
* gdb.python/py-symtab.exp: New File.
* gdb.python/py-block.exp: New File.
* gdb.python/py-symbol.c: New File.
* gdb.python/py-block.c: New File.
2010-02-24 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Frames In Python): Add block, find_sal, function
and select method descriptions.
(Python API): Add Blocks In Python, Symbols in Python and Symbol
Tables in Python to menu.
(Blocks In Python): New node.
(Symbols In Python): New node.
(Symbol Tables in Python): New node.
2010-02-24 22:18:28 +01:00
|
|
|
|
0, /*tp_members */
|
|
|
|
|
symbol_object_getset /*tp_getset */
|
|
|
|
|
};
|