A stack trace is also useful, but in a different way. Routine tracing is helpful to see stuff like order of events, what is actually called, timing, if program flow is as expected and performance profiling. Stack trace is not useful in these cases.
Stack Trace, however, is very useful when you break on an error and wonder "OK, how did I get here???".
A not-perfect but possible approach would be (did something similar some time ago but not for these purposes. There may be errors, this is not the exact code but just the idea)
Replace any direct Sub call by xCallSub(module,procedureName)
where xCallSub is
B4X:
Sub xCallSub(Component as Object, procedurename as string) as Object
Dim O as Object
#if TRACING
log("START:"...) 'DateTiime, procedure name,...
#end if
O=CallSub(Component, procedurename)
#if TRACING
log("EXIT"&.....) 'Datetime, .....
#end if
return O
end sub
And define TRACING depending on your build configuration (or, if you don't want this overhead, replace any "xCallSub" string in the project for "CallSub" again)
You can also do it for CallSub2, CallSub3, CallSubDelayed...as needed
Also, for events, they should be defined in the following way
B4X:
Sub myButton_Click
xCallSubDelayed(Me,"myButtonClickHandler")
end sub
Sub myButtonClickHandler
' process the event here
end Sub