Browse Source

+ added function gdbmiwrap.C2PascalNumberPrefix for converting C number prefixes
to Pascal (i.e. 0x to $, 0 to &)
* use the new function when parsing numbers returned by gdb. This fixes parsing
of octal numbers, which are sometimes returned by gdb (no idea why).

git-svn-id: trunk@30104 -

nickysn 10 years ago
parent
commit
8ef6845930
1 changed files with 18 additions and 4 deletions
  1. 18 4
      ide/gdbmiwrap.pas

+ 18 - 4
ide/gdbmiwrap.pas

@@ -123,6 +123,7 @@ type
   end;
   end;
 
 
 function QuoteString(S: string): string;
 function QuoteString(S: string): string;
+function C2PascalNumberPrefix(const S: string): string;
 
 
 implementation
 implementation
 
 
@@ -154,6 +155,19 @@ begin
   Result := '"' + Result + '"';
   Result := '"' + Result + '"';
 end;
 end;
 
 
+function C2PascalNumberPrefix(const S: string): string;
+begin
+  { hex: 0x -> $ }
+  if (Length(S) >= 3) and (s[1] = '0') and ((s[2] = 'x') or (s[2] = 'X')) then
+    exit('$' + Copy(S, 3, Length(S) - 2));
+
+  { oct: 0 -> & }
+  if (Length(S) >= 2) and (s[1] = '0') and ((s[2] >= '0') and (s[2] <= '7')) then
+    exit('&' + Copy(S, 2, Length(S) - 1));
+
+  Result := S;
+end;
+
 function TGDBMI_Value.AsString: string;
 function TGDBMI_Value.AsString: string;
 begin
 begin
   Result := (self as TGDBMI_StringValue).StringValue;
   Result := (self as TGDBMI_StringValue).StringValue;
@@ -161,17 +175,17 @@ end;
 
 
 function TGDBMI_Value.AsLongInt: LongInt;
 function TGDBMI_Value.AsLongInt: LongInt;
 begin
 begin
-  Result := StrToInt(AsString);
+  Result := StrToInt(C2PascalNumberPrefix(AsString));
 end;
 end;
 
 
 function TGDBMI_Value.AsCoreAddr: CORE_ADDR;
 function TGDBMI_Value.AsCoreAddr: CORE_ADDR;
 begin
 begin
 {$if defined(TARGET_IS_64BIT)}
 {$if defined(TARGET_IS_64BIT)}
-  Result := StrToQWord(AsString);
+  Result := StrToQWord(C2PascalNumberPrefix(AsString));
 {$elseif defined(CPU64)}
 {$elseif defined(CPU64)}
-  Result := StrToInt64(AsString);
+  Result := StrToInt64(C2PascalNumberPrefix(AsString));
 {$else}
 {$else}
-  Result := StrToInt(AsString);
+  Result := StrToInt(C2PascalNumberPrefix(AsString));
 {$endif}
 {$endif}
 end;
 end;