Forum > Debugger
When debugging, how can I re-execute code that has already been executed?
(1/1)
yinhuajian:
I assume I have the following code:
pascal
function get1(str: string): string;
begin
Result := 'hello:' + str;
end;
function get2(str: string): string;
begin
Result := 'hi:' + str;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
str1: string;
str2: string
begin
str1 := get1('tom');
str2 := get2('jack');
end;
My question:
I tried to set a breakpoint at str1 := get1('tom'); to observe the execution process of the get1() function. After get1() finishes executing, the code proceeds to str2 := get2('jack');.
At this point, if I want to go back to str1 := get1('tom'); without stopping the debugging session, just like in other IDEs, to observe the execution process of the get1() function again, is that possible?
dbannon:
yinhuajian, you cannot rollback the execution point, if thats what you are asking. If you follow the debugger to the get2() call, the get1() is over. If you just want to see the result of the get1() call, just hover the mouse over str1 and you will see it.
Maybe you want the oldest of all debugging techniques, sprinkle some writeln() in there.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var str1: string = ''; str2: string = '';begin writeln(str1); str1 := get1('tom'); writeln(str1); writeln(str2); str2 := get2('jack'); writeln(str2);end;
Note that I have initialised str1 and str2 and wrapped the code in code markers, select your code and click the # button.
Davo
ALLIGATOR:
https://drive.google.com/file/d/1kZSzNSkViBSN7U-0g4dOXSenb04gvsbV
You can do this in Lazarus trunk git [main] FpDebug
Navigation
[0] Message Index