This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 3/3] Make it simpler to add events to Python
- From: Simon Marchi <simon dot marchi at polymtl dot ca>
- To: Tom Tromey <tom at tromey dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 09 Sep 2017 19:05:05 +0200
- Subject: Re: [RFA 3/3] Make it simpler to add events to Python
- Authentication-results: sourceware.org; auth=none
- References: <20170909003353.25883-1-tom@tromey.com> <20170909003353.25883-4-tom@tromey.com>
On 2017-09-09 02:33, Tom Tromey wrote:
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".
Hi Tom,
This looks great. The patch is ok, I have two little nits below, which
you can address before pushing if you agree.
diff --git a/gdb/python/py-event-types.def
b/gdb/python/py-event-types.def
new file mode 100644
index 0000000..d35cbe5
--- /dev/null
+++ b/gdb/python/py-event-types.def
@@ -0,0 +1,120 @@
+/* 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.
+
I think it would be clearer if you added the macro "prototype" here,
otherwise the parameter names refer to nothing.
GDB_PY_DEFINE_EVENT_TYPE (name, py_path, py_bame, doc, base) ...
+ 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.
+*/
+
+GDB_PY_DEFINE_EVENT_TYPE (breakpoint,
+ "gdb.BreakpointEvent",
+ "BreakpointEvent",
The py_path and py_name are duplicated everywhere. We could get rid of
py_path. At the only place where it is used, we can replace it with
"gdb." py_name
Thanks,
Simon