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 "If it is
hoge piyo" with gdb, Start it and start debugging with "
, 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.
- c ++ - c language: please tell me how to deal with the error message "bus error"!
- c ++ - i don't understand why i get an error in a program that uses c language pointers
- python - vscode: i can't debug django apps
- c ++ - c language fial reading and writing
- c ++ - i want to port the functionalized fizzbuzz implemented in ruby to c language
- c ++ - delete and change the contents from the c language text file
- c ++ - c language two-dimensional array pointer replacement
- c ++ - c language file operation
- i want to use c ++ code in python