bradleyjkemp / memviz

Visualize your Go data structures using graphviz
MIT License
1.3k stars 51 forks source link

improve big struct display #32

Open cch123 opened 6 years ago

cch123 commented 6 years ago

I combined memviz with https://github.com/sitano/gsysint to display structure of runtime.g, and there are many fields in this struct.

Expected Behaviour

What were you wanting/expecting to happen? The layout of a struct can be displayed as multiple lines or a table or something.

Actual Behaviour

What actually happens at the moment? The struct is displayed as a single line, and too wide.

Example input

If possible, provide a small code sample which reproduces the issue (or, for a feature request, code that should work after the feature is implemented)

package main

import (
    "os"
    "sync/atomic"
    "unsafe"

    "github.com/bradleyjkemp/memviz"
    "github.com/sitano/gsysint"
)

func main() {
    var gp unsafe.Pointer

    atomic.StorePointer(&gp, gsysint.GetG())

    gg := (*gsysint.G)(gp)
    memviz.Map(os.Stdout, gg)
}

Screenshot/Example output (if applicable)

digraph {

}
bradleyjkemp commented 6 years ago

Hmm yeah that's a tricky one. I think displaying it as multiple rows would be quite messy with pointers coming out of the middle.

Would it help if the struct could be drawn vertically instead of horizontally? Then it's a lot easier to scroll through each field

cch123 commented 6 years ago

vertical display is also ok~

my render result can be found here

https://github.com/cch123/misc/blob/master/demo.jpg