Android Question Is Sub Routine tracing possible?

Discussion in 'Android Questions' started by Robert Valentino, Mar 24, 2015.

  1. Robert Valentino

    Robert Valentino Well-Known Member Licensed User

    Is there a way in Debug mode to turn on routine tracing?

    I know I can go put Log messages in the beginning and ALL the exit points of me routines (what a pain this would be)

    It would be nice if there was someway to turn this type of feature on so I could easily see the execution path so maybe I can tighten things up.

    Brian Robinson and Troberg like this.
  2. Troberg

    Troberg Well-Known Member Licensed User

    Yes, that's something I've longed for in just about every dev environment I've worked in. A log, somewhat like this:

    2015-03-25 07:42:02.142 Main.SelectFile_Click()
    2015-03-25 07:42:02.144 Main.ShowFileSelector(Startdir="/")
    2015-03-25 07:42:15.764 Main.SaveSettings()

    Edit: Once in place, this would also be a large step towards a code profiler.
    Last edited: Mar 25, 2015
  3. Brian Robinson

    Brian Robinson Active Member Licensed User

  4. Troberg

    Troberg Well-Known Member Licensed User

    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???".
  5. Brian Robinson

    Brian Robinson Active Member Licensed User

    Ahh yes... sorry - didn't really read it well enough did I.

    Yes, both editions would be great...

    If you add as a wish, I will like.
  6. Reviewnow

    Reviewnow Active Member Licensed User

  7. JordiCP

    JordiCP Well-Known Member Licensed User

    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
    Sub xCallSub(Component as Object, procedurename as stringas Object
    Dim O as Object
    #if TRACING
       log("START:"...) 'DateTiime, procedure name,...
    #end if
    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, needed

    Also, for events, they should be defined in the following way

    Sub myButton_Click
    end sub

    Sub myButtonClickHandler
    ' process the event here
    end Sub

    Hope this helps
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice