Sign in Join

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

Mailing lists / fpc-devel / 2008-01

bug in ptype for dyn array (debug info / gdb)?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Martin

I was trying to look at e content of dyn-arrays under gdb and found that it is very hard to get results.

(you may also want to look at
http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=viewtopic&t=4763

)

I used ptype to look at what gdb (under Lazarus) thinks the variable is. declaring the following in my source (same for word/integer/...):

type
   Tab = array of byte;
var
    ab  : Tab;
    ab2 : array of byte;
    b1 : ^tab;

in "gbb -i mi"

ptype ab

type = array [0..-1] of BYTE

ptype @ab\n"

type = ^BYTE

ptype ab2

type = array [0..-1] of BYTE

ptype @ab2
type = ^(array [0..-1] of BYTE)

ptype b1

type = ^BYTE

I would assume that the type info is included by fpc?

IMHO it is inconsistent, and partly incorrect. So I am looking for any feedback, maybe I got something wrong, maybe it is a bug, maybe there is an intention?

-inconsistent: ab and ab2 are the same type to the debugger, yet @ab and @ab2 return different

-incorrect: ab and ab2 are "array [] of byte", but in reality they are pointers.
As a result "-data-evaluate-expression ab[0]" does return the wrong value (It contains a byte out of the address of ab)

I don't know what the correct values should be, and despite the debugger returning a ptype of "^{array [0..-1] of BYTE"; I don't know if that can be set.

In terms of data evaluation, if ^(array...) is not possible (or does not work in gdb?) then ^BYTE would probably be the best choice? Forcing b1 to point to the array ("b1=@(ab[0]"), and not to it's address ("") allows to do b1^[x] and get the correct data.

I don't expect there is a way to have ptype return the pascal declaraton (which hdes the fact about the pointer), yet have gdb knowing of the pointer?

Regards
Martin

Reply by email

Jonas Maebe
to Martin
Martin wrote
IMHO it is inconsistent, and partly incorrect. So I am looking for any feedback, maybe I got something wrong, maybe it is a bug, maybe there is an intention?

Dynamic arrays are currently not properly handled in the debug information by the compiler.

Jonas

Reply by email