FpDebugger (console): Several improvements on the output of the console-debugger

git-svn-id: trunk@45424 -
This commit is contained in:
joost 2014-06-09 09:35:28 +00:00
parent 5c3fd8af1d
commit eaef9905a5
2 changed files with 37 additions and 8 deletions

View File

@ -93,6 +93,12 @@ var
MShowCommands: TFPDCommandList;
MSetCommands: TFPDCommandList;
resourcestring
sAddBreakpoint = 'Breakpoint added at address %s.';
sAddBreakpointFailed = 'Adding breakpoint at %s failed.';
sRemoveBreakpoint = 'Breakpoint removed from address %s.';
sRemoveBreakpointFailed = 'Removing breakpoint at %s failed.';
procedure HandleCommand(ACommand: String; out CallProcessLoop: boolean);
begin
MCommands.HandleCommand(ACommand, CallProcessLoop);
@ -189,12 +195,12 @@ var
AValue: TFpDbgValue;
begin
CallProcessLoop:=false;
if GController.MainProcess = nil
then begin
WriteLN('No Process');
Exit;
end;
CallProcessLoop:=false;
S := AParams;
P := GetPart([], [' ', #9], S);
@ -236,13 +242,13 @@ begin
if Remove
then begin
if GController.CurrentProcess.RemoveBreak(Address)
then WriteLn('breakpoint removed')
else WriteLn('remove breakpoint failed');
then WriteLn(format(sRemoveBreakpoint,[FormatAddress(Address)]))
else WriteLn(Format(sRemoveBreakpointFailed, [FormatAddress(Address)]));
end
else begin
if GController.CurrentProcess.AddBreak(Address) <> nil
then WriteLn('breakpoint added')
else WriteLn('add breakpoint failed');
then WriteLn(format(sAddBreakpoint, [FormatAddress(Address)]))
else WriteLn(Format(sAddBreakpointFailed, [FormatAddress(Address)]));
end;
end
else begin
@ -264,11 +270,11 @@ begin
bp := TDbgInstance(GController.CurrentProcess).AddBreak(P, Line);
if bp = nil
then begin
WriteLn('add breakpoint failed');
WriteLn(Format(sAddBreakpointFailed, [S]));
Exit;
end;
WriteLn('breakpoint added at: ', FormatAddress(bp.Location));
WriteLn(format(sAddBreakpoint, [FormatAddress(bp.Location)]))
end;
end;
@ -579,7 +585,14 @@ end;
procedure HandleQuit(AParams: String; out CallProcessLoop: boolean);
begin
WriteLN('Quitting ...');
CallProcessLoop := assigned(GController.MainProcess);
if assigned(GController.MainProcess) then
begin
WriteLn('Killing application ...');
GController.Stop;
CallProcessLoop:=true;
end
else
CallProcessLoop := false;
CustomApplication.Terminate;
end;

View File

@ -52,6 +52,7 @@ type
procedure GControllerExceptionEvent(var continue: boolean; const ExceptionClass, ExceptionMessage: string);
procedure GControllerCreateProcessEvent(var continue: boolean);
procedure GControllerHitBreakpointEvent(var continue: boolean; const Breakpoint: TDbgBreakpoint);
procedure GControllerProcessExitEvent(ExitCode: DWord);
procedure OnLog(const AString: string; const ALogLevel: TFPDLogLevel);
protected
Procedure DoRun; override;
@ -66,6 +67,11 @@ uses
FpDbgUtil,
FPDGlobal;
resourcestring
sBreakpointReached = 'Breakpoint reached at %s.';
sProcessPaused = 'Process paused.';
sProcessExited = 'Process ended with exit-code %d.';
{ TFPDLoop }
procedure TFPDLoop.GControllerExceptionEvent(var continue: boolean; const ExceptionClass, ExceptionMessage: string);
@ -84,6 +90,11 @@ begin
writeln('Program raised exception class '''+ExceptionClass+'''.');
end;
procedure TFPDLoop.GControllerProcessExitEvent(ExitCode: DWord);
begin
writeln(format(sProcessExited,[ExitCode]));
end;
procedure TFPDLoop.ShowDisas;
var
a: TDbgPtr;
@ -185,6 +196,10 @@ end;
procedure TFPDLoop.GControllerHitBreakpointEvent(var continue: boolean; const Breakpoint: TDbgBreakpoint);
begin
if assigned(Breakpoint) then
writeln(Format(sBreakpointReached, [FormatAddress(Breakpoint.Location)]))
else
writeln(sProcessPaused);
if not continue then
begin
ShowCode;
@ -228,6 +243,7 @@ begin
GController.OnHitBreakpointEvent:=@GControllerHitBreakpointEvent;
GController.OnCreateProcessEvent:=@GControllerCreateProcessEvent;
GController.OnExceptionEvent:=@GControllerExceptionEvent;
GController.OnProcessExitEvent:=@GControllerProcessExitEvent;
end;
initialization