From: Maxim Grigoriev <maxim@tensilica.com>
To: Jim Blandy <jimb@codesourcery.com>
Cc: gdb@sourceware.org, Marc Gauthier <marc@tensilica.com>,
Ross Morley <ross@tensilica.com>
Subject: Re: Understanding GDB frames
Date: Wed, 23 May 2007 01:01:00 -0000 [thread overview]
Message-ID: <4653924D.5030304@hq.tensilica.com> (raw)
In-Reply-To: <m34pm476qn.fsf@codesourcery.com>
>> I think distinguishing frames can be improved by using the third
>> argument of frame_id, which is a "special address". Most of the
>> implementations don't use it.
> What would you put there?
Let's look at the following frame ID template:
{
stack_addr = <frame pointer of the frame>
code_addr = <PC of the entry point of the frame function>
special_addr = (Frame_Level << 24) | (<Return Address> & 0xffffff)
}
Where Frame_Level == frame_relative_level (frame) & 0xff .
I think it's going to cover
1) Recursion ;
2) void foo (void) { }
void bar (void) { }
main ()
{
int i;
for (i = 0; i < 2; i++)
{
void (*f) (void) = i ? foo : bar;
f ();
}
}
3) { foo(); foo(); }
4) All the cases when function is called from different levels;
But, this case is still a problem :
5) for (i = 0; i < 10; i++) foo ();
Anyway, doesn't it look like a reasonably inexpensive improvement ?
-- Maxim
Jim Blandy wrote:
> Maxim Grigoriev <maxim@tensilica.com> writes:
>
>>> It's worth pointing out that the 'PC' in a frame ID isn't the current
>>> PC within the function. It's always the PC of the function's entry
>>> point, so that stepping within a function doesn't cause the frame ID
>>> to change. Usually it's a PC value returned by 'frame_func_unwind',
>>> which takes care of calling get_pc_function_start for you.
>>>
>> We've been using a function return address instead of the PC of the
>> function's entry, and it works just fine.
>>
>
> Hmm. Consider:
>
> void foo (void) { }
> void bar (void) { }
>
> main ()
> {
> int i;
>
> for (i = 0; i < 2; i++)
> {
> void (*f) (void) = i ? foo : bar;
> f ();
> }
> }
>
> So, main will call bar first, then foo. Both calls will have
> identical incoming sp's, and identical return addresses.
>
> Using the callee's entry point is more direct; there's less
> opportunity for things to go wrong. And the rest of GDB is already
> working to cover up the shortcomings of that approach. :)
>
>
>> I think distinguishing frames can be improved by using the third
>> argument of frame_id, which is a "special address". Most of the
>> implementations don't use it.
>>
>
> What would you put there?
>
>
next prev parent reply other threads:[~2007-05-23 1:01 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-21 22:24 Maxim Grigoriev
2007-05-21 23:28 ` Ross Morley
2007-05-22 2:05 ` Nick Roberts
2007-05-22 2:31 ` Daniel Jacobowitz
2007-05-22 2:51 ` Nick Roberts
2007-05-22 10:58 ` Daniel Jacobowitz
2007-05-22 8:40 ` Ross Morley
2007-05-22 16:10 ` Marc Gauthier
2007-05-22 16:36 ` Daniel Jacobowitz
2007-05-22 18:14 ` Vladimir Prus
2007-05-22 18:33 ` Jim Ingham
2007-05-22 18:36 ` Daniel Jacobowitz
2007-05-23 21:45 ` Jim Blandy
2007-05-22 17:20 ` Ross Morley
2007-05-22 20:24 ` Nick Roberts
2007-05-22 21:12 ` Maxim Grigoriev
2007-05-22 1:40 ` Joel Brobecker
2007-05-22 2:29 ` Daniel Jacobowitz
2007-05-22 18:37 ` Jim Blandy
2007-05-22 19:17 ` Maxim Grigoriev
2007-05-22 20:25 ` Nick Roberts
2007-05-22 20:33 ` Ross Morley
2007-05-22 20:45 ` Maxim Grigoriev
2007-05-22 21:26 ` Nick Roberts
2007-05-23 7:00 ` Eli Zaretskii
2007-05-23 10:48 ` Daniel Jacobowitz
2007-05-23 12:44 ` Eli Zaretskii
2007-05-22 23:56 ` Jim Blandy
2007-05-23 1:01 ` Maxim Grigoriev [this message]
2007-05-23 2:24 ` Daniel Jacobowitz
2007-05-23 16:37 ` Maxim Grigoriev
2007-05-23 0:05 ` Jim Blandy
2007-05-23 0:17 ` Ross Morley
2007-05-23 0:32 ` Jim Blandy
2007-05-23 2:24 ` Ross Morley
2007-05-23 21:52 ` Jim Blandy
2007-05-24 0:05 ` Ross Morley
2007-05-24 1:24 ` Ross Morley
2007-05-24 21:56 ` Jim Blandy
2007-05-23 0:17 ` Daniel Jacobowitz
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=4653924D.5030304@hq.tensilica.com \
--to=maxim@tensilica.com \
--cc=gdb@sourceware.org \
--cc=jimb@codesourcery.com \
--cc=marc@tensilica.com \
--cc=ross@tensilica.com \
/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