golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.02k stars 17.54k forks source link

x/tools/gopls: add a source action to see assembly for a range of lines #69122

Open firelizzard18 opened 4 weeks ago

firelizzard18 commented 4 weeks ago

Is your feature request related to a problem? Please describe. I wanted to understand why this allocates:

func normalize(v any) (any, typeCode, bool) {
    switch v := v.(type) {
    case string:
        return v, typeCodeString, true
    // ...
    }
}

Describe the solution you'd like I'd like to be able to select a line and view the assembly for that line (or for a range of lines).

Describe alternatives you've considered I can (and did) use "Browse amd64 assembly for normalize" but that doesn't scale well to larger functions.

Additional context https://github.com/golang/go/issues/67478

findleyr commented 3 weeks ago

CC @adonovan

Since this is a gopls feature request, transferring to the Go issue tracker.

findleyr commented 3 weeks ago

Prior art: https://github.com/loov/lensm

adonovan commented 3 weeks ago

This is a reasonable request, though before we invest piecemeal in small improvements to the assembly UI, we should consider whether installing a more sophisticated disassembly visualization (including blocks and control-flow edges, similar to https://github.com/aclements/objbrowse or https://github.com/loov/lensm) is a better use of time.

As an immediate workaround, you can use the L%d line numbers in the third column to figure out which instructions belong to the source statement of interest.

firelizzard18 commented 3 weeks ago

@adonovan I’d be happy with visualization like that. I’m fine changing this issue to that if you’d like.