Debugging CoreFX on Unix ========================== CoreFX can be debugged on unix using both lldb and visual studio code ## Using lldb and SOS - Run the test using msbuild at least once with `/t:BuildAndTest`. - [Install version 3.9 of lldb](https://github.com/dotnet/coreclr/blob/master/Documentation/building/debugging-instructions.md#debugging-core-dumps-with-lldb) and launch lldb with dotnet as the process and arguments matching the arguments used when running the test through msbuild. - Load the sos plugin using `plugin load libsosplugin.so`. - Type `soshelp` to get help. You can now use all sos commands like `bpmd`. You may need to supply a path to load SOS. It can be found next to libcoreclr.so. For example: ``` (lldb) plugin load libsosplugin.so error: no such file (lldb) image list libcoreclr.so [ 0] ..... /home/dan/dotnet/shared/Microsoft.NETCoreApp/2.0.4/libcoreclr.so (lldb) plugin load /home/dan/dotnet/shared/Microsoft.NETCoreApp/2.0.4/libcoreclr.so ``` ## Debugging core dumps with lldb It is also possible to debug .NET Core crash dumps using lldb and SOS. In order to do this, you need all of the following: - You will find the dump url to download the crash dump file in the test logs, something similar to:
2017-10-10 21:17:48,020: INFO: proc(54): run_and_log_output: Output: dumplingid: eefcb1cc36977ccf86f457ee28a33a7b4cc24e13 2017-10-10 21:17:48,020: INFO: proc(54): run_and_log_output: Output: https://dumpling.azurewebsites.net/api/dumplings/archived/eefcb1cc36977ccf86f457ee28a33a7b4cc24e13- The crash dump file. We have a service called "Dumpling" which collects, uploads, and archives crash dump files during all of our CI jobs and official builds. - On Linux, there is an utility called `createdump` (see [doc](https://github.com/dotnet/coreclr/blob/master/Documentation/botr/xplat-minidump-generation.md "doc")) that can be setup to generate core dumps when a managed app throws an unhandled exception or faults. - Matching coreclr/corefx runtime bits from the crash. To get these, you should either: - Download the matching Jenkins archive onto your repro machine. - Check out the coreclr and corefx repositories at the appropriate commit and re-build the necessary portions. - You can also download the matching "symbols" nuget package from myget.org. There is a "Download Symbols" button in the myget UI for this purpose. - lldb version 3.9. The SOS plugin (i.e. libsosplugin.so) provided is now built for lldb 3.9. In order to install lldb 3.9 just run the following commands: ``` ~$ echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.9 main" | sudo tee /etc/apt/sources.list.d/llvm.list ~$ wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - ~$ sudo apt-get update ~$ sudo apt-get install lldb-3.9 ``` Once you have everything listed above, you are ready to start debugging. You need to specify an extra parameter to lldb in order for it to correctly resolve the symbols for libcoreclr.so. Use a command like this: ``` lldb-3.9 -O "settings set target.exec-search-paths