Rocket jBASE

 View Only

Debugging a jRemote and/or RESTful service API (Linux)

  • 1.  Debugging a jRemote and/or RESTful service API (Linux)

    ROCKETEER
    Posted 06-21-2022 13:57
    When developing RESTful service APIs or server side code used for jRemote (e.g. ODBC) it can be cumbersome to use logging and/or temporary writes to a file to trouble shoot the send/receive messages in your jBC server side code. In jBASE 5.8, when you start jbase_agent you can optionally include the following options:

    -S single session
    -d (enable debugging)
    -Jr (redirect debugging to another device)
    -J[D,d] (force the program/subroutine into the debugger at start up)

    Note that the -J options are standard jBASE program execution options for debugging.

    The difference between the D and d are that the D will force a debug on all EXECUTEs whereas the d drops into the debugger on the first program being executed. This may be a requirement especially if this is a RESTful API then the initial program will be an EXECUTE from the jbase_agent worker process.

    The advantage of using -JD or -Jd is not having place a DEBUG statement in your code. Though you may still find this easier depending on your situation.

    If debugging using the session where jbase_agent is being run is not viable then the -Jr option will be required. In this case, the first step is to have your debug window ready
    $ tty
    /dev/pts/0
    $ sleep 99999999​

    The first command above returns the tty device we'll be using for our debug redirect.
    The second command is a way to suppress the request data/status of your tty from the jbase_agent process (try it without the sleep and you'll get a better idea).

    You may also want to change the break/interrupt command on the intended debugging session so you don't accidentally break out of the sleep command.

    $ tty
    /dev/pts/0
    $ ssty intr ^k
    $ sleep 999999999

    i.e. change the break/interrupt to ctrl-K


    Next step is to {re}start jbase_agent with the added options.

    $ jbase_agent -d -JD -Jr/dev/pts/0 ....(continue with the other start up options)​

    Now when you test your remote request you should see

    jBASE debugger->

    on the session denoted by the -Jr  (i.e. the /dev/pts/0 session).

    From here you can debug the code just like you would any other jBC program/subroutine.

    You may also want to include a -Jp option to include source locations.

    $ jbase_agent -d -JD -Jr/dev/pts/0 -Jp/dbms/myapp/BP:/dbms/shared/INCLUDE

    If you didn't specify the -Jp you can still use the p command in the debugger.

    You may also want to include a -S option when starting jbase_agent so that only one request at a time will be handled. This isn't a requirement for debugging but if multiple requests come through your debug session will be somewhat confusing as your debugging tty session will be potentially debugging multiple programs at the same time.

    Similarly without remote debugging:

    $ jbase_agent -d -JD -Jp/dbms/myapp/BP:/dbms/shared/INCLUDE​

    and with a single jbase_agent process:

    $ jbase_agent -S -d -JD -Jp/dbms/myapp/BP:/dbms/shared/INCLUDE



    ------------------------------
    Peter Falson
    Rocket Internal - All Brands
    ------------------------------