Recent

Author Topic: Any library to generate a call stack?  (Read 550 times)

Kurt

  • Jr. Member
  • **
  • Posts: 59
Any library to generate a call stack?
« on: November 30, 2023, 01:01:19 am »
Is there any library that generates a call stack - or any other easy way to do it?  Something like in heaptrc?

I have a couple behaviours happening behind the scenes in Indy I need to track down and I can't reproduce them easily on the test bench.  I am getting a callback in my code that marks a session termination and I want to trace that back to why the session it being terminated since none of the conditions seem to be met.  I've added as much logging as I can, but a call stack would be ideal.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9708
  • Debugger - SynEdit - and more
    • wiki
Re: Any library to generate a call stack?
« Reply #1 on: November 30, 2023, 01:29:56 am »
Dump_Stack in system, and you can look at the source.
In LazLogger:  DebuglnStack 

If you compiled with -gl then you may get unitnames and lines (On Mac you may need FPC fixes or trunk for that).

If you distribute to a client, you can use strip.exe to remove line info. But make a copy of the executable file before (it has to be copy of the actual compilation you distribute. NOT a newly recompiled exe).

Then you can paste the addresses into "leaks and traces" (view menu ) and press resolve (test if that works for your platform, before relying on it / only works without address space randomization or other relocation stuff)

Kurt

  • Jr. Member
  • **
  • Posts: 59
Re: Any library to generate a call stack?
« Reply #2 on: December 01, 2023, 08:15:15 pm »
Thank-you, that's just what I'm looking for.  Your post also lead me to https://wiki.freepascal.org/Logging_exceptions which has some other excellent suggestions too.

 

TinyPortal © 2005-2018