For others who are reading this question, I will show additional information regarding getting the value of a character. The symbol is found as described above by Eric, but it is difficult to determine how to obtain the actual value of the symbol. The code below is a procedure that fills TMemo (memLocalVariables) with local variables each time it is called. There are some features that are missing, like neatly formatting a variable's value and accessing call parameters. I call this from the debugger state "dsDebugSuspended". A less intuitive bit is accessing character data on the stack and using the stack base pointer. A great way to find out how the compiler works! But maybe there is a utility function somewhere I did not find ...? Eric?
procedure DrawLocalVariables; var ProgramExecution : TdwsProgramExecution; I : integer; Sym : TSymbol; V : variant; Adr : integer; SymbolTable : TSymbolTable; begin memLocalVariables.Lines.Clear; ProgramExecution := TdwsProgramExecution( dwsDebugger1.Execution ); SymbolTable := ProgramExecution.CurrentProg.Table; For I := 0 to SymbolTable.Count-1 do begin Sym := SymbolTable[I]; if Sym is TDataSymbol then begin Adr := TDataSymbol( Sym).StackAddr + ProgramExecution.Stack.BasePointer; ProgramExecution.Stack.ReadValue( Adr, V ); memLocalVariables.Lines.Add( Format( '%s = %s', [ Sym.Name, VarToStr(V) ] )); end; end; end;
source share