gitlab.com/Raven-IO/raven-delve@v1.22.4/pkg/terminal/disasmprint.go (about)

     1  package terminal
     2  
     3  import (
     4  	"bufio"
     5  	"fmt"
     6  	"io"
     7  	"path/filepath"
     8  	"text/tabwriter"
     9  
    10  	"gitlab.com/Raven-IO/raven-delve/service/api"
    11  )
    12  
    13  func disasmPrint(dv api.AsmInstructions, out io.Writer, showHeader bool) {
    14  	bw := bufio.NewWriter(out)
    15  	defer bw.Flush()
    16  	if len(dv) > 0 && dv[0].Loc.Function != nil && showHeader {
    17  		fmt.Fprintf(bw, "TEXT %s(SB) %s\n", dv[0].Loc.Function.Name(), dv[0].Loc.File)
    18  	}
    19  	tw := tabwriter.NewWriter(bw, 1, 8, 1, '\t', 0)
    20  	defer tw.Flush()
    21  	for _, inst := range dv {
    22  		atbp := ""
    23  		if inst.Breakpoint {
    24  			atbp = "*"
    25  		}
    26  		atpc := ""
    27  		if inst.AtPC {
    28  			atpc = "=>"
    29  		}
    30  		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)
    31  	}
    32  }