Debugger: Clean up debugln without log_group

This commit is contained in:
Martin 2023-03-02 15:47:21 +01:00
parent 179dc59dc6
commit 1caa678dcf
12 changed files with 80 additions and 76 deletions

View File

@ -542,7 +542,7 @@ function TFpDbgInfoCallContext.AddOrdinalParam(AParamSymbolType: TFpSymbol; AVal
var var
ParamSymbol: TFpValue; ParamSymbol: TFpValue;
begin begin
debugln(['TFpDbgInfoCallContext.AddOrdinalParam ',FNextParamRegister]); debugln(FPDBG_FUNCCALL, ['TFpDbgInfoCallContext.AddOrdinalParam ',FNextParamRegister]);
Result := False; Result := False;
if AParamSymbolType = nil then if AParamSymbolType = nil then
AParamSymbolType := TFpSymbolCallParamOrdinalOrPointer.Create('', 0) AParamSymbolType := TFpSymbolCallParamOrdinalOrPointer.Create('', 0)

View File

@ -802,7 +802,6 @@ function TDbgWinProcess.Continue(AProcess: TDbgProcess; AThread: TDbgThread;
Result := True; Result := True;
break; break;
end; end;
debugln(['HasThreadInSkippingBreak ',Result]);
end; end;
var var
@ -811,7 +810,7 @@ var
WinAThread: TDbgWinThread absolute AThread; WinAThread: TDbgWinThread absolute AThread;
HasExceptionCleared, EventThreadNeedsTempBrkRemove: Boolean; HasExceptionCleared, EventThreadNeedsTempBrkRemove: Boolean;
begin begin
debugln(FPDBG_WINDOWS, ['TDbgWinProcess.Continue ',SingleStep, ' # ', ' # ',DbgSTime]); debugln(FPDBG_WINDOWS, ['TDbgWinProcess.Continue ',SingleStep, ' # ', ' # ',DbgSTime]);
HasExceptionCleared := (WinAThread <> nil) and WinAThread.FHasExceptionCleared; HasExceptionCleared := (WinAThread <> nil) and WinAThread.FHasExceptionCleared;
if assigned(AThread) and not FThreadMap.HasId(AThread.ID) then begin if assigned(AThread) and not FThreadMap.HasId(AThread.ID) then begin
@ -984,10 +983,10 @@ begin
// we currently do not use the file handle => close it // we currently do not use the file handle => close it
if MDebugEvent.CreateProcessInfo.hFile <> 0 then if MDebugEvent.CreateProcessInfo.hFile <> 0 then
if not CloseHandle(MDebugEvent.CreateProcessInfo.hFile) then if not CloseHandle(MDebugEvent.CreateProcessInfo.hFile) then
debugln([DBG_WARNINGS, 'Failed to close new process file handle: ',GetLastErrorText]); debugln(DBG_WARNINGS, ['Failed to close new process file handle: ',GetLastErrorText]);
if _DebugActiveProcessStop <> nil then if _DebugActiveProcessStop <> nil then
if not _DebugActiveProcessStop(MDebugEvent.dwProcessId) then if not _DebugActiveProcessStop(MDebugEvent.dwProcessId) then
debugln([DBG_WARNINGS, 'Failed to detach: ',GetLastErrorText]); debugln(DBG_WARNINGS, ['Failed to detach: ',GetLastErrorText]);
Windows.ContinueDebugEvent(MDebugEvent.dwProcessId, MDebugEvent.dwThreadId, DBG_CONTINUE); Windows.ContinueDebugEvent(MDebugEvent.dwProcessId, MDebugEvent.dwThreadId, DBG_CONTINUE);
Done := False; Done := False;

View File

@ -117,7 +117,7 @@ uses
SysUtils; SysUtils;
var var
DBG_CMD_ECHO, DBG_CMD_ECHO_FULL: PLazLoggerLogGroup; DBG_WARNINGS, DBG_CMD_ECHO, DBG_CMD_ECHO_FULL: PLazLoggerLogGroup;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: WaitForHandles Function: WaitForHandles
@ -157,7 +157,7 @@ begin
end; end;
if Max=0 then begin if Max=0 then begin
// no valid handle, so no change possible // no valid handle, so no change possible
DebugLn('WaitForHandles: Error: no handles'); DebugLn(DBG_WARNINGS or DBG_CMD_ECHO, 'WaitForHandles: Error: no handles');
exit; exit;
end; end;
@ -249,7 +249,7 @@ begin
R := Windows.PeekNamedPipe(PipeHandle, nil, 0, nil, @TotalBytesAvailable, nil); R := Windows.PeekNamedPipe(PipeHandle, nil, 0, nil, @TotalBytesAvailable, nil);
if not R then begin if not R then begin
// PeekNamedPipe failed // PeekNamedPipe failed
DebugLn('PeekNamedPipe failed, GetLastError is ', IntToStr(GetLastError)); DebugLn(DBG_WARNINGS or DBG_CMD_ECHO, 'PeekNamedPipe failed, GetLastError is ', IntToStr(GetLastError));
Exit; Exit;
end; end;
if R then begin if R then begin
@ -401,12 +401,12 @@ begin
then begin then begin
try try
FDbgProcess.Execute; FDbgProcess.Execute;
DebugLn('[TCmdLineDebugger] Debug PID: ', IntToStr(FDbgProcess.Handle)); DebugLn(DBG_CMD_ECHO, '[TCmdLineDebugger] Debug PID: ', IntToStr(FDbgProcess.Handle));
Result := FDbgProcess.Running; Result := FDbgProcess.Running;
except except
on E: Exception do begin on E: Exception do begin
FOutputBuf := E.Message; FOutputBuf := E.Message;
DebugLn('Exception while executing debugger: ', FOutputBuf); DebugLn(DBG_WARNINGS or DBG_CMD_ECHO, 'Exception while executing debugger: ', FOutputBuf);
end; end;
end; end;
end; end;
@ -622,7 +622,7 @@ begin
{$EndIf} {$EndIf}
end end
else begin else begin
DebugLn('[TCmdLineDebugger.SendCmdLn] Unable to send <', ACommand, '>. No process running.'); DebugLn(DBG_WARNINGS or DBG_CMD_ECHO, '[TCmdLineDebugger.SendCmdLn] Unable to send <', ACommand, '>. No process running.');
DoWriteError; DoWriteError;
end; end;
end; end;
@ -658,6 +658,7 @@ begin
end; end;
initialization initialization
DBG_WARNINGS := DebugLogger.FindOrRegisterLogGroup('DBG_CMD_ECHO' {$IF defined(DBG_VERBOSE) or defined(DBG_CMD_ECHO)} , True {$ENDIF} );
DBG_CMD_ECHO := DebugLogger.FindOrRegisterLogGroup('DBG_CMD_ECHO' {$IF defined(DBG_VERBOSE) or defined(DBG_CMD_ECHO)} , True {$ENDIF} ); DBG_CMD_ECHO := DebugLogger.FindOrRegisterLogGroup('DBG_CMD_ECHO' {$IF defined(DBG_VERBOSE) or defined(DBG_CMD_ECHO)} , True {$ENDIF} );
DBG_CMD_ECHO_FULL := DebugLogger.FindOrRegisterLogGroup('DBG_CMD_ECHO_FULL' {$IF defined(DBG_VERBOSE_FULL_DATA) or defined(DBG_CMD_ECHO_FULL)} , True {$ENDIF} ); DBG_CMD_ECHO_FULL := DebugLogger.FindOrRegisterLogGroup('DBG_CMD_ECHO_FULL' {$IF defined(DBG_VERBOSE_FULL_DATA) or defined(DBG_CMD_ECHO_FULL)} , True {$ENDIF} );

View File

@ -4066,7 +4066,7 @@ begin
else else
begin begin
// unknown // unknown
debugln(['WARNING: TGDBMIDisassembleResultList.Parse: unknown disass entry', debugln(DBG_VERBOSE or DBG_WARNINGS, ['WARNING: TGDBMIDisassembleResultList.Parse: unknown disass entry',
DbgsPCLen(Itm^.Name),': ',DbgsPCLen(Itm^.Value)]); DbgsPCLen(Itm^.Name),': ',DbgsPCLen(Itm^.Value)]);
end; end;
end; end;
@ -5042,7 +5042,7 @@ function TGDBMIDebuggerCommandDisassemble.DoExecute: Boolean;
if DisAssList.Count < 2 if DisAssList.Count < 2
then begin then begin
debugln('Error failed to get enough data for dsassemble'); debugln(DBG_WARNINGS, 'Error failed to get enough data for dsassemble');
// create a dummy range, so we will not retry // create a dummy range, so we will not retry
NewRange.Capacity := 1; NewRange.Capacity := 1;
NewRange.RangeStartAddr := AFirstAddr.Value; NewRange.RangeStartAddr := AFirstAddr.Value;
@ -5737,7 +5737,7 @@ begin
exit; exit;
end; end;
DebugLn(['TGDBMIDebuggerBase.StartDebugging WorkingDir="', FTheDebugger.WorkingDir,'"']); DebugLn(DBG_VERBOSE, ['TGDBMIDebuggerBase.StartDebugging WorkingDir="', FTheDebugger.WorkingDir,'"']);
if FTheDebugger.WorkingDir <> '' if FTheDebugger.WorkingDir <> ''
then begin then begin
// to workaround a possible bug in gdb, first set the workingdir to . // to workaround a possible bug in gdb, first set the workingdir to .
@ -6594,7 +6594,7 @@ function TGDBMIDebuggerCommandExecute.ProcessStopped(const AParams: String;
if (DebuggerState = dsRun) if (DebuggerState = dsRun)
then begin then begin
debugln(['********** WARNING: breakpoint hit, but nothing known about it ABreakId=', ABreakID, ' brbtno=', List.Values['bkptno'] ]); debugln(DBG_VERBOSE or DBG_WARNINGS, ['********** WARNING: breakpoint hit, but nothing known about it ABreakId=', ABreakID, ' brbtno=', List.Values['bkptno'] ]);
{$IFDEF DBG_VERBOSE_BRKPOINT} {$IFDEF DBG_VERBOSE_BRKPOINT}
debugln(['-*- List of breakpoints Cnt=', FTheDebugger.Breakpoints.Count]); debugln(['-*- List of breakpoints Cnt=', FTheDebugger.Breakpoints.Count]);
for ABreakID := 0 to FTheDebugger.Breakpoints.Count - 1 do for ABreakID := 0 to FTheDebugger.Breakpoints.Count - 1 do
@ -7444,7 +7444,7 @@ var
end; end;
if i < 0 if i < 0
then begin then begin
DebugLn(['CommandExecute: exStepOver, frame not found: ', i]); DebugLn(DBG_VERBOSE or DBG_WARNINGS, ['CommandExecute: exStepOver, frame not found: ', i]);
DoEndStepping; // TODO: User-error feedback DoEndStepping; // TODO: User-error feedback
end; end;
end; end;
@ -7732,8 +7732,8 @@ begin
then begin then begin
// Handle the unforeseen // Handle the unforeseen
if (StoppedParams <> '') if (StoppedParams <> '')
then debugln(['ERROR: Got stop params, but did not change FTheDebugger.state: ', StoppedParams]) then debugln(DBG_VERBOSE or DBG_WARNINGS, ['ERROR: Got stop params, but did not change FTheDebugger.state: ', StoppedParams])
else debugln(['ERROR: Got NO stop params at all, but was running']); else debugln(DBG_VERBOSE or DBG_WARNINGS, ['ERROR: Got NO stop params at all, but was running']);
SetDebuggerState(dsPause); SetDebuggerState(dsPause);
end; end;
end; end;
@ -8873,7 +8873,7 @@ var
Report, Report2: string; Report, Report2: string;
begin begin
try try
debugln(['ERROR: Exception occurred in ',Sender.ClassName+': ', debugln(DBG_VERBOSE or DBG_WARNINGS, ['ERROR: Exception occurred in ',Sender.ClassName+': ',
AnException.ClassName, ' Msg="', AnException.Message, '" Addr=', dbgs(ExceptAddr), AnException.ClassName, ' Msg="', AnException.Message, '" Addr=', dbgs(ExceptAddr),
' Dbg.State=', dbgs(State)]); ' Dbg.State=', dbgs(State)]);
Report := BackTraceStrFunc(ExceptAddr); Report := BackTraceStrFunc(ExceptAddr);
@ -8886,7 +8886,7 @@ begin
end; end;
except except
end; end;
debugln(Report); debugln(DBG_VERBOSE or DBG_WARNINGS, [Report]);
if MessageDlg(gdbmiTheDebuggerExperiencedAnUnknownCondition, if MessageDlg(gdbmiTheDebuggerExperiencedAnUnknownCondition,
Format(gdbmiPressIgnoreToContinueDebuggingThisMayNOTBeSafePres, Format(gdbmiPressIgnoreToContinueDebuggingThisMayNOTBeSafePres,
@ -9258,7 +9258,7 @@ begin
except except
On E: Exception do DoUnknownException(Self, E); On E: Exception do DoUnknownException(Self, E);
else else
debugln(['ERROR: Exception occurred in ',ClassName+': ', debugln(DBG_VERBOSE or DBG_WARNINGS, ['ERROR: Exception occurred in ',ClassName+': ',
'" Addr=', dbgs(ExceptAddr), ' Dbg.State=', dbgs(State)]); '" Addr=', dbgs(ExceptAddr), ' Dbg.State=', dbgs(State)]);
end; end;
@ -12821,7 +12821,7 @@ begin
On E: Exception do FTheDebugger.DoUnknownException(Self, E) On E: Exception do FTheDebugger.DoUnknownException(Self, E)
else else
debugln(['ERROR: Exception occurred in ',ClassName+'.DoExecute ', debugln(DBG_VERBOSE or DBG_WARNINGS, ['ERROR: Exception occurred in ',ClassName+'.DoExecute ',
'" Addr=', dbgs(ExceptAddr), ' Dbg.State=', dbgs(FTheDebugger.State)]); '" Addr=', dbgs(ExceptAddr), ' Dbg.State=', dbgs(FTheDebugger.State)]);
end; end;
// No re-raise in the except block. So no try-finally required // No re-raise in the except block. So no try-finally required

View File

@ -735,7 +735,7 @@ begin
Result.Kind := CheckKeyword; Result.Kind := CheckKeyword;
if Result.Kind = ptprkSimple then begin if Result.Kind = ptprkSimple then begin
Result.Kind := ptprkError; Result.Kind := ptprkError;
debugln('** WARNING: ptype info format error: ' + ATypeText); debugln(DBG_WARNINGS, '** WARNING: ptype info format error: ' + ATypeText);
exit; exit;
end; end;
@ -1831,7 +1831,7 @@ begin
end; end;
if CurPtr < EndPtr then debugln(['Scan aborted: ', PCLenToString(FText)]); if CurPtr < EndPtr then debugln(DBG_WARNINGS, ['Scan aborted: ', PCLenToString(FText)]);
if CurPtr < EndPtr then FreeAndNil(Result); if CurPtr < EndPtr then FreeAndNil(Result);
end; end;
@ -2587,7 +2587,7 @@ var
then exit; then exit;
if IsReqError(t) if IsReqError(t)
then debugln('Failed "ptype expr^[^]" request for class expression'); then debugln(DBG_WARNINGS, 'Failed "ptype expr^[^]" request for class expression');
if (not IsReqError(t)) and (ptprfPointer in FReqResults[t].Result.Flags) if (not IsReqError(t)) and (ptprfPointer in FReqResults[t].Result.Flags)
then begin then begin

View File

@ -206,7 +206,7 @@ function dbgsInstr(AnInstr: TDBGInstruction): String;
implementation implementation
var var
DBGMI_TIMEOUT_DEBUG, DBG_THREAD_AND_FRAME, DBG_VERBOSE: PLazLoggerLogGroup; DBGMI_TIMEOUT_DEBUG, DBGMI_QUEUE_DEBUG, DBG_THREAD_AND_FRAME, DBG_VERBOSE: PLazLoggerLogGroup;
function dbgs(AState: TDBGInstructionState): String; function dbgs(AState: TDBGInstructionState): String;
begin begin
@ -294,7 +294,7 @@ end;
procedure TDBGInstruction.SetContentReceieved; procedure TDBGInstruction.SetContentReceieved;
begin begin
FState := disContentReceived; FState := disContentReceived;
debugln('disContentReceived'); debugln(DBG_VERBOSE and DBGMI_QUEUE_DEBUG, 'disContentReceived');
end; end;
procedure TDBGInstruction.InternalCreate(ACommand: String; AThread, procedure TDBGInstruction.InternalCreate(ACommand: String; AThread,
@ -333,7 +333,7 @@ end;
procedure TDBGInstruction.Cancel; procedure TDBGInstruction.Cancel;
begin begin
debugln(['TDBGInstruction.Cancel ', Command]); debugln(DBGMI_QUEUE_DEBUG, ['TDBGInstruction.Cancel ', Command]);
if FState = disQueued then if FState = disQueued then
FQueue.RemoveInstruction(Self) FQueue.RemoveInstruction(Self)
else else
@ -357,7 +357,7 @@ end;
procedure TDBGInstruction.MarkAsSuccess; procedure TDBGInstruction.MarkAsSuccess;
begin begin
debugln(['TDBGInstruction.MarkAsSuccess SUCCESS ', Command]); debugln(DBGMI_QUEUE_DEBUG, ['TDBGInstruction.MarkAsSuccess SUCCESS ', Command]);
FState := disComleted; FState := disComleted;
if FOnSuccess <> nil then FOnSuccess(Self); if FOnSuccess <> nil then FOnSuccess(Self);
if FOnFinish <> nil then FOnFinish(Self); if FOnFinish <> nil then FOnFinish(Self);
@ -368,7 +368,7 @@ end;
procedure TDBGInstruction.MarkAsFailed; procedure TDBGInstruction.MarkAsFailed;
begin begin
debugln(['TDBGInstruction.MarkAsFailed FAILED ',Command]); debugln(DBGMI_QUEUE_DEBUG, ['TDBGInstruction.MarkAsFailed FAILED ',Command]);
FState := disFailed; FState := disFailed;
if FOnFailure <> nil then FOnFailure(Self); if FOnFailure <> nil then FOnFailure(Self);
if FOnFinish <> nil then FOnFinish(Self); if FOnFinish <> nil then FOnFinish(Self);
@ -436,7 +436,7 @@ begin
exit; exit;
if FRunningInstruction <> nil then if FRunningInstruction <> nil then
exit; exit;
debugln(['TDBGInstructionQueue.RunQueue ', dbgsInstr(FCurrentInstruction), ' / ', dbgsInstr(FRunningInstruction)]); debugln(DBGMI_QUEUE_DEBUG, ['TDBGInstructionQueue.RunQueue ', dbgsInstr(FCurrentInstruction), ' / ', dbgsInstr(FRunningInstruction)]);
if FCurrentInstruction = nil then begin if FCurrentInstruction = nil then begin
FCurrentInstruction := GetNextInstructionToRun; FCurrentInstruction := GetNextInstructionToRun;
@ -444,7 +444,7 @@ debugln(['TDBGInstructionQueue.RunQueue ', dbgsInstr(FCurrentInstruction), ' / '
exit; exit;
FCurrentInstruction.AddReference; FCurrentInstruction.AddReference;
RemoveInstruction(FCurrentInstruction); RemoveInstruction(FCurrentInstruction);
DebugLnEnter(['>> Current Instruction: ', FCurrentInstruction.Command]); DebugLn(DBG_VERBOSE and DBGMI_QUEUE_DEBUG, ['>> Current Instruction: ', FCurrentInstruction.Command]);
end; end;
// set FCurrentInstruction to a pre running state, while changing stack.... // set FCurrentInstruction to a pre running state, while changing stack....
@ -547,15 +547,14 @@ end;
procedure TDBGInstructionQueue.DoInstructionFinished(Sender: TDBGInstruction); procedure TDBGInstructionQueue.DoInstructionFinished(Sender: TDBGInstruction);
begin begin
DebugLnExit(['<< Finished Instruction: ', FRunningInstruction.Command, ' // ', Sender=FRunningInstruction]); DebugLn(DBGMI_QUEUE_DEBUG, ['<< Finished Instruction: ', FRunningInstruction.Command, ' // ', Sender=FRunningInstruction]);
if nil = FCurrentInstruction then DebugLnExit(['<< Current Instruction: ']);
ReleaseRefAndNil(FRunningInstruction); ReleaseRefAndNil(FRunningInstruction);
RunQueue; RunQueue;
end; end;
procedure TDBGInstructionQueue.RunInstruction(AnInstruction: TDBGInstruction); procedure TDBGInstructionQueue.RunInstruction(AnInstruction: TDBGInstruction);
begin begin
DebugLnEnter(['>> Running Instruction: ', AnInstruction.Command]); DebugLn(DBGMI_QUEUE_DEBUG, ['>> Running Instruction: ', AnInstruction.Command]);
FRunningInstruction := AnInstruction; FRunningInstruction := AnInstruction;
FRunningInstruction.AddReference; FRunningInstruction.AddReference;
FRunningInstruction.SendCommandDataToDBG; FRunningInstruction.SendCommandDataToDBG;
@ -655,7 +654,7 @@ end;
procedure TDBGInstructionQueue.QueueInstruction(AnInstruction: TDBGInstruction); procedure TDBGInstructionQueue.QueueInstruction(AnInstruction: TDBGInstruction);
begin begin
debugln(['TDBGInstructionQueue.QueueInstruction ', AnInstruction.DebugText]); debugln(DBGMI_QUEUE_DEBUG, ['TDBGInstructionQueue.QueueInstruction ', AnInstruction.DebugText]);
Assert(AnInstruction.State = disNew, 'queue only new instr'); Assert(AnInstruction.State = disNew, 'queue only new instr');
AnInstruction.AddReference; AnInstruction.AddReference;
AnInstruction.FNextQueuedInstruction := nil; AnInstruction.FNextQueuedInstruction := nil;
@ -671,6 +670,7 @@ end;
initialization initialization
DBGMI_TIMEOUT_DEBUG := DebugLogger.FindOrRegisterLogGroup('DBGMI_TIMEOUT_DEBUG' {$IFDEF DBGMI_TIMEOUT_DEBUG} , True {$ENDIF} ); DBGMI_TIMEOUT_DEBUG := DebugLogger.FindOrRegisterLogGroup('DBGMI_TIMEOUT_DEBUG' {$IFDEF DBGMI_TIMEOUT_DEBUG} , True {$ENDIF} );
DBGMI_QUEUE_DEBUG := DebugLogger.FindOrRegisterLogGroup('DBGMI_QUEUE_DEBUG' {$IFDEF DBGMI_QUEUE_DEBUG} , True {$ENDIF} );
DBG_THREAD_AND_FRAME := DebugLogger.FindOrRegisterLogGroup('DBG_THREAD_AND_FRAME' {$IFDEF DBG_THREAD_AND_FRAME} , True {$ENDIF} ); DBG_THREAD_AND_FRAME := DebugLogger.FindOrRegisterLogGroup('DBG_THREAD_AND_FRAME' {$IFDEF DBG_THREAD_AND_FRAME} , True {$ENDIF} );
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} ); DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );

View File

@ -166,20 +166,17 @@ begin
break; break;
if r < 0 then begin if r < 0 then begin
DebugLn('TTTTT pipe err'); DebugLn(DBG_WARNINGS, 'TDebugProcessReadThread.Execute: pipe err');
Queue(FOnPipeError); Queue(FOnPipeError);
exit; exit;
end; end;
if (R > 0) and (FpFD_ISSET(FStream.Handle,FDS)=1) then begin if (R > 0) and (FpFD_ISSET(FStream.Handle,FDS)=1) then begin
DebugLn('TTTTT data avail');
Queue(FOnDataAvail); Queue(FOnDataAvail);
RTLeventWaitFor(FAsyncLoopWaitEvent); RTLeventWaitFor(FAsyncLoopWaitEvent);
DebugLn('TTTTT data avail continue');
end; end;
end; end;
DebugLn(['TTTTT loop end ', Terminated]);
RemoveQueuedEvents(Self, FOnDataAvail); RemoveQueuedEvents(Self, FOnDataAvail);
RemoveQueuedEvents(Self, FOnPipeError); RemoveQueuedEvents(Self, FOnPipeError);
end; end;
@ -225,7 +222,7 @@ end;
procedure TDebugAsyncProcess.ThreadPipeError; procedure TDebugAsyncProcess.ThreadPipeError;
begin begin
DebugLn(['got pipe err / is running ', Running]); DebugLn(DBG_WARNINGS, ['TDebugAsyncProcess.ThreadPipeError: got pipe err / is running ', Running]);
Terminate(0); Terminate(0);
HandleProcessTermination(0, cerExit, 0); HandleProcessTermination(0, cerExit, 0);
end; end;
@ -253,7 +250,6 @@ end;
procedure TDebugAsyncProcess.HandleProcessTermination(AData: PtrInt; procedure TDebugAsyncProcess.HandleProcessTermination(AData: PtrInt;
AReason: TChildExitReason; AInfo: dword); AReason: TChildExitReason; AInfo: dword);
begin begin
DebugLn('HandleProcessTermination');
UnhookProcessHandle; UnhookProcessHandle;
UnhookPipeHandle; UnhookPipeHandle;
if FOnTerminate <> nil then if FOnTerminate <> nil then
@ -311,9 +307,7 @@ begin
if FReadThread <> nil then begin if FReadThread <> nil then begin
TerminataThread; TerminataThread;
FReadThread.WaitFor; FReadThread.WaitFor;
debugln(['DESTROY thread destroying']);
FreeAndNil(FReadThread); FreeAndNil(FReadThread);
debugln(['DESTROY thread destroyed']);
end; end;
{$ENDIF} {$ENDIF}
inherited; inherited;
@ -328,9 +322,7 @@ begin
if FReadThread <> nil then begin if FReadThread <> nil then begin
TerminataThread; TerminataThread;
FReadThread.WaitFor; FReadThread.WaitFor;
debugln(['DESTROY thread destroying']);
FreeAndNil(FReadThread); FreeAndNil(FReadThread);
debugln(['DESTROY thread destroyed']);
end; end;
{$ENDIF} {$ENDIF}
Result := inherited Terminate(AExitCode); Result := inherited Terminate(AExitCode);
@ -547,7 +539,7 @@ end;
procedure TDebugProcess.StopDebugProcess; procedure TDebugProcess.StopDebugProcess;
begin begin
debugln(['TDebugProcess.StopDebugProcess FDbgProcess = nil ',FDbgProcess = nil]); debugln(DBG_VERBOSE, ['TDebugProcess.StopDebugProcess FDbgProcess = nil ',FDbgProcess = nil]);
if FDbgProcess = nil then exit; if FDbgProcess = nil then exit;
FDbgProcess.Terminate(0); FDbgProcess.Terminate(0);

View File

@ -347,6 +347,8 @@ type
end; end;
implementation implementation
var
DBG_VERBOSE, DBG_WARNINGS, FPDBG_FUNCCALL: PLazLoggerLogGroup;
{ TFpDbgDebggerThreadWorkerItem } { TFpDbgDebggerThreadWorkerItem }
@ -845,7 +847,7 @@ begin
if not (FunctionResultSymbolType.Kind in [skInteger, skCurrency, skPointer, skEnum, if not (FunctionResultSymbolType.Kind in [skInteger, skCurrency, skPointer, skEnum,
skCardinal, skBoolean, skChar, skClass, skString, skAnsiString, skWideString]) skCardinal, skBoolean, skChar, skClass, skString, skAnsiString, skWideString])
then begin then begin
DebugLn(['Error result kind ', dbgs(FunctionSymbolType.Kind)]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, ['Error result kind ', dbgs(FunctionSymbolType.Kind)]);
AnError := CreateError(fpErrAnyError, ['Result type of function not supported']); AnError := CreateError(fpErrAnyError, ['Result type of function not supported']);
exit; exit;
end; end;
@ -854,7 +856,7 @@ begin
if (not FunctionResultSymbolType.ReadSize(nil, FunctionResultDataSize)) or if (not FunctionResultSymbolType.ReadSize(nil, FunctionResultDataSize)) or
(FunctionResultDataSize > FDebugger.MemManager.RegisterSize(0)) (FunctionResultDataSize > FDebugger.MemManager.RegisterSize(0))
then begin then begin
DebugLn(['Error result size', dbgs(FunctionResultDataSize)]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, ['Error result size', dbgs(FunctionResultDataSize)]);
//ReturnMessage := 'Unable to call function. The size of the function-result exceeds the content-size of a register.'; //ReturnMessage := 'Unable to call function. The size of the function-result exceeds the content-size of a register.';
AnError := CreateError(fpErrAnyError, ['Result type of function not supported']); AnError := CreateError(fpErrAnyError, ['Result type of function not supported']);
exit; exit;
@ -878,7 +880,7 @@ begin
StringResultDecRefAddress := FDebugger.GetCached_FPC_ANSISTR_DECR_REF; StringResultDecRefAddress := FDebugger.GetCached_FPC_ANSISTR_DECR_REF;
if (StringResultDecRefAddress = 0) then begin if (StringResultDecRefAddress = 0) then begin
DebugLn(['Error result kind ', dbgs(FunctionSymbolType.Kind)]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, ['Error result kind ', dbgs(FunctionSymbolType.Kind)]);
AnError := CreateError(fpErrAnyError, ['Result type of function not supported']); AnError := CreateError(fpErrAnyError, ['Result type of function not supported']);
exit; exit;
end; end;
@ -900,7 +902,7 @@ begin
ProcAddress := AFunctionValue.EntryPCAddress; ProcAddress := AFunctionValue.EntryPCAddress;
if not IsReadableLoc(ProcAddress) then begin if not IsReadableLoc(ProcAddress) then begin
DebugLn(['Error proc addr']); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, ['Error proc addr']);
AnError := CreateError(fpErrAnyError, ['Unable to calculate function address']); AnError := CreateError(fpErrAnyError, ['Unable to calculate function address']);
exit; exit;
end; end;
@ -935,7 +937,7 @@ begin
else begin else begin
ExprParamVal := AParams.Items[FoundIdx].ResultValue; ExprParamVal := AParams.Items[FoundIdx].ResultValue;
if (ExprParamVal = nil) then begin if (ExprParamVal = nil) then begin
DebugLn('Internal error for arg %d ', [FoundIdx]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'Internal error for arg %d ', [FoundIdx]);
AnError := AnExpressionPart.Expression.Error; AnError := AnExpressionPart.Expression.Error;
if not IsError(AnError) then if not IsError(AnError) then
AnError := CreateError(fpErrAnyError, ['internal error, computing parameter']); AnError := CreateError(fpErrAnyError, ['internal error, computing parameter']);
@ -945,7 +947,7 @@ begin
rk := ExprParamVal.Kind; rk := ExprParamVal.Kind;
if not(rk in [skInteger, {skCurrency,} skPointer, skEnum, skCardinal, skBoolean, skChar, skClass, skRecord, skString, skAnsiString, skWideString]) if not(rk in [skInteger, {skCurrency,} skPointer, skEnum, skCardinal, skBoolean, skChar, skClass, skRecord, skString, skAnsiString, skWideString])
then begin then begin
DebugLn('Error not supported kind arg %d : %s ', [FoundIdx, dbgs(rk)]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'Error not supported kind arg %d : %s ', [FoundIdx, dbgs(rk)]);
AnError := CreateError(fpErrAnyError, ['parameter type not supported']); AnError := CreateError(fpErrAnyError, ['parameter type not supported']);
exit; exit;
end; end;
@ -986,7 +988,7 @@ begin
if (TempSymbol.Kind <> rk) and if (TempSymbol.Kind <> rk) and
( (TempSymbol.Kind in [skInteger, skCardinal]) <> (rk in [skInteger, skCardinal]) ) ( (TempSymbol.Kind in [skInteger, skCardinal]) <> (rk in [skInteger, skCardinal]) )
then begin then begin
DebugLn('Error kind mismatch for arg %d : %s <> %s', [FoundIdx, dbgs(TempSymbol.Kind), dbgs(rk)]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'Error kind mismatch for arg %d : %s <> %s', [FoundIdx, dbgs(TempSymbol.Kind), dbgs(rk)]);
AnError := CreateError(fpErrAnyError, ['wrong type for parameter']); AnError := CreateError(fpErrAnyError, ['wrong type for parameter']);
exit; exit;
end; end;
@ -996,7 +998,7 @@ begin
ParameterSymbolArr[FoundIdx].TypeSym := TempSymbol; ParameterSymbolArr[FoundIdx].TypeSym := TempSymbol;
end; end;
//if not IsTargetOrRegNotNil(FDebugger.DbgController.CurrentProcess.CallParamDefaultLocation(FoundIdx)) then begin //if not IsTargetOrRegNotNil(FDebugger.DbgController.CurrentProcess.CallParamDefaultLocation(FoundIdx)) then begin
// DebugLn('error to many args / not supported / arg > %d ', [FoundIdx]); // DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'error to many args / not supported / arg > %d ', [FoundIdx]);
// AnError := CreateError(fpErrAnyError, ['too many parameter / not supported']); // AnError := CreateError(fpErrAnyError, ['too many parameter / not supported']);
// exit; // exit;
//end; //end;
@ -1005,7 +1007,7 @@ begin
end; end;
if (FoundIdx <> PCnt) then begin if (FoundIdx <> PCnt) then begin
DebugLn(['Error param count']); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, ['Error param count']);
AnError := CreateError(fpErrAnyError, ['wrong amount of parameters']); AnError := CreateError(fpErrAnyError, ['wrong amount of parameters']);
exit; exit;
end; end;
@ -1017,7 +1019,7 @@ begin
try try
if (ASelfValue <> nil) then begin if (ASelfValue <> nil) then begin
if not CallContext.AddParam(SelfTypeSym.TypeInfo, ASelfValue) then begin if not CallContext.AddParam(SelfTypeSym.TypeInfo, ASelfValue) then begin
DebugLn('Internal error for self'); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'Internal error for self');
AnError := CallContext.LastError; AnError := CallContext.LastError;
exit; exit;
end; end;
@ -1025,7 +1027,7 @@ begin
if (StringResultDecRefAddress <> 0) then begin if (StringResultDecRefAddress <> 0) then begin
if not CallContext.AddStringResult then begin if not CallContext.AddStringResult then begin
DebugLn('Internal error for string result'); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'Internal error for string result');
AnError := CallContext.LastError; AnError := CallContext.LastError;
exit; exit;
end; end;
@ -1040,14 +1042,14 @@ begin
else else
ParRes := CallContext.AddParam(ParameterSymbolArr[i].TypeSym.TypeInfo, ParameterSymbolArr[i].ParamVal); ParRes := CallContext.AddParam(ParameterSymbolArr[i].TypeSym.TypeInfo, ParameterSymbolArr[i].ParamVal);
if not ParRes then begin if not ParRes then begin
DebugLn('Internal error for arg %d ', [i]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'Internal error for arg %d ', [i]);
AnError := CallContext.LastError; AnError := CallContext.LastError;
exit; exit;
end; end;
end; end;
if not CallContext.FinalizeParams then begin if not CallContext.FinalizeParams then begin
DebugLn('Internal error after params'); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, 'Internal error after params');
AnError := CallContext.LastError; AnError := CallContext.LastError;
exit; exit;
end; end;
@ -1056,7 +1058,7 @@ begin
FDebugger.RunProcessLoop(not FAllowFunctionsAllThread); FDebugger.RunProcessLoop(not FAllowFunctionsAllThread);
if not CallContext.IsValid then begin if not CallContext.IsValid then begin
DebugLn(['Error in call ',CallContext.Message]); DebugLn(FPDBG_FUNCCALL or DBG_WARNINGS, ['Error in call ',CallContext.Message]);
//ReturnMessage := CallContext.Message; //ReturnMessage := CallContext.Message;
AnError := CallContext.LastError; AnError := CallContext.LastError;
if not IsError(AnError) then if not IsError(AnError) then
@ -1477,5 +1479,10 @@ begin
inherited Create(ADebugger, twpUser); inherited Create(ADebugger, twpUser);
end; end;
initialization
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );
DBG_WARNINGS := DebugLogger.FindOrRegisterLogGroup('DBG_WARNINGS' {$IFDEF DBG_WARNINGS} , True {$ENDIF} );
FPDBG_FUNCCALL := DebugLogger.FindOrRegisterLogGroup('FPDBG_FUNCCALL' {$IFDEF FPDBG_FUNCCALL} , True {$ENDIF} );
end. end.

View File

@ -586,7 +586,7 @@ begin
else else
if not FpDebugger.EvaluateExpression(WatchValue, WatchValue.Expression, ResText, ResTypeInfo) if not FpDebugger.EvaluateExpression(WatchValue, WatchValue.Expression, ResText, ResTypeInfo)
then begin then begin
if IsWatchValueAlive then debugln(['TFPGDBMIWatches.InternalRequestData FAILED ', WatchValue.Expression]); if IsWatchValueAlive then debugln(DBG_ERRORS, ['TFPGDBMIWatches.InternalRequestData FAILED ', WatchValue.Expression]);
if IsWatchValueAlive then if IsWatchValueAlive then
inherited InternalRequestData(WatchValue); inherited InternalRequestData(WatchValue);
end; end;

View File

@ -612,7 +612,7 @@ begin
sleep(30); sleep(30);
end; end;
debugln(['TFpLldbDbgMemReader.ReadMemory got mem ', AnAddress, ' ', ASize, ' ', Length(InStr.Res)]); debugln(DBG_VERBOSE, ['TFpLldbDbgMemReader.ReadMemory got mem ', AnAddress, ' ', ASize, ' ', Length(InStr.Res)]);
if Length(InStr.Res) <> ASize then if Length(InStr.Res) <> ASize then
exit; exit;
@ -822,7 +822,7 @@ begin
if (FpDebugger.FWatchEvalList.Count = 0) or (FWatchEvalLock > 0) or FWatchEvalCancel then if (FpDebugger.FWatchEvalList.Count = 0) or (FWatchEvalLock > 0) or FWatchEvalCancel then
exit; exit;
debugln(['ProcessEvalList ']); debugln(DBG_VERBOSE, ['ProcessEvalList ']);
inc(FWatchEvalLock); inc(FWatchEvalLock);
FpDebugger.LockUnLoadDwarf; FpDebugger.LockUnLoadDwarf;
try // TODO: if the stack/thread is changed, registers will be wrong try // TODO: if the stack/thread is changed, registers will be wrong
@ -840,7 +840,7 @@ debugln(['ProcessEvalList ']);
ResTypeInfo := nil; ResTypeInfo := nil;
if not FpDebugger.EvaluateExpression(WatchValue, WatchValue.Expression, ResText, ResTypeInfo) if not FpDebugger.EvaluateExpression(WatchValue, WatchValue.Expression, ResText, ResTypeInfo)
then begin then begin
if IsWatchValueAlive then debugln(['TFPLldbWatches.InternalRequestData FAILED ', WatchValue.Expression]); if IsWatchValueAlive then debugln(DBG_VERBOSE or DBG_ERRORS, ['TFPLldbWatches.InternalRequestData FAILED ', WatchValue.Expression]);
if IsWatchValueAlive then if IsWatchValueAlive then
inherited InternalRequestData(WatchValue); inherited InternalRequestData(WatchValue);
end; end;

View File

@ -409,6 +409,8 @@ type
end; end;
implementation implementation
var
DBG_VERBOSE: PLazLoggerLogGroup;
{ TLldbInstructionValueBase } { TLldbInstructionValueBase }
@ -424,7 +426,7 @@ begin
'}': dec(FCurly); '}': dec(FCurly);
end; end;
inc(i); inc(i);
if FCurly<0 then debugln(['ParseStruct curly too low ', FCurly]); if FCurly<0 then debugln(DBG_VERBOSE, ['ParseStruct curly too low ', FCurly]);
end; end;
Result := FCurly <= 0; Result := FCurly <= 0;
end; end;
@ -1312,7 +1314,6 @@ begin
if StrStartsWith(AData, '* thread #') or StrStartsWith(AData, ' thread #') then begin if StrStartsWith(AData, '* thread #') or StrStartsWith(AData, ' thread #') then begin
DebugLn(['######### add ',AData]);
l := Length(FRes); l := Length(FRes);
SetLength(FRes, l+1); SetLength(FRes, l+1);
FRes[l] := AData; FRes[l] := AData;
@ -1481,6 +1482,8 @@ begin
Queue.SendDataToDBG(Self, 'version'); // end marker // do not sent before new prompt Queue.SendDataToDBG(Self, 'version'); // end marker // do not sent before new prompt
end; end;
initialization
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );
end. end.

View File

@ -1914,7 +1914,7 @@ function HasConsoleSupport: Boolean;
implementation implementation
var var
DBG_DATA_MONITORS, DBG_LOCATION_INFO: PLazLoggerLogGroup; DBG_VERBOSE, DBG_BREAKPOINT, DBG_DATA_MONITORS, DBG_LOCATION_INFO: PLazLoggerLogGroup;
function dbgs(AFlag: TDebuggerLocationFlag): String; function dbgs(AFlag: TDebuggerLocationFlag): String;
begin begin
@ -2596,7 +2596,7 @@ begin
NewSnap.LoadDataFromXMLConfig(AConfig, APath + 'SnapEntry' + IntToStr(i) + '/', UIProv); NewSnap.LoadDataFromXMLConfig(AConfig, APath + 'SnapEntry' + IntToStr(i) + '/', UIProv);
if not(NewSnap.IsHistory or NewSnap.IsSnapshot) then begin if not(NewSnap.IsHistory or NewSnap.IsSnapshot) then begin
RemoveHistoryEntryFromMonitors(NewSnap); // TODO: add user feedback / warning RemoveHistoryEntryFromMonitors(NewSnap); // TODO: add user feedback / warning
debugln(['************** Snapshot loaded, but not kept']); debugln(DBG_VERBOSE, ['************** Snapshot loaded, but not kept']);
end; end;
NewSnap.ReleaseReference; NewSnap.ReleaseReference;
end; end;
@ -2611,7 +2611,7 @@ begin
NewSnap.LoadDataFromXMLConfig(AConfig, APath + 'HistEntry' + IntToStr(i) + '/', UIProv); NewSnap.LoadDataFromXMLConfig(AConfig, APath + 'HistEntry' + IntToStr(i) + '/', UIProv);
if not(NewSnap.IsHistory or NewSnap.IsSnapshot) then begin if not(NewSnap.IsHistory or NewSnap.IsSnapshot) then begin
RemoveHistoryEntryFromMonitors(NewSnap); // TODO: add user feedback / warning RemoveHistoryEntryFromMonitors(NewSnap); // TODO: add user feedback / warning
debugln(['************** Snapshot loaded, but not kept']); debugln(DBG_VERBOSE, ['************** Snapshot loaded, but not kept']);
end; end;
NewSnap.ReleaseReference; NewSnap.ReleaseReference;
end; end;
@ -5613,9 +5613,9 @@ procedure TIDEBreakPoint.DisableGroups;
var var
n: Integer; n: Integer;
begin begin
{$IFDEF DBG_BREAKPOINT} {$IFDEF DBG_BREAKPOINT}
DebugLn(['DisableGroups: ', DebugText, ' Cnt=', FDisableGroupList.Count]); DebugLn(DBG_BREAKPOINT, ['DisableGroups: ', DebugText, ' Cnt=', FDisableGroupList.Count]);
{$ENDIF} {$ENDIF}
for n := 0 to FDisableGroupList.Count - 1 do for n := 0 to FDisableGroupList.Count - 1 do
FDisableGroupList[n].Enabled := False; FDisableGroupList[n].Enabled := False;
end; end;
@ -5650,9 +5650,9 @@ procedure TIDEBreakPoint.EnableGroups;
var var
n: Integer; n: Integer;
begin begin
{$IFDEF DBG_BREAKPOINT} {$IFDEF DBG_BREAKPOINT}
DebugLn(['EnableGroups: ', DebugText, ' Cnt=', FEnableGroupList.Count]); DebugLn(DBG_BREAKPOINT, ['EnableGroups: ', DebugText, ' Cnt=', FEnableGroupList.Count]);
{$ENDIF} {$ENDIF}
for n := 0 to FEnableGroupList.Count - 1 do for n := 0 to FEnableGroupList.Count - 1 do
FEnableGroupList[n].Enabled := True; FEnableGroupList[n].Enabled := True;
@ -8346,6 +8346,8 @@ begin
end; end;
initialization initialization
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );
DBG_BREAKPOINT := DebugLogger.FindOrRegisterLogGroup('DBG_BREAKPOINT' {$IFDEF DBG_BREAKPOINT} , True {$ENDIF} );
DBG_DATA_MONITORS := DebugLogger.FindOrRegisterLogGroup('DBG_DATA_MONITORS' {$IFDEF DBG_DATA_MONITORS} , True {$ENDIF} ); DBG_DATA_MONITORS := DebugLogger.FindOrRegisterLogGroup('DBG_DATA_MONITORS' {$IFDEF DBG_DATA_MONITORS} , True {$ENDIF} );
DBG_LOCATION_INFO := DebugLogger.FindOrRegisterLogGroup('DBG_LOCATION_INFO' {$IFDEF DBG_LOCATION_INFO} , True {$ENDIF} ); DBG_LOCATION_INFO := DebugLogger.FindOrRegisterLogGroup('DBG_LOCATION_INFO' {$IFDEF DBG_LOCATION_INFO} , True {$ENDIF} );