#helping with debuging python module
79 messages · Page 1 of 1 (latest)
When your question is answered use !solved or the button below to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
I didn't have to do anything special, just run the whole python process in your debugger
which debugger
Which one do you normally use?
i mean cpp one or python one
C++ one
How do you use it normally?
In some kind of IDE?
Or in the terminal?
And which C++ debugger is it?
So just set python as the executable in launch.json
And you can give it command line arguments to run your script/whatever
it dont stop at the breakpoint
in the python file
and even in the cpp
i think so
If it doesn't work, then probably not
Can you recompile it and try again? If this doesn't work, show the exact compilation command you used
i used cmake so i just let it to make the library
i did recompile it and try again 6 or 7 time
What CMAKE_BUILD_TYPE do you use? Debug?
debug
Ok. Delete the build directory and rebuild in verbose mode. Show the compilation commands
what is verbose mode
Do you know how to use cmake from the terminal?
yes
Then instead of cmake --build ... do cmake --build ... --verbose
It should show the compilation commands
What python are you testing the module with?
3.12.11
I mean msys2 python or not?
https://www.msys2.org/docs/python/ this claims that the official versions of python for windows are not compatible with binary modules built in msys2
msys2 python
Okay, that's good
Where do you place your breakpoint? Are you sure this function is getting called?
Try printing something from your module
i put a breakpoint in the constructure of a class in the python file
then put another breakpoint in somewhere in the constructure function
idk if i spelled constructure correct
btw what did you tell me to debug python with gdb
gdb python src.py?
Yeah, that should work
however, it dont work
Did you do this yet?
Does it not work if you place breakpoint on the line that prints stuff?
To be clear, when you run it in a debugger, you see the text being printed, but the breakpoint on the exact same C++ line doesn't get triggered?
i dont stop on breakpoint
Alright
I've created this file, called 1.cpp:
#include <iostream>
#include <pybind11/pybind11.h>
PYBIND11_MODULE(example, m)
{
m.def("foo", []
{
std::cout << "Hello!\n";
});
}
Compiled with g++ 1.cpp `pkg-config --libs --cflags python3-embed` -Ipybind11/include -shared -o example.pyd -g in MSYS2 UCRT64
Then did gdb --args python3 -c 'import example; example.foo()'
b 1.cpp:8
y
r
And the breakpoint is being hit
Test the exact same thing, see if it's being hit for you or not
do you know how a confusing polygon called
whatsgoingon
❓
i have no idea what you say
I've tried debugging a simple module and it works for me
I've given you the exact steps on how to do that
Test if this process works for you or not
it say no debuging symbol found in python3
That shouldn't matter, continue with the steps and see if it works
i run the compile command but it doesnt work
Please read my last comment again