6

I'm developing a C(++) extension for python. I have a library in C that I wrap using Swig. Unfortunately I have some error that I would like to debug that is within the C extension. My program makes heavy use of MsgBuffer class which I send over a serial connection. All the messages may contain multiple parts. If I add a MsgPart to a MsgBuffer, then the msg should make a copy of the message, but currently it looks like I'm adding a reference, because once I modify the part, add the modified part, the initial part looks like it is modified as well.

So What I would like to do is set a breakpoint in my python program and step through the debugger.

pin = 12  # Pin 12 on Teensy3.2
pullup = False  # No need for enabling pull up resistor.
msg = MsgBuffer(TEENSY_REQ_INPUT_PIN)
part= MsgPart()
part.write_uint32(pin)
msg.add_part(part)
part.write_uint32(1 if pullup else 0)
msg.add_part(part) # I would like to set a breakpoint here in order to see whether it is added as reference or it is copied in the c extension
self._serial.write_msg(msg)

I would like to step from python's debugger into a C debugger. How I now currently do this is to put a input('press enter') and attach a C debugger to the process, but I find this inconvenient. I would like to step into the extension from python, is this possible?

3
  • That would be convenient. I usually set breakpoints in the C code and attach the C debugger - there is no need to modify any code with inputs. Commented Aug 22, 2019 at 18:06
  • It can be configured and done using eclipse, pdb and gdb. On Windows, it is a little simpler, learn.microsoft.com/en-us/visualstudio/python/…. What platform are you using Commented Aug 22, 2019 at 18:14
  • @JensMunk Currently i'm using Ubuntu-18.04 linux, I'm targeting windows as well, but this is coming at a later state (although I'm feeling a bit sorry now if that is much easier). I'm using IntelliJ clion (for c(++) extensions) and can use pycharm to remain in the 'IntelliJ envrironment. Generally, my scripts terminate before i've got time to attach the debugger, hence the input. Commented Aug 23, 2019 at 9:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.