Hello chaps,
I have looked through the list but cant find anything definitive on this one...
I am using -gstabs to compile as -g on its own gives "internal error - unimplemented function unk_lang_create_fundamental_type called." (as per an earlier post).
I can get things to display by casting them to their type Type(Var) with initial letters capitalised. Where I get really stuck is trying to use this technique on a thingy (its a union in C - I dont know much pascal so I dont know what its called - sorry).
This isnt real code - its so I can try to explain a little better...
TYPE
header = RECORD item1 : WORD; item2 : WORD; item3 : LONGWORD; END;
type1 = PACKED RECORD hdr ; header; custom1 : BYTE; END;
{ you get the idea...}
thingy = RECORD CASE INTEGER OF 1: (member1 : type1); 2: (member2 : type2); 3: (member3 : type3); END;
VAR dummy1 : header; dummy2 : type1; dummy3 : thingy;
From within GDB when the program is running, I can inspect the contents of
dummy1 by doing
p Header(Dummy1) ( I would expect a simple p dummy1 to work but any debug is better than none).
How do I get it to display member2 (assuming that member2 is the relevent member). I can tell which structure to use as there is a variable that has been set. Out of interest, is there a way of telling which member is the relevent one just by looking at dummy3?
Sorry if this is really amateurish - I am a C programmer that has suddenly inherited a whole load of Pascal and I must admit that I am struggling with the debugger. It works fine for me in C - I am hoping that it is my ignorance that is the cause of the problem.
If there are any publications, online or in print (I have the GPC documentation but it didnt help on this one) that you recommend, please post away.
Thanks for any insight,
Bryan "Brain Murders" Meredith
Bryan Meredith wrote:
Hello chaps,
I have looked through the list but cant find anything definitive on this one...
I am using -gstabs to compile as -g on its own gives "internal error - unimplemented function unk_lang_create_fundamental_type called." (as per an earlier post).
I can get things to display by casting them to their type Type(Var) with initial letters capitalised. Where I get really stuck is trying to use this technique on a thingy (its a union in C - I dont know much pascal so I dont know what its called - sorry).
This isnt real code - its so I can try to explain a little better...
TYPE
header = RECORD item1 : WORD; item2 : WORD; item3 : LONGWORD; END;
type1 = PACKED RECORD hdr ; header; custom1 : BYTE; END;
{ you get the idea...}
thingy = RECORD CASE INTEGER OF 1: (member1 : type1); 2: (member2 : type2); 3: (member3 : type3); END;
VAR dummy1 : header; dummy2 : type1; dummy3 : thingy;
From within GDB when the program is running, I can inspect the contents of
dummy1 by doing
p Header(Dummy1) ( I would expect a simple p dummy1 to work but any debug is better than none).
Using gpc-20030507 (or newest gpc-20030830) and gdb-5.2 (or gdb-5.3) I have no problem to print dummy2:
(gdb) print dummy2 $8 = {Hdr = {Item1 = 0, Item2 = 0, Item3 = 0}, Custom1 = 0} (gdb) print dummy2.Hdr $9 = {Item1 = 0, Item2 = 0, Item3 = 0} (gdb)
However `dummy3' is a variant record. AFAIKS gdb lacks proper support for variant records (and gpc may have own problems, just masked by gdb inability). Variant records are very much like C unions -- but members (variants) are named by constants. It is possible to store name of active variant in a separate field (called selector), but this field is ommited from `dummy3', so you have to use the same methods you would use for a C union.
Just a little hint: call command in gdb allows you to write your own print functions -- may be worthwile if you will be working for long tie with the code.
How do I get it to display member2 (assuming that member2 is the relevent member). I can tell which structure to use as there is a variable that has been set. Out of interest, is there a way of telling which member is the relevent one just by looking at dummy3?
A little correction. I wrote that there is problem with variant records and gdb. However, after checking I see that the problem is limited, gdb just does not print names (selector values) corresponding to variants. You can print members:
(gdb) print dummy3 $7 = { = { = {Member1 = {Hdr = {Item1 = 0, Item2 = 0, Item3 = 0}, Custom1 = 0}}, = {Member2 = []}, = {Member3 = 0}}} (gdb) print dummy3.Member1 $8 = {Hdr = {Item1 = 0, Item2 = 0, Item3 = 0}, Custom1 = 0} (gdb)
On Saturday 06 Dec 2003 02:28, Waldek Hebisch wrote:
How do I get it to display member2 (assuming that member2 is the relevent member). I can tell which structure to use as there is a variable that has been set. Out of interest, is there a way of telling which member is the relevent one just by looking at dummy3?
A little correction. I wrote that there is problem with variant records and gdb. However, after checking I see that the problem is limited, gdb just does not print names (selector values) corresponding to variants. You can print members:
(gdb) print dummy3 $7 = { = { = {Member1 = {Hdr = {Item1 = 0, Item2 = 0, Item3 = 0}, Custom1 = 0}}, = {Member2 = []}, = {Member3 = 0}}} (gdb) print dummy3.Member1 $8 = {Hdr = {Item1 = 0, Item2 = 0, Item3 = 0}, Custom1 = 0} (gdb)
Thats interesting.
The problem I get is that gdb complains of incomplete types.
(gdb) p Raatimer(M_msgbuf) $7 = {Daaheader = <incomplete type>, Iaaatcode = 5, Iaafil = 0} (gdb) p M_msgbuf $8 = <incomplete type> (gdb) p M_msgbuf.Daaheader A parse error in expression, near `Daaheader'. (gdb) p Raaheader(M_msgbuf.Daaheader) A parse error in expression, near `Daaheader)'.
As you can see, I cant get to Daaheader.
I wonder is this is anything to do with the fact that the types are all declared in other units and brought in with the uses clause? I have a .gdbinit file to ensure that it can see the source directories.
Bryan Meredith wrote
The problem I get is that gdb complains of incomplete types.
(gdb) p Raatimer(M_msgbuf) $7 = {Daaheader = <incomplete type>, Iaaatcode = 5, Iaafil = 0} (gdb) p M_msgbuf $8 = <incomplete type> (gdb) p M_msgbuf.Daaheader A parse error in expression, near `Daaheader'. (gdb) p Raaheader(M_msgbuf.Daaheader) A parse error in expression, near `Daaheader)'.
As you can see, I cant get to Daaheader.
I wonder is this is anything to do with the fact that the types are all declared in other units and brought in with the uses clause? I have a .gdbinit file to ensure that it can see the source directories.
The problem seem to be that gdb does not know the structure of the `Raaheader' type. It is not a "well known problem". Instead of guessing just post problematic code. Simplify the code, if you can, but make sure that the problem persist after simplification.
By the way, you should be able to print values of variables even if source is not available (description of variables is inside the executable).
On Saturday 06 Dec 2003 22:45, Waldek Hebisch wrote:
Bryan Meredith wrote
The problem I get is that gdb complains of incomplete types.
(gdb) p Raatimer(M_msgbuf) $7 = {Daaheader = <incomplete type>, Iaaatcode = 5, Iaafil = 0} (gdb) p M_msgbuf $8 = <incomplete type> (gdb) p M_msgbuf.Daaheader A parse error in expression, near `Daaheader'. (gdb) p Raaheader(M_msgbuf.Daaheader) A parse error in expression, near `Daaheader)'.
As you can see, I cant get to Daaheader.
I wonder is this is anything to do with the fact that the types are all declared in other units and brought in with the uses clause? I have a .gdbinit file to ensure that it can see the source directories.
The problem seem to be that gdb does not know the structure of the `Raaheader' type. It is not a "well known problem". Instead of guessing just post problematic code. Simplify the code, if you can, but make sure that the problem persist after simplification.
By the way, you should be able to print values of variables even if source is not available (description of variables is inside the executable).
I have finally had a chance to put an example together. The pascal files and the output from gdb are available here:
http://www.brainmurders.pwp.blueyonder.co.uk/pascal/
I didn't want to post it all inline but I can if that's what is preferred - the files are quite small.
If you need any more information from me, please ask - I could really do with the help.
Thanks in advance, Bryan "Brain Murders" Meredith
On 7 Jan 2004 at 21:08, Bryan Meredith wrote:
I have finally had a chance to put an example together. The pascal files and the output from gdb are available here:
I can confirm that the problem is reproducible with gpc version 20030830, based on gcc-3.3.2, and gdb 6.0 (ix86-mingw).
-- Dave
On Sunday 11 Jan 2004 01:25, J. David Bryan wrote:
On 7 Jan 2004 at 21:08, Bryan Meredith wrote:
I have finally had a chance to put an example together. The pascal files and the output from gdb are available here:
I can confirm that the problem is reproducible with gpc version 20030830, based on gcc-3.3.2, and gdb 6.0 (ix86-mingw).
-- Dave
BUMP!!!
Anyone have any further comments on this at all (please)?
Thanks, Bryan "Brain Murders" Meredith
Bryan Meredith wrote:
On Sunday 11 Jan 2004 01:25, J. David Bryan wrote:
On 7 Jan 2004 at 21:08, Bryan Meredith wrote:
I have finally had a chance to put an example together. The pascal files and the output from gdb are available here:
I can confirm that the problem is reproducible with gpc version 20030830, based on gcc-3.3.2, and gdb 6.0 (ix86-mingw).
-- Dave
BUMP!!!
Anyone have any further comments on this at all (please)?
I can reproduce the problem, but it will take some time to fix.