This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Calculating array length
- From: Joost van der Sluis <joost at cnoc dot nl>
- To: archer at sourceware dot org
- Date: Sun, 07 Jun 2009 12:22:53 +0200
- Subject: Calculating array length
Hi all,
First a quick introduction. I'm using gdb to debug my pascal (fpc)
programs, on Linux,OSX and Windows. But there are quite some
difficulties with the gdb<->fpc combination which makes debugging hard.
There were a lot of discussions if some fpc-users should build their own
debugger, but imho it would be better to try to improve the combination
of fpc and gdb. (Although my knowledge of c is pretty bad)
In the past Pierre Muller worked on this but he is not that active
anymore, although he's still willing to help. And I thought that I could
take a look if I could help somewhere.
The archer project is very usefull in this, because with Dwarf-3 some
new things are introduced which can be used to generate better
debug-information for pascal-languages.
I can conclude now already that it's a good thing to look at gdb and fpc
together, because there are comments in the fpc-code like 'we have to
store all identifiers in uppercase into the debug-info, because gdb
needs that', while you can find a comment in the gdb-code like 'all
identifiers are written in capitals by fpc, we have to take care of
that'.
But I also have a lot of questions, I hope this is the right place for
them.
First question is the calculation of the length of an array-type in
type_length_get(), gdbtypes.c. (I'm using the archer-jankratochvil-sla
branch to improve the handling of arrays)
The length is calculated as follows: (count-1)*byte_stride+element_size.
Ok, so why 'count-1'? Count is the actual item-count, why substract it
with one? And why is the element_size added? byte_stride (when defined)
should replace the element_size?
It doesn't make sense to me, as it should be: 'count*byte_stride'?
Can anyone explain this to me?
Regards,
Joost van der Sluis.