2017-03-19 22:45:54 +00:00
|
|
|
package terminal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"path/filepath"
|
|
|
|
"text/tabwriter"
|
2018-10-13 13:45:53 +00:00
|
|
|
|
2019-04-15 14:43:01 +00:00
|
|
|
"github.com/go-delve/delve/service/api"
|
2017-03-19 22:45:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func DisasmPrint(dv api.AsmInstructions, out io.Writer) {
|
|
|
|
bw := bufio.NewWriter(out)
|
|
|
|
defer bw.Flush()
|
|
|
|
if len(dv) > 0 && dv[0].Loc.Function != nil {
|
2018-10-13 13:45:53 +00:00
|
|
|
fmt.Fprintf(bw, "TEXT %s(SB) %s\n", dv[0].Loc.Function.Name(), dv[0].Loc.File)
|
2017-03-19 22:45:54 +00:00
|
|
|
}
|
|
|
|
tw := tabwriter.NewWriter(bw, 1, 8, 1, '\t', 0)
|
|
|
|
defer tw.Flush()
|
|
|
|
for _, inst := range dv {
|
|
|
|
atbp := ""
|
|
|
|
if inst.Breakpoint {
|
|
|
|
atbp = "*"
|
|
|
|
}
|
|
|
|
atpc := ""
|
|
|
|
if inst.AtPC {
|
|
|
|
atpc = "=>"
|
|
|
|
}
|
|
|
|
fmt.Fprintf(tw, "%s\t%s:%d\t%#x%s\t%x\t%s\n", atpc, filepath.Base(inst.Loc.File), inst.Loc.Line, inst.Loc.PC, atbp, inst.Bytes, inst.Text)
|
|
|
|
}
|
|
|
|
}
|