How to detect if running under debugger?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to detect if running under debugger?

1,629件の閲覧回数
RichTestardi
Senior Contributor II
Hi all,
 
I'd like my code to be able to detect if it is running under the debugger, so I can print to the debug console (using the Trap #14 halt mechanism) if it is available.  I'm wondering if there is a way to do this generically, without having to change the project files...
 
The only way I have managed to do this is to modify the debugger cfg file to modify a MCU register from its default value, such as:
 
; Debugger attached flag -- MCF_GPIO_PORTAN == 0
writemem.b 0x4010000A 0x00
 
And then I test for it in early boot:
 
    // we read MCF_GPIO_PORTAN's initial value to determine if the debugger is attached
    // N.B. this value must be set by the debugger's cfg file!
    if (! MCF_GPIO_PORTAN) {
        debugger_attached = 1;
    } else {
        // turn off pstclk to reduce emi
        MCF_CLOCK_SYNCR |= MCF_CLOCK_SYNCR_DISCLK;
    }
 
The problem with this is it requires the cfg file modification, which I'd like to not have to do.
 
Does anyone know of a better way to do this?  Thanks!
 
-- Rich
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 返信

577件の閲覧回数
RichTestardi
Senior Contributor II
Sorry, I'm running CW for CF v7.1, using both MCF52221 and MCF52233.
0 件の賞賛
返信