How to debug windows dll used inside python?

On Windows7, I have a python script that uses the Windows DLL using the .NET Common Language Runtime (CLR). The error occurs in one of the used DLLs, but the standard Python debugger only debugs the level of Python code (and not the DLL).

How can I debug what happens inside a dll?

+5
source share
2 answers

If you have Microsoft Visual Studio,

1) open the Visual Studio project in which your library is a part (or create a new project).

2) If you configured your DLL for debugging (you created it with debugging information, and it will be used by python), you can set breakpoints in the DLL code.

3) Run the program you want to debug, as usual.

4) Return to the Visual Studio development environment and go to the Debug menu. Select the Attach to Process option. Then you will get a list of all running processes.

5) Select the process you want to debug, it will be your python program or the runtime in which your program is running.

6) Sit back and wait for one of your breakpoints to hit, or you can try Break All from the Debug menu to temporarily stop the program.

This is a common way to start debugging not only python programs, but any program in which you need to debug the DLL used by the program.

Note that the above tip works best if you yourself have created a DLL with debug information and use your python application. If this is a third-party DLL in which you do not have the source code, you can still debug Visual Studio, but you need to know the assembly language (since the source code is usually not available).

+7
source
0
source

Source: https://habr.com/ru/post/1207756/


All Articles