This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Spotting inferior function calls from Python
- From: Doug Evans <dje at google dot com>
- To: Nick Bull <nicholaspbull at gmail dot com>
- Cc: gdb <gdb at sourceware dot org>
- Date: Tue, 9 Apr 2013 09:19:20 -0700
- Subject: Re: Spotting inferior function calls from Python
- References: <CABbKtXsjFYs6ywFgGcw6SzmiWuM1CgK8=mh8Q5eaR_sUXczfUw at mail dot gmail dot com>
On Fri, Apr 5, 2013 at 4:48 AM, Nick Bull <nicholaspbull@gmail.com> wrote:
> Hi,
>
> I would like my Python code to be notified when gdb causes a function to be
> run on the inferior outside of the normal program flow. For example, this
> could be used to warn the user that any side-effects might change future
> program execution.
>
> I can't simply hook the 'call' command because there are many other
> commands which could in principle invoke inferior functions, and too many
> false positives would be inconvenient.
>
> It looks as though all such function calls happen via
> call_function_by_hand. So the simplest approach would be for me to create a
> new observer type which is notified in call_function_by_hand, and a
> corresponding Python event type. Does that sound sensible?
>
> And is such a patch likely to be accepted for inclusion, assuming all
> formatting and copyright assignment requirements are met?
Is such a warning sufficiently useful?
And if it is useful, it might make more sense to just add it to gdb proper.
Are there other uses for such an observer?
I'm not sure. [I'm not objecting, just requesting more data.]
Plus for full coverage you need to intercept not just hand-called
functions but target memory and register writes (and reads if they're
to device registers and such, but one could punt on that in the first
pass, I think).
fwiw, One feature I would like to see added is the ability to
intercept hand-called functions and run some Python code instead.
[I mightn't implement the warning using this. Just fyi.]