Skip to content

LLDB sos commands don't write output to SBCommandReturnObject #4086

Description

@defufna

Description

I had a custom lldb command written in python that calls clrstack on all threads listed by clrthreads. The command stopped working after I updated dotnet-sos to 7.0.410101 (it's still broken on 7.0.430602). The reason why it's broken is that it commands executed with SBCommandInterpreter.HandleCommand do not write their output to lldb.SBCommandReturnObject, I checked both output and error streams of the command and both are empty.

To reproduce this issue, you can use the following lldb command:

script res=lldb.SBCommandReturnObject(); lldb.debugger.GetCommandInterpreter().HandleCommand("clrstack", res);res.GetOutputSize()

The command will print clrstack output on the console and 0 after that, this behavior is same for all sos commands.
If you use a lldb command, for example "bt" the provided snippet will print nothing and return some number greater than 0

Configuration

dotnet --info

.NET SDK:
Version: 7.0.100
Commit: e12b7af219

Runtime Environment:
OS Name: gentoo
OS Version: 2.13
OS Platform: Linux
RID: linux-x64
Base Path: /home/user/.dotnet/sdk/7.0.100/

Host:
Version: 7.0.0
Architecture: x64
Commit: d099f075e4

.NET SDKs installed:
7.0.100 [/home/user/.dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.0 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.0 [/home/user/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/home/user/.dotnet]

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Regression?

Other information

It used to work before I updated, but I can't remember the exact version of dotnet-sos I had, something pretty old, probably 6.*

Activity

  1. self-assigned this
    on Jul 20, 2023
  2. added this to the 8.0.0 milestone on Jul 20, 2023
  3. Unity-Harry commented on Jun 4, 2024

    @Unity-Harry

    Hello, any update on this issue?
    I've just hit the same thing while trying to write some custom LLDB tooling which processes CLR data.
    In particular I'm trying to capture the results of ip2md into a python string

  4. mikem8361 commented on Jun 4, 2024

    @mikem8361
    Contributor

    I've been working on some changes that would lead to fixing this issue. It will take some bigger infrastructure changes to SOS to allow per command output.

  5. Unity-Harry commented on Jun 4, 2024

    @Unity-Harry

    I've been working on some changes that would lead to fixing this issue. It will take some bigger infrastructure changes to SOS to allow per command output.

    Thanks for the reply!

    In the meantime, do you have any suggestions for getting the C# method name (signature) from a given address in LLDB?

    I was trying to use ip2md and extract the name portion of the output, but I'm now wondering if there's another way I can go about this more directly?

  6. defufna commented on Jun 4, 2024

    @defufna
    Author
  7. mikem8361 commented on Jun 4, 2024

    @mikem8361
    Contributor

    You can write managed C# SOS commands now using the above CLRMD. Some examples are in https://github.com/dotnet/diagnostics/tree/main/src/Microsoft.Diagnostics.ExtensionCommands.

  8. added
    enhancementNew feature or request
    and removed
    bugSomething isn't working
    on Jul 23, 2024
  9. modified the milestones: 8.0.0, Future on Jul 23, 2024
  10. leculver commented on Feb 18, 2026

    @leculver
    Contributor

    I know this is an older issue at this point but thank you for filing it. I've been fighting this in a personal project for a while now and this issue captures what I was seeing.

    Of course the right fix is to always use ClrMD and not try to screen scrape SOS. SOS is not an interface, and ClrMD is.

    Even still this really breaks some diagnostic features, it's a bug, and I have a fix I'm working on.

  11. leculver commented on Feb 18, 2026

    @leculver
    Contributor

    Fix #5728

  12. added
    bugSomething isn't working
    and removed
    enhancementNew feature or request
    on Feb 18, 2026
  13. locked and limited conversation to collaborators on Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions