Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

implementing call stack

5 views
Skip to first unread message

John Smith

unread,
Nov 15, 2009, 3:33:02 PM11/15/09
to

Hi,

Im working on a asm debugger. The source is a higher level programming
language (VHDL), which is similar in some aspect to Pascal/C (the source may
contain procedures). Now I can put breakpoints to the source VHDL code and
the debugger stay correctly at a point in the x86 code. Im using runtime
code patching, no WaitForDebugEvent etc.. My question: how could I display
the call stack and the 'Locals'?
'Locals': when the user select a stack frame, the local variables are
displayed in a window (like in Delphi7).
I assume no extra generated code for displaying call stack for example in
Delphi7.

Thanks


Tim Roberts

unread,
Nov 15, 2009, 6:29:40 PM11/15/09
to

"John Smith" <j.s...@MUNGED.microcosmotalk.com> wrote:
>
>Im working on a asm debugger. The source is a higher level programming
>language (VHDL), which is similar in some aspect to Pascal/C (the source may
>contain procedures).

But VHDL is radically different from Pascal/C, in that the procedures can
all run simultaneously.

>Now I can put breakpoints to the source VHDL code and
>the debugger stay correctly at a point in the x86 code. Im using runtime
>code patching, no WaitForDebugEvent etc.. My question: how could I display
>the call stack and the 'Locals'?

The only way to know this is to know the implementation used by the
compiler. We can't offer you any generic advice on this. Even if you know
that local variables are stores on the stack, you can't display the
individual values unless you can access compiler debug information that
tells you the mapping.

>'Locals': when the user select a stack frame, the local variables are
>displayed in a window (like in Delphi7).
>I assume no extra generated code for displaying call stack for example in
>Delphi7.

Delphi7 generates an extra file containing "debug symbols" that tells which
stack offsets have which local variables. You need the same thing for your
VHDL compiler.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

JohnSmith

unread,
Nov 15, 2009, 11:29:24 PM11/15/09
to

On Nov 16, 12:29=A0am, Tim Roberts <t...@MUNGED.microcosmotalk.com>
wrote:

> "John Smith" <j.sm...@MUNGED.microcosmotalk.com> wrote:
>
> >Im working on a asm debugger. The source is a higher level programming
> >language (VHDL), which is similar in some aspect to Pascal/C (the source=
may
> >contain procedures).

Of course, but consider the current delta cycle. It was just an
example. We can talk about then
Pascal (Delphi7).

>
> But VHDL is radically different from Pascal/C, in that the procedures can
> all run simultaneously.
>
> >Now I can put breakpoints to the source VHDL code and
> >the debugger stay correctly at a point in the x86 code. Im using runtime

> >code patching, no WaitForDebugEvent etc.. My question: how could I displ=
ay


> >the call stack and the 'Locals'?
>
> The only way to know this is to know the implementation used by the

> compiler. =A0We can't offer you any generic advice on this. =A0Even if yo=


u know
> that local variables are stores on the stack, you can't display the
> individual values unless you can access compiler debug information that
> tells you the mapping.

I have the own debug info structure.

>
> >'Locals': when the user select a stack frame, the local variables are
> >displayed in a window (like in Delphi7).

> >I assume no extra generated code for displaying call stack for example i=
n
> >Delphi7.
>
> Delphi7 generates an extra file containing "debug symbols" that tells whi=
ch
> stack offsets have which local variables. =A0You need the same thing for =
your
> VHDL compiler.

Ok, but how Delphi7 do that? How recover the call stack?

> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.

Thanks

Tim Roberts

unread,
Nov 18, 2009, 3:19:29 AM11/18/09
to

JohnSmith <csne...@MUNGED.microcosmotalk.com> wrote:
>
>On Nov 16, 12:29=A0am, Tim Roberts <t...@MUNGED.microcosmotalk.com>
>wrote:
>>
>> Delphi7 generates an extra file containing "debug symbols" that tells
>> which stack offsets have which local variables. You need the same
>> thing for your VHDL compiler.

>
>Ok, but how Delphi7 do that? How recover the call stack?

The ebp register points to the stack frame. The symbol file tells Delphi
that variable "xyz" is an integer located -24 bytes from the start of the
stack frame. All the debugger has to do is add that offset to the ebp
value from the paused program.

In a highly optimized program, it gets harder. The compiler might not use
ebp for the stack frame, choosing instead to access variables through esp.
In that case, the debugger will also need to know how much esp has changed
at each source line.

0 new messages