From 0429c822c15f2383e3330e55f849aecf95b737c1 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 30 Jun 2022 02:26:55 +0200 Subject: [PATCH] LazDebuggerFp: debugln for function calling (watch-eval) --- components/fpdebug/fpdbgcallcontextinfo.pas | 6 ++++++ components/fpdebug/fpdbgcontroller.pas | 10 +++++++++- components/fpdebug/fpdbginfo.pas | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/components/fpdebug/fpdbgcallcontextinfo.pas b/components/fpdebug/fpdbgcallcontextinfo.pas index fc772c4492..c0f39f7c6c 100644 --- a/components/fpdebug/fpdbgcallcontextinfo.pas +++ b/components/fpdebug/fpdbgcallcontextinfo.pas @@ -93,6 +93,9 @@ type implementation +var + FPDBG_FUNCCALL: PLazLoggerLogGroup; + { TFpValueCallParamStringByRef } function TFpValueCallParamStringByRef.GetDwarfDataAddress(out @@ -377,6 +380,7 @@ begin if FOrigStackPtr <> 0 then FDbgThread.SetStackPointerRegisterValue(FOrigStackPtr); + debugln(FPDBG_FUNCCALL, ['CallRoutine END (CTX DESTROY)']); end; function TFpDbgInfoCallContext.WriteStack: Boolean; @@ -578,5 +582,7 @@ begin AVal := TFpValueConstString.Create(s); end; +initialization + FPDBG_FUNCCALL := DebugLogger.FindOrRegisterLogGroup('FPDBG_FUNCCALL' {$IFDEF FPDBG_FUNCCALL} , True {$ENDIF} ); end. diff --git a/components/fpdebug/fpdbgcontroller.pas b/components/fpdebug/fpdbgcontroller.pas index d8a740de45..9cb8a259e7 100644 --- a/components/fpdebug/fpdbgcontroller.pas +++ b/components/fpdebug/fpdbgcontroller.pas @@ -421,7 +421,7 @@ uses FpImgReaderBase, FpDbgCommon; var - DBG_VERBOSE, DBG_WARNINGS, FPDBG_COMMANDS: PLazLoggerLogGroup; + DBG_VERBOSE, DBG_WARNINGS, FPDBG_COMMANDS, FPDBG_FUNCCALL: PLazLoggerLogGroup; { TDbgControllerCallRoutineCmd } @@ -451,6 +451,7 @@ end; procedure TDbgControllerCallRoutineCmd.Init; begin + debugln(FPDBG_FUNCCALL, ['CallRoutine INIT - Cmd.Init - ProcessLoop starts']); inherited Init; FCallContext.WriteStack; @@ -569,6 +570,7 @@ end; procedure TDbgControllerCallRoutineCmd.RestoreOriginalCode; begin + debugln(FPDBG_FUNCCALL, ['CallRoutine -- << Restore orig Code']); if not FProcess.WriteInstructionCode(FOriginalInstructionPointer, Length(FOriginalCode), FOriginalCode[0]) then raise Exception.Create('Failed to restore the original code at the instruction-pointer'); end; @@ -582,11 +584,13 @@ end; procedure TDbgControllerCallRoutineCmd.StoreInstructionPointer; begin + debugln(FPDBG_FUNCCALL, ['CallRoutine -- >> Store IP']); FOriginalInstructionPointer := FController.CurrentThread.GetInstructionPointerRegisterValue; end; procedure TDbgControllerCallRoutineCmd.RestoreInstructionPointer; begin + debugln(FPDBG_FUNCCALL, ['CallRoutine -- << Restore IP']); {$ifdef cpui386} FController.CurrentThread.SetRegisterValue('eip', FOriginalInstructionPointer); {$else} @@ -604,6 +608,7 @@ end; procedure TDbgControllerCallRoutineCmd.RestoreRegisters; begin + debugln(FPDBG_FUNCCALL, ['CallRoutine -- << RestoreRegisters']); FController.CurrentThread.RestoreRegisters; end; @@ -614,6 +619,7 @@ end; procedure TDbgControllerCallRoutineCmd.StoreRegisters; begin + debugln(FPDBG_FUNCCALL, ['CallRoutine -- >> StoreRegisters']); FController.CurrentThread.StoreRegisters; end; @@ -1937,6 +1943,7 @@ function TDbgController.Call(const FunctionAddress: TFpDbgMemLocation; var Context: TFpDbgInfoCallContext; begin + debugln(FPDBG_FUNCCALL, ['CallRoutine BEGIN']); Context := TFpDbgInfoCallContext.Create(ABaseContext, AMemReader, AMemConverter, FCurrentProcess, FCurrentThread); Context.AddReference; InitializeCommand(TDbgControllerCallRoutineCmd.Create(self, FunctionAddress, Context)); @@ -1947,6 +1954,7 @@ initialization DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} ); DBG_WARNINGS := DebugLogger.FindOrRegisterLogGroup('DBG_WARNINGS' {$IFDEF DBG_WARNINGS} , True {$ENDIF} ); FPDBG_COMMANDS := DebugLogger.FindOrRegisterLogGroup('FPDBG_COMMANDS' {$IFDEF FPDBG_COMMANDS} , True {$ENDIF} ); + FPDBG_FUNCCALL := DebugLogger.FindOrRegisterLogGroup('FPDBG_FUNCCALL' {$IFDEF FPDBG_FUNCCALL} , True {$ENDIF} ); end. diff --git a/components/fpdebug/fpdbginfo.pas b/components/fpdebug/fpdbginfo.pas index a7c5d80f92..c05c5a1d45 100644 --- a/components/fpdebug/fpdbginfo.pas +++ b/components/fpdebug/fpdbginfo.pas @@ -632,6 +632,9 @@ function dbgs(ADbgSymbolKind: TDbgSymbolKind): String; overload; implementation +var + FPDBG_FUNCCALL: PLazLoggerLogGroup; + function dbgs(ADbgSymbolKind: TDbgSymbolKind): String; begin Result := ''; @@ -751,6 +754,7 @@ end; procedure TFpDbgAbstractCallContext.SetError(const Message: string); begin + debugln(FPDBG_FUNCCALL, ['CallRoutine -- !!! Ctx.SetError: ', Message]); FIsValid := False; FMessage := Message; end; @@ -1859,5 +1863,7 @@ begin FHasInfo := True; end; +initialization + FPDBG_FUNCCALL := DebugLogger.FindOrRegisterLogGroup('FPDBG_FUNCCALL' {$IFDEF FPDBG_FUNCCALL} , True {$ENDIF} ); end.