* [RFA] Handle runtime loader dyn sym resolution in reverse
@ 2008-10-25 3:04 Michael Snyder
2008-10-25 6:50 ` teawater
2008-10-25 16:10 ` Joel Brobecker
0 siblings, 2 replies; 6+ messages in thread
From: Michael Snyder @ 2008-10-25 3:04 UTC (permalink / raw)
To: gdb-patches, teawater
[-- Attachment #1: Type: text/plain, Size: 298 bytes --]
This is for both the main trunk and the record/replay branch
(so I'd appreciate review by both Hui and a global maintainer).
It fixes a bug where you try to "reverse-next" over a
first-time dynamic function call (eg. printf). Infrun
would get lost when it stepped into the jump table
backwards.
[-- Attachment #2: shmain.txt --]
[-- Type: text/plain, Size: 1210 bytes --]
2008-10-24 Michael Snyder <msnyder@vmware.com>
* infrun.c (handle_inferior_event): Handle dynamic symbol
resolution in reverse.
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.322.2.14
diff -u -p -r1.322.2.14 infrun.c
--- infrun.c 23 Oct 2008 23:24:45 -0000 1.322.2.14
+++ infrun.c 25 Oct 2008 02:57:37 -0000
@@ -3212,6 +3212,22 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
if (execution_direction == EXEC_REVERSE)
{
struct symtab_and_line sr_sal;
+
+ if (ecs->stop_func_start == 0
+ && in_solib_dynsym_resolve_code (stop_pc))
+ {
+ /* Stepped into runtime loader dynamic symbol
+ resolution code. Since we're in reverse,
+ we have already backed up through the runtime
+ loader and the dynamic function. This is just
+ the trampoline (jump table).
+
+ Just keep stepping, we'll soon be home.
+ */
+ keep_going (ecs);
+ return;
+ }
+ /* Normal (staticly linked) function call return. */
init_sal (&sr_sal);
sr_sal.pc = ecs->stop_func_start;
insert_step_resume_breakpoint_at_sal (sr_sal, null_frame_id);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Handle runtime loader dyn sym resolution in reverse
2008-10-25 3:04 [RFA] Handle runtime loader dyn sym resolution in reverse Michael Snyder
@ 2008-10-25 6:50 ` teawater
2008-10-25 16:10 ` Joel Brobecker
1 sibling, 0 replies; 6+ messages in thread
From: teawater @ 2008-10-25 6:50 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Great! It's OK to me. Please check it into 0930 branch and main tree.
On Sat, Oct 25, 2008 at 10:58, Michael Snyder <msnyder@vmware.com> wrote:
> This is for both the main trunk and the record/replay branch
> (so I'd appreciate review by both Hui and a global maintainer).
>
> It fixes a bug where you try to "reverse-next" over a
> first-time dynamic function call (eg. printf). Infrun
> would get lost when it stepped into the jump table
> backwards.
>
>
> 2008-10-24 Michael Snyder <msnyder@vmware.com>
>
> * infrun.c (handle_inferior_event): Handle dynamic symbol
> resolution in reverse.
>
> Index: infrun.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/infrun.c,v
> retrieving revision 1.322.2.14
> diff -u -p -r1.322.2.14 infrun.c
> --- infrun.c 23 Oct 2008 23:24:45 -0000 1.322.2.14
> +++ infrun.c 25 Oct 2008 02:57:37 -0000
> @@ -3212,6 +3212,22 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
> if (execution_direction == EXEC_REVERSE)
> {
> struct symtab_and_line sr_sal;
> +
> + if (ecs->stop_func_start == 0
> + && in_solib_dynsym_resolve_code (stop_pc))
> + {
> + /* Stepped into runtime loader dynamic symbol
> + resolution code. Since we're in reverse,
> + we have already backed up through the runtime
> + loader and the dynamic function. This is just
> + the trampoline (jump table).
> +
> + Just keep stepping, we'll soon be home.
> + */
> + keep_going (ecs);
> + return;
> + }
> + /* Normal (staticly linked) function call return. */
> init_sal (&sr_sal);
> sr_sal.pc = ecs->stop_func_start;
> insert_step_resume_breakpoint_at_sal (sr_sal, null_frame_id);
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Handle runtime loader dyn sym resolution in reverse
2008-10-25 3:04 [RFA] Handle runtime loader dyn sym resolution in reverse Michael Snyder
2008-10-25 6:50 ` teawater
@ 2008-10-25 16:10 ` Joel Brobecker
2008-10-26 14:15 ` teawater
2008-10-27 4:48 ` Michael Snyder
1 sibling, 2 replies; 6+ messages in thread
From: Joel Brobecker @ 2008-10-25 16:10 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches, teawater
> This is for both the main trunk and the record/replay branch
> (so I'd appreciate review by both Hui and a global maintainer).
I took a look. The patch itself is missing a little bit of context
(in terms of the code), so I wasn't sure whether I was looking at
inserting this hunk at the right place, but I think I found it:
if (ecs->event_thread->step_over_calls == STEP_OVER_ALL)
{
/* We're doing a "next".
Normal (forward) execution: set a breakpoint at the
callee's return address (the address at which the caller
will resume).
Reverse (backward) execution. set the step-resume
breakpoint at the start of the function that we just
stepped into (backwards), and continue to there. When we
get there, we'll need to single-step back to the caller. */
if (execution_direction == EXEC_REVERSE)
> 2008-10-24 Michael Snyder <msnyder@vmware.com>
>
> * infrun.c (handle_inferior_event): Handle dynamic symbol
> resolution in reverse.
Looks OK to me, but I don't understand why you check that stop_func_start
is zero. If I were to make a guess, it would be to quickly dismiss
the case were we reverse stepped into a function call, and so don't
need to check for trampolines (in other words, a CPU saver).
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Handle runtime loader dyn sym resolution in reverse
2008-10-25 16:10 ` Joel Brobecker
@ 2008-10-26 14:15 ` teawater
2008-10-27 4:48 ` Michael Snyder
1 sibling, 0 replies; 6+ messages in thread
From: teawater @ 2008-10-26 14:15 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Michael Snyder, gdb-patches
Hi Joel,
This patch fix the bug that I send in
http://sourceware.org/ml/gdb-patches/2008-10/msg00485.html
Thanks,
Hui
On Sun, Oct 26, 2008 at 00:09, Joel Brobecker <brobecker@adacore.com> wrote:
>> This is for both the main trunk and the record/replay branch
>> (so I'd appreciate review by both Hui and a global maintainer).
>
> I took a look. The patch itself is missing a little bit of context
> (in terms of the code), so I wasn't sure whether I was looking at
> inserting this hunk at the right place, but I think I found it:
>
> if (ecs->event_thread->step_over_calls == STEP_OVER_ALL)
> {
> /* We're doing a "next".
>
> Normal (forward) execution: set a breakpoint at the
> callee's return address (the address at which the caller
> will resume).
>
> Reverse (backward) execution. set the step-resume
> breakpoint at the start of the function that we just
> stepped into (backwards), and continue to there. When we
> get there, we'll need to single-step back to the caller. */
>
> if (execution_direction == EXEC_REVERSE)
>
>> 2008-10-24 Michael Snyder <msnyder@vmware.com>
>>
>> * infrun.c (handle_inferior_event): Handle dynamic symbol
>> resolution in reverse.
>
> Looks OK to me, but I don't understand why you check that stop_func_start
> is zero. If I were to make a guess, it would be to quickly dismiss
> the case were we reverse stepped into a function call, and so don't
> need to check for trampolines (in other words, a CPU saver).
>
> --
> Joel
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Handle runtime loader dyn sym resolution in reverse
2008-10-25 16:10 ` Joel Brobecker
2008-10-26 14:15 ` teawater
@ 2008-10-27 4:48 ` Michael Snyder
2008-10-27 5:00 ` Michael Snyder
1 sibling, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2008-10-27 4:48 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, teawater
Joel Brobecker wrote:
>
>> 2008-10-24 Michael Snyder <msnyder@vmware.com>
>>
>> * infrun.c (handle_inferior_event): Handle dynamic symbol
>> resolution in reverse.
>
> Looks OK to me, but I don't understand why you check that stop_func_start
> is zero. If I were to make a guess, it would be to quickly dismiss
> the case were we reverse stepped into a function call, and so don't
> need to check for trampolines (in other words, a CPU saver).
Correct, but it's more than a CPU saver.
If we are in a function (stop_func_start is non-zero),
then we can set a step_resume breakpoint and continue,
which is way faster than single stepping.
We single-step only when we have to, ie. when we have
actually stepped into the fixup jump table.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] Handle runtime loader dyn sym resolution in reverse
2008-10-27 4:48 ` Michael Snyder
@ 2008-10-27 5:00 ` Michael Snyder
0 siblings, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2008-10-27 5:00 UTC (permalink / raw)
To: Michael Snyder; +Cc: Joel Brobecker, gdb-patches, teawater
Michael Snyder wrote:
> Joel Brobecker wrote:
>
>>> 2008-10-24 Michael Snyder <msnyder@vmware.com>
>>>
>>> * infrun.c (handle_inferior_event): Handle dynamic symbol
>>> resolution in reverse.
>> Looks OK to me, but I don't understand why you check that stop_func_start
>> is zero. If I were to make a guess, it would be to quickly dismiss
>> the case were we reverse stepped into a function call, and so don't
>> need to check for trampolines (in other words, a CPU saver).
>
> Correct, but it's more than a CPU saver.
> If we are in a function (stop_func_start is non-zero),
> then we can set a step_resume breakpoint and continue,
> which is way faster than single stepping.
>
> We single-step only when we have to, ie. when we have
> actually stepped into the fixup jump table.
The big difference is, 'in_solib_dynsym_resolve_code'
returns true when we're in the dynamic loader function
"_dl_runtime_resolve", but we really don't want to single
step through that. Since it's a function with a minsym,
we can jump over it just like any other function -- but
then we hit the jump table and have to singlestep a few
times.
The test case was sent to me by teawater, who tried to
reverse-next over a printf. GDB handled the printf call
fine, then it stepped into _dl_runtime_resolve, which it
also handled, but it stumbled over the jump table.
Committed, by the way.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-10-27 5:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-25 3:04 [RFA] Handle runtime loader dyn sym resolution in reverse Michael Snyder
2008-10-25 6:50 ` teawater
2008-10-25 16:10 ` Joel Brobecker
2008-10-26 14:15 ` teawater
2008-10-27 4:48 ` Michael Snyder
2008-10-27 5:00 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox