binutils-gdb/gdb/python/py-evtregistry.c

171 lines
5.7 KiB
C
Raw Permalink Normal View History

2011-02-05 06:27:23 +01:00
/* Python interface to inferior thread event registries.
Copyright (C) 2009-2020 Free Software Foundation, Inc.
2011-02-05 06:27:23 +01:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "command.h"
#include "py-events.h"
events_object gdb_py_events;
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 eventregistry_object_type
* python/py-arch.c (arch_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-block.c (block_syms_iterator_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-bpevent.c (breakpoint_event_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-cmd.c (cmdpy_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-continueevent.c (continue_event_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-event.h (GDBPY_NEW_EVENT_TYPE): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-events.h (thread_event_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-evtregistry.c (eventregistry_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-exitedevent.c (exited_event_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-finishbreakpoint.c (finish_breakpoint_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-function.c (fnpy_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-inferior.c (inferior_object_type, membuf_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-infthread.c (thread_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-lazy-string.c (lazy_string_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-newobjfileevent.c (new_objfile_event_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-objfile.c (objfile_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-param.c (parmpy_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-progspace.c (pspace_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-signalevent.c (signal_event_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-symtab.c (symtab_object_type, sal_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-type.c (type_object_type, field_object_type) (type_iterator_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF. * python/py-internal.h (CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF): New define. (value_object_type, block_object_type, symbol_object_type) (event_object_type, stop_event_object_type, breakpoint_object_type) (frame_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
2013-05-20 22:09:01 +02:00
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("eventregistry_object");
2011-02-05 06:27:23 +01:00
/* Implementation of EventRegistry.connect () -> NULL.
Add FUNCTION to the list of listeners. */
static PyObject *
evregpy_connect (PyObject *self, PyObject *function)
{
PyObject *func;
PyObject *callback_list = (((eventregistry_object *) self)->callbacks);
if (!PyArg_ParseTuple (function, "O", &func))
return NULL;
if (!PyCallable_Check (func))
{
PyErr_SetString (PyExc_RuntimeError, "Function is not callable");
return NULL;
}
if (PyList_Append (callback_list, func) < 0)
return NULL;
Py_RETURN_NONE;
}
/* Implementation of EventRegistry.disconnect () -> NULL.
Remove FUNCTION from the list of listeners. */
static PyObject *
evregpy_disconnect (PyObject *self, PyObject *function)
{
PyObject *func;
int index;
PyObject *callback_list = (((eventregistry_object *) self)->callbacks);
if (!PyArg_ParseTuple (function, "O", &func))
return NULL;
index = PySequence_Index (callback_list, func);
if (index < 0)
Py_RETURN_NONE;
if (PySequence_DelItem (callback_list, index) < 0)
return NULL;
Py_RETURN_NONE;
}
/* Create a new event registry. This function uses PyObject_New
and therefore returns a new reference that callers must handle. */
eventregistry_object *
create_eventregistry_object (void)
{
gdbpy_ref<eventregistry_object>
eventregistry_obj (PyObject_New (eventregistry_object,
&eventregistry_object_type));
2011-02-05 06:27:23 +01:00
if (eventregistry_obj == NULL)
2011-02-05 06:27:23 +01:00
return NULL;
eventregistry_obj->callbacks = PyList_New (0);
if (!eventregistry_obj->callbacks)
return NULL;
2011-02-05 06:27:23 +01:00
return eventregistry_obj.release ();
2011-02-05 06:27:23 +01:00
}
static void
evregpy_dealloc (PyObject *self)
{
Py_XDECREF (((eventregistry_object *) self)->callbacks);
Add support for Python 3. * NEWS: Mention Python 3 support. * varobj.c (value_get_print_value): Use python_string_to_target_string. * python/py-block.c: Use PyVarObject_HEAD_INIT in initialization of type objects. * python/py-breakpoint.c: Ditto. * python/py-cmd.c: Ditto. * python/py-event.c: Ditto. * python/py-event.h: Ditto. * python/py-evtregistry.c: Ditto. * python/py-finishbreakpoint.c: Ditto. * python/py-frame.c: Ditto. * python/py-function.c: Ditto. * python/py-infthread.c: Ditto. * python/py-lazy-string.c: Ditto. * python/py-progspace.c: Ditto. * /python/py-symbol.c: Ditto. * python/py-evts.c: (gdbpy_initialize_py_events): Add module initialization for Python 3. * python/py-inferior.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (infpy_read_memory): Return memoryview object if Python 3. (infpy_write_memory): Use "s*" operand parsing code for Python 3. (infpy_search_memory): Ditto. (get_buffer): New function for Python 3. * python/py-objfile.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (objfpy_dealloc): Use Py_TYPE to call tp_free. * python/py-param.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (get_attr): Use PyUnicode_CompareWithASCIIString if Python 3. (set_attr): Ditto. * python/py-prettyprint.c (print_string_repr): use PyBytes methods instead of PyString methods if Python 3. (print_children): Skip push_dummy_python_frame call if Python 3. * python/py-symtab.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (salpy_dealloc): Use Py_TYPE to call tp_free. * python/py-type.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (field_dealloc): Use Py_TYPE to call tp_free. (typy_dealloc): Ditto. (type_object_as_number): Adjust struct initializations for differences in layout for Python 2 vs. Python 3. * python/py-utils.c (python_string_to_unicode): Omit non-Unicode string case for Python 3. (unicode_to_encoded_python_string): Shorten code (no functional change). (python_string_to_target_python_string): Comment that in Python 3 returned value is a Python "bytes" type. (gdbpy_is_string): Omit non-Unicode string check in Python 3. (gdb_py_object_from_longest): Omit non-long integer case in Python 3. (gdb_py_object_from_ulongest): Ditto. * python/py-value.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (valpy_dealloc): Use Py_TYPE to call tp_free. (valpy_int): Omit function if Python 3. (convert_value_from_python): Use "%S" format (Python object as a string) if Python 3. (value_object_as_number): Adjust struct initializations for differences in layout for Python 2 vs. Python 3. * python/python-config.py: Adjust syntax for Python 3 compatibility. Include "sys.abiflags" string as part of python library name, if that attribute exists (Python 3). * python/python-internal.h (IS_PY3): Define if Python 3. (Py_TPFLAGS_HAVE_ITER, Py_TPFLAGS_CHECKTYPES): Define with placeholder value if Python 3. (PyInt_Check, PyInt_FromLong, PyInt_AsLong, PyString_FromString, PyString_Decode, PyString_FromFormat, PyString_Check): Define as analogous Python 3 API function if Python 3. (PyVarObject_HEAD_INIT): Define if not already defined. (Py_TYPE): Ditto. * python/python.c (eval_python_command): Omit Py_FlushLine call if Python 3. Check return values of all Python API calls for error. Supply dummy "python" and "python-interactive" commands if Python initialization failed. (_initialize_python): Convert argc to wchar_t** if Python 3. Add module initialization for Python 3. (finish_python_initialization): Pass wchar_t * argument to PySys_SetPath if Python 3. * python/lib/gdb/__init__.py: Define "reload" if Python 3. (_GdbFile): New class for common output file behavior. (GdbOutFile): Subclass from _GdbFile. (GdbOutputErrorFile): Ditto. (auto_load_packages): Adjust syntax for Python 3 compatibility. * python/lib/gdb/printing.py: Define basestr and int if Python 3. * python/lib/gdb/prompt.py: Use sorted() function rather than sort() method. * python/lib/gdb/command/explore.py: Define raw_input if Python 3. Adjust syntax for Python 3 compatibility. * python/lib/gdb/command/pretty_printers.py: Use sorted() function rather than sort() method. Adjust syntax for Python 3 compatibility. * python/lib/gdb/command/type_printers.py: Ditto. * doc/gdb.texinfo (Inferior.read_memory): Mention that the return value is a memoryview object if Python 3.
2012-12-12 17:47:30 +01:00
Py_TYPE (self)->tp_free (self);
2011-02-05 06:27:23 +01:00
}
/* Initialize the Python event registry code. */
* 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
2011-02-05 06:27:23 +01:00
gdbpy_initialize_eventregistry (void)
{
if (PyType_Ready (&eventregistry_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;
2011-02-05 06:27:23 +01:00
* python/py-arch.c (gdbpy_initialize_arch): Use gdb_pymodule_addobject. * python/py-block.c (gdbpy_initialize_blocks): Use gdb_pymodule_addobject. * python/py-breakpoint.c (gdbpy_initialize_breakpoints): Use gdb_pymodule_addobject. * python/py-cmd.c (gdbpy_initialize_breakpoints): Use gdb_pymodule_addobject. * python/py-event.c (gdbpy_initialize_event_generic): Use gdb_pymodule_addobject. * python/py-evtregistry.c (gdbpy_initialize_eventregistry): Use gdb_pymodule_addobject. * python/py-evts.c (add_new_registry): Use gdb_pymodule_addobject. (gdbpy_initialize_py_events): Likewise. * python/py-finishbreakpoint.c (gdbpy_initialize_finishbreakpoints): Use gdb_pymodule_addobject. * python/py-frame.c (gdbpy_initialize_frames): Use gdb_pymodule_addobject. * python/py-function.c (gdbpy_initialize_functions): Use gdb_pymodule_addobject. * python/py-inferior.c (gdbpy_initialize_inferior): Use gdb_pymodule_addobject. * python/py-infthread.c (gdbpy_initialize_thread): Use gdb_pymodule_addobject. * python/py-objfile.c (gdbpy_initialize_objfile): Use gdb_pymodule_addobject. * python/py-param.c (gdbpy_initialize_parameters): Use gdb_pymodule_addobject. * python/py-progspace.c (gdbpy_initialize_pspace): Use gdb_pymodule_addobject. * python/py-symbol.c (gdbpy_initialize_symbols): Use gdb_pymodule_addobject. * python/py-symtab.c (gdbpy_initialize_symtabs): Use gdb_pymodule_addobject. * python/py-type.c (gdbpy_initialize_types): Use gdb_pymodule_addobject. * python/py-utils.c (gdb_pymodule_addobject): New function. * python/py-value.c (gdbpy_initialize_values): Use gdb_pymodule_addobject. * python/python-internal.h (gdb_pymodule_addobject): Declare. * python/python.c (_initialize_python): Use gdb_pymodule_addobject.
2013-05-20 22:36:19 +02:00
return gdb_pymodule_addobject (gdb_module, "EventRegistry",
(PyObject *) &eventregistry_object_type);
2011-02-05 06:27:23 +01:00
}
[gdb] Fix more typos in comments (2) Fix typos in comments. NFC. Tested on x86_64-linux. gdb/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * aarch64-linux-tdep.c: Fix typos in comments. * aarch64-tdep.c: Same. * ada-lang.c: Same. * amd64-nat.c: Same. * arc-tdep.c: Same. * arch/aarch64-insn.c: Same. * block.c: Same. * breakpoint.h: Same. * btrace.h: Same. * c-varobj.c: Same. * cli/cli-decode.c: Same. * cli/cli-script.c: Same. * cli/cli-utils.h: Same. * coff-pe-read.c: Same. * coffread.c: Same. * compile/compile-cplus-symbols.c: Same. * compile/compile-object-run.c: Same. * completer.c: Same. * corelow.c: Same. * cp-support.c: Same. * demangle.c: Same. * dwarf-index-write.c: Same. * dwarf2-frame.c: Same. * dwarf2-frame.h: Same. * eval.c: Same. * frame-base.h: Same. * frame.h: Same. * gdbcmd.h: Same. * gdbtypes.h: Same. * gnu-nat.c: Same. * guile/scm-objfile.c: Same. * i386-tdep.c: Same. * i386-tdep.h: Same. * infcall.c: Same. * infcall.h: Same. * linux-nat.c: Same. * m68k-tdep.c: Same. * macroexp.c: Same. * memattr.c: Same. * mi/mi-cmd-disas.c: Same. * mi/mi-getopt.h: Same. * mi/mi-main.c: Same. * minsyms.c: Same. * nat/aarch64-sve-linux-sigcontext.h: Same. * objfiles.h: Same. * ppc-linux-nat.c: Same. * ppc-linux-tdep.c: Same. * ppc-tdep.h: Same. * progspace.h: Same. * prologue-value.h: Same. * python/py-evtregistry.c: Same. * python/py-instruction.h: Same. * record-btrace.c: Same. * record-full.c: Same. * remote.c: Same. * rs6000-tdep.c: Same. * ser-tcp.c: Same. * sol-thread.c: Same. * sparc-sol2-tdep.c: Same. * sparc64-tdep.c: Same. * stabsread.c: Same. * symfile.c: Same. * symtab.h: Same. * target.c: Same. * tracepoint.c: Same. * tui/tui-data.h: Same. * tui/tui-io.c: Same. * tui/tui-win.c: Same. * tui/tui.c: Same. * unittests/rsp-low-selftests.c: Same. * user-regs.h: Same. * utils.c: Same. * utils.h: Same. * valarith.c: Same. * valops.c: Same. * valprint.c: Same. * valprint.h: Same. * value.c: Same. * value.h: Same. * varobj.c: Same. * x86-nat.h: Same. * xtensa-tdep.c: Same. gdb/gdbserver/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * linux-aarch64-low.c: Fix typos in comments. * linux-arm-low.c: Same. * linux-low.c: Same. * linux-ppc-low.c: Same. * proc-service.c: Same. * regcache.h: Same. * server.c: Same. * tracepoint.c: Same. * win32-low.c: Same. gdb/stubs/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * ia64vms-stub.c: Fix typos in comments. * m32r-stub.c: Same. * m68k-stub.c: Same. * sh-stub.c: Same. gdb/testsuite/ChangeLog: 2019-10-26 Tom de Vries <tdevries@suse.de> * gdb.base/bigcore.c: Fix typos in comments. * gdb.base/ctf-ptype.c: Same. * gdb.base/long_long.c: Same. * gdb.dwarf2/dw2-op-out-param.S: Same. * gdb.python/py-evthreads.c: Same. * gdb.reverse/i387-stack-reverse.c: Same. * gdb.trace/tfile.c: Same. * lib/compiler.c: Same. * lib/compiler.cc: Same. Change-Id: I8573d84a577894270179ae30f46c48d806fc1beb
2019-10-26 09:55:32 +02:00
/* Return the number of listeners currently connected to this
2011-02-05 06:27:23 +01:00
registry. */
int
evregpy_no_listeners_p (eventregistry_object *registry)
{
return PyList_Size (registry->callbacks) == 0;
}
static PyMethodDef eventregistry_object_methods[] =
{
{ "connect", evregpy_connect, METH_VARARGS, "Add function" },
{ "disconnect", evregpy_disconnect, METH_VARARGS, "Remove function" },
{ NULL } /* Sentinel. */
};
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 eventregistry_object_type =
2011-02-05 06:27:23 +01:00
{
Add support for Python 3. * NEWS: Mention Python 3 support. * varobj.c (value_get_print_value): Use python_string_to_target_string. * python/py-block.c: Use PyVarObject_HEAD_INIT in initialization of type objects. * python/py-breakpoint.c: Ditto. * python/py-cmd.c: Ditto. * python/py-event.c: Ditto. * python/py-event.h: Ditto. * python/py-evtregistry.c: Ditto. * python/py-finishbreakpoint.c: Ditto. * python/py-frame.c: Ditto. * python/py-function.c: Ditto. * python/py-infthread.c: Ditto. * python/py-lazy-string.c: Ditto. * python/py-progspace.c: Ditto. * /python/py-symbol.c: Ditto. * python/py-evts.c: (gdbpy_initialize_py_events): Add module initialization for Python 3. * python/py-inferior.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (infpy_read_memory): Return memoryview object if Python 3. (infpy_write_memory): Use "s*" operand parsing code for Python 3. (infpy_search_memory): Ditto. (get_buffer): New function for Python 3. * python/py-objfile.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (objfpy_dealloc): Use Py_TYPE to call tp_free. * python/py-param.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (get_attr): Use PyUnicode_CompareWithASCIIString if Python 3. (set_attr): Ditto. * python/py-prettyprint.c (print_string_repr): use PyBytes methods instead of PyString methods if Python 3. (print_children): Skip push_dummy_python_frame call if Python 3. * python/py-symtab.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (salpy_dealloc): Use Py_TYPE to call tp_free. * python/py-type.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (field_dealloc): Use Py_TYPE to call tp_free. (typy_dealloc): Ditto. (type_object_as_number): Adjust struct initializations for differences in layout for Python 2 vs. Python 3. * python/py-utils.c (python_string_to_unicode): Omit non-Unicode string case for Python 3. (unicode_to_encoded_python_string): Shorten code (no functional change). (python_string_to_target_python_string): Comment that in Python 3 returned value is a Python "bytes" type. (gdbpy_is_string): Omit non-Unicode string check in Python 3. (gdb_py_object_from_longest): Omit non-long integer case in Python 3. (gdb_py_object_from_ulongest): Ditto. * python/py-value.c: Use PyVarObject_HEAD_INIT in initialization of type objects. (valpy_dealloc): Use Py_TYPE to call tp_free. (valpy_int): Omit function if Python 3. (convert_value_from_python): Use "%S" format (Python object as a string) if Python 3. (value_object_as_number): Adjust struct initializations for differences in layout for Python 2 vs. Python 3. * python/python-config.py: Adjust syntax for Python 3 compatibility. Include "sys.abiflags" string as part of python library name, if that attribute exists (Python 3). * python/python-internal.h (IS_PY3): Define if Python 3. (Py_TPFLAGS_HAVE_ITER, Py_TPFLAGS_CHECKTYPES): Define with placeholder value if Python 3. (PyInt_Check, PyInt_FromLong, PyInt_AsLong, PyString_FromString, PyString_Decode, PyString_FromFormat, PyString_Check): Define as analogous Python 3 API function if Python 3. (PyVarObject_HEAD_INIT): Define if not already defined. (Py_TYPE): Ditto. * python/python.c (eval_python_command): Omit Py_FlushLine call if Python 3. Check return values of all Python API calls for error. Supply dummy "python" and "python-interactive" commands if Python initialization failed. (_initialize_python): Convert argc to wchar_t** if Python 3. Add module initialization for Python 3. (finish_python_initialization): Pass wchar_t * argument to PySys_SetPath if Python 3. * python/lib/gdb/__init__.py: Define "reload" if Python 3. (_GdbFile): New class for common output file behavior. (GdbOutFile): Subclass from _GdbFile. (GdbOutputErrorFile): Ditto. (auto_load_packages): Adjust syntax for Python 3 compatibility. * python/lib/gdb/printing.py: Define basestr and int if Python 3. * python/lib/gdb/prompt.py: Use sorted() function rather than sort() method. * python/lib/gdb/command/explore.py: Define raw_input if Python 3. Adjust syntax for Python 3 compatibility. * python/lib/gdb/command/pretty_printers.py: Use sorted() function rather than sort() method. Adjust syntax for Python 3 compatibility. * python/lib/gdb/command/type_printers.py: Ditto. * doc/gdb.texinfo (Inferior.read_memory): Mention that the return value is a memoryview object if Python 3.
2012-12-12 17:47:30 +01:00
PyVarObject_HEAD_INIT (NULL, 0)
2011-02-05 06:27:23 +01:00
"gdb.EventRegistry", /* tp_name */
sizeof (eventregistry_object), /* tp_basicsize */
0, /* tp_itemsize */
evregpy_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 event registry object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
eventregistry_object_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0 /* tp_alloc */
};