Reputation: 4029
I have a DLL written in C++. It wraps a static library. I am calling it from python with ctypes. So far, so good. I need to debug some calls in the DLL. I can hit breakpoints in the static library, but, not the DLL. I am doing this by using Attach to Process from the Debug menu. The code looks something like this:
extern "C"
{
__declspec(dllexport)
void foo()
{
int i = 0; // Can't hit breakpoint here
}
}
I am generating debug info. The pdb is sitting right next to the DLL. I am loading the DLLI think I am loading. What am I missing?
Edit I recreated the project. Problem went away. Perhaps the difference is I went from a managed C project to an MFC DLL?
Upvotes: 3
Views: 6125
Reputation: 2272
When you attach to a running process using MS Visual Studio, make sure you have the options set for both "Managed Code" and "Native Code". This will ensure your breakpoints in any type of code, native or managed, will be honored by the MS Visual Studio debugger. Otherwise, MS Visual Studio will use its "automatic" settings, which results in it only honoring break points that it sees in its "type" of project (for instance: a MFC project is native code (unmanged) and therefore won't normally debug managed code sections, while a .Net project is managed code and won't bother to stop for break points in "unmanaged" native code.)
You can set this option at attach time by selecting the "Select..." button, and swapping the radio button from "Automatic" to "Debug these code types". Under "Debug these code types", check the box beside "Managed" and "Native". You can select more options if you work with other types that MS Visual Studio recognizes (like T-SQL for SQL Server code, etc).
Upvotes: 2