Recent

Author Topic: identify unhandled exception in source code  (Read 3319 times)

sporex

  • New Member
  • *
  • Posts: 18
identify unhandled exception in source code
« on: January 02, 2022, 03:25:04 pm »
Hello,

I am executing a code on a headless Raspberry Pi that I cannot run under debug control (i.e. only access via SSH).
The build mode is "Debug"
The error message I get is:
An unhandled exception occurred at $00011A74 :
ERangeError : Range check error

I cannot run the code on the RPi with the IDE because the hardware environment is missing there.
From the old days of Turbo Pascal I remember that there was a menu item where you just entered the error address and the IDE pointed you to the source code line.

Is there a similar function in lazarus?

The IDE is v1.2.4 with FPC 2.6.4 and the RPi is Debian Jessie

Your help is appreciated.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7865
  • Debugger - SynEdit - and more
    • wiki
Re: identify unhandled exception in source code
« Reply #1 on: January 02, 2022, 03:59:19 pm »
If you can compile with "line info" there is an option that the exe prints the addresses while on the raspi.

Otherwise, you can try
- compile with debug info (dwarf). (keep a copy of this file)
- strip debug info
- run / get address
   the address must be in a line looking like from a stack trace (eg. gdb) / I don't recall all the formats....
- menu: view > leaks and traces
- paste
- "resolve" against the exe with debug info.

It should work, if you can get the address pasted. Which means it needs to have some trace like text around it.

If your exe prints a list of addresses, with a line "... trace" or ... stack ... above => that should do it....

Bart

  • Hero Member
  • *****
  • Posts: 4689
    • Bart en Mariska's Webstek
Re: identify unhandled exception in source code
« Reply #2 on: January 02, 2022, 03:59:59 pm »
Compile the application with full debug info: -Criot -g -gl -FaLazLogger,LCLExceptionStacktrace
When the exception occurs at least you have a change of getting a backtrace.

Bart

sporex

  • New Member
  • *
  • Posts: 18
Re: identify unhandled exception in source code
« Reply #3 on: January 02, 2022, 04:48:49 pm »
If you can compile with "line info" there is an option that the exe prints the addresses while on the raspi.

Otherwise, you can try
- compile with debug info (dwarf). (keep a copy of this file)
- strip debug info
- run / get address
   the address must be in a line looking like from a stack trace (eg. gdb) / I don't recall all the formats....
- menu: view > leaks and traces
- paste
- "resolve" against the exe with debug info.

It should work, if you can get the address pasted. Which means it needs to have some trace like text around it.

If your exe prints a list of addresses, with a line "... trace" or ... stack ... above => that should do it....


Thank you
If you can compile with "line info": This should be in Project Options/Compilation + Linking ? (I have only optimization levels)
Otherwise: debugging with Dwarf is enabled (giving me a file with *.dbg extension)
Strip debug info: is not clear to me.
In the Run dialogue I have no option for "get address"
On the target MCU I get Heap Traces that are not meaningful for me.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7865
  • Debugger - SynEdit - and more
    • wiki
Re: identify unhandled exception in source code
« Reply #4 on: January 02, 2022, 05:13:36 pm »
If you can compile with "line info": This should be in Project Options/Compilation + Linking ? (I have only optimization levels)
Otherwise: debugging with Dwarf is enabled (giving me a file with *.dbg extension)
Strip debug info: is not clear to me.
In the Run dialogue I have no option for "get address"
On the target MCU I get Heap Traces that are not meaningful for me.

*.dbg => external debug info.
That is only supported by some tools.

If you disable "external debug info" then you get a bigger exe instead.

If you can copy that big exe to your raspi => use it as it is.

If you can't (and only if you can't), there is a tool called "strip" in the fpc folder. It will remove the debug info.
If you must do that, keep a copy of the big exe. You will need it to "resolve" addresses.

"run / get address" => run: the english verb, not the menu.
=> run your app on the target, and wait for it to print the address of the error (or ideally it prints a trace, just like the heaptrc).
=> A trace like this will work in "leak and traces".

If you copied the "big exe" to your raspi, you may have lines on the trace already.
If not, try "leak and traces" (view menu).



Once the error happened, you need only the trace of the error.

Because of the crash, some memory is not freed => that is why you get the heap traces.
However, if you get heaptraces, without the crash, then you have a memory leak.

sporex

  • New Member
  • *
  • Posts: 18
Re: identify unhandled exception in source code
« Reply #5 on: January 02, 2022, 07:10:55 pm »
"If you disable "external debug info" then you get a bigger exe instead." OK
"If you can copy that big exe to your raspi => use it as it is." If I recompile I get a new exe that is more verbose?
I will try that and report back shortly

sporex

  • New Member
  • *
  • Posts: 18
Re: identify unhandled exception in source code
« Reply #6 on: January 03, 2022, 01:10:34 pm »
It works.
Thank you very much

 

TinyPortal © 2005-2018