A function defined in C language is called from Python and used.
At this time, I want to set a breakpoint in the C function with the debugger and trace the variable.
Is there a way like this?

If it is a simple C language, it can be debugged easily using the gdb debugger etc., but I could not find a way to debug C functions called in Python.
Therefore, we are currently doing print debugging.

In addition, I want to debug in the executable format, rather than compiling C into Python and running it.

As a method of calling C from Python, a C file is compiled as a shared library and called with ctype.
However, as long as debugging is possible, the C call method does not matter.

  • Answer # 1

    You don't have to think too deeply.

    For example, there is an executable file called hoge, and when debugging a program to be executed with "hoge piyo" with gdb, Start it and start debugging with "run piyo".

    If it is

    , if it is a program to be executed as "python3 hoge.py", start gdb with "gdb python3" and "run hoge.py"should start debugging. Of course, you can't debug python scripts.
    Once I put a breakpoint and executed it, I was able to get to where the break took place.