mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-23 20:20:32 +02:00
* improvements to the libgdb.a version of Print[Formatted]Command:
* return got_error=true in case of an error (fixes display of local variables of a parent function from a nested one) * fixed returning an error message (previously it would return an empty string) * trimming the #10 at the end simplified by the use of an ansistring function * we now also trim whitespace from the end, which was previously done in TWatch.Get_new_value, so I assume it was necessary for some gdb versions git-svn-id: trunk@30077 -
This commit is contained in:
parent
e0c4e0456f
commit
de6975d001
@ -423,11 +423,26 @@ end;
|
|||||||
|
|
||||||
{ print }
|
{ print }
|
||||||
|
|
||||||
|
function TrimEnd(s: AnsiString): AnsiString;
|
||||||
|
var
|
||||||
|
I: LongInt;
|
||||||
|
begin
|
||||||
|
if (s<>'') and (s[Length(s)]=#10) then
|
||||||
|
begin
|
||||||
|
I:=Length(s);
|
||||||
|
while (i>1) and ((s[i-1]=' ') or (s[i-1]=#9)) do
|
||||||
|
dec(i);
|
||||||
|
delete(s,i,Length(s)-i+1);
|
||||||
|
end;
|
||||||
|
TrimEnd:=s;
|
||||||
|
end;
|
||||||
|
|
||||||
function TGDBController.InternalGetValue(Const expr : string) : AnsiString;
|
function TGDBController.InternalGetValue(Const expr : string) : AnsiString;
|
||||||
var
|
var
|
||||||
p,p2,p3 : pchar;
|
p,p2,p3 : pchar;
|
||||||
st : string;
|
st : string;
|
||||||
WindowWidth : longint;
|
WindowWidth : longint;
|
||||||
|
saved_got_error: Boolean;
|
||||||
begin
|
begin
|
||||||
Command('show width');
|
Command('show width');
|
||||||
p:=GetOutput;
|
p:=GetOutput;
|
||||||
@ -454,13 +469,8 @@ begin
|
|||||||
if WindowWidth<>-1 then
|
if WindowWidth<>-1 then
|
||||||
Command('set width 0xffffffff');
|
Command('set width 0xffffffff');
|
||||||
Command('p '+expr);
|
Command('p '+expr);
|
||||||
|
saved_got_error:=got_error;
|
||||||
p:=GetOutput;
|
p:=GetOutput;
|
||||||
p3:=nil;
|
|
||||||
if assigned(p) and (p[strlen(p)-1]=#10) then
|
|
||||||
begin
|
|
||||||
p3:=p+strlen(p)-1;
|
|
||||||
p3^:=#0;
|
|
||||||
end;
|
|
||||||
if assigned(p) then
|
if assigned(p) then
|
||||||
p2:=strpos(p,'=')
|
p2:=strpos(p,'=')
|
||||||
else
|
else
|
||||||
@ -474,18 +484,16 @@ begin
|
|||||||
p:=strpos(p,')')+1;
|
p:=strpos(p,')')+1;
|
||||||
while p^ in [' ',#9] do
|
while p^ in [' ',#9] do
|
||||||
inc(p);
|
inc(p);
|
||||||
if assigned(p) then
|
if assigned(p) and not saved_got_error then
|
||||||
InternalGetValue:=AnsiString(p)
|
InternalGetValue:=TrimEnd(AnsiString(p))
|
||||||
else
|
else
|
||||||
InternalGetValue:=AnsiString(GetError);
|
InternalGetValue:=TrimEnd(AnsiString(GetError));
|
||||||
if assigned(p3) then
|
|
||||||
p3^:=#10;
|
|
||||||
got_error:=false;
|
|
||||||
if WindowWidth<>-1 then
|
if WindowWidth<>-1 then
|
||||||
begin
|
begin
|
||||||
str(WindowWidth,st);
|
str(WindowWidth,st);
|
||||||
Command('set width '+St);
|
Command('set width '+St);
|
||||||
end;
|
end;
|
||||||
|
got_error:=saved_got_error;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user