debugging hint – sorry if you already all know this

Home Forums General Programming debugging hint – sorry if you already all know this

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #118271
    shookingshooking
    Participant
    • Topics: 14
    • Replies: 60
    • Total: 74

    So if you have seen some of my posts you know I am struggling with Ctrlr 5.3 v 6.x – I am trying to backport my panel to the more stable 5.3.
    Oh and I have an Autistic brain so want to know every details even ask obscure questions plus talk to myself a lot – sorry

    So here’s a trick I use to help me home in on what my panel is up to

    If this functionality already exists then apologies – but please point me to where it is because nothing is that obvious in Ctrlr.

    ALGORITHM

    Open a file to log debug info – I know there is a debug log but I not managed to get it working.
    This example is on Windows, I dont know if it works on Linux or Mac.
    Of course you would rip this out from your released panel

    Create some logging functions and routinely write out when you enter a Lua method (at the moment this is manual. With the GNU C compilers it was possible to “hook” into push/pop function for really neat debugging)

    Log stuff

    Watch your program ..it crashed? Where

    WITHOUT this method

    
    3: UnhandledExceptionFilter + 0x1ea
    4: memset + 0x1b32
    5: _C_specific_handler + 0x96
    6: _chkstk + 0x11f
    7: RtlRaiseException + 0x399
    8: KiUserExceptionDispatcher + 0x2e
    29: BaseThreadInitThunk + 0x14
    30: RtlUserThreadStart + 0x21
    

    which is handy for Atom but not for me regarding what my panel did.

    With my approach

    
    $ tail -f MyMultiPanel_DebugLog.log
    05/08/20 14:02:22       [FILE: [string "afterLoadSetGlobals"]]:         Line: 134               FUNC:
    05/08/20 14:02:22       [TRACEBACK]
    05/08/20 14:02:22       [FILE: [string "setupGlobalArray"]]:            Line: 9         FUNC: setupGlobalArray
    05/08/20 14:02:22       [FILE: [string "afterLoadSetGlobals"]]:         Line: 135               FUNC:
    05/08/20 14:02:22       [TRACEBACK]
    05/08/20 14:02:22       [FILE: [string "setupGlobalArray"]]:            Line: 9         FUNC: setupGlobalArray
    05/08/20 14:02:22       [FILE: [string "afterLoadSetGlobals"]]:         Line: 136               FUNC:
    05/08/20 14:02:22       [TRACEBACK]
    05/08/20 14:02:22       [FILE: [string "setupGlobalArray"]]:            Line: 9         FUNC: setupGlobalArray
    05/08/20 14:02:22       [FILE: [string "afterLoadSetGlobals"]]:         Line: 137               FUNC:
    05/08/20 14:02:30       [TRACEBACK]
    05/08/20 14:02:30       [FILE: [string "k1checkReturn_modchange"]]:             Line: 13                FUNC:
    05/08/20 14:02:30       [TRACEBACK]
    05/08/20 14:02:30       [FILE: [string "handlePanelMidiMessage"]]:              Line: 11                FUNC:
    05/08/20 14:02:40       [TRACEBACK]
    05/08/20 14:02:40       [FILE: [string "midiReset"]]:           Line: 10                FUNC:
    05/08/20 14:02:45       [TRACEBACK]
    05/08/20 14:02:45       [FILE: [string "requestMultiPatch"]]:           Line: 8         FUNC:
    05/08/20 14:02:45       [TRACEBACK]
    05/08/20 14:02:45       [FILE: [string "handlePanelMidiMessage"]]:              Line: 11                FUNC:
    05/08/20 14:02:45       [TRACEBACK]
    05/08/20 14:02:45       [FILE: [string "handleKawaiSysex"]]:            Line: 20                FUNC: handleKawaiSysex
    05/08/20 14:02:45       [FILE: [string "handlePanelMidiMessage"]]:              Line: 65                FUNC:
    05/08/20 14:02:45       [TRACEBACK]
    05/08/20 14:02:45       [FILE: [string "processMultiD"]]:               Line: 222               FUNC: processMultiD
    05/08/20 14:02:45       [FILE: [string "handleKawaiSysex"]]:            Line: 106               FUNC:
    05/08/20 14:02:45       [FILE: [string "handlePanelMidiMessage"]]:              Line: 65                FUNC:
    05/08/20 14:02:45       [TRACEBACK]
    05/08/20 14:02:45       [FILE: [string "processMultiD"]]:               Line: 4         FUNC: validateSysexHeader
    05/08/20 14:02:45       [FILE: [string "processMultiD"]]:               Line: 225               FUNC:
    05/08/20 14:02:45       [FILE: [string "handleKawaiSysex"]]:            Line: 106               FUNC:
    05/08/20 14:02:45       [FILE: [string "handlePanelMidiMessage"]]:              Line: 65                FUNC:
    

    And so somewhere in between entering this func and the return (but before I call a new function) I am hitting a crash … narrowed the space down quite a bit.

    I know func is not necessarily a well defined concept in Lua – working on that.
    But if I place

    
    writeSelectedValueToK1 = function(--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)
    
    -- CHANNEL_FIX for sysex and B0,B1 etc
    -- where are we?
    
        g_debugFile = openDebugFile()
        whereAmI(g_debugFile, __DFUNC__())
    ----------------------------------------------
    
        local chan = 0
        console("writeSelectedValueToK1 ")
        local whichTab = panel:getModulatorByName("multiTab"):getComponent():getPropertyInt("uiTabsCurrentTab")
        if g_lastSelectedSingleLCD ~= -1 and whichTab == 1 then
            -- write out the selected single
            console("Would write out SINGLE patch "..g_lastSelectedSingleLCD.." for a single")
            packageSingle(chan, g_lastSelectedSingleLCD)
        elseif g_lastSelectedMultiLCD ~= -1 and whichTab == 0 then
            -- write out the selected multi
            console("Would write out MUTLI patch "..(g_lastSelectedMultiLCD+64).." for a multi")
            packageMulti(chan, g_lastSelectedMultiLCD+64)
        else
            console("No select patch at this moment")
        end
    end
    

    Then I get a backtrace from that point (ie who called me).
    And this is where I start debugging from to try to work out what causes crash.

    #118282
    shookingshooking
    Participant
    • Topics: 14
    • Replies: 60
    • Total: 74

    and then … after I get it working again … Ctrlr throws all my Lua to /dev/null. In 5.3 as well as 6.x now.
    Sorry but this is getting a little concerning – I can see I am not the first victim here.
    Also, in 5.3 there doesnt seem to be an export – in 6.x you can save the Lua.

    All very well for folks to say “just back it up” (which I have last night backup of) but there’s no easy way to be sure what Ctrlr writes.

    Really quite unstable environment.

    Recently when I recovered my code (from fragements) the next day the Ctrlr had found a lot of my code anyhow … go figure.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
There is currently 0 users and 29 guests online
No users are currently active
Forum Statistics
Threads: 2,394, Posts: 16,752, Members: 59,357
Most users ever online was 12 on January 22, 2019 3:47 pm
Do NOT follow this link or you will be banned from the site!