gdb com, completely avoid string cmp once break reason matched

This commit is contained in:
Basile Burg 2017-02-09 23:22:33 +01:00
parent 4e7cf83fad
commit f5ac773110
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 28 additions and 10 deletions

View File

@ -526,6 +526,22 @@ type
destructor destroy; override; destructor destroy; override;
end; end;
const
SR_exec = 0;
SR_access_watchpoint_trigger = 1;
SR_location_reached = 2;
SR_syscall_return = 3;
SR_vfork = 4;
SR_syscall_entry = 5;
SR_watchpoint_trigger= 6;
SR_read_watchpoint_trigger = 8;
SR_breakpoint_hit = 9;
SR_end_stepping_range = 10;
SR_function_finished = 11;
SR_fork = 13;
SR_solib_event = 14;
type
// Perfect static hash-set that detect a GDB stop reason // Perfect static hash-set that detect a GDB stop reason
stopReasons = record stopReasons = record
public public
@ -562,7 +578,7 @@ type
); );
class function hash(const w: string): Byte; static; {$IFNDEF DEBUG}inline;{$ENDIF} class function hash(const w: string): Byte; static; {$IFNDEF DEBUG}inline;{$ENDIF}
public public
class function match(const w: string): PString; static; {$IFNDEF DEBUG}inline;{$ENDIF} class function match(const w: string): shortint; static; {$IFNDEF DEBUG}inline;{$ENDIF}
end; end;
implementation implementation
@ -1006,16 +1022,16 @@ begin
end; end;
{$IFDEF DEBUG}{$POP}{$ENDIF} {$IFDEF DEBUG}{$POP}{$ENDIF}
class function stopReasons.match(const w: string): PString; class function stopReasons.match(const w: string): shortint;
var var
h: Byte; h: Byte;
begin begin
result := nil; result := -1;
if (length(w) < 4) or (length(w) > 25) then if (length(w) < 4) or (length(w) > 25) then
exit; exit;
h := hash(w); h := hash(w);
if fHasEntry[h] and (fWords[h] = w) then if fHasEntry[h] and (fWords[h] = w) then
result := @fWords[h]; result := h;
end; end;
{$ENDREGION} {$ENDREGION}
@ -2050,7 +2066,7 @@ procedure TCEGdbWidget.interpretJson;
end; end;
var var
r: PString; r: shortint;
i,j: integer; i,j: integer;
val: TJSONData; val: TJSONData;
obj: TJSONObject; obj: TJSONObject;
@ -2077,13 +2093,15 @@ begin
begin begin
reason := val.AsString; reason := val.AsString;
r := stopReasons.match(reason); r := stopReasons.match(reason);
if assigned(r) then if r <> -1 then
begin begin
case r^ of case r of
'breakpoint-hit': brkreason := dbBreakPoint; SR_breakpoint_hit:
'watchpoint-trigger', 'access-watchpoint-trigger', 'read-watchpoint-trigger': brkreason := dbBreakPoint;
SR_watchpoint_trigger, SR_access_watchpoint_trigger, SR_read_watchpoint_trigger:
brkreason:= dbWatch; brkreason:= dbWatch;
else brkreason := dbStep; else
brkreason := dbStep;
end; end;
if brkreason = dbWatch then if brkreason = dbWatch then
begin begin