Skip to content

Commit eea334b

Browse files
committed
Fixed trailing space when trace event has no operands
1 parent 089d5d0 commit eea334b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

trace.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package m68k
22

33
import (
4+
"bytes"
45
"fmt"
56
)
67

@@ -15,15 +16,21 @@ type stepTrace struct {
1516
}
1617

1718
func (c *stepTrace) String() string {
19+
b := &bytes.Buffer{}
20+
fmt.Fprintf(b, "%08X %s", c.addr, c.op)
21+
if c.sz != noSize {
22+
b.WriteByte('.')
23+
b.WriteByte([]byte{'b', 'w', 'l'}[c.sz])
24+
}
1825
operands := c.dst
1926
if c.dst == "" {
2027
operands = c.src
2128
} else if c.src != "" {
2229
operands = fmt.Sprintf("%s,%s", c.src, c.dst)
2330
}
24-
if c.sz == noSize {
25-
return fmt.Sprintf("%08X %s %s", c.addr, c.op, operands)
31+
if operands != "" {
32+
b.WriteByte(' ')
33+
b.WriteString(operands)
2634
}
27-
sz := []string{"b", "w", "l"}[c.sz]
28-
return fmt.Sprintf("%08X %s.%s %s", c.addr, c.op, sz, operands)
35+
return b.String()
2936
}

0 commit comments

Comments
 (0)