This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Python API: Add gdb.is_in_prologue and gdb.is_in_epilogue.
- From: Doug Evans <dje at google dot com>
- To: Martin Galvan <martin dot galvan at tallertechnologies dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 22 Oct 2014 12:23:44 -0700
- Subject: Re: [PATCH] Python API: Add gdb.is_in_prologue and gdb.is_in_epilogue.
- Authentication-results: sourceware.org; auth=none
- References: <1413986485-4673-1-git-send-email-martin dot galvan at tallertechnologies dot com>
Martin Galvan writes:
> Added two new functions to the Python API: gdb.is_in_prologue and gdb.is_in_epilogue.
> These expose the in_prologue and gdbarch_in_function_epilogue_p functions
> respectively, which are useful for checking if the values of local variables are
> valid when single-stepping through machine instructions.
>
> Also added tests for gdb.is_in_prologue only. The reason of this is that
> the tests work by checking the first instruction of a given function, as that's
> conventionally part of the prologue. Testing gdb.is_in_epilogue seems to be
> architecture-dependant (for instance, the last instruction of a function is
> reported as part of an epilogue by gdbarch_in_function_epilogue_p for ARM,
> but not always for x86_64), so I didn't include a test for it.
Hi.
We should have a test for is_in_epilogue anyway.
The canonical choice is to just make it amd64-linux specific.
API functions like these are problematic.
Users don't expect API functions to be heuristic-based,
and that is all these can ever be in the general case.
The patch does try to provide the user some guarantees
("however if the result is @code{False} you can be sure
@value{GDBN} is right."),
but it's not clear to me this will be true in the general case.
I may have missed something so I'm certainly willing to be
persuaded otherwise.
I might be ok with this patch if the functions were named something like
"maybe_is_in_prologue" and "maybe_is_in_epilogue".
That way they scream to the user (and future code readers) "Heads Up!"