Polynomial
Polynomial

Reputation: 28316

Debugging mixed Delphi (native) and C# code, getting "binary was built without debug information"

I've got a C# DLL with native exports, which is called from some Delphi 2009 code. The Delphi code uses LoadLibrary and GetProcAddress to access the exported functions. I'd like to debug the managed part of the code at runtime, but I'm running into trouble.

When I launch the application, the breakpoints appear properly, but fail to be hit.

My current setup is the following:

I've tried enabling unmanaged code debugging, but that causes an error saying "binary was built without debug information". If I continue, all breakpoints are disabled.

When I checked the modules list, the executable shows as having no debug symbols. Delphi doesn't generate a PDB (it can't, since it's a closed-spec proprietary format) but it generates a MAP file instead. I had a look around for MAP-to-PDB converter tools, but it seems there's only a tool for doing the reverse of what I need.

I'm not really interested in debugging the Delphi code from Visual Studio, since I can already do that in the CodeGear Delphi IDE, but is there a way to debug the managed code at runtime in this situation?

Upvotes: 3

Views: 2132

Answers (2)

Polynomial
Polynomial

Reputation: 28316

Ok, I found a solution. The issue wasn't with debug symbols, but rather the type of code being debugged. If you launch an application from your project startup settings, the debugger starts in mixed mode, which requires native symbols to be available in order to catch C# code invoked from native code.

I wasn't able to get Visual Studio to accept the pdb files created by tds2dbg, so I found a workaround. In order to ensure that the debugger launches in managed mode, attach to the process instead of launching it, like so:

  1. Debug -> Attach to process...
  2. Select the running process.
  3. Click the "Select..." button to the right of "Attach to".
  4. Select "Debug these code types"
  5. Check Managed (v2.0, v1.1, v1.0) for .NET 3.5 or less, or Managed (v4.0) for .NET 4.0 or later. Not sure why v3.5 is excluded from the naming here.
  6. Click OK, click Attach.

After this, all breakpoints should work nicely :)

Upvotes: 4

André
André

Reputation: 9112

There is a "tds2pdb" you can try to create a .pdb file: http://code.google.com/p/map2dbg/downloads/detail?name=tds2pdb102.zip

Note: it's not a complete .pdb file (specs aren't available) but at least it is working for stack traces. However, not all symbols (classes, variables, parameters) are exported. But you can always try...

Upvotes: 1

Related Questions