Reputation: 633
I have a RAD Studio C++ project on Windows which make use of several DLLs that are built using MS Visual Studio. One major impediment for debugging is that the debugger does not show symbols within the DLL. Visual Studio creates debug symbols in PDB format, whereas RAD Studio seems to generate DWARF symbols. The two projects share a common build directory.
I have heard that lately PDB support has been added for the modern C++ compiler. Would this solve my problem? Can I somehow tell the debugger to use my PDBs, which are lying around in the build directory anyway?
Upvotes: 0
Views: 73
Reputation: 633
While I have no explanation to why it works and why it previously didn't, I can offer a minimal example here that does work.
Minimal example:
File: main.cpp (RAD Studio)
#include <iostream>
#include <tchar.h>
extern "C" __declspec(dllimport) void foo();
#pragma link "foo.dll.a"
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "entered _tmain()\n";
foo();
std::cout << "exiting _tmain()\n";
}
File: foo_dll.cpp (Visual Studio and CMake)
#include <iostream>
extern "C" __declspec(dllexport) void foo()
{
std::cout << "in foo()\n";
}
File: CMakeLists.txt (for building the dll)
cmake_minimum_required(VERSION 3.28)
project(foo)
add_library(foo SHARED)
target_sources(foo PRIVATE foo_dll.cpp)
add_custom_command(TARGET foo POST_BUILD
COMMAND mkexp $<TARGET_FILE:foo>.a $<TARGET_FILE:foo>
)
After compiling main.cpp in Borland and executing cmake using:
cmake -G "Visual Studio 15 2017" -B build -A x64
cmake --build build
I can now set a break point inside function foo()
and the debugger will halt on it.
One minor issue is that stepping into foo()
by pressing F7 (step into) is not supported: the debugger did not halt upon function entry, but only at program exit.
Upvotes: 0