Hi all,
I am currently trying to improve GDB pascal support by trying to add support for printing individual chars of a string. (printing the whole strings does work for both compilers).
The code that I have works now nicely for Free Pascal, but when I tried to check the code for GPC, I got several bad surprises.
test.p
var S : string;
begin S:='Simple test'; Writeln(s); end.
1) ptyp S where S is a pascal string leads to problems... because the stabs format for the strings is weird...
.stabs "S:S(0,46)=s264Capacity:(0,4),0,32;length:(0,4),32,32;_p_schema_:(0,47)=@ s2048;@S;S(0,48)=r(0,1);0000000000001;0000000000400;,64,2048;;",40,0,5,_S Looking into stabsread.c I found out that @S sets is_string to 1, but the fact that after this the type is a S mans that GDB inteprets this as a set type which is transformed into a bitstring type...
(you can see this if you use) (gdb) p S._p_schema_
Thus, if I add the missing support for bitstring indexes, I get a true or false printout.... where I would like to have a char output...
The problem is that bitstring seems to be the wrong choice here, I understand bitstring as being a packed array of boolean values (probably fortran or modula-2)
the correct choice would be to get the compiler to generate an array type instead of a set type after the @S; this would then give a correct TYPE_CODE_STRING type for the _p_schema_ field....
I am now rather clueless about how to add support for this feature for GPC :(
PS: I would like to have more feedback about the pascal language support in GDB from all of you.
Does noone on this list use GDB? If you ever encounter any pascal language problems in GDB, please report them, I does not read all GPC list mails completely, but I always give more attention if debugger is involved...
Pierre Muller Institut Charles Sadron 6,rue Boussingault F 67083 STRASBOURG CEDEX (France) mailto:muller@ics.u-strasbg.fr Phone : (33)-3-88-41-40-07 Fax : (33)-3-88-41-40-99
Hello.
Pierre Muller wrote:
- ptyp S
where S is a pascal string leads to problems... because the stabs format for the strings is weird...
.stabs "S:S(0,46)=s264Capacity:(0,4),0,32;length:(0,4),32,32;_p_schema_:(0,47)=@ s2048;@S;S(0,48)=r(0,1);0000000000001;0000000000400;,64,2048;;",40,0,5,_S Looking into stabsread.c I found out that @S sets is_string to 1, but the fact that after this the type is a S mans that GDB inteprets this as a set type which is transformed into a bitstring type...
The code in GPC which generates the stabs for strings is rather old - and obviously buggy.
(you can see this if you use) (gdb) p S._p_schema_
Thus, if I add the missing support for bitstring indexes, I get a true or false printout.... where I would like to have a char output...
What would be the correct `.stabs' for a Pascal string?
It is a record internally, containing the capacity, the length, and the actual chars. It would be nice if GDB could "know" that it as a string.
The problem is that bitstring seems to be the wrong choice here, I understand bitstring as being a packed array of boolean values (probably fortran or modula-2)
It's a `set' or `packed array of Boolean' in Pascal, and probably also in Modula 2. (I have never seen such a thing in Fortran.)
the correct choice would be to get the compiler to generate an array type instead of a set type after the @S; this would then give a correct TYPE_CODE_STRING type for the _p_schema_ field....
I am now rather clueless about how to add support for this feature for GPC :(
I do not yet really understand how the compiler outputs debug information, but I get the impression that I can add support for that feature in GPC when you help me to understand how those `.stabs' work at all.
Does noone on this list use GDB?
I use it regularly, but due to some bugs in GPC's debug information output (e.g. concerning strings;-) I never dared to dive more deeply into it.
Thanks,
Peter
At 23:46 29/04/02 +0200, Peter Gerwinski wrote:
Hello.
Pierre Muller wrote:
- ptyp S
where S is a pascal string leads to problems... because the stabs format for the strings is weird...
.stabs
"S:S(0,46)=s264Capacity:(0,4),0,32;length:(0,4),32,32;_p_schema_:(0,47)=@
s2048;@S;S(0,48)=r(0,1);0000000000001;0000000000400;,64,2048;;",40,0,5,_S Looking into stabsread.c I found out that @S sets is_string to 1, but the fact that after this the type is a S mans that GDB inteprets this as a set type which is transformed into a bitstring type...
The code in GPC which generates the stabs for strings is rather old
- and obviously buggy.
(you can see this if you use) (gdb) p S._p_schema_
Thus, if I add the missing support for bitstring indexes, I get a true or false printout.... where I would like to have a char output...
What would be the correct `.stabs' for a Pascal string?
I this that chaning the S(0,48)=r... into a ar... should do it (if I understood the stabsread.ccode correctly).
It is a record internally, containing the capacity, the length, and the actual chars. It would be nice if GDB could "know" that it as a string.
It is already recognized as a string (see the is_pascal_string_type function in p-lang.c in gdb current CVS sources)
This is the reason why printing out a complete string works... (by the way, I have some doubtsabout the GPC schemata, are they not all having the two Capacity and length field as the GPC strings?)
The problem is that bitstring seems to be the wrong choice here, I understand bitstring as being a packed array of boolean values (probably fortran or modula-2)
It's a `set' or `packed array of Boolean' in Pascal, and probably also in Modula 2. (I have never seen such a thing in Fortran.)
It was only a guess. But did you (or the GPC specific code) set the type of the _p_schema_ field to a set type? Why isn't it simply an array type?
the correct choice would be to get the compiler to generate an array
type instead of
a set type after the @S; this would then give a correct TYPE_CODE_STRING type for the _p_schema_ field....
I am now rather clueless about how to add support for this feature for GPC :(
I do not yet really understand how the compiler outputs debug information, but I get the impression that I can add support for that feature in GPC when you help me to understand how those `.stabs' work at all.
And I never looked inside the GPCsource code :( So I suppose that you are telling me that the stabs is generated by GCC common code andf nothing GPC specific, is that correct?
Does noone on this list use GDB?
I use it regularly, but due to some bugs in GPC's debug information output (e.g. concerning strings;-) I never dared to dive more deeply into it.
Which version of GDB do you use? Did you ever try to debug object code with it? I don't know if GPC object code can be debugged with current GDB.
Thanks,
Thanks for the answer.