Page 1 of 1
ErrorHandler query
Posted: Fri Apr 18, 2025 11:15 pm
by ozzie
In my program I use OnErrorCall(@generalErrorHandler()) where generalErrorHandler() logs as much info as I find useful to track down the cause of the error. However, in log files recently sent me by a user, a memory error was detected in a short procedure that's called from many different parts of the program. What I would really like to know is where this procedure was called from, ie the calling procedure. Is there some way I can modify my generalErrorHandler procedure get that info for future instances? The program only runs under Windows, so if there's a Windows function that helps then that would be OK.
Re: ErrorHandler query
Posted: Sat Apr 19, 2025 4:27 am
by Olli
On ASM backend, you have the RSP register (x64 hardware), or ESP register (x86 hardware) which indicates the memory address of a call. This is hardly automatical.
Softly, you have the runtime system which gives you more inforlations.
More softly, you should insert you own process stack, on each procedure. This is a list, updated on every procedure executions, and available to the error handler.
Re: ErrorHandler query
Posted: Sat Apr 19, 2025 6:45 am
by jacdelad
Depending on how many functions your program has, you can offer some kind of extended log mode, which logs all calls plus the error message into a file. See #PB_Compiler_Procedure, create macro which automatically logs the current function.