This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Detect if program is running under debugger

Is there some register/status bit that a program can use to detect if it is running under the debugger?

 

BR. Leo.

  • Hi Leo,

    Please provide some basic information that will be helpful for us to better answer in a better way:

    1) Is it a TI board or custom board you are using?

    2) Which series of C5000 DSP processor are you using?

    3) What is the context/purpose of you needing to detect if a program is running under the debugger?

    Thank you and regards,

    -Jon M

  • 1) Both. CPU's usually provides this kind of information in a register e.g. ARM Cortex has the C_DEBUGEN bit in the DHCSR register.

    2) C550x and possibly C553x.

    3) For standard error handling:

    - If debugger present: Break into debugger using E_STOP.

    - If no debugger: Log error in NVS and reset.

     

    BR. Leo.

     

  •  

      You could write the code this way: 

    int resetOnError = 1;

    void errorHandler(void) { 

     if (error) {

       asm(" ESTOP_1");

      if (resetOnError) {

           logError(error);

           reset();

     }

    }

    }

    In this way the code would break if the debugger were attached; otherwise the breakpoint would be ignored.  In the debugger, you could change 'resetOnError' to zero before continuing execution.

    Regards,

     Bill