File: disasmprint.go

package info (click to toggle)
delve 1.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,136 kB
  • sloc: ansic: 111,947; sh: 194; asm: 147; makefile: 43; python: 23
file content (32 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package terminal

import (
	"bufio"
	"fmt"
	"io"
	"path/filepath"
	"text/tabwriter"

	"github.com/go-delve/delve/service/api"
)

func disasmPrint(dv api.AsmInstructions, out io.Writer, showHeader bool) {
	bw := bufio.NewWriter(out)
	defer bw.Flush()
	if len(dv) > 0 && dv[0].Loc.Function != nil && showHeader {
		fmt.Fprintf(bw, "TEXT %s(SB) %s\n", dv[0].Loc.Function.Name(), dv[0].Loc.File)
	}
	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)
	}
}