Problem with debugger lazarus / 12-Debugger ---------------------------------------------------------------------- shadeofgray · 2007-12-20 19:29 Hello! I am using Win32 version of Lazarus (0.9.24 beta) and have problems with debugger. Here is sample code: Code: [Select] procedure TForm1.BtnTestClick(Sender: TObject); var     A:      array of Double;     v:      double; begin     SetLength(A, 1);     a[0]:=2;     v:=a[0];     Memo1.Lines.Add('DONE'); end; I placed breakpoint after the last line. At this breakpoint I used Evaluate/Modify tool and got "v=2" , "a[0]=2.343973527005793e-308". And i got even stranger results when I tried to use Evaluate/Modify on arrays which are members of data structures. What does it mean? Is Evaluate/Modify tool unfinished, unstable or what? ---------------------------------------------------------------------- shadeofgray · 2007-12-21 07:18 May be the right question is - does anyone experience same behavior? ---------------------------------------------------------------------- Marc · 2007-12-21 10:16 evaluating (dyn) arrays is tricky and iirc not supported. Problem is that gdb is very C oriented, so language constructs which are not possible in C usually cannot be evaluated. ---------------------------------------------------------------------- Martin_fr · 2008-01-03 17:26 hm I done a bit of debugging: the problem is that a dynarray is in truth a pointer to an array. actually it points into the middle of a structure...   var a : array of Integer;   setlength(a,22) then a contins the address x x-4 : integer = high(a) = 21 x     : frst element x +1: 2nd element .... if it was array of integer then the 2nd element is at x+4. I do not know what happens if you use byte alignment? So how to access the true value? *** WARNING FIRST *** The below code means you access memory through pointers and calculated values. You could end up anywhere, and if you make a type, or use an index out of bounds or something else on your system differs to mine => you may get a crash, you may hang your entire operating system, you may ??? well anything can happen.  BUT usually, you will just get an error message if you mess up. *** Well if you have a : array of integer; // or a 4byte numeri type, then: (a[0]+0)^ (a[0]+4)^ (a[0]+8)^ and for the size [high(a)] (a[0]-4)^ in case of " a: array of byte" it is more fun (anybody got an easier solution?) ^BYTE(^LONGINT(@a1)^+0)^ ^BYTE(^LONGINT(@a1)^+1)^ ^BYTE(^LONGINT(@a1)^+2)^ and for the size ^BYTE(^LONGINT(@a1)^-4)^ ---------------- ok now my question: IMHO this is a bug in fpc? because "ptype" should not be an "array[0..-1] of BYTE", it should be a pointer to this datatype. Any opinions on this? ---------------------------------------------------------------------- Marc · 2008-01-04 08:53 maybe it should, but question remains, does gdb understand ? (if so, better ask thison the freepascal mailinglist or forum)