1. Larry Peters
  2. PowerBuilder
  3. Tuesday, 22 December 2020 16:10 PM UTC

Must have been asked before but is there a way to examine the PB call stack programmatically at run-time?

TIA

Larry Peters

 

Larry Peters Accepted Answer Pending Moderation
  1. Saturday, 26 December 2020 07:43 AM UTC
  2. PowerBuilder
  3. # 1

Thanks Arthur.

Now to see if it will work for me.

Best Regards

Larry

Comment
There are no comments made yet.
Larry Peters Accepted Answer Pending Moderation
  1. Thursday, 24 December 2020 11:07 AM UTC
  2. PowerBuilder
  3. # 2

Hi Arthur,

Thank you very much for the effort on my behalf.

However I need to stretch your goodwill as I'm still running with PB2017 R3 1880. Will the DLL you so kindly provided work with this release or will I need a PB2017-specific version? I know I could test it to find out but since I won't do that till boxing day I thought I'd ask the question.

Again, thank you so very much.

Best Regards and Merry Christmas

Larry

Comment
  1. Arthur Hefti
  2. Friday, 25 December 2020 12:24 PM UTC
  1. Helpful
There are no comments made yet.
Arthur Hefti Accepted Answer Pending Moderation
  1. Thursday, 24 December 2020 05:26 AM UTC
  2. PowerBuilder
  3. # 3

Hi

I cloned the git repository, created objects and a project for PB2019 (R2) and compiled it with the latest VS version.

You can download the DLL from https://drive.infomaniak.com/app/share/124668/29128503-51f4-44f8-80de-d02d721f5fd4. Import the sr* files from the zip subfolder into your project and copy the DLL to your "main" folder.

The stack trace can be called with:

string ls_Stack[]

stack_trace( ls_Stack )

I did not test any of the other functions.

Regards
Arthur

N.B. Jeremy put a lot of work into this! I did a simple adaption and compilation. 

Comment
There are no comments made yet.
Larry Peters Accepted Answer Pending Moderation
  1. Tuesday, 22 December 2020 23:56 PM UTC
  2. PowerBuilder
  3. # 4

Thanks John,

Yes, that does appear to be a fallback solution which I'm still considering. Trouble is there are many functions (>20) and each would need it's own unique memory variable and also every early exit from the functions would need to reset the variable. It's possible and doable but I'm still hoping for a "call stack" solution.

I found some C++ code in GitHub https://github.com/lakeman/fastfuncs written by Jeremy Lakeman in 2011 which appears to be able to query the call stack. I'm not that savvy with C++ so I haven't yet been able to compile it to test it. Maybe someone can help me with instructions on how to compile a PowerBuilder-useable DLL?

Best Regards

Larry

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 22 December 2020 23:23 PM UTC
  2. PowerBuilder
  3. # 5

Hi, Larry - 

Could you add a global or instance boolean (depending if the function is a global function or an object function, you did not elaborate) that the function in question checks when it begins and if True, reports the recursive call? If False, sets it to True, runs, then resets it to False before exiting?

This doesn't give you the execution call stack, but it would let you determine if the function is being invoked recursively.

Regards, John

Comment
There are no comments made yet.
Larry Peters Accepted Answer Pending Moderation
  1. Tuesday, 22 December 2020 18:27 PM UTC
  2. PowerBuilder
  3. # 6

Thanks Chris,

A quick look at your framework seems to indicate that you provide a way to trace the call stack as part of the PBDEBUG method.

Let me describe my need: I believe a function in my app is being called recursively causing a crash which bypasses SystemError. So I was looking to test in that function whether it had been called before in the call stack. Which is why I was looking for a way to examine the call stack. I'm not sure if your framework would help me...

However, if there exists another way to trap the recursive error I would love to  know what it is.

Thanks and Regards

Larry

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 22 December 2020 19:01 PM UTC
Hi Larry;

Unfortunately, we cannot see the Call Stack from within our PowerScript code when an error happens. That would certainly be a nice enhancement IMHO.

What I do though is when you know there is an unrecoverable section of your App's code is to "dynamically" turn on stack tracing just *before* you enter the part where your app becomes unstable. That way, at least you can see the calling stack as it goes into the crash zone (not be be confused with Crash Badicoot - LOL).

  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 22 December 2020 17:15 PM UTC
  2. PowerBuilder
  3. # 7
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.