Forum > Debugger
An instruction to pause the debugger. [SOLVED]
BrunoK:
Debugger : FpDebug, Lazarus 3.99
I have a pascal code generator and would like the generated code to be able to pause the execution with an instruction, like for the following code snippet from a CocoR grammar file :
--- 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";}};} ---SynchNext<const aCurrentInputSymbol: integer; const aAfterSymName, aAheadSymName: string> (. var lAfterSym, lAheadSym: integer; var lNextSym, lDefaultSym, lPrevSym : integer; lScanner: TRC5ExportScanner; .) = (. lScanner:=GetScanner; lDefaultSym := identSym; if not lScanner.fHashList.Hash(aAfterSymName, lAfterSym, lDefaultSym) then Exit; if not lScanner.fHashList.Hash(aAheadSymName, lAheadSym, lDefaultSym) then Exit; while fCurrentInputSymbol<>EOFSYMB do begin if fCurrentInputSymbol=lAheadSym then begin { Some checking about aAfterSymName preceding found aAheadSymName } if lPrevSym<>lAfterSym then { Scanner.pos}{PAUSE HERE >} DebuggerPause; // <===== Programmed pause lDefaultSym := lAfterSym; Exit; end; lPrevSym := fCurrentInputSymbol; Get; end; .) .
At DebuggerPause is there an existing instruction that would put the debugger in pause on that line.
Martin_fr:
yes, kinda....
On Windows:
--- 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";}};} ---DebugBreakoder Win/Linux
--- 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";}};} ---asmint 3end;(mind the space before the 3)
At least the latter, should probably be IFDEFed for debugging only. I.e., compile for debug with -dMY_DBG_DEFINE (which then goes into the ifdef)
Only, by default the debugger ignores both (the first one also ends on a "int 3")
In the Option, Debugger Backend, in the settings for FpDebug is "HandleDebugBreakInstruction", which is set to "IgnoreAll". Uncheck the IgnoreAll.
Downside: Other code (libraries) can also contain "int 3" => and then that will also enter debug pause.
BrunoK:
Uncheck'ed the IgnoreAll.
Put in my code
--- 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";}};} --- if lPrevSym=lAfterSym then { Scanner.pos} asm int 3 end; // <- as suggested lDefaultSym := lAfterSym; Exit; Raises
--- Quote ---
--- 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";}};} ---[Window Title] prjR5DataReportToDB [Content]Access violation. Press OK to ignore and risk data corruption.Press Abort to kill the program. [OK] [Abort]
--- End quote ---
What didn't I understand ?
MarkMLl:
--- Quote from: Martin_fr on June 29, 2024, 05:23:14 pm ---
--- 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";}};} ---asmint 3end;(mind the space before the 3)
At least the latter, should probably be IFDEFed for debugging only. I.e., compile for debug with -dMY_DBG_DEFINE (which then goes into the ifdef)
Only, by default the debugger ignores both (the first one also ends on a "int 3")
In the Option, Debugger Backend, in the settings for FpDebug is "HandleDebugBreakInstruction", which is set to "IgnoreAll". Uncheck the IgnoreAll.
Downside: Other code (libraries) can also contain "int 3" => and then that will also enter debug pause.
--- End quote ---
Thanks very much for that Martin. I admit to fairly regularly having an Assert(false,... if I want to be alerted that a program has got itself into a thoroughly discombobulated state.
MarkMLl
440bx:
--- Quote from: BrunoK on June 29, 2024, 06:37:00 pm ---Uncheck'ed the IgnoreAll.
What didn't I understand ?
--- End quote ---
I just tried the "asm int 3 end;" and it didn't work. The program execution got messed up.
If you are using Windows, use DebugBreak(), that one works. I use it all the time.
HTH.
ETA:
using "asm int 3 end;" does work with GDB. I know because that's what I used all the time before FpDebug supported DebugBreak();
Because of Martin's answer to you, I'm guessing that FpDebug now is supposed to support "asm int 3 end;" too but, as I mentioned above, I tried it and execution got messed up. IOW, "asm int 3 end;" isn't working quite right at this time.
Navigation
[0] Message Index
[#] Next page