* handle absolute on strings correctly for dwarf debug info, resolves #39816

This commit is contained in:
florian 2022-07-05 23:04:17 +02:00
parent a19add9c88
commit e28238da9b
2 changed files with 53 additions and 14 deletions

View File

@ -2200,24 +2200,52 @@ implementation
end;
sl_vec:
begin
if not assigned(currdef) or
(currdef.typ<>arraydef) then
if not assigned(currdef) then
internalerror(2009031201);
{ can't handle offsets with indirections yet }
if indirection then
exit;
if not is_packed_array(currdef) then
elesize:=tarraydef(currdef).elesize
else
begin
elesize:=tarraydef(currdef).elepackedbitsize;
{ can't calculate the address of a non-byte aligned element }
if (elesize mod 8)<>0 then
exit;
elesize:=elesize div 8;
end;
inc(offset,(symlist^.value.svalue-tarraydef(currdef).lowrange)*elesize);
currdef:=tarraydef(currdef).elementdef;
case currdef.typ of
arraydef:
begin
if not is_packed_array(currdef) then
elesize:=tarraydef(currdef).elesize
else
begin
elesize:=tarraydef(currdef).elepackedbitsize;
{ can't calculate the address of a non-byte aligned element }
if (elesize mod 8)<>0 then
exit;
elesize:=elesize div 8;
end;
inc(offset,(symlist^.value.svalue-tarraydef(currdef).lowrange)*elesize);
currdef:=tarraydef(currdef).elementdef;
end;
stringdef:
begin
case tstringdef(currdef).stringtype of
st_widestring,st_unicodestring:
begin
inc(offset,(symlist^.value.svalue-1)*2);
currdef:=cwidechartype;
end;
st_shortstring:
begin
inc(offset,symlist^.value.svalue);
currdef:=cansichartype;
end;
st_ansistring:
begin
inc(offset,symlist^.value.svalue-1);
currdef:=cansichartype;
end;
else
Internalerror(2022070502);
end;
end;
else
internalerror(2022070501);
end;
end;
else
internalerror(2009031403);

11
tests/webtbs/tw39816.pp Normal file
View File

@ -0,0 +1,11 @@
{ %OPT=-g }
program Project1;
{$mode objfpc}{$H+}
Var
S:String[100];
C:Char absolute S[1];
begin
s:='asdf';
writeln(s);
end.