From: Kevin Pouget <kevin.pouget@gmail.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFC - Python] New ObjFile event
Date: Mon, 28 Mar 2011 08:51:00 -0000 [thread overview]
Message-ID: <AANLkTikMWKaZ98AHREx7zBPSW07KxkjLd3vL7yoMnSFk@mail.gmail.com> (raw)
In-Reply-To: <AANLkTin=YO__Mz88HPFoT7a6_it5BxthnUdODJMs52eG@mail.gmail.com>
sorry, gdb/python/py-newobjfileevent.c has not been included in the
patch, here is its content:
-----
/* Python interface to new object file loading events.
Copyright (C) 2009, 2010, 2011 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/>. */
#include "py-event.h"
static PyTypeObject new_objfile_event_object_type;
PyObject *
create_new_objfile_event_object (void)
{
return create_event_object (&new_objfile_event_object_type);
}
/* Callback function which notifies observers when a new objfile event occurs.
This function will create a new Python new_objfile event object.
Return -1 if emit fails. */
int
emit_new_objfile_event (struct objfile *objfile)
{
PyObject *event;
if (evregpy_no_listeners_p (gdb_py_events.newobjfile))
return 0;
event = create_new_objfile_event_object ();
if (event)
return evpy_emit_event (event, gdb_py_events.newobjfile);
return -1;
}
GDBPY_NEW_EVENT_TYPE (new_objfile,
"gdb.NewObjFileEvent",
"NewObjFileEvent",
"GDB new object file event object",
event_object_type,
static);
---
On Mon, Mar 28, 2011 at 4:06 AM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> Hello,
>
> following this discussion at
> http://sourceware.org/ml/gdb/2011-03/msg00136.html, I would like to
> suggest a patch for the Python event system. Based on the ''exited",
> "cont", ... events, this patch allows a python script to register an
> interest to the loading of new object files in the debuggee. GDB
> observer "observer_attach_new_objfile" is used to trigger the Python
> callback.
>
> This patch completes the auto-loading feature
> (http://sourceware.org/gdb/current/onlinedocs/gdb/objfile_002dgdb_002epy-file.html#objfile_002dgdb_002epy-file),
> and, likewise, allows Python's "gdb.current_objfile ()" to return the current
> object file.
>
> Here is an example of it utilization:
>
>> def obj_handler (event):
>> if gdb.current_objfile () is not None:
>> print "-->",gdb.current_objfile ().filename
>> else:
>> print "---------------->Cleanup"
>>
>> gdb.events.newobjfile.connect (obj_handler)
>
>
> There is still one thing I'm not happy with in the code, it's how to
> 'properly' access "gdbpy_current_objfile" ? I commented out "static"
> and declared it "extern" when I needed it, but that's certainly not
> the best way:
>
> gdb/python/python.c
> /*static*/ struct objfile *gdbpy_current_objfile;
> gdb/python/py-inferior.c
> extern struct objfile *gdbpy_current_objfile;
>
>
> please let me know what you thing about it
>
> Cordially,
>
> Kevin
>
next prev parent reply other threads:[~2011-03-28 8:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AANLkTimybJtpUzy13FuLxQQMJfeWQuf3-cgqGmu23Bq5@mail.gmail.com>
2011-03-28 8:49 ` Kevin Pouget
2011-03-28 8:51 ` Kevin Pouget [this message]
2011-03-28 9:00 ` Phil Muldoon
2011-03-28 8:54 ` Phil Muldoon
2011-03-28 9:03 ` Phil Muldoon
2011-03-28 10:02 ` Kevin Pouget
2011-03-28 20:28 ` Tom Tromey
2011-03-29 11:11 ` Kevin Pouget
2011-03-30 11:32 ` Kevin Pouget
2011-03-30 12:14 ` Phil Muldoon
2011-03-30 12:15 ` Kevin Pouget
2011-05-19 20:21 ` Tom Tromey
2011-05-23 8:44 ` Kevin Pouget
2011-09-01 9:56 ` Kevin Pouget
2011-09-01 11:01 ` Eli Zaretskii
2011-09-01 11:09 ` Kevin Pouget
2011-10-03 16:32 ` Tom Tromey
[not found] ` <CAPftXULEe9R4m7tF=vtJe6NTXHSFAkXgsHCPb3r0mU4wKx0FFg@mail.gmail.com>
2011-10-04 8:25 ` Kevin Pouget
2011-10-04 17:02 ` Tom Tromey
2011-10-05 11:10 ` Kevin Pouget
2011-10-05 14:16 ` Tom Tromey
2011-10-05 17:40 ` Eli Zaretskii
2011-10-07 7:40 ` Kevin Pouget
2011-10-07 7:54 ` Kevin Pouget
2011-10-07 8:37 Andreas Tobler
2011-10-07 8:44 ` Kevin Pouget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTikMWKaZ98AHREx7zBPSW07KxkjLd3vL7yoMnSFk@mail.gmail.com \
--to=kevin.pouget@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox