mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 07:19:40 +02:00
DBG: Parse filenames returned by gdb for escape sequences
git-svn-id: trunk@28354 -
This commit is contained in:
parent
76cd8c6607
commit
594f4eb14b
@ -61,7 +61,9 @@ function GetLine(var ABuffer: String): String;
|
|||||||
function ConvertToCString(const AText: String): String;
|
function ConvertToCString(const AText: String): String;
|
||||||
function ConvertPathDelims(const AFileName: String): String;
|
function ConvertPathDelims(const AFileName: String): String;
|
||||||
function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char = '\'): String;
|
function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char = '\'): String;
|
||||||
|
function UnEscapeOctal(const AValue: String): String;
|
||||||
function UnQuote(const AValue: String): String;
|
function UnQuote(const AValue: String): String;
|
||||||
|
function ConvertGdbPathAndFile(const AValue: String): String; // fix path, delim, unescape, and to utf8
|
||||||
|
|
||||||
|
|
||||||
procedure SmartWriteln(const s: string);
|
procedure SmartWriteln(const s: string);
|
||||||
@ -181,6 +183,54 @@ begin
|
|||||||
Result[i] := PathDelim;
|
Result[i] := PathDelim;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function UnEscapeOctal(const AValue: String): String;
|
||||||
|
var
|
||||||
|
c, cnt, len: Integer;
|
||||||
|
Src, Dst: PChar;
|
||||||
|
Oct: PChar;
|
||||||
|
begin
|
||||||
|
len := Length(AValue);
|
||||||
|
if len = 0 then Exit('');
|
||||||
|
|
||||||
|
Src := @AValue[1];
|
||||||
|
cnt := len;
|
||||||
|
SetLength(Result, len); // allocate initial space
|
||||||
|
|
||||||
|
Dst := @Result[1];
|
||||||
|
while cnt > 0 do
|
||||||
|
begin
|
||||||
|
if (Src^ = '\') and ((Src+1)^ in ['0'..'7', '\'])
|
||||||
|
then begin
|
||||||
|
inc(Src);
|
||||||
|
dec(cnt);
|
||||||
|
if Src^ <> '\'
|
||||||
|
then begin
|
||||||
|
Oct := Src;
|
||||||
|
c := 0;
|
||||||
|
while (Src^ in ['0'..'7']) and (cnt > 0)
|
||||||
|
do begin
|
||||||
|
c := (c * 8) + ord(Src^) - ord('0');
|
||||||
|
Inc(Src);
|
||||||
|
Dec(cnt);
|
||||||
|
end;
|
||||||
|
//c := UnicodeToUTF8SkipErrors(c, Dst);
|
||||||
|
//inc(Dst, c);
|
||||||
|
Dst^ := chr(c and 255);
|
||||||
|
if (c and 255) <> 0
|
||||||
|
then Inc(Dst);
|
||||||
|
if cnt = 0 then Break;
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Dst^ := Src^;
|
||||||
|
Inc(Dst);
|
||||||
|
Inc(Src);
|
||||||
|
Dec(cnt);
|
||||||
|
end;
|
||||||
|
|
||||||
|
SetLength(Result, Dst - @Result[1]); // adjust to actual length
|
||||||
|
end;
|
||||||
|
|
||||||
function Unquote(const AValue: String): String;
|
function Unquote(const AValue: String): String;
|
||||||
var
|
var
|
||||||
len: Integer;
|
len: Integer;
|
||||||
@ -193,6 +243,11 @@ begin
|
|||||||
else Result := AValue;
|
else Result := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ConvertGdbPathAndFile(const AValue: String): String;
|
||||||
|
begin
|
||||||
|
Result := AnsiToUtf8(ConvertPathDelims(UnEscapeOctal(AValue)));
|
||||||
|
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;
|
||||||
|
@ -2445,7 +2445,7 @@ function TGDBMIDebuggerCommandExecute.ProcessStopped(const AParams: String;
|
|||||||
if ExecuteCommand('info line * pointer(%s)', [S], R)
|
if ExecuteCommand('info line * pointer(%s)', [S], R)
|
||||||
then begin
|
then begin
|
||||||
Result.SrcLine := StrToIntDef(GetPart('Line ', ' of', R.Values), -1);
|
Result.SrcLine := StrToIntDef(GetPart('Line ', ' of', R.Values), -1);
|
||||||
Result.SrcFile := ConvertPathDelims(GetPart('\"', '\"', R.Values));
|
Result.SrcFile := ConvertGdbPathAndFile(GetPart('\"', '\"', R.Values));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4671,8 +4671,8 @@ begin
|
|||||||
Val(Frame.Values['addr'], Location.Address, e);
|
Val(Frame.Values['addr'], Location.Address, e);
|
||||||
if e=0 then ;
|
if e=0 then ;
|
||||||
Location.FuncName := Frame.Values['func'];
|
Location.FuncName := Frame.Values['func'];
|
||||||
Location.SrcFile := ConvertPathDelims(Frame.Values['file']);
|
Location.SrcFile := ConvertGdbPathAndFile(Frame.Values['file']);
|
||||||
Location.SrcFullName := ConvertPathDelims(Frame.Values['fullname']);
|
Location.SrcFullName := ConvertGdbPathAndFile(Frame.Values['fullname']);
|
||||||
Location.SrcLine := StrToIntDef(Frame.Values['line'], -1);
|
Location.SrcLine := StrToIntDef(Frame.Values['line'], -1);
|
||||||
|
|
||||||
Frame.Free;
|
Frame.Free;
|
||||||
@ -6313,8 +6313,8 @@ begin
|
|||||||
Val(AFrameInfo.Values['addr'], addr, e);
|
Val(AFrameInfo.Values['addr'], addr, e);
|
||||||
if e=0 then ;
|
if e=0 then ;
|
||||||
func := AFrameInfo.Values['func'];
|
func := AFrameInfo.Values['func'];
|
||||||
filename := ConvertPathDelims(AFrameInfo.Values['file']);
|
filename := ConvertGdbPathAndFile(AFrameInfo.Values['file']);
|
||||||
fullname := ConvertPathDelims(AFrameInfo.Values['fullname']);
|
fullname := ConvertGdbPathAndFile(AFrameInfo.Values['fullname']);
|
||||||
line := AFrameInfo.Values['line'];
|
line := AFrameInfo.Values['line'];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -7794,8 +7794,8 @@ begin
|
|||||||
Val(Frame.Values['addr'], Location.Address, e);
|
Val(Frame.Values['addr'], Location.Address, e);
|
||||||
if e=0 then ;
|
if e=0 then ;
|
||||||
Location.FuncName := Frame.Values['func'];
|
Location.FuncName := Frame.Values['func'];
|
||||||
Location.SrcFile := ConvertPathDelims(Frame.Values['file']);
|
Location.SrcFile := ConvertGdbPathAndFile(Frame.Values['file']);
|
||||||
Location.SrcFullName := ConvertPathDelims(Frame.Values['fullname']);
|
Location.SrcFullName := ConvertGdbPathAndFile(Frame.Values['fullname']);
|
||||||
Location.SrcLine := StrToIntDef(Frame.Values['line'], -1);
|
Location.SrcLine := StrToIntDef(Frame.Values['line'], -1);
|
||||||
|
|
||||||
Frame.Free;
|
Frame.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user