Shop OBEX P1 Docs P2 Docs Learn Events
PROPOSAL: Disable DEBUG compilation per-object — Parallax Forums

PROPOSAL: Disable DEBUG compilation per-object

We posting spin language proposals now?

There's already a number of DEBUG_ constants that can be defined to modify DEBUG behaviour.

Can we add one that disables compilation of debug statements on a per-object basis? Maybe DEBUG_DISABLE ? This way, debug code could be left in a library object without clogging up the main application's output. Especially relevant to the USB code, since in some cases there are timing issues caused by the DEBUG output.

So basically:

  • If the debugger is not enabled, no debug statements are built, full stop.
  • If the debugger is enabled and DEBUG_DISABLE is set in an object, debug statements in that object are not built.
  • If the debugger is enabled and the special constant is not set, build debug statements as normal.

@cgracey
@ersmith

Comments

  • evanhevanh Posts: 15,915

    I like it.

  • Seems like it should be straightforward to implement in flexspin (you could probably do it, but I'm happy to as well). Let's see what @cgracey and @macca think.

  • It would be handy, especially if you need to focus on just one thing at a time and you use other objects written with existing DEBUG statements in them.

  • @ersmith said:
    Seems like it should be straightforward to implement in flexspin (you could probably do it, but I'm happy to as well). Let's see what @cgracey and @macca think.

    I have implemented it so it works also with object parameters:

    OBJ
    driver : "driver_object" | DEBUG_DISABLED=1
    

    Actually any value disable debug it just checks if defined.

  • Wuerfel_21Wuerfel_21 Posts: 5,052
    edited 2023-06-09 09:57

    I have implemented it so it works also with object parameters:

    Well that was the intent. Though I'd say it's slightly better to check for a non-zero value, so it can be disabled by default and then overriden to being enabled.

  • ersmithersmith Posts: 6,052
    edited 2023-06-10 15:06

    Should the constant be DEBUG_DISABLE (as in the original post) or DEBUG_DISABLED (as in the example @macca posted)? I lean towards the first, but obviously it's easy to do either way.

  • Oh, didn't even notice the discrepancy. Idk it doesn't matter.

  • @ersmith said:
    Should the constant be DEBUG_DISABLE (as in the original post) or DEBUG_DISABLED (as in the example @macca posted)? I lean towards the first, but obviously it's easy to do either way.

    @Wuerfel_21 said:
    Oh, didn't even notice the discrepancy. Idk it doesn't matter.

    Ah... I hadn't noticed it either... :smile: doesn't matter to me, maybe DEBUG_DISABLE is more syntactically correct given the actual effect depends on the expression evaluation.

  • We all seem to slightly prefer DEBUG_DISABLE, so that it is.

    I consider this feature a blocker for non-beta release of the usbnew driver, btw (so you can debug your application without getting spammed with USB-related stuff or having to edit the driver file)

Sign In or Register to comment.