Search code examples
.netlldb

Debug .NET Core 6 with lldb is showing assembly code on breakpoint, how do I show the dotnet code?


For lldb I want to see the .NET code when I hit a break point instead I see assembly code.

My .csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
       <OutputType>Exe</OutputType>
       <TargetFramework>net6.0</TargetFramework>
       <ImplicitUsings>enable</ImplicitUsings>
       <Nullable>enable</Nullable>
       <SelfContained>false</SelfContained>
       <PublishSingleFile>true</PublishSingleFile>
       <DebugType>embedded</DebugType>
    </PropertyGroup>
</Project>

I've also used

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
       <OutputType>Exe</OutputType>
       <TargetFramework>net6.0</TargetFramework>
       <ImplicitUsings>enable</ImplicitUsings>
       <Nullable>enable</Nullable>
       <PublishSingleFile>true</PublishSingleFile>
       <DebugType>embedded</DebugType>
    </PropertyGroup>
</Project>

My output

    $ lldb -o "target create hello" -o "bpmd hello.dll services.Hello.GetHello" -o "process launch -s" 
    Current symbol store settings:
    -> Cache: /home/shawn/.dotnet/symbolcache
    -> Server: https://msdl.microsoft.com/download/symbols/ Timeout: 4 RetryCount: 0
    (lldb) target create hello
    Current executable set to '/home/shawn/hello/bin/Debug/net6.0/linux-arm64/publish/hello' (aarch64).
    (lldb) bpmd hello.dll services.Hello.GetHello
    (lldb) process launch -s
    Process 1722 launched: '/home/shawn/hello/bin/Debug/net6.0/linux-arm64/publish/hello' (aarch64)
    (lldb) process continue
    Process 1722 resuming
    1 location added to breakpoint 1
    (lldb) JITTED hello!services.Hello.GetHello()
    Setting breakpoint: breakpoint set --address 0x0000FFFF7E43FA60 [services.Hello.GetHello()]
    Process 1722 stopped
    * thread #1, name = 'hello', stop reason = breakpoint 3.1
    frame #0: 0x0000ffff7e43fa60
    ->  0xffff7e43fa60: stp    x29, x30, [sp, #-0x20]!
        0xffff7e43fa64: mov    x29, sp
        0xffff7e43fa68: str    xzr, [x29, #0x10]
        0xffff7e43fa6c: str    x0, [x29, #0x18]
   (lldb) process continue
    Process 1722 resuming
    Hi
    Process 1722 exited with status = 0 (0x00000000) 
    (lldb) exit

I've also tried

    $ lldb -o "target create dotnet" -o "settings set target.run-args ./hello.dll" -o "bpmd hello.dll services.Hello.GetHello" -o "process launch -s" 
    Current symbol store settings:
    -> Cache: /home/shawn/.dotnet/symbolcache
    -> Server: https://msdl.microsoft.com/download/symbols/ Timeout: 4 RetryCount: 0
    (lldb) target create dotnet
    Current executable set to 'dotnet' (aarch64).
    (lldb) settings set target.run-args ./hello.dll
    (lldb) bpmd hello.dll services.Hello.GetHello
    (lldb) process launch -s
    Process 1559 launched: '/home/shawn/.dotnet/dotnet' (aarch64)
    (lldb) process continue
    Process 1559 resuming
    1 location added to breakpoint 1
    (lldb) JITTED hello!services.Hello.GetHello()
    Setting breakpoint: breakpoint set --address 0x0000FFFF7E40FA60 [services.Hello.GetHello()]
    Process 1559 stopped
    * thread #1, name = 'dotnet', stop reason = breakpoint 3.1
    frame #0: 0x0000ffff7e40fa60
    ->  0xffff7e40fa60: stp    x29, x30, [sp, #-0x20]!
        0xffff7e40fa64: mov    x29, sp
        0xffff7e40fa68: str    xzr, [x29, #0x10]
        0xffff7e40fa6c: str    x0, [x29, #0x18]
        (lldb) process continue
    Process 1559 resuming
    Hi
    Process 1559 exited with status = 0 (0x00000000) 
    (lldb) exit

Any thoughts on how I can output the C# code in the breakpoint?

Expecting: C# Code

I've tried building with different .csproj setting to include the pdb, along with running with .NET and stand alone


Solution

  • At the moment it is not supported by the dotnet team. I switch to netcoredbg

    Issue found here: https://github.com/dotnet/diagnostics/issues/4240