mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 12:03:41 +08:00
Make it simpler to add events to Python
The first patch in this series went through several iterations as I'd forgotten how many places had to be touched to add a new event and a new event type. This patch simplifies the process using two new ".def" files. Now, a new event type can be added by adding a line to "py-event-types.def", and a new event registry can be added by adding a line to "py-all-events.def". ChangeLog 2017-09-11 Tom Tromey <tom@tromey.com> * python/python.c (do_start_initialization): Use py-event-types.def to initialize types. Define all object type structures. * python/python-internal.h: Don't declare event initialization functions. * python/py-threadevent.c (thread_event_object_type): Don't define. * python/py-stopevent.c (stop_event_object_type): Don't define. * python/py-signalevent.c (signal_event_object_type): Don't declare or define. * python/py-newobjfileevent.c (new_objfile_event_object_type) (clear_objfiles_event_object_type): Don't declare or define. * python/py-infevents.c (inferior_call_pre_event_object_type) (inferior_call_post_event_object_type) (register_changed_event_object_type) (memory_changed_event_object_type): Don't declare or define. * python/py-inferior.c (new_thread_event_object_type) (new_inferior_event_object_type) (inferior_deleted_event_object_type): Don't declare or define. * python/py-exitedevent.c (exited_event_object_type): Don't declare or define. * python/py-evts.c (gdbpy_initialize_py_events): Use py-all-events.def. * python/py-events.h (thread_event_object_type): Don't declare. (events_object): Use py-all-events.def. * python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove. Use py-event-types.def. * python/py-event-types.def: New file. * python/py-continueevent.c (create_continue_event_object): Don't declare or define. * python/py-bpevent.c (breakpoint_event_object_type): Don't declare or define. * python/py-all-events.def: New file.
This commit is contained in:
parent
35c61a1dd5
commit
7d221d749c
@ -1,3 +1,39 @@
|
||||
2017-09-11 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* python/python.c (do_start_initialization): Use
|
||||
py-event-types.def to initialize types.
|
||||
Define all object type structures.
|
||||
* python/python-internal.h: Don't declare event initialization
|
||||
functions.
|
||||
* python/py-threadevent.c (thread_event_object_type): Don't
|
||||
define.
|
||||
* python/py-stopevent.c (stop_event_object_type): Don't define.
|
||||
* python/py-signalevent.c (signal_event_object_type): Don't
|
||||
declare or define.
|
||||
* python/py-newobjfileevent.c (new_objfile_event_object_type)
|
||||
(clear_objfiles_event_object_type): Don't declare or define.
|
||||
* python/py-infevents.c (inferior_call_pre_event_object_type)
|
||||
(inferior_call_post_event_object_type)
|
||||
(register_changed_event_object_type)
|
||||
(memory_changed_event_object_type): Don't declare or define.
|
||||
* python/py-inferior.c (new_thread_event_object_type)
|
||||
(new_inferior_event_object_type)
|
||||
(inferior_deleted_event_object_type): Don't declare or define.
|
||||
* python/py-exitedevent.c (exited_event_object_type): Don't
|
||||
declare or define.
|
||||
* python/py-evts.c (gdbpy_initialize_py_events): Use
|
||||
py-all-events.def.
|
||||
* python/py-events.h (thread_event_object_type): Don't declare.
|
||||
(events_object): Use py-all-events.def.
|
||||
* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove. Use
|
||||
py-event-types.def.
|
||||
* python/py-event-types.def: New file.
|
||||
* python/py-continueevent.c (create_continue_event_object): Don't
|
||||
declare or define.
|
||||
* python/py-bpevent.c (breakpoint_event_object_type): Don't
|
||||
declare or define.
|
||||
* python/py-all-events.def: New file.
|
||||
|
||||
2017-09-11 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* python/py-threadevent.c (create_thread_event_object): Return
|
||||
|
40
gdb/python/py-all-events.def
Normal file
40
gdb/python/py-all-events.def
Normal file
@ -0,0 +1,40 @@
|
||||
/* Python event definitions -*- c++ -*-
|
||||
|
||||
Copyright (C) 2017 Free Software Foundation, Inc.
|
||||
|
||||
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/>. */
|
||||
|
||||
/* To use this file, define GDB_PY_DEFINE_EVENT to expand how you
|
||||
like, then include the file.
|
||||
|
||||
GDB_PY_DEFINE_EVENT has one parameter, the name of the event.
|
||||
*/
|
||||
|
||||
GDB_PY_DEFINE_EVENT(stop)
|
||||
GDB_PY_DEFINE_EVENT(cont)
|
||||
GDB_PY_DEFINE_EVENT(exited)
|
||||
GDB_PY_DEFINE_EVENT(new_objfile)
|
||||
GDB_PY_DEFINE_EVENT(clear_objfiles)
|
||||
GDB_PY_DEFINE_EVENT(new_inferior)
|
||||
GDB_PY_DEFINE_EVENT(inferior_deleted)
|
||||
GDB_PY_DEFINE_EVENT(new_thread)
|
||||
GDB_PY_DEFINE_EVENT(inferior_call)
|
||||
GDB_PY_DEFINE_EVENT(memory_changed)
|
||||
GDB_PY_DEFINE_EVENT(register_changed)
|
||||
GDB_PY_DEFINE_EVENT(breakpoint_created)
|
||||
GDB_PY_DEFINE_EVENT(breakpoint_deleted)
|
||||
GDB_PY_DEFINE_EVENT(breakpoint_modified)
|
||||
GDB_PY_DEFINE_EVENT(before_prompt)
|
@ -21,9 +21,6 @@
|
||||
#include "py-stopevent.h"
|
||||
#include "py-ref.h"
|
||||
|
||||
extern PyTypeObject breakpoint_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
/* Create and initialize a BreakpointEvent object. This acquires new
|
||||
references to BREAKPOINT_LIST and FIRST_BP. */
|
||||
|
||||
@ -47,9 +44,3 @@ create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp)
|
||||
|
||||
return breakpoint_event_obj;
|
||||
}
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (breakpoint,
|
||||
"gdb.BreakpointEvent",
|
||||
"BreakpointEvent",
|
||||
"GDB breakpoint stop event object",
|
||||
stop_event_object_type);
|
||||
|
@ -21,9 +21,6 @@
|
||||
#include "py-event.h"
|
||||
#include "py-ref.h"
|
||||
|
||||
extern PyTypeObject continue_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
static gdbpy_ref<>
|
||||
create_continue_event_object (void)
|
||||
{
|
||||
@ -45,9 +42,3 @@ emit_continue_event (ptid_t ptid)
|
||||
return evpy_emit_event (event.get (), gdb_py_events.cont);
|
||||
return -1;
|
||||
}
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (continue,
|
||||
"gdb.ContinueEvent",
|
||||
"ContinueEvent",
|
||||
"GDB continue event object",
|
||||
thread_event_object_type);
|
||||
|
107
gdb/python/py-event-types.def
Normal file
107
gdb/python/py-event-types.def
Normal file
@ -0,0 +1,107 @@
|
||||
/* Python event definitions -*- c++ -*-
|
||||
|
||||
Copyright (C) 2017 Free Software Foundation, Inc.
|
||||
|
||||
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/>. */
|
||||
|
||||
/* To use this file, define GDB_PY_DEFINE_EVENT_TYPE to expand how you
|
||||
like, then include the file.
|
||||
|
||||
Each invocation is of the form:
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base)
|
||||
|
||||
NAME is the name of the event.
|
||||
PY_NAME a string representing what the event should be called in
|
||||
python.
|
||||
DOC Python documentation for the new event type
|
||||
BASE the base event for this event usually just event_object_type.
|
||||
*/
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (breakpoint,
|
||||
"BreakpointEvent",
|
||||
"GDB breakpoint stop event object",
|
||||
stop_event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (continue,
|
||||
"ContinueEvent",
|
||||
"GDB continue event object",
|
||||
thread_event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (exited,
|
||||
"ExitedEvent",
|
||||
"GDB exited event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (new_thread,
|
||||
"NewThreadEvent",
|
||||
"GDB new thread event object",
|
||||
thread_event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (new_inferior,
|
||||
"NewInferiorEvent",
|
||||
"GDB new inferior event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (inferior_deleted,
|
||||
"InferiorDeletedEvent",
|
||||
"GDB inferior deleted event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (inferior_call_pre,
|
||||
"InferiorCallPreEvent",
|
||||
"GDB inferior function pre-call event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (inferior_call_post,
|
||||
"InferiorCallPostEvent",
|
||||
"GDB inferior function post-call event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (register_changed,
|
||||
"RegisterChangedEvent",
|
||||
"GDB register change event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (memory_changed,
|
||||
"MemoryChangedEvent",
|
||||
"GDB memory change event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (new_objfile,
|
||||
"NewObjFileEvent",
|
||||
"GDB new object file event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (clear_objfiles,
|
||||
"ClearObjFilesEvent",
|
||||
"GDB clear object files event object",
|
||||
event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (signal,
|
||||
"SignalEvent",
|
||||
"GDB signal event object",
|
||||
stop_event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (stop,
|
||||
"StopEvent",
|
||||
"GDB stop event object",
|
||||
thread_event_object_type);
|
||||
|
||||
GDB_PY_DEFINE_EVENT_TYPE (thread,
|
||||
"ThreadEvent",
|
||||
"GDB thread event object",
|
||||
event_object_type);
|
@ -26,74 +26,12 @@
|
||||
#include "inferior.h"
|
||||
#include "py-ref.h"
|
||||
|
||||
/* This macro creates the following functions:
|
||||
|
||||
gdbpy_initialize_{NAME}_event
|
||||
Used to add the newly created event type to the gdb module.
|
||||
|
||||
and the python type data structure for the event:
|
||||
|
||||
struct PyTypeObject {NAME}_event_object_type
|
||||
|
||||
NAME is the name of the event.
|
||||
PY_PATH is a string representing the module and python name of
|
||||
the event.
|
||||
PY_NAME a string representing what the event should be called in
|
||||
python.
|
||||
DOC Python documentation for the new event type
|
||||
BASE the base event for this event usually just event_object_type.
|
||||
*/
|
||||
|
||||
#define GDBPY_NEW_EVENT_TYPE(name, py_path, py_name, doc, base) \
|
||||
\
|
||||
PyTypeObject name##_event_object_type \
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object") \
|
||||
= { \
|
||||
PyVarObject_HEAD_INIT (NULL, 0) \
|
||||
py_path, /* tp_name */ \
|
||||
sizeof (event_object), /* tp_basicsize */ \
|
||||
0, /* tp_itemsize */ \
|
||||
evpy_dealloc, /* tp_dealloc */ \
|
||||
0, /* tp_print */ \
|
||||
0, /* tp_getattr */ \
|
||||
0, /* tp_setattr */ \
|
||||
0, /* tp_compare */ \
|
||||
0, /* tp_repr */ \
|
||||
0, /* tp_as_number */ \
|
||||
0, /* tp_as_sequence */ \
|
||||
0, /* tp_as_mapping */ \
|
||||
0, /* tp_hash */ \
|
||||
0, /* tp_call */ \
|
||||
0, /* tp_str */ \
|
||||
0, /* tp_getattro */ \
|
||||
0, /* tp_setattro */ \
|
||||
0, /* tp_as_buffer */ \
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \
|
||||
doc, /* tp_doc */ \
|
||||
0, /* tp_traverse */ \
|
||||
0, /* tp_clear */ \
|
||||
0, /* tp_richcompare */ \
|
||||
0, /* tp_weaklistoffset */ \
|
||||
0, /* tp_iter */ \
|
||||
0, /* tp_iternext */ \
|
||||
0, /* tp_methods */ \
|
||||
0, /* tp_members */ \
|
||||
0, /* tp_getset */ \
|
||||
&base, /* tp_base */ \
|
||||
0, /* tp_dict */ \
|
||||
0, /* tp_descr_get */ \
|
||||
0, /* tp_descr_set */ \
|
||||
0, /* tp_dictoffset */ \
|
||||
0, /* tp_init */ \
|
||||
0 /* tp_alloc */ \
|
||||
}; \
|
||||
\
|
||||
int \
|
||||
gdbpy_initialize_##name##_event (void) \
|
||||
{ \
|
||||
return gdbpy_initialize_event_generic (&name##_event_object_type, \
|
||||
py_name); \
|
||||
}
|
||||
/* Declare all event types. */
|
||||
#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
|
||||
extern PyTypeObject name##_event_object_type \
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
#include "py-event-types.def"
|
||||
#undef GDB_PY_DEFINE_EVENT_TYPE
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -24,9 +24,6 @@
|
||||
#include "python-internal.h"
|
||||
#include "inferior.h"
|
||||
|
||||
extern PyTypeObject thread_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
/* Stores a list of objects to be notified when the event for which this
|
||||
registry tracks occurs. */
|
||||
|
||||
@ -42,21 +39,10 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
eventregistry_object *stop;
|
||||
eventregistry_object *cont;
|
||||
eventregistry_object *exited;
|
||||
eventregistry_object *new_objfile;
|
||||
eventregistry_object *clear_objfiles;
|
||||
eventregistry_object *new_inferior;
|
||||
eventregistry_object *inferior_deleted;
|
||||
eventregistry_object *new_thread;
|
||||
eventregistry_object *inferior_call;
|
||||
eventregistry_object *memory_changed;
|
||||
eventregistry_object *register_changed;
|
||||
eventregistry_object *breakpoint_created;
|
||||
eventregistry_object *breakpoint_deleted;
|
||||
eventregistry_object *breakpoint_modified;
|
||||
eventregistry_object *before_prompt;
|
||||
#define GDB_PY_DEFINE_EVENT(name) \
|
||||
eventregistry_object *name;
|
||||
#include "py-all-events.def"
|
||||
#undef GDB_PY_DEFINE_EVENT
|
||||
|
||||
PyObject *module;
|
||||
|
||||
|
@ -62,55 +62,11 @@ gdbpy_initialize_py_events (void)
|
||||
if (!gdb_py_events.module)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.stop, "stop") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.cont, "cont") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.exited, "exited") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.inferior_call,
|
||||
"inferior_call") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.memory_changed,
|
||||
"memory_changed") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.register_changed,
|
||||
"register_changed") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.new_objfile, "new_objfile") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.clear_objfiles, "clear_objfiles") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.new_inferior, "new_inferior") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.inferior_deleted, "inferior_deleted") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.new_thread, "new_thread") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.breakpoint_created,
|
||||
"breakpoint_created") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.breakpoint_deleted,
|
||||
"breakpoint_deleted") < 0)
|
||||
return -1;
|
||||
if (add_new_registry (&gdb_py_events.breakpoint_modified,
|
||||
"breakpoint_modified") < 0)
|
||||
return -1;
|
||||
|
||||
if (add_new_registry (&gdb_py_events.before_prompt, "before_prompt") < 0)
|
||||
#define GDB_PY_DEFINE_EVENT(name) \
|
||||
if (add_new_registry (&gdb_py_events.name, #name) < 0) \
|
||||
return -1;
|
||||
#include "py-all-events.def"
|
||||
#undef GDB_PY_DEFINE_EVENT
|
||||
|
||||
if (gdb_pymodule_addobject (gdb_module,
|
||||
"events",
|
||||
|
@ -20,9 +20,6 @@
|
||||
#include "defs.h"
|
||||
#include "py-event.h"
|
||||
|
||||
extern PyTypeObject exited_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
static PyObject *
|
||||
create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
|
||||
{
|
||||
@ -67,10 +64,3 @@ emit_exited_event (const LONGEST *exit_code, struct inferior *inf)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (exited,
|
||||
"gdb.ExitedEvent",
|
||||
"ExitedEvent",
|
||||
"GDB exited event object",
|
||||
event_object_type);
|
||||
|
@ -30,13 +30,6 @@
|
||||
#include "py-event.h"
|
||||
#include "py-stopevent.h"
|
||||
|
||||
extern PyTypeObject new_thread_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject new_inferior_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject inferior_deleted_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
struct threadlist_entry {
|
||||
thread_object *thread_obj;
|
||||
struct threadlist_entry *next;
|
||||
@ -1042,19 +1035,3 @@ PyTypeObject membuf_object_type = {
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
};
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (new_thread,
|
||||
"gdb.NewThreadEvent",
|
||||
"NewThreadEvent",
|
||||
"GDB new thread event object",
|
||||
thread_event_object_type);
|
||||
GDBPY_NEW_EVENT_TYPE (new_inferior,
|
||||
"gdb.NewInferiorEvent",
|
||||
"NewInferiorEvent",
|
||||
"GDB new inferior event object",
|
||||
event_object_type);
|
||||
GDBPY_NEW_EVENT_TYPE (inferior_deleted,
|
||||
"gdb.InferiorDeletedEvent",
|
||||
"InferiorDeletedEvent",
|
||||
"GDB inferior deleted event object",
|
||||
event_object_type);
|
||||
|
@ -21,15 +21,6 @@
|
||||
#include "py-event.h"
|
||||
#include "py-ref.h"
|
||||
|
||||
extern PyTypeObject inferior_call_pre_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject inferior_call_post_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject register_changed_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject memory_changed_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
/* Construct either a gdb.InferiorCallPreEvent or a
|
||||
gdb.InferiorCallPostEvent. */
|
||||
|
||||
@ -172,28 +163,3 @@ emit_register_changed_event (struct frame_info* frame, int regnum)
|
||||
return evpy_emit_event (event.get (), gdb_py_events.register_changed);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (inferior_call_pre,
|
||||
"gdb.InferiorCallPreEvent",
|
||||
"InferiorCallPreEvent",
|
||||
"GDB inferior function pre-call event object",
|
||||
event_object_type);
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (inferior_call_post,
|
||||
"gdb.InferiorCallPostEvent",
|
||||
"InferiorCallPostEvent",
|
||||
"GDB inferior function post-call event object",
|
||||
event_object_type);
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (register_changed,
|
||||
"gdb.RegisterChangedEvent",
|
||||
"RegisterChangedEvent",
|
||||
"GDB register change event object",
|
||||
event_object_type);
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (memory_changed,
|
||||
"gdb.MemoryChangedEvent",
|
||||
"MemoryChangedEvent",
|
||||
"GDB memory change event object",
|
||||
event_object_type);
|
||||
|
@ -20,11 +20,6 @@
|
||||
#include "defs.h"
|
||||
#include "py-event.h"
|
||||
|
||||
extern PyTypeObject new_objfile_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject clear_objfiles_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
static PyObject *
|
||||
create_new_objfile_event_object (struct objfile *objfile)
|
||||
{
|
||||
@ -62,11 +57,6 @@ emit_new_objfile_event (struct objfile *objfile)
|
||||
return -1;
|
||||
}
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (new_objfile,
|
||||
"gdb.NewObjFileEvent",
|
||||
"NewObjFileEvent",
|
||||
"GDB new object file event object",
|
||||
event_object_type);
|
||||
|
||||
/* Subroutine of emit_clear_objfiles_event to simplify it. */
|
||||
|
||||
@ -107,9 +97,3 @@ emit_clear_objfiles_event (void)
|
||||
return evpy_emit_event (event.get (), gdb_py_events.clear_objfiles);
|
||||
return -1;
|
||||
}
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (clear_objfiles,
|
||||
"gdb.ClearObjFilesEvent",
|
||||
"ClearObjFilesEvent",
|
||||
"GDB clear object files event object",
|
||||
event_object_type);
|
||||
|
@ -20,9 +20,6 @@
|
||||
#include "defs.h"
|
||||
#include "py-stopevent.h"
|
||||
|
||||
extern PyTypeObject signal_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
|
||||
gdbpy_ref<>
|
||||
create_signal_event_object (enum gdb_signal stop_signal)
|
||||
{
|
||||
@ -45,9 +42,3 @@ create_signal_event_object (enum gdb_signal stop_signal)
|
||||
|
||||
return signal_event_obj;
|
||||
}
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (signal,
|
||||
"gdb.SignalEvent",
|
||||
"SignalEvent",
|
||||
"GDB signal event object",
|
||||
stop_event_object_type);
|
||||
|
@ -96,9 +96,3 @@ emit_stop_event (struct bpstats *bs, enum gdb_signal stop_signal)
|
||||
|
||||
return evpy_emit_event (stop_event_obj.get (), gdb_py_events.stop);
|
||||
}
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (stop,
|
||||
"gdb.StopEvent",
|
||||
"StopEvent",
|
||||
"GDB stop event object",
|
||||
thread_event_object_type);
|
||||
|
@ -68,9 +68,3 @@ create_thread_event_object (PyTypeObject *py_type, PyObject *thread)
|
||||
|
||||
return thread_event_obj;
|
||||
}
|
||||
|
||||
GDBPY_NEW_EVENT_TYPE (thread,
|
||||
"gdb.ThreadEvent",
|
||||
"ThreadEvent",
|
||||
"GDB thread event object",
|
||||
event_object_type);
|
||||
|
@ -373,8 +373,6 @@ extern PyTypeObject symbol_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symbol_object");
|
||||
extern PyTypeObject event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject stop_event_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
|
||||
extern PyTypeObject breakpoint_object_type
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_object");
|
||||
extern PyTypeObject frame_object_type
|
||||
@ -606,36 +604,6 @@ int gdbpy_initialize_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_py_events (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_stop_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_signal_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_breakpoint_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_continue_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_inferior_call_pre_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_inferior_call_post_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_register_changed_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_memory_changed_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_exited_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_thread_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_new_objfile_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_clear_objfiles_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_new_inferior_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_inferior_deleted_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_new_thread_event (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_arch (void)
|
||||
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
|
||||
int gdbpy_initialize_xmethods (void)
|
||||
|
@ -1591,26 +1591,17 @@ do_start_initialization ()
|
||||
|| gdbpy_initialize_eventregistry () < 0
|
||||
|| gdbpy_initialize_py_events () < 0
|
||||
|| gdbpy_initialize_event () < 0
|
||||
|| gdbpy_initialize_stop_event () < 0
|
||||
|| gdbpy_initialize_signal_event () < 0
|
||||
|| gdbpy_initialize_breakpoint_event () < 0
|
||||
|| gdbpy_initialize_continue_event () < 0
|
||||
|| gdbpy_initialize_inferior_call_pre_event () < 0
|
||||
|| gdbpy_initialize_inferior_call_post_event () < 0
|
||||
|| gdbpy_initialize_register_changed_event () < 0
|
||||
|| gdbpy_initialize_memory_changed_event () < 0
|
||||
|| gdbpy_initialize_exited_event () < 0
|
||||
|| gdbpy_initialize_thread_event () < 0
|
||||
|| gdbpy_initialize_new_objfile_event () < 0
|
||||
|| gdbpy_initialize_clear_objfiles_event () < 0
|
||||
|| gdbpy_initialize_new_inferior_event () < 0
|
||||
|| gdbpy_initialize_inferior_deleted_event () < 0
|
||||
|| gdbpy_initialize_new_thread_event () < 0
|
||||
|| gdbpy_initialize_arch () < 0
|
||||
|| gdbpy_initialize_xmethods () < 0
|
||||
|| gdbpy_initialize_unwind () < 0)
|
||||
return false;
|
||||
|
||||
#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
|
||||
if (gdbpy_initialize_event_generic (&name##_event_object_type, py_name) < 0) \
|
||||
return false;
|
||||
#include "py-event-types.def"
|
||||
#undef GDB_PY_DEFINE_EVENT_TYPE
|
||||
|
||||
gdbpy_to_string_cst = PyString_FromString ("to_string");
|
||||
if (gdbpy_to_string_cst == NULL)
|
||||
return false;
|
||||
@ -1963,4 +1954,51 @@ struct PyModuleDef python_GdbModuleDef =
|
||||
NULL
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Define all the event objects. */
|
||||
#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
|
||||
PyTypeObject name##_event_object_type \
|
||||
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object") \
|
||||
= { \
|
||||
PyVarObject_HEAD_INIT (NULL, 0) \
|
||||
"gdb." py_name, /* tp_name */ \
|
||||
sizeof (event_object), /* tp_basicsize */ \
|
||||
0, /* tp_itemsize */ \
|
||||
evpy_dealloc, /* tp_dealloc */ \
|
||||
0, /* tp_print */ \
|
||||
0, /* tp_getattr */ \
|
||||
0, /* tp_setattr */ \
|
||||
0, /* tp_compare */ \
|
||||
0, /* tp_repr */ \
|
||||
0, /* tp_as_number */ \
|
||||
0, /* tp_as_sequence */ \
|
||||
0, /* tp_as_mapping */ \
|
||||
0, /* tp_hash */ \
|
||||
0, /* tp_call */ \
|
||||
0, /* tp_str */ \
|
||||
0, /* tp_getattro */ \
|
||||
0, /* tp_setattro */ \
|
||||
0, /* tp_as_buffer */ \
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \
|
||||
doc, /* tp_doc */ \
|
||||
0, /* tp_traverse */ \
|
||||
0, /* tp_clear */ \
|
||||
0, /* tp_richcompare */ \
|
||||
0, /* tp_weaklistoffset */ \
|
||||
0, /* tp_iter */ \
|
||||
0, /* tp_iternext */ \
|
||||
0, /* tp_methods */ \
|
||||
0, /* tp_members */ \
|
||||
0, /* tp_getset */ \
|
||||
&base, /* tp_base */ \
|
||||
0, /* tp_dict */ \
|
||||
0, /* tp_descr_get */ \
|
||||
0, /* tp_descr_set */ \
|
||||
0, /* tp_dictoffset */ \
|
||||
0, /* tp_init */ \
|
||||
0 /* tp_alloc */ \
|
||||
};
|
||||
#include "py-event-types.def"
|
||||
#undef GDB_PY_DEFINE_EVENT_TYPE
|
||||
|
||||
#endif /* HAVE_PYTHON */
|
||||
|
Loading…
Reference in New Issue
Block a user