Debug of program exit

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

Debug of program exit

ソリューションへジャンプ
2,465件の閲覧回数
oaf
Contributor IV

In my world I don't use exit() at all, but sometimes a nasty error could happen inside a library func

which calls exit(). In the comp.c this function is implemented as this:

void _exit(int status)

{

// disable all interrupts, run infinite loop

    __asm("cpsid i");

    while(1);

}

What would be much nicer is if the sw could just enter the debugger. Do I have to patch the source, or is there a

non intrusive way of do this?

タグ(2)
1 解決策
2,128件の閲覧回数
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have checked the source code file and it is located in KSDK_1.1.0\rtos\mqx\mqx\source\psp\cortex_m\compiler\gcc_arm\comp.c, i.e. this program module is a part of MQX. It is a static source code file and you can modify it.

    

This issue is related to MQX software solution. I will move it.

Best Regards,

Marek Neuzil

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
2,129件の閲覧回数
marek_neuzil
NXP Employee
NXP Employee

Hello,

I have checked the source code file and it is located in KSDK_1.1.0\rtos\mqx\mqx\source\psp\cortex_m\compiler\gcc_arm\comp.c, i.e. this program module is a part of MQX. It is a static source code file and you can modify it.

    

This issue is related to MQX software solution. I will move it.

Best Regards,

Marek Neuzil

0 件の賞賛
返信
2,128件の閲覧回数
oaf
Contributor IV

Ok,

If I may wish a solution with a function-pointer, weak-link would be better, as you then doesn't have to change the library source.

BTW:what is the assembly instruction for breakpoint?

0 件の賞賛
返信
2,128件の閲覧回数
DavidS
NXP Employee
NXP Employee
   __asm("bkpt 4"); //DES example of using assembly code in "C" source to halt/break in the code.  A debugger can then step over and the resume execution.

Regards,

David

0 件の賞賛
返信
2,128件の閲覧回数
jvasil
Contributor III

In some example code, I've seen this coded with a '0' instead of a '4'.  ARM documentation says:

"The BKPT instruction causes the processor to enter Debug state. Debug tools can use this to investigate system state when the instruction at a particular address is reached.

In both ARM state and Thumb state, imm is ignored by the ARM hardware. However, a debugger can use it to store additional information about the breakpoint." [ARM Information Center]

So I'm curious if there is any particular reason for using '4'?

I'm also curious about what happens if a bkpt instruction is executed when there is no debugger connected.  I assume this acts similar to either a NOP or a HALT but haven't found a description of this yet.

Thanks,

James

0 件の賞賛
返信
2,128件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi James,

No particular reason for "4" other than it works.

My testing without debugger has behavior of a HALT.

Regards,

David

2,128件の閲覧回数
jvasil
Contributor III

Thanks.  Just FYI, '0' seems to work too.  Guess you COULD look at this value to take some action in the debugger.

Too bad about the behavior--guess that means can't leave bkpt instructions sprinkled in the code!!

0 件の賞賛
返信