aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/link.go2
-rw-r--r--src/cmd/internal/obj/objfile.go10
-rw-r--r--src/cmd/internal/obj/plist.go2
-rw-r--r--src/cmd/internal/obj/util.go15
4 files changed, 24 insertions, 5 deletions
diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go
index 6cff335ddf..dfecdfbb37 100644
--- a/src/cmd/internal/obj/link.go
+++ b/src/cmd/internal/obj/link.go
@@ -599,7 +599,7 @@ type Pcdata struct {
type Link struct {
Headtype objabi.HeadType
Arch *LinkArch
- Debugasm bool
+ Debugasm int
Debugvlog bool
Debugpcln string
Flag_shared bool
diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go
index 4fbaafe347..49301f04d5 100644
--- a/src/cmd/internal/obj/objfile.go
+++ b/src/cmd/internal/obj/objfile.go
@@ -240,7 +240,13 @@ func (w *objWriter) writeSymDebug(s *LSym) {
fmt.Fprintf(ctxt.Bso, "\n")
if s.Type == objabi.STEXT {
for p := s.Func.Text; p != nil; p = p.Link {
- fmt.Fprintf(ctxt.Bso, "\t%#04x %v\n", uint(int(p.Pc)), p)
+ var s string
+ if ctxt.Debugasm > 1 {
+ s = p.String()
+ } else {
+ s = p.InnermostString()
+ }
+ fmt.Fprintf(ctxt.Bso, "\t%#04x %s\n", uint(int(p.Pc)), s)
}
}
for i := 0; i < len(s.P); i += 16 {
@@ -283,7 +289,7 @@ func (w *objWriter) writeSymDebug(s *LSym) {
func (w *objWriter) writeSym(s *LSym) {
ctxt := w.ctxt
- if ctxt.Debugasm {
+ if ctxt.Debugasm > 0 {
w.writeSymDebug(s)
}
diff --git a/src/cmd/internal/obj/plist.go b/src/cmd/internal/obj/plist.go
index 6710b375f1..9d376f739f 100644
--- a/src/cmd/internal/obj/plist.go
+++ b/src/cmd/internal/obj/plist.go
@@ -27,7 +27,7 @@ func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc, myimportpath string
var plink *Prog
for p := plist.Firstpc; p != nil; p = plink {
- if ctxt.Debugasm && ctxt.Debugvlog {
+ if ctxt.Debugasm > 0 && ctxt.Debugvlog {
fmt.Printf("obj: %v\n", p)
}
plink = p.Link
diff --git a/src/cmd/internal/obj/util.go b/src/cmd/internal/obj/util.go
index 46c3d7b17b..f1517d3d5d 100644
--- a/src/cmd/internal/obj/util.go
+++ b/src/cmd/internal/obj/util.go
@@ -17,6 +17,9 @@ const REG_NONE = 0
func (p *Prog) Line() string {
return p.Ctxt.OutermostPos(p.Pos).Format(false, true)
}
+func (p *Prog) InnermostLine() string {
+ return p.Ctxt.InnermostPos(p.Pos).Format(false, true)
+}
// InnermostLineNumber returns a string containing the line number for the
// innermost inlined function (if any inlining) at p's position
@@ -118,6 +121,16 @@ func (p *Prog) String() string {
return fmt.Sprintf("%.5d (%v)\t%s", p.Pc, p.Line(), p.InstructionString())
}
+func (p *Prog) InnermostString() string {
+ if p == nil {
+ return "<nil Prog>"
+ }
+ if p.Ctxt == nil {
+ return "<Prog without ctxt>"
+ }
+ return fmt.Sprintf("%.5d (%v)\t%s", p.Pc, p.InnermostLine(), p.InstructionString())
+}
+
// InstructionString returns a string representation of the instruction without preceding
// program counter or file and line number.
func (p *Prog) InstructionString() string {
@@ -177,7 +190,7 @@ func (ctxt *Link) NewProg() *Prog {
}
func (ctxt *Link) CanReuseProgs() bool {
- return !ctxt.Debugasm
+ return ctxt.Debugasm == 0
}
func Dconv(p *Prog, a *Addr) string {