2010-04-15 21:54:13 +02:00
|
|
|
|
/* Python interface to program spaces.
|
|
|
|
|
|
2019-01-01 07:01:51 +01:00
|
|
|
|
Copyright (C) 2010-2019 Free Software Foundation, Inc.
|
2010-04-15 21:54:13 +02: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 "python-internal.h"
|
|
|
|
|
#include "charset.h"
|
|
|
|
|
#include "progspace.h"
|
|
|
|
|
#include "objfiles.h"
|
|
|
|
|
#include "language.h"
|
2010-12-18 03:08:43 +01:00
|
|
|
|
#include "arch-utils.h"
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
#include "solib.h"
|
|
|
|
|
#include "block.h"
|
2010-04-15 21:54:13 +02:00
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
PyObject_HEAD
|
|
|
|
|
|
|
|
|
|
/* The corresponding pspace. */
|
|
|
|
|
struct program_space *pspace;
|
|
|
|
|
|
2014-10-31 01:05:17 +01:00
|
|
|
|
/* Dictionary holding user-added attributes.
|
|
|
|
|
This is the __dict__ attribute of the object. */
|
|
|
|
|
PyObject *dict;
|
|
|
|
|
|
2010-04-15 21:54:13 +02:00
|
|
|
|
/* The pretty-printer list of functions. */
|
|
|
|
|
PyObject *printers;
|
* NEWS: Update.
* data-directory/Makefile.in (PYTHON_FILES): Add
type_printers.py.
* python/lib/gdb/command/type_printers.py: New file.
* python/lib/gdb/command/types.py (TypePrinter): New class.
(_get_some_type_recognizers, get_type_recognizers,
apply_type_recognizers, register_type_printer): New
functions.
* python/py-objfile.c (objfile_object) <type_printers>: New
field.
(objfpy_dealloc): Decref new field.
(objfpy_new): Set new field.
(objfpy_get_type_printers, objfpy_set_type_printers): New
functions.
(objfile_to_objfile_object): Set new field.
(objfile_getset): Add "type_printers".
* python/py-progspace.c (pspace_object) <type_printers>: New
field.
(pspy_dealloc): Decref new field.
(pspy_new): Set new field.
(pspy_get_type_printers, pspy_set_type_printers): New functions.
(pspace_to_pspace_object): Set new field.
(pspace_getset): Add "type_printers".
* python/python.c (start_type_printers, apply_type_printers,
free_type_printers): New functions.
(_initialize_python): Set gdb.type_printers.
* python/python.h (start_type_printers, apply_type_printers,
free_type_printers): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new fields.
(do_free_global_table, create_global_typedef_table,
find_global_typedef): New functions.
(find_typedef_in_hash): Use find_global_typedef.
(whatis_exp): Use create_global_typedef_table. Change cleanup
handling.
* typeprint.h (struct type_print_options) <global_typedefs,
global_printers>: New fields.
doc
* gdb.texinfo (Symbols): Document "info type-printers",
"enable type-printer" and "disable type-printer".
(Python API): Add new node to menu.
(Type Printing API): New node.
(Progspaces In Python): Document type_printers field.
(Objfiles In Python): Likewise.
(gdb.types) <get_type_recognizers, apply_type_recognizers,
register_type_printer, TypePrinter>: Document.
testsuite
* gdb.base/completion.exp: Update for "info type-printers".
* gdb.python/py-typeprint.cc: New file.
* gdb.python/py-typeprint.exp: New file.
* gdb.python/py-typeprint.py: New file.
2012-11-12 18:41:59 +01:00
|
|
|
|
|
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* stack.c (backtrace_command_1): Add "no-filters", and Python frame
filter logic.
(backtrace_command): Add "no-filters" option parsing.
(_initialize_stack): Alter help to reflect "no-filters" option.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-framefilter.o
(SUBDIR_PYTHON_SRCS): Add py-framefilter.c
(py-frame.o): Add target
* data-directory/Makefile.in (PYTHON_DIR): Add Python frame
filter files.
* python/python.h: Add new frame filter constants, and flag enum.
(apply_frame_filter): Add definition.
* python/python.c (apply_frame_filter): New non-Python
enabled function.
* python/py-utils.c (py_xdecref): New function.
(make_cleanup_py_xdecref): Ditto.
* python/py-objfile.c: Declare frame_filters dictionary.
(objfpy_dealloc): Add frame_filters dealloc.
(objfpy_new): Initialize frame_filters attribute.
(objfile_to_objfile_object): Ditto.
(objfpy_get_frame_filters): New function.
(objfpy_set_frame_filters): New function.
* python/py-progspace.c: Declare frame_filters dictionary.
(pspy_dealloc): Add frame_filters dealloc.
(pspy_new): Initialize frame_filters attribute.
(pspacee_to_pspace_object): Ditto.
(pspy_get_frame_filters): New function.
(pspy_set_frame_filters): New function.
* python/py-framefilter.c: New file.
* python/lib/gdb/command/frame_filters.py: New file.
* python/lib/gdb/frames.py: New file.
* python/lib/gdb/__init__.py: Initialize global frame_filters
dictionary
* python/lib/gdb/FrameDecorator.py: New file.
* python/lib/gdb/FrameIterator.py: New file.
* mi/mi-cmds.c (mi_cmds): Add frame filters command.
* mi/mi-cmds.h: Declare.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames): Add
--no-frame-filter logic, and Python frame filter logic.
(stack_enable_frame_filters): New function.
(parse_no_frame_option): Ditto.
(mi_cmd_stack_list_frames): Add --no-frame-filter and Python frame
filter logic.
(mi_cmd_stack_list_locals): Ditto.
(mi_cmd_stack_list_args): Ditto.
(mi_cmd_stack_list_variables): Ditto.
* NEWS: Add frame filter note.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-framefilter.py: New File.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter.c: Ditto.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter-mi.c: Ditto,
* gdb.python/py-framefilter-gdb.py.in: Ditto.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Backtrace): Add "no-filter" argument.
(Python API): Add Frame Filters API, Frame Wrapper API,
Writing a Frame Filter/Wrapper, Managing Management of Frame
Filters chapter entries.
(Frame Filters API): New Node.
(Frame Wrapper API): New Node.
(Writing a Frame Filter): New Node.
(Managing Frame Filters): New Node.
(Progspaces In Python): Add note about frame_filters attribute.
(Objfiles in Python): Ditto.
(GDB/MI Stack Manipulation): Add -enable-frame-filters command,
@anchors and --no-frame-filters option to -stack-list-variables,
-stack-list-frames, -stack-list-locals and -stack-list-arguments
commands.
2013-05-10 12:26:03 +02:00
|
|
|
|
/* The frame filter list of functions. */
|
|
|
|
|
PyObject *frame_filters;
|
2015-04-01 20:49:12 +02:00
|
|
|
|
|
|
|
|
|
/* The frame unwinder list. */
|
|
|
|
|
PyObject *frame_unwinders;
|
|
|
|
|
|
* NEWS: Update.
* data-directory/Makefile.in (PYTHON_FILES): Add
type_printers.py.
* python/lib/gdb/command/type_printers.py: New file.
* python/lib/gdb/command/types.py (TypePrinter): New class.
(_get_some_type_recognizers, get_type_recognizers,
apply_type_recognizers, register_type_printer): New
functions.
* python/py-objfile.c (objfile_object) <type_printers>: New
field.
(objfpy_dealloc): Decref new field.
(objfpy_new): Set new field.
(objfpy_get_type_printers, objfpy_set_type_printers): New
functions.
(objfile_to_objfile_object): Set new field.
(objfile_getset): Add "type_printers".
* python/py-progspace.c (pspace_object) <type_printers>: New
field.
(pspy_dealloc): Decref new field.
(pspy_new): Set new field.
(pspy_get_type_printers, pspy_set_type_printers): New functions.
(pspace_to_pspace_object): Set new field.
(pspace_getset): Add "type_printers".
* python/python.c (start_type_printers, apply_type_printers,
free_type_printers): New functions.
(_initialize_python): Set gdb.type_printers.
* python/python.h (start_type_printers, apply_type_printers,
free_type_printers): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new fields.
(do_free_global_table, create_global_typedef_table,
find_global_typedef): New functions.
(find_typedef_in_hash): Use find_global_typedef.
(whatis_exp): Use create_global_typedef_table. Change cleanup
handling.
* typeprint.h (struct type_print_options) <global_typedefs,
global_printers>: New fields.
doc
* gdb.texinfo (Symbols): Document "info type-printers",
"enable type-printer" and "disable type-printer".
(Python API): Add new node to menu.
(Type Printing API): New node.
(Progspaces In Python): Document type_printers field.
(Objfiles In Python): Likewise.
(gdb.types) <get_type_recognizers, apply_type_recognizers,
register_type_printer, TypePrinter>: Document.
testsuite
* gdb.base/completion.exp: Update for "info type-printers".
* gdb.python/py-typeprint.cc: New file.
* gdb.python/py-typeprint.exp: New file.
* gdb.python/py-typeprint.py: New file.
2012-11-12 18:41:59 +01:00
|
|
|
|
/* The type-printer list. */
|
|
|
|
|
PyObject *type_printers;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
|
|
|
|
/* The debug method list. */
|
|
|
|
|
PyObject *xmethods;
|
2010-04-15 21:54:13 +02:00
|
|
|
|
} pspace_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 12:20:21 +01:00
|
|
|
|
extern PyTypeObject pspace_object_type
|
2013-05-20 22:09:01 +02:00
|
|
|
|
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pspace_object");
|
2010-04-15 21:54:13 +02:00
|
|
|
|
|
|
|
|
|
static const struct program_space_data *pspy_pspace_data_key;
|
|
|
|
|
|
2018-09-13 21:40:41 +02:00
|
|
|
|
/* Require that PSPACE_OBJ be a valid program space ID. */
|
|
|
|
|
#define PSPY_REQUIRE_VALID(pspace_obj) \
|
|
|
|
|
do { \
|
|
|
|
|
if (pspace_obj->pspace == nullptr) \
|
|
|
|
|
{ \
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError, \
|
|
|
|
|
_("Program space no longer exists.")); \
|
|
|
|
|
return NULL; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
2010-04-15 21:54:13 +02:00
|
|
|
|
|
|
|
|
|
/* An Objfile method which returns the objfile's file name, or None. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_get_filename (PyObject *self, void *closure)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *obj = (pspace_object *) self;
|
2010-05-17 23:23:25 +02:00
|
|
|
|
|
2010-04-15 21:54:13 +02:00
|
|
|
|
if (obj->pspace)
|
|
|
|
|
{
|
|
|
|
|
struct objfile *objfile = obj->pspace->symfile_object_file;
|
2010-05-17 23:23:25 +02:00
|
|
|
|
|
2010-09-22 22:00:53 +02:00
|
|
|
|
if (objfile)
|
2018-10-25 00:40:00 +02:00
|
|
|
|
return (host_string_to_python_string (objfile_name (objfile))
|
|
|
|
|
.release ());
|
2010-04-15 21:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
pspy_dealloc (PyObject *self)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *ps_self = (pspace_object *) self;
|
2010-05-17 23:23:25 +02:00
|
|
|
|
|
2014-10-31 01:05:17 +01:00
|
|
|
|
Py_XDECREF (ps_self->dict);
|
2010-04-15 21:54:13 +02:00
|
|
|
|
Py_XDECREF (ps_self->printers);
|
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* stack.c (backtrace_command_1): Add "no-filters", and Python frame
filter logic.
(backtrace_command): Add "no-filters" option parsing.
(_initialize_stack): Alter help to reflect "no-filters" option.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-framefilter.o
(SUBDIR_PYTHON_SRCS): Add py-framefilter.c
(py-frame.o): Add target
* data-directory/Makefile.in (PYTHON_DIR): Add Python frame
filter files.
* python/python.h: Add new frame filter constants, and flag enum.
(apply_frame_filter): Add definition.
* python/python.c (apply_frame_filter): New non-Python
enabled function.
* python/py-utils.c (py_xdecref): New function.
(make_cleanup_py_xdecref): Ditto.
* python/py-objfile.c: Declare frame_filters dictionary.
(objfpy_dealloc): Add frame_filters dealloc.
(objfpy_new): Initialize frame_filters attribute.
(objfile_to_objfile_object): Ditto.
(objfpy_get_frame_filters): New function.
(objfpy_set_frame_filters): New function.
* python/py-progspace.c: Declare frame_filters dictionary.
(pspy_dealloc): Add frame_filters dealloc.
(pspy_new): Initialize frame_filters attribute.
(pspacee_to_pspace_object): Ditto.
(pspy_get_frame_filters): New function.
(pspy_set_frame_filters): New function.
* python/py-framefilter.c: New file.
* python/lib/gdb/command/frame_filters.py: New file.
* python/lib/gdb/frames.py: New file.
* python/lib/gdb/__init__.py: Initialize global frame_filters
dictionary
* python/lib/gdb/FrameDecorator.py: New file.
* python/lib/gdb/FrameIterator.py: New file.
* mi/mi-cmds.c (mi_cmds): Add frame filters command.
* mi/mi-cmds.h: Declare.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames): Add
--no-frame-filter logic, and Python frame filter logic.
(stack_enable_frame_filters): New function.
(parse_no_frame_option): Ditto.
(mi_cmd_stack_list_frames): Add --no-frame-filter and Python frame
filter logic.
(mi_cmd_stack_list_locals): Ditto.
(mi_cmd_stack_list_args): Ditto.
(mi_cmd_stack_list_variables): Ditto.
* NEWS: Add frame filter note.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-framefilter.py: New File.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter.c: Ditto.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter-mi.c: Ditto,
* gdb.python/py-framefilter-gdb.py.in: Ditto.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Backtrace): Add "no-filter" argument.
(Python API): Add Frame Filters API, Frame Wrapper API,
Writing a Frame Filter/Wrapper, Managing Management of Frame
Filters chapter entries.
(Frame Filters API): New Node.
(Frame Wrapper API): New Node.
(Writing a Frame Filter): New Node.
(Managing Frame Filters): New Node.
(Progspaces In Python): Add note about frame_filters attribute.
(Objfiles in Python): Ditto.
(GDB/MI Stack Manipulation): Add -enable-frame-filters command,
@anchors and --no-frame-filters option to -stack-list-variables,
-stack-list-frames, -stack-list-locals and -stack-list-arguments
commands.
2013-05-10 12:26:03 +02:00
|
|
|
|
Py_XDECREF (ps_self->frame_filters);
|
2015-04-01 20:49:12 +02:00
|
|
|
|
Py_XDECREF (ps_self->frame_unwinders);
|
* NEWS: Update.
* data-directory/Makefile.in (PYTHON_FILES): Add
type_printers.py.
* python/lib/gdb/command/type_printers.py: New file.
* python/lib/gdb/command/types.py (TypePrinter): New class.
(_get_some_type_recognizers, get_type_recognizers,
apply_type_recognizers, register_type_printer): New
functions.
* python/py-objfile.c (objfile_object) <type_printers>: New
field.
(objfpy_dealloc): Decref new field.
(objfpy_new): Set new field.
(objfpy_get_type_printers, objfpy_set_type_printers): New
functions.
(objfile_to_objfile_object): Set new field.
(objfile_getset): Add "type_printers".
* python/py-progspace.c (pspace_object) <type_printers>: New
field.
(pspy_dealloc): Decref new field.
(pspy_new): Set new field.
(pspy_get_type_printers, pspy_set_type_printers): New functions.
(pspace_to_pspace_object): Set new field.
(pspace_getset): Add "type_printers".
* python/python.c (start_type_printers, apply_type_printers,
free_type_printers): New functions.
(_initialize_python): Set gdb.type_printers.
* python/python.h (start_type_printers, apply_type_printers,
free_type_printers): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new fields.
(do_free_global_table, create_global_typedef_table,
find_global_typedef): New functions.
(find_typedef_in_hash): Use find_global_typedef.
(whatis_exp): Use create_global_typedef_table. Change cleanup
handling.
* typeprint.h (struct type_print_options) <global_typedefs,
global_printers>: New fields.
doc
* gdb.texinfo (Symbols): Document "info type-printers",
"enable type-printer" and "disable type-printer".
(Python API): Add new node to menu.
(Type Printing API): New node.
(Progspaces In Python): Document type_printers field.
(Objfiles In Python): Likewise.
(gdb.types) <get_type_recognizers, apply_type_recognizers,
register_type_printer, TypePrinter>: Document.
testsuite
* gdb.base/completion.exp: Update for "info type-printers".
* gdb.python/py-typeprint.cc: New file.
* gdb.python/py-typeprint.exp: New file.
* gdb.python/py-typeprint.py: New file.
2012-11-12 18:41:59 +01:00
|
|
|
|
Py_XDECREF (ps_self->type_printers);
|
2014-05-20 15:53:04 +02:00
|
|
|
|
Py_XDECREF (ps_self->xmethods);
|
2012-12-12 17:47:30 +01:00
|
|
|
|
Py_TYPE (self)->tp_free (self);
|
2010-04-15 21:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 21:24:54 +02:00
|
|
|
|
/* Initialize a pspace_object.
|
|
|
|
|
The result is a boolean indicating success. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
pspy_initialize (pspace_object *self)
|
|
|
|
|
{
|
|
|
|
|
self->pspace = NULL;
|
2016-05-19 05:19:17 +02:00
|
|
|
|
|
|
|
|
|
self->dict = PyDict_New ();
|
|
|
|
|
if (self->dict == NULL)
|
|
|
|
|
return 0;
|
2014-10-13 21:24:54 +02:00
|
|
|
|
|
|
|
|
|
self->printers = PyList_New (0);
|
|
|
|
|
if (self->printers == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
self->frame_filters = PyDict_New ();
|
|
|
|
|
if (self->frame_filters == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2015-04-01 20:49:12 +02:00
|
|
|
|
self->frame_unwinders = PyList_New (0);
|
|
|
|
|
if (self->frame_unwinders == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2014-10-13 21:24:54 +02:00
|
|
|
|
self->type_printers = PyList_New (0);
|
|
|
|
|
if (self->type_printers == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
self->xmethods = PyList_New (0);
|
|
|
|
|
if (self->xmethods == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-15 21:54:13 +02:00
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
|
|
|
|
|
{
|
2017-01-12 00:28:43 +01:00
|
|
|
|
gdbpy_ref<pspace_object> self ((pspace_object *) type->tp_alloc (type, 0));
|
2010-05-17 23:23:25 +02:00
|
|
|
|
|
2017-01-12 00:28:43 +01:00
|
|
|
|
if (self != NULL)
|
2010-04-15 21:54:13 +02:00
|
|
|
|
{
|
2017-01-12 00:28:43 +01:00
|
|
|
|
if (!pspy_initialize (self.get ()))
|
|
|
|
|
return NULL;
|
2010-04-15 21:54:13 +02:00
|
|
|
|
}
|
2014-10-13 21:24:54 +02:00
|
|
|
|
|
2017-01-12 00:28:43 +01:00
|
|
|
|
return (PyObject *) self.release ();
|
2010-04-15 21:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
|
pspy_get_printers (PyObject *o, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
2010-05-17 23:23:25 +02:00
|
|
|
|
|
2010-04-15 21:54:13 +02:00
|
|
|
|
Py_INCREF (self->printers);
|
|
|
|
|
return self->printers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
pspy_set_printers (PyObject *o, PyObject *value, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
2010-05-17 23:23:25 +02:00
|
|
|
|
|
2010-04-15 21:54:13 +02:00
|
|
|
|
if (! value)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"cannot delete the pretty_printers attribute");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! PyList_Check (value))
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"the pretty_printers attribute must be a list");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Take care in case the LHS and RHS are related somehow. */
|
2018-12-27 19:53:20 +01:00
|
|
|
|
gdbpy_ref<> tmp (self->printers);
|
2010-04-15 21:54:13 +02:00
|
|
|
|
Py_INCREF (value);
|
|
|
|
|
self->printers = value;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* stack.c (backtrace_command_1): Add "no-filters", and Python frame
filter logic.
(backtrace_command): Add "no-filters" option parsing.
(_initialize_stack): Alter help to reflect "no-filters" option.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-framefilter.o
(SUBDIR_PYTHON_SRCS): Add py-framefilter.c
(py-frame.o): Add target
* data-directory/Makefile.in (PYTHON_DIR): Add Python frame
filter files.
* python/python.h: Add new frame filter constants, and flag enum.
(apply_frame_filter): Add definition.
* python/python.c (apply_frame_filter): New non-Python
enabled function.
* python/py-utils.c (py_xdecref): New function.
(make_cleanup_py_xdecref): Ditto.
* python/py-objfile.c: Declare frame_filters dictionary.
(objfpy_dealloc): Add frame_filters dealloc.
(objfpy_new): Initialize frame_filters attribute.
(objfile_to_objfile_object): Ditto.
(objfpy_get_frame_filters): New function.
(objfpy_set_frame_filters): New function.
* python/py-progspace.c: Declare frame_filters dictionary.
(pspy_dealloc): Add frame_filters dealloc.
(pspy_new): Initialize frame_filters attribute.
(pspacee_to_pspace_object): Ditto.
(pspy_get_frame_filters): New function.
(pspy_set_frame_filters): New function.
* python/py-framefilter.c: New file.
* python/lib/gdb/command/frame_filters.py: New file.
* python/lib/gdb/frames.py: New file.
* python/lib/gdb/__init__.py: Initialize global frame_filters
dictionary
* python/lib/gdb/FrameDecorator.py: New file.
* python/lib/gdb/FrameIterator.py: New file.
* mi/mi-cmds.c (mi_cmds): Add frame filters command.
* mi/mi-cmds.h: Declare.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames): Add
--no-frame-filter logic, and Python frame filter logic.
(stack_enable_frame_filters): New function.
(parse_no_frame_option): Ditto.
(mi_cmd_stack_list_frames): Add --no-frame-filter and Python frame
filter logic.
(mi_cmd_stack_list_locals): Ditto.
(mi_cmd_stack_list_args): Ditto.
(mi_cmd_stack_list_variables): Ditto.
* NEWS: Add frame filter note.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-framefilter.py: New File.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter.c: Ditto.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter-mi.c: Ditto,
* gdb.python/py-framefilter-gdb.py.in: Ditto.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Backtrace): Add "no-filter" argument.
(Python API): Add Frame Filters API, Frame Wrapper API,
Writing a Frame Filter/Wrapper, Managing Management of Frame
Filters chapter entries.
(Frame Filters API): New Node.
(Frame Wrapper API): New Node.
(Writing a Frame Filter): New Node.
(Managing Frame Filters): New Node.
(Progspaces In Python): Add note about frame_filters attribute.
(Objfiles in Python): Ditto.
(GDB/MI Stack Manipulation): Add -enable-frame-filters command,
@anchors and --no-frame-filters option to -stack-list-variables,
-stack-list-frames, -stack-list-locals and -stack-list-arguments
commands.
2013-05-10 12:26:03 +02:00
|
|
|
|
/* Return the Python dictionary attribute containing frame filters for
|
|
|
|
|
this program space. */
|
|
|
|
|
PyObject *
|
|
|
|
|
pspy_get_frame_filters (PyObject *o, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
Py_INCREF (self->frame_filters);
|
|
|
|
|
return self->frame_filters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set this object file's frame filters dictionary to FILTERS. */
|
|
|
|
|
static int
|
|
|
|
|
pspy_set_frame_filters (PyObject *o, PyObject *frame, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
if (! frame)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"cannot delete the frame filter attribute");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! PyDict_Check (frame))
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"the frame filter attribute must be a dictionary");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Take care in case the LHS and RHS are related somehow. */
|
2018-12-27 19:53:20 +01:00
|
|
|
|
gdbpy_ref<> tmp (self->frame_filters);
|
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* stack.c (backtrace_command_1): Add "no-filters", and Python frame
filter logic.
(backtrace_command): Add "no-filters" option parsing.
(_initialize_stack): Alter help to reflect "no-filters" option.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-framefilter.o
(SUBDIR_PYTHON_SRCS): Add py-framefilter.c
(py-frame.o): Add target
* data-directory/Makefile.in (PYTHON_DIR): Add Python frame
filter files.
* python/python.h: Add new frame filter constants, and flag enum.
(apply_frame_filter): Add definition.
* python/python.c (apply_frame_filter): New non-Python
enabled function.
* python/py-utils.c (py_xdecref): New function.
(make_cleanup_py_xdecref): Ditto.
* python/py-objfile.c: Declare frame_filters dictionary.
(objfpy_dealloc): Add frame_filters dealloc.
(objfpy_new): Initialize frame_filters attribute.
(objfile_to_objfile_object): Ditto.
(objfpy_get_frame_filters): New function.
(objfpy_set_frame_filters): New function.
* python/py-progspace.c: Declare frame_filters dictionary.
(pspy_dealloc): Add frame_filters dealloc.
(pspy_new): Initialize frame_filters attribute.
(pspacee_to_pspace_object): Ditto.
(pspy_get_frame_filters): New function.
(pspy_set_frame_filters): New function.
* python/py-framefilter.c: New file.
* python/lib/gdb/command/frame_filters.py: New file.
* python/lib/gdb/frames.py: New file.
* python/lib/gdb/__init__.py: Initialize global frame_filters
dictionary
* python/lib/gdb/FrameDecorator.py: New file.
* python/lib/gdb/FrameIterator.py: New file.
* mi/mi-cmds.c (mi_cmds): Add frame filters command.
* mi/mi-cmds.h: Declare.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames): Add
--no-frame-filter logic, and Python frame filter logic.
(stack_enable_frame_filters): New function.
(parse_no_frame_option): Ditto.
(mi_cmd_stack_list_frames): Add --no-frame-filter and Python frame
filter logic.
(mi_cmd_stack_list_locals): Ditto.
(mi_cmd_stack_list_args): Ditto.
(mi_cmd_stack_list_variables): Ditto.
* NEWS: Add frame filter note.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-framefilter.py: New File.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter.c: Ditto.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter-mi.c: Ditto,
* gdb.python/py-framefilter-gdb.py.in: Ditto.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Backtrace): Add "no-filter" argument.
(Python API): Add Frame Filters API, Frame Wrapper API,
Writing a Frame Filter/Wrapper, Managing Management of Frame
Filters chapter entries.
(Frame Filters API): New Node.
(Frame Wrapper API): New Node.
(Writing a Frame Filter): New Node.
(Managing Frame Filters): New Node.
(Progspaces In Python): Add note about frame_filters attribute.
(Objfiles in Python): Ditto.
(GDB/MI Stack Manipulation): Add -enable-frame-filters command,
@anchors and --no-frame-filters option to -stack-list-variables,
-stack-list-frames, -stack-list-locals and -stack-list-arguments
commands.
2013-05-10 12:26:03 +02:00
|
|
|
|
Py_INCREF (frame);
|
|
|
|
|
self->frame_filters = frame;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-01 20:49:12 +02:00
|
|
|
|
/* Return the list of the frame unwinders for this program space. */
|
|
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
|
pspy_get_frame_unwinders (PyObject *o, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
Py_INCREF (self->frame_unwinders);
|
|
|
|
|
return self->frame_unwinders;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set this program space's list of the unwinders to UNWINDERS. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
pspy_set_frame_unwinders (PyObject *o, PyObject *unwinders, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
if (!unwinders)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"cannot delete the frame unwinders list");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!PyList_Check (unwinders))
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"the frame unwinders attribute must be a list");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Take care in case the LHS and RHS are related somehow. */
|
2018-12-27 19:53:20 +01:00
|
|
|
|
gdbpy_ref<> tmp (self->frame_unwinders);
|
2015-04-01 20:49:12 +02:00
|
|
|
|
Py_INCREF (unwinders);
|
|
|
|
|
self->frame_unwinders = unwinders;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
* NEWS: Update.
* data-directory/Makefile.in (PYTHON_FILES): Add
type_printers.py.
* python/lib/gdb/command/type_printers.py: New file.
* python/lib/gdb/command/types.py (TypePrinter): New class.
(_get_some_type_recognizers, get_type_recognizers,
apply_type_recognizers, register_type_printer): New
functions.
* python/py-objfile.c (objfile_object) <type_printers>: New
field.
(objfpy_dealloc): Decref new field.
(objfpy_new): Set new field.
(objfpy_get_type_printers, objfpy_set_type_printers): New
functions.
(objfile_to_objfile_object): Set new field.
(objfile_getset): Add "type_printers".
* python/py-progspace.c (pspace_object) <type_printers>: New
field.
(pspy_dealloc): Decref new field.
(pspy_new): Set new field.
(pspy_get_type_printers, pspy_set_type_printers): New functions.
(pspace_to_pspace_object): Set new field.
(pspace_getset): Add "type_printers".
* python/python.c (start_type_printers, apply_type_printers,
free_type_printers): New functions.
(_initialize_python): Set gdb.type_printers.
* python/python.h (start_type_printers, apply_type_printers,
free_type_printers): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new fields.
(do_free_global_table, create_global_typedef_table,
find_global_typedef): New functions.
(find_typedef_in_hash): Use find_global_typedef.
(whatis_exp): Use create_global_typedef_table. Change cleanup
handling.
* typeprint.h (struct type_print_options) <global_typedefs,
global_printers>: New fields.
doc
* gdb.texinfo (Symbols): Document "info type-printers",
"enable type-printer" and "disable type-printer".
(Python API): Add new node to menu.
(Type Printing API): New node.
(Progspaces In Python): Document type_printers field.
(Objfiles In Python): Likewise.
(gdb.types) <get_type_recognizers, apply_type_recognizers,
register_type_printer, TypePrinter>: Document.
testsuite
* gdb.base/completion.exp: Update for "info type-printers".
* gdb.python/py-typeprint.cc: New file.
* gdb.python/py-typeprint.exp: New file.
* gdb.python/py-typeprint.py: New file.
2012-11-12 18:41:59 +01:00
|
|
|
|
/* Get the 'type_printers' attribute. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_get_type_printers (PyObject *o, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
Py_INCREF (self->type_printers);
|
|
|
|
|
return self->type_printers;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-20 15:53:04 +02:00
|
|
|
|
/* Get the 'xmethods' attribute. */
|
|
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
|
pspy_get_xmethods (PyObject *o, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
Py_INCREF (self->xmethods);
|
|
|
|
|
return self->xmethods;
|
|
|
|
|
}
|
|
|
|
|
|
* NEWS: Update.
* data-directory/Makefile.in (PYTHON_FILES): Add
type_printers.py.
* python/lib/gdb/command/type_printers.py: New file.
* python/lib/gdb/command/types.py (TypePrinter): New class.
(_get_some_type_recognizers, get_type_recognizers,
apply_type_recognizers, register_type_printer): New
functions.
* python/py-objfile.c (objfile_object) <type_printers>: New
field.
(objfpy_dealloc): Decref new field.
(objfpy_new): Set new field.
(objfpy_get_type_printers, objfpy_set_type_printers): New
functions.
(objfile_to_objfile_object): Set new field.
(objfile_getset): Add "type_printers".
* python/py-progspace.c (pspace_object) <type_printers>: New
field.
(pspy_dealloc): Decref new field.
(pspy_new): Set new field.
(pspy_get_type_printers, pspy_set_type_printers): New functions.
(pspace_to_pspace_object): Set new field.
(pspace_getset): Add "type_printers".
* python/python.c (start_type_printers, apply_type_printers,
free_type_printers): New functions.
(_initialize_python): Set gdb.type_printers.
* python/python.h (start_type_printers, apply_type_printers,
free_type_printers): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new fields.
(do_free_global_table, create_global_typedef_table,
find_global_typedef): New functions.
(find_typedef_in_hash): Use find_global_typedef.
(whatis_exp): Use create_global_typedef_table. Change cleanup
handling.
* typeprint.h (struct type_print_options) <global_typedefs,
global_printers>: New fields.
doc
* gdb.texinfo (Symbols): Document "info type-printers",
"enable type-printer" and "disable type-printer".
(Python API): Add new node to menu.
(Type Printing API): New node.
(Progspaces In Python): Document type_printers field.
(Objfiles In Python): Likewise.
(gdb.types) <get_type_recognizers, apply_type_recognizers,
register_type_printer, TypePrinter>: Document.
testsuite
* gdb.base/completion.exp: Update for "info type-printers".
* gdb.python/py-typeprint.cc: New file.
* gdb.python/py-typeprint.exp: New file.
* gdb.python/py-typeprint.py: New file.
2012-11-12 18:41:59 +01:00
|
|
|
|
/* Set the 'type_printers' attribute. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
pspy_set_type_printers (PyObject *o, PyObject *value, void *ignore)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
if (! value)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"cannot delete the type_printers attribute");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! PyList_Check (value))
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_TypeError,
|
|
|
|
|
"the type_printers attribute must be a list");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Take care in case the LHS and RHS are related somehow. */
|
2018-12-27 19:53:20 +01:00
|
|
|
|
gdbpy_ref<> tmp (self->type_printers);
|
* NEWS: Update.
* data-directory/Makefile.in (PYTHON_FILES): Add
type_printers.py.
* python/lib/gdb/command/type_printers.py: New file.
* python/lib/gdb/command/types.py (TypePrinter): New class.
(_get_some_type_recognizers, get_type_recognizers,
apply_type_recognizers, register_type_printer): New
functions.
* python/py-objfile.c (objfile_object) <type_printers>: New
field.
(objfpy_dealloc): Decref new field.
(objfpy_new): Set new field.
(objfpy_get_type_printers, objfpy_set_type_printers): New
functions.
(objfile_to_objfile_object): Set new field.
(objfile_getset): Add "type_printers".
* python/py-progspace.c (pspace_object) <type_printers>: New
field.
(pspy_dealloc): Decref new field.
(pspy_new): Set new field.
(pspy_get_type_printers, pspy_set_type_printers): New functions.
(pspace_to_pspace_object): Set new field.
(pspace_getset): Add "type_printers".
* python/python.c (start_type_printers, apply_type_printers,
free_type_printers): New functions.
(_initialize_python): Set gdb.type_printers.
* python/python.h (start_type_printers, apply_type_printers,
free_type_printers): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new fields.
(do_free_global_table, create_global_typedef_table,
find_global_typedef): New functions.
(find_typedef_in_hash): Use find_global_typedef.
(whatis_exp): Use create_global_typedef_table. Change cleanup
handling.
* typeprint.h (struct type_print_options) <global_typedefs,
global_printers>: New fields.
doc
* gdb.texinfo (Symbols): Document "info type-printers",
"enable type-printer" and "disable type-printer".
(Python API): Add new node to menu.
(Type Printing API): New node.
(Progspaces In Python): Document type_printers field.
(Objfiles In Python): Likewise.
(gdb.types) <get_type_recognizers, apply_type_recognizers,
register_type_printer, TypePrinter>: Document.
testsuite
* gdb.base/completion.exp: Update for "info type-printers".
* gdb.python/py-typeprint.cc: New file.
* gdb.python/py-typeprint.exp: New file.
* gdb.python/py-typeprint.py: New file.
2012-11-12 18:41:59 +01:00
|
|
|
|
Py_INCREF (value);
|
|
|
|
|
self->type_printers = value;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 21:40:41 +02:00
|
|
|
|
/* Implement the objfiles method. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_get_objfiles (PyObject *self_, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) self_;
|
|
|
|
|
|
|
|
|
|
PSPY_REQUIRE_VALID (self);
|
|
|
|
|
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
gdbpy_ref<> list (PyList_New (0));
|
|
|
|
|
if (list == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (self->pspace != NULL)
|
|
|
|
|
{
|
Change all_objfiles adapter to be a method on program_space
This changes the all_objfiles range adapter to be a method on the
program space, and fixes up all the users.
gdb/ChangeLog
2019-01-17 Tom Tromey <tom@tromey.com>
* progspace.h (program_space) <objfiles_range>: New typedef.
<objfiles>: New method.
<objfiles_head>: Rename from objfiles.
(object_files): Update.
* guile/scm-progspace.c (gdbscm_progspace_objfiles): Update.
* guile/scm-pretty-print.c
(ppscm_find_pretty_printer_from_objfiles): Update.
* guile/scm-objfile.c (gdbscm_objfiles): Update.
* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
Update.
* python/py-progspace.c (pspy_get_objfiles): Update.
* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
Update.
* python/py-objfile.c (objfpy_lookup_objfile_by_name)
(objfpy_lookup_objfile_by_build_id): Update.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
Update.
* symtab.c (iterate_over_symtabs, matching_obj_sections)
(expand_symtab_containing_pc, lookup_objfile_from_block)
(lookup_static_symbol, basic_lookup_transparent_type)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, info_sources_command)
(default_collect_symbol_completion_matches_break_on)
(make_source_files_completion_list, find_main_name): Update.
* symmisc.c (print_symbol_bcache_statistics)
(print_objfile_statistics, maintenance_print_symbols)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs)
(maintenance_expand_symtabs, maintenance_info_line_tables):
Update.
* symfile.c (remove_symbol_file_command, overlay_invalidate_all)
(find_pc_overlay, find_pc_mapped_section, list_overlays_command)
(map_overlay_command, unmap_overlay_command)
(simple_overlay_update, expand_symtabs_matching)
(map_symbol_filenames): Update.
* symfile-debug.c (set_debug_symfile): Update.
* spu-tdep.c (spu_overlay_update, spu_objfile_from_frame):
Update.
* source.c (select_source_symtab, forget_cached_source_info):
Update.
* solib.c (solib_read_symbols): Update.
* solib-spu.c (append_ocl_sos): Update.
* psymtab.c (maintenance_print_psymbols)
(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
* probe.c (parse_probes_in_pspace, find_probe_by_pc): Update.
* printcmd.c (info_symbol_command): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created):
Update.
* objfiles.h (class all_objfiles): Remove.
* objfiles.c (have_partial_symbols, have_full_symbols)
(have_minimal_symbols, qsort_cmp, update_section_map)
(shared_objfile_contains_address_p)
(default_iterate_over_objfiles_in_search_order): Update.
* objc-lang.c (info_selectors_command, info_classes_command)
(find_methods): Update.
* minsyms.c (find_solib_trampoline_target): Update.
* maint.c (maintenance_info_sections)
(maintenance_translate_address, count_symtabs_and_blocks):
Update.
* main.c (captured_main_1): Update.
* linux-thread-db.c (try_thread_db_load_from_pdir)
(has_libpthread): Update.
* linespec.c (iterate_over_all_matching_symtabs)
(search_minsyms_for_name): Update.
* jit.c (jit_find_objf_with_entry_addr): Update.
* hppa-tdep.c (find_unwind_entry)
(hppa_lookup_stub_minimal_symbol): Update.
* gcore.c (gcore_create_callback, objfile_find_memory_regions):
Update.
* elfread.c (elf_gnu_ifunc_resolve_by_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* dwarf2-frame.c (dwarf2_frame_find_fde): Update.
* dwarf-index-write.c (save_gdb_index_command): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* blockframe.c (find_pc_partial_function): Update.
* ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols)
(ada_collect_symbol_completion_matches)
(ada_add_global_exceptions): Update.
2019-01-16 00:55:05 +01:00
|
|
|
|
for (objfile *objf : self->pspace->objfiles ())
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
{
|
2018-09-13 07:06:09 +02:00
|
|
|
|
gdbpy_ref<> item = objfile_to_objfile_object (objf);
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
|
2018-09-13 07:06:09 +02:00
|
|
|
|
if (item == nullptr
|
|
|
|
|
|| PyList_Append (list.get (), item.get ()) == -1)
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list.release ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of solib_name (Long) -> String.
|
|
|
|
|
Returns the name of the shared library holding a given address, or None. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_solib_name (PyObject *o, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
char *soname;
|
2018-10-02 21:47:54 +02:00
|
|
|
|
gdb_py_ulongest pc;
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
PSPY_REQUIRE_VALID (self);
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
soname = solib_name_from_address (self->pspace, pc);
|
|
|
|
|
if (soname == nullptr)
|
|
|
|
|
Py_RETURN_NONE;
|
2018-10-25 00:40:00 +02:00
|
|
|
|
return host_string_to_python_string (soname).release ();
|
2018-09-13 21:40:41 +02:00
|
|
|
|
}
|
2010-04-15 21:54:13 +02:00
|
|
|
|
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
/* Return the innermost lexical block containing the specified pc value,
|
|
|
|
|
or 0 if there is none. */
|
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_block_for_pc (PyObject *o, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
gdb_py_ulongest pc;
|
|
|
|
|
const struct block *block = NULL;
|
|
|
|
|
struct compunit_symtab *cust = NULL;
|
|
|
|
|
|
|
|
|
|
PSPY_REQUIRE_VALID (self);
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-04-04 00:02:42 +02:00
|
|
|
|
try
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
{
|
|
|
|
|
scoped_restore_current_program_space saver;
|
|
|
|
|
|
|
|
|
|
set_current_program_space (self->pspace);
|
|
|
|
|
cust = find_pc_compunit_symtab (pc);
|
|
|
|
|
|
|
|
|
|
if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
|
|
|
|
|
block = block_for_pc (pc);
|
|
|
|
|
}
|
2019-04-03 23:59:07 +02:00
|
|
|
|
catch (const gdb_exception &except)
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
{
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
|
|
|
|
|
{
|
|
|
|
|
PyErr_SetString (PyExc_RuntimeError,
|
|
|
|
|
_("Cannot locate object file for block."));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (block)
|
|
|
|
|
return block_to_block_object (block, COMPUNIT_OBJFILE (cust));
|
|
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of the find_pc_line function.
|
|
|
|
|
Returns the gdb.Symtab_and_line object corresponding to a PC value. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_find_pc_line (PyObject *o, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
gdb_py_ulongest pc_llu;
|
|
|
|
|
PyObject *result = NULL; /* init for gcc -Wall */
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
PSPY_REQUIRE_VALID (self);
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2019-04-04 00:02:42 +02:00
|
|
|
|
try
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
{
|
|
|
|
|
struct symtab_and_line sal;
|
|
|
|
|
CORE_ADDR pc;
|
|
|
|
|
scoped_restore_current_program_space saver;
|
|
|
|
|
|
|
|
|
|
set_current_program_space (self->pspace);
|
|
|
|
|
|
|
|
|
|
pc = (CORE_ADDR) pc_llu;
|
|
|
|
|
sal = find_pc_line (pc, 0);
|
|
|
|
|
result = symtab_and_line_to_sal_object (sal);
|
|
|
|
|
}
|
2019-04-03 23:59:07 +02:00
|
|
|
|
catch (const gdb_exception &except)
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
{
|
|
|
|
|
GDB_PY_HANDLE_EXCEPTION (except);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of is_valid (self) -> Boolean.
|
|
|
|
|
Returns True if this program space still exists in GDB. */
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
|
pspy_is_valid (PyObject *o, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
pspace_object *self = (pspace_object *) o;
|
|
|
|
|
|
|
|
|
|
if (self->pspace == NULL)
|
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-15 21:54:13 +02:00
|
|
|
|
/* Clear the PSPACE pointer in a Pspace object and remove the reference. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
py_free_pspace (struct program_space *pspace, void *datum)
|
|
|
|
|
{
|
2014-05-20 22:06:26 +02:00
|
|
|
|
/* This is a fiction, but we're in a nasty spot: The pspace is in the
|
|
|
|
|
process of being deleted, we can't rely on anything in it. Plus
|
|
|
|
|
this is one time when the current program space and current inferior
|
|
|
|
|
are not in sync: All inferiors that use PSPACE may no longer exist.
|
|
|
|
|
We don't need to do much here, and since "there is always an inferior"
|
|
|
|
|
using target_gdbarch suffices.
|
|
|
|
|
Note: We cannot call get_current_arch because it may try to access
|
|
|
|
|
the target, which may involve accessing data in the pspace currently
|
|
|
|
|
being deleted. */
|
|
|
|
|
struct gdbarch *arch = target_gdbarch ();
|
2010-04-15 21:54:13 +02:00
|
|
|
|
|
2016-11-08 00:08:36 +01:00
|
|
|
|
gdbpy_enter enter_py (arch, current_language);
|
2017-01-12 00:28:43 +01:00
|
|
|
|
gdbpy_ref<pspace_object> object ((pspace_object *) datum);
|
2010-04-15 21:54:13 +02:00
|
|
|
|
object->pspace = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 05:44:19 +02:00
|
|
|
|
/* Return a new reference to the Python object of type Pspace
|
2010-04-15 21:54:13 +02:00
|
|
|
|
representing PSPACE. If the object has already been created,
|
|
|
|
|
return it. Otherwise, create it. Return NULL and set the Python
|
|
|
|
|
error on failure. */
|
|
|
|
|
|
2018-09-13 05:44:19 +02:00
|
|
|
|
gdbpy_ref<>
|
2010-04-15 21:54:13 +02:00
|
|
|
|
pspace_to_pspace_object (struct program_space *pspace)
|
|
|
|
|
{
|
2018-09-13 05:44:19 +02:00
|
|
|
|
PyObject *result
|
|
|
|
|
((PyObject *) program_space_data (pspace, pspy_pspace_data_key));
|
|
|
|
|
if (result == NULL)
|
2010-04-15 21:54:13 +02:00
|
|
|
|
{
|
2018-09-13 05:44:19 +02:00
|
|
|
|
gdbpy_ref<pspace_object> object
|
|
|
|
|
((pspace_object *) PyObject_New (pspace_object, &pspace_object_type));
|
|
|
|
|
if (object == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (!pspy_initialize (object.get ()))
|
|
|
|
|
return NULL;
|
2014-05-20 15:53:04 +02:00
|
|
|
|
|
2018-09-13 05:44:19 +02:00
|
|
|
|
object->pspace = pspace;
|
|
|
|
|
set_program_space_data (pspace, pspy_pspace_data_key, object.get ());
|
|
|
|
|
result = (PyObject *) object.release ();
|
2010-04-15 21:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 05:44:19 +02:00
|
|
|
|
return gdbpy_ref<>::new_reference (result);
|
2010-04-15 21:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
* 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 22:28:52 +02:00
|
|
|
|
int
|
2010-04-15 21:54:13 +02:00
|
|
|
|
gdbpy_initialize_pspace (void)
|
|
|
|
|
{
|
|
|
|
|
pspy_pspace_data_key
|
* auto-load.c (_initialize_auto_load): Update.
* solib-svr4.c (_initialize_svr4_solib): Update
* solib-dsbt.c (_initialize_dsbt_solib): Update.
* solib-darwin.c (_initialize_darwin_solib): Update.
* registry.h: New file.
* python/py-progspace.c (gdbpy_initialize_pspace): Update.
* python/py-inferior.c (gdbpy_initialize_inferior): Update.
* progspace.h: Include registry.h. Use DECLARE_REGISTRY.
(register_program_space_data_with_cleanup)
(register_program_space_data, program_space_alloc_data)
(clear_program_space_data, set_program_space_data)
(program_space_data): Don't declare.
* progspace.c: Use DEFINE_REGISTRY.
(struct program_space_data, struct
program_space_data_registration, struct
program_space_data_registry, program_space_data_registry)
(register_program_space_data_with_cleanup)
(register_program_space_data, program_space_alloc_data)
(program_space_free_data, clear_program_space_data)
(set_program_space_data, program_space_data): Remove.
* objfiles.h: Include registry.h. Use DECLARE_REGISTRY.
(struct objfile) <data, num_data>: Replace with REGISTRY_FIELDS.
(register_objfile_data_with_cleanup, register_objfile_data)
(clear_objfile_data, set_objfile_data, objfile_data): Don't
declare.
* objfiles.c: Use DEFINE_REGISTRY.
(struct objfile_data, struct objfile_data_registration, struct
objfile_data_registry, objfile_data_registry)
(register_objfile_data_with_cleanup, register_objfile_data)
(objfile_alloc_data, objfile_free_data, clear_objfile_data)
(set_objfile_data, objfile_data): Remove.
(_initialize_objfiles): Update.
* jit.c (_initialize_jit): Update.
* inflow.c (_initialize_inflow): Update.
* inferior.h: Include registry.h. Use DECLARE_REGISTRY.
(struct inferior) <data, num_data>: Replace with REGISTRY_FIELDS.
(register_inferior_data_with_cleanup, register_inferior_data)
(clear_inferior_data, set_inferior_data, inferior_data): Don't
declare.
* inferior.c: Use DEFINE_REGISTRY.
(struct inferior_data, struct inferior_data_registration, struct
inferior_data_registry, inferior_data_registry)
(register_inferior_data_with_cleanup, register_inferior_data)
(inferior_alloc_data, inferior_free_data clear_inferior_data)
(set_inferior_data, inferior_data): Remove.
* auxv.c (_initialize_auxv): Update.
* ada-lang.c (_initialize_ada_language): Update.
* breakpoint.c (_initialize_breakpoint): Update.
* i386-nat.c (i386_use_watchpoints): Update.
2012-08-22 17:17:21 +02:00
|
|
|
|
= register_program_space_data_with_cleanup (NULL, py_free_pspace);
|
2010-04-15 21:54:13 +02:00
|
|
|
|
|
|
|
|
|
if (PyType_Ready (&pspace_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 22:28:52 +02:00
|
|
|
|
return -1;
|
2010-04-15 21:54:13 +02:00
|
|
|
|
|
2013-05-20 22:36:19 +02:00
|
|
|
|
return gdb_pymodule_addobject (gdb_module, "Progspace",
|
|
|
|
|
(PyObject *) &pspace_object_type);
|
2010-04-15 21:54:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-Wwrite-strings: Wrap PyGetSetDef for construction with string literals
Unfortunately, PyGetSetDef's 'name' and 'doc' members are 'char *'
instead of 'const char *', meaning that in order to list-initialize
PyGetSetDef arrays using string literals requires writing explicit
'char *' casts. For example:
static PyGetSetDef value_object_getset[] = {
- { "address", valpy_get_address, NULL, "The address of the value.",
+ { (char *) "address", valpy_get_address, NULL,
+ (char *) "The address of the value.",
NULL },
- { "is_optimized_out", valpy_get_is_optimized_out, NULL,
- "Boolean telling whether the value is optimized "
+ { (char *) "is_optimized_out", valpy_get_is_optimized_out, NULL,
+ (char *) "Boolean telling whether the value is optimized "
"out (i.e., not available).",
NULL },
- { "type", valpy_get_type, NULL, "Type of the value.", NULL },
- { "dynamic_type", valpy_get_dynamic_type, NULL,
- "Dynamic type of the value.", NULL },
- { "is_lazy", valpy_get_is_lazy, NULL,
- "Boolean telling whether the value is lazy (not fetched yet\n\
+ { (char *) "type", valpy_get_type, NULL,
+ (char *) "Type of the value.", NULL },
+ { (char *) "dynamic_type", valpy_get_dynamic_type, NULL,
+ (char *) "Dynamic type of the value.", NULL },
+ { (char *) "is_lazy", valpy_get_is_lazy, NULL,
+ (char *) "Boolean telling whether the value is lazy (not fetched yet\n\
from the inferior). A lazy value is fetched when needed, or when\n\
the \"fetch_lazy()\" method is called.", NULL },
{NULL} /* Sentinel */
We have ~20 such arrays, and I first wrote a patch that fixed all of
them like that... It's not pretty...
One way to make these a bit less ugly would be add a new macro that
hides the casts, like:
#define GDBPY_GSDEF(NAME, GET, SET, DOC, CLOSURE) \
{ (char *) NAME, GET, SET, (char *) DOC, CLOSURE }
and then use it like:
static PyGetSetDef value_object_getset[] = {
GDBPY_GSDEF ("address", valpy_get_address, NULL,
"The address of the value.", NULL),
GDBPY_GSDEF ("is_optimized_out", valpy_get_is_optimized_out, NULL,
"Boolean telling whether the value is optimized ", NULL),
{NULL} /* Sentinel */
};
But since we have C++11, which gives us constexpr and list
initialization, I thought of a way that requires no changes where the
arrays are initialized:
We add a new type that extends PyGetSetDef (called gdb_PyGetSetDef),
and add constexpr constructors that accept const 'name' and 'doc', and
then list/aggregate initialization simply "calls" these matching
constructors instead.
I put "calls" in quotes, because given "constexpr", it's all done at
compile time, and there's no overhead either in binary size or at run
time. In fact, we get identical binaries, before/after this change.
Unlike the fixes that fix some old Python API to match the API of more
recent Python, this switches to using explicit "gdb_PyGetSetDef"
everywhere, just to be clear that we are using our own version of it.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* python/python-internal.h (gdb_PyGetSetDef): New type.
* python/py-block.c (block_object_getset)
(breakpoint_object_getset): Now a gdb_PyGetSetDef array.
* python/py-event.c (event_object_getset)
(finish_breakpoint_object_getset): Likewise.
* python/py-inferior.c (inferior_object_getset): Likewise.
* python/py-infthread.c (thread_object_getset): Likewise.
* python/py-lazy-string.c (lazy_string_object_getset): Likewise.
* python/py-linetable.c (linetable_entry_object_getset): Likewise.
* python/py-objfile.c (objfile_getset): Likewise.
* python/py-progspace.c (pspace_getset): Likewise.
* python/py-record-btrace.c (btpy_insn_getset, btpy_call_getset):
Likewise.
* python/py-record.c (recpy_record_getset): Likewise.
* python/py-symbol.c (symbol_object_getset): Likewise.
* python/py-symtab.c (symtab_object_getset, sal_object_getset):
Likewise.
* python/py-type.c (type_object_getset, field_object_getset):
Likewise.
* python/py-value.c (value_object_getset): Likewise.
2017-04-05 20:21:36 +02:00
|
|
|
|
static gdb_PyGetSetDef pspace_getset[] =
|
2010-04-15 21:54:13 +02:00
|
|
|
|
{
|
2014-10-31 01:05:17 +01:00
|
|
|
|
{ "__dict__", gdb_py_generic_dict, NULL,
|
|
|
|
|
"The __dict__ for this progspace.", &pspace_object_type },
|
2010-04-15 21:54:13 +02:00
|
|
|
|
{ "filename", pspy_get_filename, NULL,
|
|
|
|
|
"The progspace's main filename, or None.", NULL },
|
|
|
|
|
{ "pretty_printers", pspy_get_printers, pspy_set_printers,
|
|
|
|
|
"Pretty printers.", NULL },
|
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* stack.c (backtrace_command_1): Add "no-filters", and Python frame
filter logic.
(backtrace_command): Add "no-filters" option parsing.
(_initialize_stack): Alter help to reflect "no-filters" option.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-framefilter.o
(SUBDIR_PYTHON_SRCS): Add py-framefilter.c
(py-frame.o): Add target
* data-directory/Makefile.in (PYTHON_DIR): Add Python frame
filter files.
* python/python.h: Add new frame filter constants, and flag enum.
(apply_frame_filter): Add definition.
* python/python.c (apply_frame_filter): New non-Python
enabled function.
* python/py-utils.c (py_xdecref): New function.
(make_cleanup_py_xdecref): Ditto.
* python/py-objfile.c: Declare frame_filters dictionary.
(objfpy_dealloc): Add frame_filters dealloc.
(objfpy_new): Initialize frame_filters attribute.
(objfile_to_objfile_object): Ditto.
(objfpy_get_frame_filters): New function.
(objfpy_set_frame_filters): New function.
* python/py-progspace.c: Declare frame_filters dictionary.
(pspy_dealloc): Add frame_filters dealloc.
(pspy_new): Initialize frame_filters attribute.
(pspacee_to_pspace_object): Ditto.
(pspy_get_frame_filters): New function.
(pspy_set_frame_filters): New function.
* python/py-framefilter.c: New file.
* python/lib/gdb/command/frame_filters.py: New file.
* python/lib/gdb/frames.py: New file.
* python/lib/gdb/__init__.py: Initialize global frame_filters
dictionary
* python/lib/gdb/FrameDecorator.py: New file.
* python/lib/gdb/FrameIterator.py: New file.
* mi/mi-cmds.c (mi_cmds): Add frame filters command.
* mi/mi-cmds.h: Declare.
* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames): Add
--no-frame-filter logic, and Python frame filter logic.
(stack_enable_frame_filters): New function.
(parse_no_frame_option): Ditto.
(mi_cmd_stack_list_frames): Add --no-frame-filter and Python frame
filter logic.
(mi_cmd_stack_list_locals): Ditto.
(mi_cmd_stack_list_args): Ditto.
(mi_cmd_stack_list_variables): Ditto.
* NEWS: Add frame filter note.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-framefilter.py: New File.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter.c: Ditto.
* gdb.python/py-framefilter-mi.exp: Ditto.
* gdb.python/py-framefilter-mi.c: Ditto,
* gdb.python/py-framefilter-gdb.py.in: Ditto.
2013-05-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Backtrace): Add "no-filter" argument.
(Python API): Add Frame Filters API, Frame Wrapper API,
Writing a Frame Filter/Wrapper, Managing Management of Frame
Filters chapter entries.
(Frame Filters API): New Node.
(Frame Wrapper API): New Node.
(Writing a Frame Filter): New Node.
(Managing Frame Filters): New Node.
(Progspaces In Python): Add note about frame_filters attribute.
(Objfiles in Python): Ditto.
(GDB/MI Stack Manipulation): Add -enable-frame-filters command,
@anchors and --no-frame-filters option to -stack-list-variables,
-stack-list-frames, -stack-list-locals and -stack-list-arguments
commands.
2013-05-10 12:26:03 +02:00
|
|
|
|
{ "frame_filters", pspy_get_frame_filters, pspy_set_frame_filters,
|
|
|
|
|
"Frame filters.", NULL },
|
2015-04-01 20:49:12 +02:00
|
|
|
|
{ "frame_unwinders", pspy_get_frame_unwinders, pspy_set_frame_unwinders,
|
|
|
|
|
"Frame unwinders.", NULL },
|
* NEWS: Update.
* data-directory/Makefile.in (PYTHON_FILES): Add
type_printers.py.
* python/lib/gdb/command/type_printers.py: New file.
* python/lib/gdb/command/types.py (TypePrinter): New class.
(_get_some_type_recognizers, get_type_recognizers,
apply_type_recognizers, register_type_printer): New
functions.
* python/py-objfile.c (objfile_object) <type_printers>: New
field.
(objfpy_dealloc): Decref new field.
(objfpy_new): Set new field.
(objfpy_get_type_printers, objfpy_set_type_printers): New
functions.
(objfile_to_objfile_object): Set new field.
(objfile_getset): Add "type_printers".
* python/py-progspace.c (pspace_object) <type_printers>: New
field.
(pspy_dealloc): Decref new field.
(pspy_new): Set new field.
(pspy_get_type_printers, pspy_set_type_printers): New functions.
(pspace_to_pspace_object): Set new field.
(pspace_getset): Add "type_printers".
* python/python.c (start_type_printers, apply_type_printers,
free_type_printers): New functions.
(_initialize_python): Set gdb.type_printers.
* python/python.h (start_type_printers, apply_type_printers,
free_type_printers): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update for new fields.
(do_free_global_table, create_global_typedef_table,
find_global_typedef): New functions.
(find_typedef_in_hash): Use find_global_typedef.
(whatis_exp): Use create_global_typedef_table. Change cleanup
handling.
* typeprint.h (struct type_print_options) <global_typedefs,
global_printers>: New fields.
doc
* gdb.texinfo (Symbols): Document "info type-printers",
"enable type-printer" and "disable type-printer".
(Python API): Add new node to menu.
(Type Printing API): New node.
(Progspaces In Python): Document type_printers field.
(Objfiles In Python): Likewise.
(gdb.types) <get_type_recognizers, apply_type_recognizers,
register_type_printer, TypePrinter>: Document.
testsuite
* gdb.base/completion.exp: Update for "info type-printers".
* gdb.python/py-typeprint.cc: New file.
* gdb.python/py-typeprint.exp: New file.
* gdb.python/py-typeprint.py: New file.
2012-11-12 18:41:59 +01:00
|
|
|
|
{ "type_printers", pspy_get_type_printers, pspy_set_type_printers,
|
|
|
|
|
"Type printers.", NULL },
|
2014-05-20 15:53:04 +02:00
|
|
|
|
{ "xmethods", pspy_get_xmethods, NULL,
|
|
|
|
|
"Debug methods.", NULL },
|
2010-04-15 21:54:13 +02:00
|
|
|
|
{ NULL }
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-13 21:40:41 +02:00
|
|
|
|
static PyMethodDef progspace_object_methods[] =
|
|
|
|
|
{
|
|
|
|
|
{ "objfiles", pspy_get_objfiles, METH_NOARGS,
|
|
|
|
|
"Return a sequence of objfiles associated to this program space." },
|
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
2013-12-27 03:50:05 +01:00
|
|
|
|
{ "solib_name", pspy_solib_name, METH_VARARGS,
|
|
|
|
|
"solib_name (Long) -> String.\n\
|
|
|
|
|
Return the name of the shared library holding a given address, or None." },
|
|
|
|
|
{ "block_for_pc", pspy_block_for_pc, METH_VARARGS,
|
|
|
|
|
"Return the block containing the given pc value, or None." },
|
|
|
|
|
{ "find_pc_line", pspy_find_pc_line, METH_VARARGS,
|
|
|
|
|
"find_pc_line (pc) -> Symtab_and_line.\n\
|
|
|
|
|
Return the gdb.Symtab_and_line object corresponding to the pc value." },
|
|
|
|
|
{ "is_valid", pspy_is_valid, METH_NOARGS,
|
|
|
|
|
"is_valid () -> Boolean.\n\
|
|
|
|
|
Return true if this program space is valid, false if not." },
|
2018-09-13 21:40:41 +02:00
|
|
|
|
{ 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 12:20:21 +01:00
|
|
|
|
PyTypeObject pspace_object_type =
|
2010-04-15 21:54:13 +02:00
|
|
|
|
{
|
2012-12-12 17:47:30 +01:00
|
|
|
|
PyVarObject_HEAD_INIT (NULL, 0)
|
2010-04-15 21:54:13 +02:00
|
|
|
|
"gdb.Progspace", /*tp_name*/
|
|
|
|
|
sizeof (pspace_object), /*tp_basicsize*/
|
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
|
pspy_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, /*tp_flags*/
|
|
|
|
|
"GDB progspace object", /* tp_doc */
|
|
|
|
|
0, /* tp_traverse */
|
|
|
|
|
0, /* tp_clear */
|
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
|
0, /* tp_iter */
|
|
|
|
|
0, /* tp_iternext */
|
2018-09-13 21:40:41 +02:00
|
|
|
|
progspace_object_methods, /* tp_methods */
|
2010-04-15 21:54:13 +02:00
|
|
|
|
0, /* tp_members */
|
|
|
|
|
pspace_getset, /* tp_getset */
|
|
|
|
|
0, /* tp_base */
|
|
|
|
|
0, /* tp_dict */
|
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
|
0, /* tp_descr_set */
|
2014-10-31 01:05:17 +01:00
|
|
|
|
offsetof (pspace_object, dict), /* tp_dictoffset */
|
2010-04-15 21:54:13 +02:00
|
|
|
|
0, /* tp_init */
|
|
|
|
|
0, /* tp_alloc */
|
|
|
|
|
pspy_new, /* tp_new */
|
|
|
|
|
};
|