On 22/01/2023 11:24, Martin Frb via lazarus wrote:
Though this relies on being able to detect
   PChar  <>  String  <>  array of char
which is a PITA.

Example:
  FPC 3.3.1 (but IIRC also 3.2.x)
  tested on Win, but similar on other OS
  dwarf-3

var
  s1: AnsiString;
  s2: array of char;


Both are encoded as
    DW_TAG_array_type

The name is not relevant, since the user could have done "type Foo = type AnsiString"

The debugger can only make the difference by looking at "current implementation in fpc"

For an array, FPC adds
- a stride
- a type for the subrange.

Both are not guaranteed, and could change any day.

If they do, a string may suddenly be shown as
  s1:   ('H','e','l','l','o',' ','W','o','r','l','d')

----------------
With DWARF-2  string are using the same dwarf as "PChar" (independent of its new name).

So for the watch "s1[2]" you get the value
PChar 'l'; String 'e'

Because the debugger simply can't tell if the index is 1 or 0 based.


--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to