Skip to content

Improve the usability of SOS around open/closed generic types #1573

Open
@tmds

Description

@tmds

I can't figure out how to see the contents of a Span<byte> using lldb and sos.

For example:

using System;

namespace console
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            Span<byte> span1 = new byte[] { 1, 2, 3 };
            Span<byte> span2 = stackalloc byte[] { 4, 5, 6 };
            Foo(span1, span2);
        }

        public static void Foo(Span<byte> span1, Span<byte> span2)
        {
            Console.WriteLine(span1.Length + span2.Length);
        }
    }
}
$ lldb bin/Debug/net5.0/console
(lldb) target create "bin/Debug/net5.0/console"
Current executable set to '/tmp/console/bin/Debug/net5.0/console' (x86_64).
(lldb) bpmd Program.cs:16
(lldb) process launch
Process 46873 launched: '/tmp/console/bin/Debug/net5.0/console' (x86_64)
1 location added to breakpoint 1
JITTED console!console.Program.Foo(System.Span`1<Byte>, System.Span`1<Byte>)
Setting breakpoint: breakpoint set --address 0x00007FFF7DD16280 [console.Program.Foo(System.Span`1<Byte>, System.Span`1<Byte>)]
Process 46873 stopped
* thread #1, name = 'console', stop reason = breakpoint 3.1
    frame #0: 0x00007fff7dd16280
->  0x7fff7dd16280: pushq  %rbp
    0x7fff7dd16281: subq   $0x30, %rsp
    0x7fff7dd16285: leaq   0x30(%rsp), %rbp
    0x7fff7dd1628a: movq   %rdi, -0x10(%rbp)
(lldb) clrstack -a
OS Thread Id: 0xb719 (1)
        Child SP               IP Call Site
00007FFFFFFFC6B8 00007FFF7DD16280 console.Program.Foo(System.Span`1<Byte>, System.Span`1<Byte>) [/tmp/console/Program.cs @ 15]
    PARAMETERS:
        span1 (<CLR reg>) = 0x00007fff5000b728
        span2 (<CLR reg>) = 0x00007fffffffc6c0

00007FFFFFFFC6C0 00007FFF7DD15E31 console.Program.Main(System.String[]) [/tmp/console/Program.cs @ 11]
    PARAMETERS:
        args (0x00007FFFFFFFC748) = 0x00007fff5000a358
    LOCALS:
        0x00007FFFFFFFC738 = 0x00007fff5000b728
        0x00007FFFFFFFC728 = 0x00007fffffffc6c0
        0x00007FFFFFFFC718 = 0x00007fffffffc6c0

(lldb) 

What commands can I use to print the content of these Spans?

cc @mikem8361

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions