Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-08

Viewing stack content

7 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

When debugging e.g. a cdecl call to a standard library, how can one inspect the top few words on the stack?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote
When debugging e.g. a cdecl call to a standard library, how can one inspect the top few words on the stack?

Usually at least the top most frame is shown (though locals, and params may not)
If further frames or some info is missing, then it usually means gdb does not know how to read the stackframe.

Not sure what can be done.

Reply by email

Martin
to Martin
Martin wrote 12 lines
On 09/08/2012 14:02, Mark Morgan Lloyd wrote: > When debugging e.g. a cdecl call to a standard library, how can one > inspect the top few words on the stack? > Usually at least the top most frame is shown (though locals, and params may not) If further frames or some info is missing, then it usually means gdb does not know how to read the stackframe. Not sure what can be done.

If you mean raw memory

depends on cpu. Intel with esp, add a watch, set to memory dump: ^Byte($esp)[-20]

starts 20 bytes before esp

Reply by email

Mark Morgan Lloyd
to Martin
Martin wrote 19 lines
On 09/08/2012 14:09, Martin wrote: > On 09/08/2012 14:02, Mark Morgan Lloyd wrote: >> When debugging e.g. a cdecl call to a standard library, how can one >> inspect the top few words on the stack? >> > > Usually at least the top most frame is shown (though locals, and > params may not) > If further frames or some info is missing, then it usually means gdb > does not know how to read the stackframe. > > Not sure what can be done. > If you mean raw memory depends on cpu. Intel with esp, add a watch, set to memory dump: ^Byte($esp)[-20] starts 20 bytes before esp

Thanks, I think that'll do. I'm trying to sort out a shared library call- the interface to the library is working properly but I suspect a higher-level shim is confusing a pointer and a value somewhere.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 12 lines
Martin wrote: > If you mean raw memory > > depends on cpu. Intel with esp, add a watch, set to memory dump: > ^Byte($esp)[-20] > > starts 20 bytes before esp Thanks, I think that'll do. I'm trying to sort out a shared library call- the interface to the library is working properly but I suspect a higher-level shim is confusing a pointer and a value somewhere.

If you wont words, and use laz trunk, instead of memory-dump, you can set the watches "repeat count" to see multiple indexed elements, following the given one.

Then you can typecast ^word. The index is not in bytes, but whatever the size of the specified type

Reply by email

Mark Morgan Lloyd
to Martin
Martin wrote 20 lines
On 09/08/2012 15:01, Mark Morgan Lloyd wrote: > Martin wrote: >> If you mean raw memory >> >> depends on cpu. Intel with esp, add a watch, set to memory dump: >> ^Byte($esp)[-20] >> >> starts 20 bytes before esp > > Thanks, I think that'll do. I'm trying to sort out a shared library > call- the interface to the library is working properly but I suspect a > higher-level shim is confusing a pointer and a value somewhere. > If you wont words, and use laz trunk, instead of memory-dump, you can set the watches "repeat count" to see multiple indexed elements, following the given one. Then you can typecast ^word. The index is not in bytes, but whatever the size of the specified type

Thanks, I'll try that later. I noticed the checkbox on the non-trunk version on this machine, but it doesn't yet have any effect.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 11 lines
Martin wrote: > If you wont words, and use laz trunk, instead of memory-dump, you can > set the watches "repeat count" to see multiple indexed elements, > following the given one. > > Then you can typecast ^word. The index is not in bytes, but whatever > the size of the specified type Thanks, I'll try that later. I noticed the checkbox on the non-trunk version on this machine, but it doesn't yet have any effect.

Checkbox? You mean edit?

http://wiki.lazarus.freepascal.org/IDE_Window:_Watch_list#Watch_Properties

Show quoted text 9 lines
"Repeat Count" is implemented in Lazarus 1.1 (SVN, trunk). It can be used to get array slices. The watch specifies the first element of the array "A[7]" (must have an index). With a "Repeat count" of 20, this shows A[7] to A[26]. It can also be used with a dynamic array (no index given). Then it specifies haw many elements to show, beginning with DynA[0]

A pointer, acts like an array, because it can be dereferenced using an index

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120809/31a24026/attachment.html>

Reply by email