[Lazarus] using dwarf with special tricks [Re: Generating line info]

Martin lazarus at mfriebe.de
Mon Sep 19 21:16:23 CEST 2011


On 19/09/2011 19:54, cobines wrote:
>> - Why do you prefer stabs?
> Because I always had problems with DWARF, at least on Win32. I have
> GDB 7.3.2 from MinGW. STABS seems to work better. There is problem
Same gdb here => and that should also be included in trunk snapshots, or 
download able from the binariy section of lazarus svn.

using fpc trunk

> with stacktrace, like Bart posted. I cannot cast pointers, variables
> to PChar, PByte, PByteArray, which I use often to look at the bytes.
> For example try to do:
>
> "pbytearray(form1.fcaption)^"
> "pchar(form1.fcaption)^"
> "pbyte(pointer(0x5238a4))^"
>
> For example I want to display reference count of string:
>
> "plongint(form1.fcaption)[-2]"
>
> Doesn't work with DWARF.

Lets look at them individually (and maybe what are the declarations for 
those types?

The last one (without quotes)

plongint(form1.fcaption)[-2]

works here. (make sure your lcl is compiled with dwarf too, though I 
would expect it to work anyway)

Also look at the error. Maybe "plongint" is not defined? Then try

^longint(form1.fcaption)[-2]



---
just tried
pbytearray(form1.fcaption)^

worked as well


>> - Why do you prefer stabs generated by -g, rather than choosing explicitly?
> I thought -g always chooses the best supported debug info for the
> platform. I thought it chooses Stabs not Dwarf since it works better.
> Maybe that is not the case.

Well it chooses what the fpc devel thing to be best.

I have done my own tests, and run plenty of test my self, and tested 
many expressions against a huge amount of combinations of gdb versions 
betweeen 6.3.5 and 7.3 / fpc 2.4.2 to trunk, with both settings.

The result is that most things work on both. The Lazarus IDE also takes 
care of the many of the issues either format has.

2 things that dwarf can indeed not.
- correctly determining that a "var param pointer to object" as in 
"function foo(var BAR: PObject)", if used in an expression  "BAR^" with 
one deref => actually is TObject and not PObject
   hardly a tragedy => how many people use PObject, and how many have it 
as var param?
- some complex expressions that relay on accessing members of elements 
of dyn-arrays "dyn^[1].a" => that is a bit of an issue, I agree

On the plus site, you get the "property Counter: integer read FCounter" 
=> that you can inspect.

Lot's of people, especially those less experienced, try to inspect 
things like this using hints => and with dwarf, they have at least a few 
they can expect. with stabs it doesn't work at all.

(personally I use the watches window, and can directly type FCounter, 
but as I said, lot's of people try to use the hints)

---
So for using within Lazarus, IMHO dwarf is at least as good as stabs.

using outside lazarus => I do not know



>
> Otherwise there's no problem. I figured out I can set Stabs in default
> options for new project.
>

Exactly, ...




More information about the Lazarus mailing list