pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.13k stars 484 forks source link

Semihosting: How about halting debugger on SYS_EXIT? #1521

Open rgrr opened 1 year ago

rgrr commented 1 year ago

OpenOCD behaves that way, that debugging is halted if the target issues SYS_EXIT (0x18).

Should be a oneliner if one knows the corresponding call.

And another idea which goes into the same direction: how about command line options to start the target in gdbserver mode and exit pyocd if SYS_EXIT is executed? This would allow very easy in target coverage testing.

Hoohaha commented 1 year ago

Hi @rgrr ,

We are using gdb command: continue & to start execution. & can make continue run in background and not blocking the gdb.

If you want to exit debuging, you can send interrupt.

We are using this way to get coverage data from target with pyocd.

rgrr commented 1 year ago

My idea is to omit gdb and do pyocd the job. After finding out, that pyocd is controllable via API there seem to be multiple ways to get to the goal. I guess I will expand the API examples section a bit.

Nevertheless, openocd behavior to halt debugging (as if there was a breakpoint) is TMO very helpful if in a debug session. Pyocd currently shows you a "running" target in gdb although effectively it has stopped at the BKPT.