My cpp library is called libcalctest.so
I have built a csharp wrapper around it called as MyCalcWrapper which calls the functions in libcalctest.so via pinvoke
I am using MyCalcWrapper in a csharp application called as MyNewConsoleApp
If i run it i get correct output however i am not able to debug the cpp functions.
I tried using 2 vscode one for csharp application and one for cpp library having different launch.json files for each
Launch.json for cpp library
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/libcalctest.so",
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"processId":"${command:pickProcess}",
"preLaunchTask": "BUILD",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
Launch.json for CSharp project
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C# Debug",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/MyNewConsoleApp.csproj"
}
]
}
First i start debug the csharp process and then take the process id and attach the cpp debugger to it.
When i attach the cpp debugger i get the following output in debug console
New LWP 31789]
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/libthread_db.so.1”.
__futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x5daf3810b934) at ./nptl/futex-internal.c:57
Loaded ‘/lib/x86_64-linux-gnu/libpthread.so.0’. Symbols loaded.
Loaded ‘/lib/x86_64-linux-gnu/libdl.so.2’. Symbols loaded.
Loaded ‘/lib/x86_64-linux-gnu/libstdc++.so.6’. Symbols loaded.
Loaded ‘/lib/x86_64-linux-gnu/libm.so.6’. Symbols loaded.
Loaded ‘/lib/x86_64-linux-gnu/libgcc_s.so.1’. Symbols loaded.
Loaded ‘/lib/x86_64-linux-gnu/libc.so.6’. Symbols loaded.
Loaded ‘/lib64/ld-linux-x86-64.so.2’. Symbols loaded.
Loaded ‘/usr/share/dotnet/host/fxr/8.0.6/libhostfxr.so’. Symbols loaded.
Loaded ‘/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.6/libhostpolicy.so’. Symbols loaded.
Loaded ‘/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.6/libcoreclr.so’. Symbols loaded.
Loaded ‘/lib/x86_64-linux-gnu/librt.so.1’. Symbols loaded.
Loaded ‘/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.6/libclrjit.so’. Symbols loaded.
Loaded ‘/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.6/libSystem.Native.so’. Symbols loaded.
when the csharp code calls the cpp function the following is added to debug console
[Thread 0x7454995ff640 (LWP 31789) exited]
Thread 1 “MyNewConsoleApp” received signal SIGTRAP, Trace/breakpoint trap.
0x00007455296c7104 in ?? ()
Please let me know what am i missing out on or what am i doing wrong here
Corrior is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.