How to get GDB to transfer control to exception handler ? lazarus / 12-Debugger ---------------------------------------------------------------------- 440bx · 2019-03-05 10:48 Hello, I have a simple exception handler to work around an occasional problem.  The code is as follows:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     {$ifdef UseWordAccessWorkaround}      try        { FPC v3.0.4 generates a word access for the expression below.  This  }        { causes an access violation if the last byte in the block is also    }        { last accessible byte.  The try/except is to work around that bug.   }       HexPtr^ := HexDigits[p^ and $F];           { second nibble          }      except        b := p^;                                   { these instructions do    }        b := b and $F;                           { not generate a word      }        HexPtr^ := HexDigits[b];                 { access.                  }      end;    {$endif} when the program is executed from the command line, the exception handler handles the exception and execution resumes normally. When running the program under GDB, GDB gets "stuck" at Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i        HexPtr^ := HexDigits[p^ and $F];           { second instead of transferring control to the exception handler. the question is: how do I tell GDB to transfer control to the exception handler so execution resumes normally ?  F7/F8/F9 only seem to cause the exception again. Attached is a complete sample program which executes as it should when invoked on the command line but gets stuck on the offending line as described above when run under GDB. Thank you for your help. PS: FPC v3.0.4, Windows 7 64bit. ---------------------------------------------------------------------- Cyrax · 2019-03-05 11:05 Are you building a 32-bit or 64-bit binary? ---------------------------------------------------------------------- 440bx · 2019-03-05 11:12 Quote from: Cyrax on March 05, 2019, 12:05:49 pmAre you building a 32-bit or 64-bit binary? Both.  Can't get past the exception in either bitness. ---------------------------------------------------------------------- Martin_fr · 2019-03-05 12:20 It works on Windows 10 64 bit. (continue running) IIRC, there are issues with either gdb, or rumour has it windows itself. That is I remember on my older system (Vista) I was not able to continue after such an exception. I do not know what makes the difference. You can try the following. 1) get gdb 8.2 from our sourceforge page. 2) use fpdebug (might need Lazarus trunk, might work on 2.0... not sure) ---------------------------------------------------------------------- 440bx · 2019-03-05 12:40 Quote from: Martin_fr on March 05, 2019, 01:20:47 pmYou can try the following. 1) get gdb 8.2 from our sourceforge page. 2) use fpdebug (might need Lazarus trunk, might work on 2.0... not sure) Thank you Martin, I will try your suggestions. ---------------------------------------------------------------------- Martin_fr · 2019-03-05 12:59 Btw, you can avoid the issue Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i HexPtr^ := HexDigits[p^ and byte($F)]; At least for me that seems to fix it. ---------------------------------------------------------------------- Cyrax · 2019-03-05 13:03 Quote from: Martin_fr on March 05, 2019, 01:59:04 pmBtw, you can avoid the issue Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i HexPtr^ := HexDigits[p^ and byte($F)]; At least for me that seems to fix it. I can confirm this. The test project in this bug report https://bugs.freepascal.org/view.php?id=35187 works after changing the problematic line to above quoted one. ---------------------------------------------------------------------- 440bx · 2019-03-05 13:54 Quote from: Martin_fr on March 05, 2019, 01:59:04 pmBtw, you can avoid the issue Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i HexPtr^ := HexDigits[p^ and byte($F)]; At least for me that seems to fix it. Very nice and simple solution.  Both Delphi (v2) and FPC versions work as expected with it.  Thank you!. Quote from: Cyrax on March 05, 2019, 02:03:14 pmI can confirm this. The test project in this bug report https://bugs.freepascal.org/view.php?id=35187 works after changing the problematic line to above quoted one. I can confirm that as well.  It solves the problem in both, 32bit and 64bit.