Cross platform remote debugging with lldb-3.8+libsosplugin.so doesn't work
I'm trying to run cross-platform lldb remote debugging using following commands:
On target (arm):
$ lldb-server p --listen *:9000
On host (x64):
$ lldb -o "platform select remote-linux" -o "platform connect connect://<target-ip>:9000" -o "target create corerun" -o "settings set target.run-args hello.exe" -o "plugin load libsosplugin.so" -o "process launch -s" -o "process handle -s false SIGUSR1 SIGUSR2" -o "breakpoint set -n LoadLibraryExW" -o "process continue" -o "sos ClrStack"
I got following error:
Failed to load data access DLL, 0x80131c4f
You can run the debugger command 'setclrpath' to control the load of libmscordaccore.so.
If that succeeds, the SOS command should work on retry.
ClrStack failed
SOS commands work well when I run remote debugging on equal host&target platforms.
During investigation we found that target platfrom definded by following code in src/ToolBox/SOS/lldbplugin/services.cpp:405
HRESULT
LLDBServices::GetExecutingProcessorType(
PULONG type)
{
#ifdef DBG_TARGET_AMD64
*type = IMAGE_FILE_MACHINE_AMD64;
#elif DBG_TARGET_ARM
*type = IMAGE_FILE_MACHINE_ARMNT;
#endif
return S_OK;
}
It seems that target debug platform defined at compile time. Is it enough to change this code only to enable cross-platform remote debugging or we have much bigger issue?
@kvochko, @Dmitri-Botcharnikov, @seanshpark
I think I need more understanding of build configuration.
libsosplugin.so may be intended only for remote debugging in AMD64.
Can you rollback src/ToolBox/SOS/lldbplugin/services.cpp:405 code and test again with remote?
@seanshpark, as I understand the reason of the issue is not in your code. I've found following comment:
//
// We do not currently support cross-platform
// debugging. Verify that cross-platform is not
// being attempted.
//
In the code below we can see the check whether target platform is equal to host platform.
ok, so we need to enable this.
When I follow above steps, I get targetPlatform == hostPlatform. There was some uncertain things.
- how did you build for the ARM target?
- how and what files did you prepare (copy) to the target?
- what folder did you run the
lldb-serverin the target? - how did you build for the x64 host?
- how did you prepare the files and where?
- what folder did you run
lldbin?
I get targetPlatform == hostPlatform too. Did you get an error Failed to load data access DLL, 0x80131c4f?
- I built CoreCLR for ARM target using following command:
LLVM_ARM_HOME=/home/epavlov/llvm-rasp-arm ./build.sh arm cross clean - I copy directory
runtime-hardfp-debug-mode-20160318.2from emulator to raspberry pi 3 with ubuntu mate 16.04, additionally I copy arm binaries from step 1 - I ran lldb-server into
runtime-hardfp-debug-mode-20160318.2directory - I built CoreCLR for x64 by command
./build.sh cleanon host machine (with installedlldb-3.8) - I copy directory
runtime-hardfp-debug-mode-20160318.2from emulator to my host machine & replacelibsosplugin.so,libsos.so,libmscordbi.so,libmscordaccore.so - I run
lldbon the x64 host in theruntime-hardfp-debug-mode-20160318.2directory copied from step 5
I'm not sure that all these steps correct, probably I did something wrong.
Did you get an error Failed to load data access DLL, 0x80131c4f?
No, there is no DLL error. These are my steps that may be different;
- I use NFS in x64 ubuntu 14.04 and mount in RPi2, copy to one folder to access from RPi2 and also copy all DLL files from CoreFX.
- For host, I use another folder not having any relation with arm taget codes, all x64 builds from 4)
- I run
lldbinside folder 5. I've tried in other place but failed to loadlibsosplugin.socause there is no such file. I've tried runlldbin folder 2) but could not load the DLL cause it was ARM binary.
I'm also not sure how remote debugging should be. I've read pages in llvm.org but not much with what files to use. I'll try to google more.
I tried to run lldb in folder from 4), there is no DLL error, but lldb starts debugging x64 corerun:
(lldb) target create corerun
Current executable set to 'corerun' (x86_64).
When I remove corerun from folder 4), then lldb shows correct architecture:
(lldb) target create corerun
Current executable set to 'corerun' (arm).
Do you have arm corerun executable on step 6)?
I didn't notice (x86_64) , (arm) . Have the same result as you.
It seems that libsosplugin erroneously directly calls supporting libraries instead of going through lldb.
This can be checked in the case of remote debugging for the same architecture (e.g. Ubuntu x64 -> Ubuntu x64). When debugger stops on breakpoint we can list loaded libraries from another console:
lsof -p <lldb-pid> | awk '{ print $9 }' | grep '\.so'
We've got the following list:
/home/dima/.lldb/module_cache/remote-linux/.cache/4F2DA89E-3872-C348-89EE-26E4FD304FEB-8AD35FAF/libcoreclr.so
/home/dima/.lldb/module_cache/remote-linux/.cache/4F2DA89E-3872-C348-89EE-26E4FD304FEB-8AD35FAF/libsos.so
/lib/x86_64-linux-gnu/liblzma.so.5.0.0
/usr/lib/x86_64-linux-gnu/libunwind-x86_64.so.8.0.1
/usr/lib/x86_64-linux-gnu/libunwind.so.8.0.1
/lib/x86_64-linux-gnu/librt-2.21.so
/home/dima/.lldb/module_cache/remote-linux/.cache/4F2DA89E-3872-C348-89EE-26E4FD304FEB-8AD35FAF/libmscordaccore.so
/home/dima/.lldb/module_cache/remote-linux/.cache/6447E392-CA89-ABDF-A62D-7CEEDC2AC072-514511C7/libcoreclrtraceptprovider.so
/home/dima/.lldb/module_cache/remote-linux/.cache/5382058B-6903-1CAA-9B99-96C11061CD16-4C9398FF/libc.so.6
/home/dima/work/dotnet/host/libsosplugin.so
/lib/x86_64-linux-gnu/libnss_files-2.21.so
/home/dima/work/dotnet/build/llvm-3.8/x64.debug/lib/readline.so
/lib/x86_64-linux-gnu/libuuid.so.1.3.0
/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so
/usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
/home/dima/.lldb/module_cache/remote-linux/.cache/EF3F6DFF-A1FB-E484-36EC-6F45CD3AABA1-57064BB4/libm.so.6
/home/dima/.lldb/module_cache/remote-linux/.cache/2BA65D97-C6A0-0490-C406-EC0753F91A52-59679042/liburcu-cds.so.1
/home/dima/.lldb/module_cache/remote-linux/.cache/55396DC5-6A5E-E281-DB25-F8A1B2EFB70F-2C0CCD75/liblttng-ust-tracepoint.so.0
/home/dima/.lldb/module_cache/remote-linux/.cache/E7F9D209-93C4-F11B-957C-32D6A84476E2-8D1FCE66/liblttng-ust.so.0
/home/dima/.lldb/module_cache/remote-linux/.cache/8C327CDB-72F1-0EB3-462F-64B6322F1E96-4412BD82/libunwind-x86_64.so.8
/home/dima/.lldb/module_cache/remote-linux/.cache/2A816C3E-BBA4-E128-13FB-D34B06FBD25B-C892A67F/ld-linux-x86-64.so.2
/home/dima/.lldb/module_cache/remote-linux/.cache/D0E735DB-ECD6-3462-DA11-4BD3F76E6EC7-BB1FACCC/libstdc++.so.6
/home/dima/.lldb/module_cache/remote-linux/.cache/AF060686-8175-0736-E052-4DF17D5A86CB-2C3F765C/libpthread.so.0
/home/dima/.lldb/module_cache/remote-linux/.cache/074BB3EE-31ED-A223-D972-28E97C85DE33-5DEC4D53/liburcu-bp.so.1
/home/dima/.lldb/module_cache/remote-linux/.cache/36311B44-5771-0AE5-578C-4BF00791DED7-359DBB92/libgcc_s.so.1
/usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
/usr/lib/x86_64-linux-gnu/libicudata.so.55.1
/usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
/lib/x86_64-linux-gnu/libutil-2.21.so
/lib/x86_64-linux-gnu/libbsd.so.0.7.0
/lib/x86_64-linux-gnu/libgcc_s.so.1
/lib/x86_64-linux-gnu/libm-2.21.so
/lib/x86_64-linux-gnu/libz.so.1.2.8
/lib/x86_64-linux-gnu/libdl-2.21.so
/usr/lib/x86_64-linux-gnu/libxml2.so.2.9.2
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
/usr/lib/x86_64-linux-gnu/libpanel.so.5.9
/lib/x86_64-linux-gnu/libtinfo.so.5.9
/lib/x86_64-linux-gnu/libncurses.so.5.9
/usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
/lib/x86_64-linux-gnu/libc-2.21.so
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
/lib/x86_64-linux-gnu/libpthread-2.21.so
/home/dima/work/dotnet/build/llvm-3.8/x64.debug/lib/liblldb.so.3.8.1
/lib/x86_64-linux-gnu/ld-2.21.so
/home/dima/.lldb/module_cache/remote-linux/.cache/11E7491E-E391-903D-EE47-1D098DD64A94-D4F3553F/libunwind.so.8
/home/dima/.lldb/module_cache/remote-linux/.cache/2B92B18D-F78A-4BBB-2FD6-0E3AA2FE13C5-14787BFC/libuuid.so.1
/home/dima/.lldb/module_cache/remote-linux/.cache/B376100C-AB1E-AC4E-5DE0-66EACFC282BF-7C0B54F3/librt.so.1
/home/dima/.lldb/module_cache/remote-linux/.cache/67699FFD-A9FD-2A55-2032-E0652A242E82-D65AA10D/libdl.so.2
The libraries form .lldb/module_cache/remote-linux/.cache are downloaded from the remote and loaded into current debugger process.
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This process is part of our issue cleanup automation.
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.