+ added parameter BreakIndex (containing the breakpoint index if we stopped on a

breakpoint, or zero otherwise) to DoSelectSourceLine, instead of using
  stop_breakpoint_number
- removed stop_breakpoint_number and all the convoluted logic around it from the
  gdb/mi interface
* made stop_breakpoint_number private in the libgdb.a interface to ensure it's
  only used for internal use; UI code should rely on the new BreakIndex
  parameter instead

git-svn-id: trunk@30003 -
This commit is contained in:
nickysn 2015-02-25 01:48:23 +00:00
parent ec71e47b83
commit 47509b0148
3 changed files with 21 additions and 32 deletions

View File

@ -70,7 +70,7 @@ type
procedure SetWidth(AWidth : longint);
procedure SetSourceDirs;
destructor Done;
procedure DoSelectSourceline(const fn:string;line:longint);virtual;
procedure DoSelectSourceline(const fn:string;line,BreakIndex:longint);virtual;
{ procedure DoStartSession;virtual;
procedure DoBreakSession;virtual;}
procedure DoEndSession(code:longint);virtual;
@ -1346,18 +1346,16 @@ begin
{$endif}
end;
procedure TDebugController.DoSelectSourceLine(const fn:string;line:longint);
procedure TDebugController.DoSelectSourceLine(const fn:string;line,BreakIndex:longint);
var
W: PSourceWindow;
Found : boolean;
PB : PBreakpoint;
S : String;
BreakIndex : longint;
stop_addr : CORE_ADDR;
i,ExitCode : longint;
ExitAddr,ExitFrame : CORE_ADDR;
begin
BreakIndex:=stop_breakpoint_number;
Desktop^.Lock;
{ 0 based line count in Editor }
if Line>0 then

View File

@ -76,8 +76,7 @@ type
{ frames and frame info while recording a frame }
frames: PPFrameEntry;
frame_count: LongInt;
command_level,
stop_breakpoint_number: LongInt;
command_level: LongInt;
signal_name: PChar;
signal_string: PChar;
current_pc: CORE_ADDR;
@ -101,7 +100,7 @@ type
procedure FlushAll; virtual;
function Query(question: PChar; args: PChar): LongInt; virtual;
{ Hooks }
procedure DoSelectSourceline(const fn: string; line: LongInt); virtual;
procedure DoSelectSourceline(const fn: string; line, BreakIndex: longint);virtual;
procedure DoStartSession; virtual;
procedure DoBreakSession; virtual;
procedure DoEndSession(code: LongInt); virtual;
@ -266,15 +265,10 @@ end;
procedure TGDBInterface.i_gdb_command(const S: string);
var
prev_stop_breakpoint_number: LongInt;
I: LongInt;
begin
Inc(command_level);
got_error := False;
if command_level = 1 then
prev_stop_breakpoint_number := 0
else
prev_stop_breakpoint_number := stop_breakpoint_number;
GDB.Command(S);
if output_raw then
for I := 0 to GDB.RawResponse.Count - 1 do
@ -290,7 +284,6 @@ begin
end;
ProcessResponse;
Dec(command_level);
stop_breakpoint_number := prev_stop_breakpoint_number;
end;
procedure TGDBInterface.WaitForProgramStop;
@ -353,7 +346,7 @@ Ignore:
else if StopReason = 'read-watchpoint-trigger' then
BreakpointNo := GDB.ExecAsyncOutput.Parameters['hw-rwpt'].AsTuple['number'].AsLongInt
else
BreakpointNo := -1;
BreakpointNo := 0;
Addr := GDB.ExecAsyncOutput.Parameters['frame'].AsTuple['addr'].AsPtrInt;
if Assigned(GDB.ExecAsyncOutput.Parameters['frame'].AsTuple['fullname']) then
@ -361,18 +354,13 @@ Ignore:
if Assigned(GDB.ExecAsyncOutput.Parameters['frame'].AsTuple['line']) then
LineNumber := GDB.ExecAsyncOutput.Parameters['frame'].AsTuple['line'].AsLongInt;
{ this resets stop_breakpoint_number to zero, so it's important to set it *afterwards* }
{ this also kills GDB.ExecAsyncOutput, because it may execute other gdb commands, so
{ this kills GDB.ExecAsyncOutput, because it may execute other gdb commands, so
make sure we have read all parameters that we need to local variables before that }
DebuggerScreen;
{ now, set stop_breakpoint_number (if applicable) }
if BreakpointNo <> -1 then
stop_breakpoint_number := BreakpointNo;
Debuggee_started := True;
current_pc := Addr;
DoSelectSourceLine(FileName, LineNumber);
DoSelectSourceLine(FileName, LineNumber, BreakpointNo);
end;
'exited-signalled':
begin
@ -489,7 +477,7 @@ begin
Query := 0;
end;
procedure TGDBInterface.DoSelectSourceline(const fn: string; line: LongInt);
procedure TGDBInterface.DoSelectSourceline(const fn: string; line, BreakIndex: LongInt);
begin
end;

View File

@ -870,6 +870,9 @@ type
pgdbinterface=^tgdbinterface;
tgdbinterface=object
private
stop_breakpoint_number : longint;
public
gdberrorbuf,
gdboutputbuf : tgdbbuffer;
got_error,
@ -885,7 +888,6 @@ type
frame_begin_seen : boolean;
frame_level,
command_level,
stop_breakpoint_number,
current_line_number,
signal_start,
signal_end,
@ -931,7 +933,7 @@ type
procedure clear_frames;
{ Highlevel }
procedure GetAddrSyminfo(addr:ptrint;var si:tsyminfo);
procedure SelectSourceline(fn:pchar;line:longint);
procedure SelectSourceline(fn:pchar;line,BreakIndex:longint);
procedure StartSession;
procedure BreakSession;
procedure EndSession(code:longint);
@ -940,7 +942,7 @@ type
procedure FlushAll; virtual;
function Query(question : pchar; args : pchar) : longint; virtual;
{ Hooks }
procedure DoSelectSourceline(const fn:string;line:longint);virtual;
procedure DoSelectSourceline(const fn:string;line,BreakIndex:longint);virtual;
procedure DoStartSession;virtual;
procedure DoBreakSession;virtual;
procedure DoEndSession(code:longint);virtual;
@ -2151,7 +2153,7 @@ begin
fname:=sym.symtab^.filename
else
fname:=nil;
SelectSourceLine(fname,sym.line);
SelectSourceLine(fname,sym.line,stop_breakpoint_number);
end;
end;
@ -3205,12 +3207,12 @@ begin
end;
procedure tgdbinterface.SelectSourceLine(fn:pchar;line:longint);
procedure tgdbinterface.SelectSourceLine(fn:pchar;line,BreakIndex:longint);
begin
if assigned(fn) then
DoSelectSourceLine(StrPas(fn),line)
DoSelectSourceLine(StrPas(fn),line,BreakIndex)
else
DoSelectSourceLine('',line);
DoSelectSourceLine('',line,BreakIndex);
end;
@ -3272,15 +3274,16 @@ end;
Default Hooks
---------------------------------------}
procedure tgdbinterface.DoSelectSourceLine(const fn:string;line:longint);
procedure tgdbinterface.DoSelectSourceLine(const fn:string;line,BreakIndex:longint);
{$ifdef Verbose}
var
s : string;
s,bs : string;
{$endif}
begin
{$ifdef Verbose}
Str(line,S);
Debug('|SelectSource '+fn+':'+s+'|');
Str(BreakIndex,BS);
Debug('|SelectSource '+fn+':'+s+','+bs+'|');
{$endif}
end;