Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixed mode assembly not loading symbol for native C++ pdbs

I am working with mixed mode assemblies in C++/CLI. All managed mode assembled pdb's get loaded when successfully in mixed mode assembly, but native dll's and pdb's are not getting loaded even though the information of native pdb's is shown in the Modules pane (i.e. in VS Debug->Windows->Modules).

I am using native dll and calling its exported function in mixed assembly in C++/CLI code. Here, functions get called successfully, but native pdb symbols are not loading and all breakpoints in the native code are shown as hollow circle and tool tips says there are no symbols loaded for this.

I have done everything, pdb placed in current directory to where the managed process is launched; deleted all obj and debug folders and recompiled every project at the same time; I even used the ChkMatch utility which shows that the symbols in the Exe and corresponding pdb match.

Is there any way to enable breakpoints of native code while calling from managed (C++/LCI Mixed mode) code?

Regards,

Usman

like image 772
Usman Avatar asked Jul 24 '10 15:07

Usman


1 Answers

Mixed-mode debugging can be hit and miss, mostly miss. First check that you've actually have mixed-mode debugging enabled. From a C# project, it is Project + Properties, Debug, Enabled unmanaged code debugging check box. Next, mixed-mode debugging is not enabled for 64-bit processes. If you run on a 64-bit operating system, make sure you force the .exe to run in 32-bit mode. Project + Properties, Build tab, Platform Target = x86.

Next verify where the debugger looked for the .pdb files. From the Debug + Windows + Modules window, right-click the DLL and select "Symbol load information". Final gasp is to use __debugbreak() in the unmanaged code.


UPDATE: Recent versions of VS (starting with VS2012) have a new managed debugging engine that is not compatible enough with the unmanaged debugging engine. Tools > Options > Debugging > General, tick "Use Managed Compatibility Mode". It enables the legacy debugging engine, the one last used in VS2010.

like image 104
Hans Passant Avatar answered Sep 28 '22 09:09

Hans Passant