mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-27 04:07:14 +01: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
|
type
|
||||||
// datatype pointing to data on the target
|
// datatype pointing to data on the target
|
||||||
TDBGPtr = type QWord;
|
TDBGPtr = DebugUtils.TDBGPtr;
|
||||||
|
|
||||||
TDBGLocationRec = record
|
TDBGLocationRec = record
|
||||||
Address: TDBGPtr;
|
Address: TDBGPtr;
|
||||||
|
|||||||
@ -39,6 +39,8 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
TDBGPtr = type QWord;
|
||||||
|
|
||||||
{ TDelayedUdateItem }
|
{ TDelayedUdateItem }
|
||||||
|
|
||||||
TDelayedUdateItem = class(TCollectionItem)
|
TDelayedUdateItem = class(TCollectionItem)
|
||||||
@ -75,6 +77,7 @@ function UnQuote(const AValue: String): String;
|
|||||||
function Quote(const AValue: String; AForce: Boolean=False): String;
|
function Quote(const AValue: String; AForce: Boolean=False): String;
|
||||||
function ConvertGdbPathAndFile(const AValue: String): String; // fix path, delim, unescape, and to utf8
|
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 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);
|
procedure SmartWriteln(const s: string);
|
||||||
|
|
||||||
@ -407,6 +410,31 @@ begin
|
|||||||
SetLength(Result, j);
|
SetLength(Result, j);
|
||||||
end;
|
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;
|
function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char): String;
|
||||||
var
|
var
|
||||||
cnt, len: Integer;
|
cnt, len: Integer;
|
||||||
|
|||||||
@ -8862,18 +8862,46 @@ function TGDBMIDebuggerCommandLocals.DoExecute: Boolean;
|
|||||||
if Name = 'this'
|
if Name = 'this'
|
||||||
then Name := 'Self';
|
then Name := 'Self';
|
||||||
|
|
||||||
Value := DeleteEscapeChars(List.Values['value']);
|
Value := List.Values['value'];
|
||||||
// try to deref. strings
|
(* GDB up to about 6.6 (stabs only) may return:
|
||||||
S := GetPart(['(pchar) ', '(ansistring) '], [], Value, True, False);
|
{name="ARGANSISTRING",value="(ANSISTRING) 0x43cc84"}
|
||||||
if S <> ''
|
* newer GDB may return AnsiString/PChar prefixed with an address (shortstring have no address)
|
||||||
then begin
|
{name="ARGANSISTRING",value="0x43cc84 'Ansi'"}
|
||||||
addr := 0;
|
*)
|
||||||
Val(S, addr, e);
|
if (lowercase(copy(Value, 1, 8)) = '(pchar) ') then begin
|
||||||
if e=0 then ;
|
delete(Value, 1, 8);
|
||||||
if addr = 0
|
if GetLeadingAddr(Value, addr) then begin
|
||||||
then Value := ''''''
|
if addr = 0
|
||||||
else Value := '''' + GetText(addr) + '''';
|
then Value := ''''''
|
||||||
end;
|
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);
|
FLocals.Add(Name, Value);
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user