Wish Display/Dump Call Stack for runtime error using B4A code only

Widget

Well-Known Member
Licensed User
Longtime User
When debugging an app in the IDE, I sometimes get an exception (red text) in the Logs panel usually because one of my classes is not initialized etc.. These are all well deserved errors.

The runtime error will tell me "Error occurred on line: 3158 (MyModuleX) and below is is the Java call stack (in red text) that I could use to painstakingly go through the java code in the projects src directory to try and trace how it got here. But that takes a lot of work.

Here is a solution that will speed things up and help us to track down these errors. I'd like to know how the program got to this line of code that cause the the exception in ModuleX from my B4A code (not the Java code).

In other words, I'd like to see a call stack showing all of the B4A Subs called (starting from Main) that got the program to this point where the error occurred. That's because many of my B4A subs could have gotten called from a variety of locations, and I need to know which one called it in order for me to figure out why the variable is uninitialized (etc.). Double clicking on any line in this call stack will show the B4A code in the editor. This will allow me to easily traverse the calling order through the subs that got me to this point where the error occurred.

In Delphi they display a call stack (list) with each line showing the order of each Delphi Sub that was called to get to line with the exception. The topmost line of the call stack is the current line where the error occurred, and the line below it is the parent Sub that called the current Sub, and so on for all of the parent Sub calls until it reaches the last item in the list where it is usually the mainline sub that started everything. (See image)

Since you probably don't need the overhead in B4A to maintain this info when the application is running, is there a way to use the Java call stack to generate the callstack for the B4A code? I'm suggesting put another tab next to Logs (or inside the Logs pane) called "Call Stack" so when an exception occurs, we can see the call stack using just the B4A code. This would make debugging code a lot easier.

TIA
 

Attachments

  • CallStack.png
    CallStack.png
    21.7 KB · Views: 230
Top