Closed awachtler closed 5 years ago
Short update on my site. With a standalone gdb-wrapper script I can now start and stop debugging.
The trick is to add an empty SIGINT-handler temporarily while GDB is running ...
from twisted.internet import reactor # pylint: disable=import-error
from twisted.internet import protocol # pylint: disable=import-error
from twisted.internet import stdio # pylint: disable=import-error
import os
import signal
class MyPP(protocol.ProcessProtocol):
def connectionMade(self):
p = protocol.Protocol()
p.dataReceived = self.onStdInData
stdio.StandardIO(p)
def onStdInData(self, data):
self.transport.write(data)
def outReceived(self, data):
print "r>", data
@staticmethod
def processEnded(data):
x = reactor.stop()
signal.signal(signal.SIGINT, signal.default_int_handler)
def ctrl_c_received(*args, **kwargs):
print "ctrl_c_received:", args, kwargs
if __name__ == "__main__":
bp = MyPP()
exe = "/home/awachtler/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gdb"
x = reactor.spawnProcess(bp , exe,
args = ["dummy", "myfirwmare.elf", "-x", "mypioinit"],
env=os.environ)
signal.signal(signal.SIGINT, ctrl_c_received)
reactor.run()
The signal replacement seems to work just on Linux, not (yet) on Windows ... I'll do continue on that particular issue.
https://bugs.python.org/issue18040 - won't fix for Py2.x :-(
Thanks so much for the hints! Please re-test with the latest dev version:
pio upgrade --dev
Configuration
Operating system:
Windows10 and Linux
PlatformIO Version (
platformio --version
):v4.0.0.rc1 and before
Description of problem
If the command
pio debug ... --interface gdb
is launched, the debugger starts regularly, openocd is started via pipe and I'm able to single step and run to a breakpoint.Nevertheless, if I let the debugger run in freerun mode (gdb-command: continue) and want to pause it after a while (e.g. to see in which endless loop my embedded programm hangs), the entire PIO is ended rather then the debugger gets halted (e.g. to evaluate a stacktrace)
PIO Version: v4.0.0rc1 and before Hardware: Custom SAM4E Board with Atmel-ICE / SAM70 board with FTDI2232 Debugger: openocd
Steps to Reproduce
on Linux
pio debug ... --interface gdb
Verify that it is not the arm-none-eabi-gdb binary
~/.platformio/packages/toolchain-arm..../bin/... gdb <your-elf-file> -x mypionit
Additional info
I saw that in commands/debug/client.py the Debugger is launched via twisted.internet.reactor module. This module catches Ctrl-C with its own handler and terminates PIO rather then forward it to the Debugger.
see also https://stackoverflow.com/questions/4125772/twisted-interrupt-callback-via-keyboardinterrupt
A quick hack works at least once per session and proofs that Ctrl-C is eaten by the twisted reactor: In commands/debug/client.py I replaced:
Edit: changed formatting