mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 06:49:38 +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 }
|
||||
|
||||
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;
|
||||
var
|
||||
p,p2,p3 : pchar;
|
||||
st : string;
|
||||
WindowWidth : longint;
|
||||
saved_got_error: Boolean;
|
||||
begin
|
||||
Command('show width');
|
||||
p:=GetOutput;
|
||||
@ -454,13 +469,8 @@ begin
|
||||
if WindowWidth<>-1 then
|
||||
Command('set width 0xffffffff');
|
||||
Command('p '+expr);
|
||||
saved_got_error:=got_error;
|
||||
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
|
||||
p2:=strpos(p,'=')
|
||||
else
|
||||
@ -474,18 +484,16 @@ begin
|
||||
p:=strpos(p,')')+1;
|
||||
while p^ in [' ',#9] do
|
||||
inc(p);
|
||||
if assigned(p) then
|
||||
InternalGetValue:=AnsiString(p)
|
||||
if assigned(p) and not saved_got_error then
|
||||
InternalGetValue:=TrimEnd(AnsiString(p))
|
||||
else
|
||||
InternalGetValue:=AnsiString(GetError);
|
||||
if assigned(p3) then
|
||||
p3^:=#10;
|
||||
got_error:=false;
|
||||
InternalGetValue:=TrimEnd(AnsiString(GetError));
|
||||
if WindowWidth<>-1 then
|
||||
begin
|
||||
str(WindowWidth,st);
|
||||
Command('set width '+St);
|
||||
end;
|
||||
got_error:=saved_got_error;
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user