From 10adb42b661bec8a8692114144c7fb3b261b0b43 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 3 Sep 2011 19:47:53 +0000 Subject: [PATCH] DBG: Unescape \t in asm git-svn-id: trunk@32171 - --- debugger/debugutils.pp | 91 +++++++++++++++++++++++++++++---------- debugger/gdbmidebugger.pp | 3 +- 2 files changed, 70 insertions(+), 24 deletions(-) diff --git a/debugger/debugutils.pp b/debugger/debugutils.pp index 09df007a75..2b3a6a9377 100644 --- a/debugger/debugutils.pp +++ b/debugger/debugutils.pp @@ -63,11 +63,13 @@ type Len: Integer; end; + TGdbUnEscapeFlags = set of (uefOctal, uefTab, uefNewLine); + function GetLine(var ABuffer: String): String; function ConvertToCString(const AText: String): String; function ConvertPathDelims(const AFileName: String): String; function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char = '\'): String; -function UnEscapeOctal(const AValue: String): String; +function UnEscapeBackslashed(const AValue: String; AFlags: TGdbUnEscapeFlags = [uefOctal]; ATabWidth: Integer = 0): String; function UnQuote(const AValue: String): String; function ConvertGdbPathAndFile(const AValue: String): String; // fix path, delim, unescape, and to utf8 @@ -194,7 +196,7 @@ begin Result[i] := PathDelim; end; -function UnEscapeOctal(const AValue: String): String; +function UnEscapeBackslashed(const AValue: String; AFlags: TGdbUnEscapeFlags = [uefOctal]; ATabWidth: Integer = 0): String; var c, cnt, len: Integer; Src, Dst: PChar; @@ -209,26 +211,69 @@ begin 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 - 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; + if (Src^ = '\') then begin + case (Src+1)^ of + '\' : + begin + inc(Src); + dec(cnt); + end; + '0'..'7' : + if uefOctal in AFlags then begin + inc(Src); + dec(cnt); + 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; + 'n' : + if uefNewLine in AFlags then begin + inc(Src, 2); + dec(cnt, 2); + Dst^ := #10; + Inc(Dst); + continue; + end; + 'r' : + if uefNewLine in AFlags then begin + inc(Src, 2); + dec(cnt, 2); + Dst^ := #13; + Inc(Dst); + continue; + end; + 't' : + if uefTab in AFlags then begin + inc(Src, 2); + dec(cnt, 2); + if ATabWidth > 0 then begin; + c := Dst - @Result[1]; + if Length(Result) < c + cnt + ATabWidth + 1 then begin + SetLength(Result, Length(Result) + ATabWidth); + Dst := @Result[1] + c; + end; + repeat + Dst^ := ' '; + Inc(Dst); + until ((Dst - @Result[1]) mod ATabWidth) = 0; + end + else begin + Dst^ := #9; + Inc(Dst); + end; + continue; + end; end; end; Dst^ := Src^; @@ -254,7 +299,7 @@ end; function ConvertGdbPathAndFile(const AValue: String): String; begin - Result := AnsiToUtf8(ConvertPathDelims(UnEscapeOctal(AValue))); + Result := AnsiToUtf8(ConvertPathDelims(UnEscapeBackslashed(AValue, [uefOctal]))); end; function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char): String; diff --git a/debugger/gdbmidebugger.pp b/debugger/gdbmidebugger.pp index 8aa9ae3415..15c27895ca 100644 --- a/debugger/gdbmidebugger.pp +++ b/debugger/gdbmidebugger.pp @@ -2194,7 +2194,8 @@ begin // SrcStatementIndex, SrcStatementCount are already set FItems[Index].ParsedInfo.Addr := PCLenToQWord(AsmList.ValuesPtr['address'], 0); - FItems[Index].ParsedInfo.Statement := PCLenToString(AsmList.ValuesPtr['inst'], True); + FItems[Index].ParsedInfo.Statement := + UnEscapeBackslashed(PCLenToString(AsmList.ValuesPtr['inst'], True), [uefTab], 16); FItems[Index].ParsedInfo.FuncName := PCLenToString(AsmList.ValuesPtr['func-name'], True); FItems[Index].ParsedInfo.Offset := PCLenToInt(AsmList.ValuesPtr['offset'], 0);