mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 04:29:25 +02:00
Debugger: Started utf8 for strings in locals
git-svn-id: trunk@41270 -
This commit is contained in:
parent
a95a2a4a8d
commit
c891a78124
@ -43,7 +43,7 @@ uses
|
||||
|
||||
type
|
||||
// datatype pointing to data on the target
|
||||
TDBGPtr = type QWord;
|
||||
TDBGPtr = DebugUtils.TDBGPtr;
|
||||
|
||||
TDBGLocationRec = record
|
||||
Address: TDBGPtr;
|
||||
|
@ -39,6 +39,8 @@ uses
|
||||
|
||||
type
|
||||
|
||||
TDBGPtr = type QWord;
|
||||
|
||||
{ TDelayedUdateItem }
|
||||
|
||||
TDelayedUdateItem = class(TCollectionItem)
|
||||
@ -75,6 +77,7 @@ function UnQuote(const AValue: String): String;
|
||||
function Quote(const AValue: String; AForce: Boolean=False): String;
|
||||
function ConvertGdbPathAndFile(const AValue: String): String; // fix path, delim, unescape, and to utf8
|
||||
function ParseGDBString(const AValue: String): String; // remove quotes(') and convert #dd chars: #9'ab'#9'x'
|
||||
function GetLeadingAddr(var AValue: String; out AnAddr: TDBGPtr; ARemoveFromValue: Boolean = False): Boolean;
|
||||
|
||||
procedure SmartWriteln(const s: string);
|
||||
|
||||
@ -407,6 +410,31 @@ begin
|
||||
SetLength(Result, j);
|
||||
end;
|
||||
|
||||
function GetLeadingAddr(var AValue: String; out AnAddr: TDBGPtr;
|
||||
ARemoveFromValue: Boolean): Boolean;
|
||||
var
|
||||
i, e: Integer;
|
||||
begin
|
||||
AnAddr := 0;
|
||||
Result := (length(AValue) >= 2) and (AValue[1] = '0') and (AValue[2] = 'x');
|
||||
|
||||
if not Result then exit;
|
||||
|
||||
i := 2;
|
||||
while (i < length(AValue)) and (AValue[i+1] in ['0'..'9', 'a'..'f', 'A'..'F']) do inc(i);
|
||||
Result := i > 2;
|
||||
if not Result then exit;
|
||||
|
||||
Val(copy(AValue,1 , i), AnAddr, e);
|
||||
Result := e = 0;
|
||||
if not Result then exit;
|
||||
|
||||
if ARemoveFromValue then begin
|
||||
if (i < length(AValue)) and (AValue[i+1] in [' ']) then inc(i);
|
||||
delete(AValue, 1, i);
|
||||
end;
|
||||
end;
|
||||
|
||||
function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char): String;
|
||||
var
|
||||
cnt, len: Integer;
|
||||
|
@ -8862,18 +8862,46 @@ function TGDBMIDebuggerCommandLocals.DoExecute: Boolean;
|
||||
if Name = 'this'
|
||||
then Name := 'Self';
|
||||
|
||||
Value := DeleteEscapeChars(List.Values['value']);
|
||||
// try to deref. strings
|
||||
S := GetPart(['(pchar) ', '(ansistring) '], [], Value, True, False);
|
||||
if S <> ''
|
||||
then begin
|
||||
addr := 0;
|
||||
Val(S, addr, e);
|
||||
if e=0 then ;
|
||||
if addr = 0
|
||||
then Value := ''''''
|
||||
else Value := '''' + GetText(addr) + '''';
|
||||
end;
|
||||
Value := List.Values['value'];
|
||||
(* GDB up to about 6.6 (stabs only) may return:
|
||||
{name="ARGANSISTRING",value="(ANSISTRING) 0x43cc84"}
|
||||
* newer GDB may return AnsiString/PChar prefixed with an address (shortstring have no address)
|
||||
{name="ARGANSISTRING",value="0x43cc84 'Ansi'"}
|
||||
*)
|
||||
if (lowercase(copy(Value, 1, 8)) = '(pchar) ') then begin
|
||||
delete(Value, 1, 8);
|
||||
if GetLeadingAddr(Value, addr) then begin
|
||||
if addr = 0
|
||||
then Value := ''''''
|
||||
else Value := MakePrintable(GetText(addr));
|
||||
end;
|
||||
end
|
||||
else
|
||||
if (lowercase(copy(Value, 1, 13)) = '(ansistring) ') then begin
|
||||
delete(Value, 1, 13);
|
||||
if GetLeadingAddr(Value, addr) then begin
|
||||
if addr = 0
|
||||
then Value := ''''''
|
||||
else Value := MakePrintable(GetText(addr)); // TODO: NoBackSlashRemove for ProcessGDBResultText
|
||||
end;
|
||||
end
|
||||
else
|
||||
if GetLeadingAddr(Value, addr, True) then
|
||||
begin
|
||||
// AnsiString
|
||||
if (length(Value) > 0) and (Value[1] in ['''', '#']) then begin
|
||||
Value := MakePrintable(ProcessGDBResultText(Value, True, True));
|
||||
end
|
||||
else
|
||||
Value := DeleteEscapeChars(List.Values['value']);
|
||||
end
|
||||
else
|
||||
// ShortString
|
||||
if (length(Value) > 0) and (Value[1] in ['''', '#']) then begin
|
||||
Value := MakePrintable(ProcessGDBResultText(Value, True, True));
|
||||
end
|
||||
else
|
||||
Value := DeleteEscapeChars(Value);
|
||||
|
||||
FLocals.Add(Name, Value);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user