diff --git a/core/godebug/stringifyitem.go b/core/godebug/stringifyitem.go index 9443c254..cef76bd2 100644 --- a/core/godebug/stringifyitem.go +++ b/core/godebug/stringifyitem.go @@ -9,13 +9,17 @@ import ( ) func StringifyItem(item debug.Item) string { + return StringifyItem2(item, 20) +} +func StringifyItem2(item debug.Item, valueStrLen int) string { is := NewItemStringifier() + is.valueStrLen = valueStrLen is.stringify(item) return is.b.String() } func StringifyItemFull(item debug.Item) string { is := NewItemStringifier() - is.fullStr = true + is.valueStrLen = -1 // full str is.stringify(item) return is.b.String() } @@ -23,13 +27,14 @@ func StringifyItemFull(item debug.Item) string { //---------- type ItemStringifier struct { - b *strings.Builder - fullStr bool + b *strings.Builder + valueStrLen int // <0 = full str } func NewItemStringifier() *ItemStringifier { is := &ItemStringifier{} is.b = &strings.Builder{} + is.valueStrLen = 20 return is } @@ -44,10 +49,10 @@ func (is *ItemStringifier) stringify(item debug.Item) { switch t := item.(type) { case *debug.ItemValue: - if is.fullStr { + if is.valueStrLen < 0 { is.p(t.Str) } else { - is.p(debug.SprintCutCheckQuote(20, t.Str)) + is.p(debug.SprintCutCheckQuote(is.valueStrLen, t.Str)) } case *debug.ItemList: // ex: func args list diff --git a/core/godebuginstance.go b/core/godebuginstance.go index 92f8e983..976554ac 100644 --- a/core/godebuginstance.go +++ b/core/godebuginstance.go @@ -290,7 +290,7 @@ func (gdi *GoDebugInstance) trace() error { msg := msgs[i] afd := gdi.di.afds[msg.offsetMsg.FileIndex] loc := fmt.Sprintf("%v:o=%d", afd.Filename, msg.offsetMsg.Offset) - s := godebug.StringifyItemFull(msg.offsetMsg.Item) + s := godebug.StringifyItem2(msg.offsetMsg.Item, 8) u := fmt.Sprintf("%v: %v", s, loc) sb.WriteString("\t" + u + "\n") } @@ -1017,6 +1017,10 @@ func (di *GDDataIndex) trace() []*GDOffsetMsg { } } + sort.Slice(res, func(a, b int) bool { + return res[a].arrivalIndex < res[b].arrivalIndex + }) + return res }