mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: use innermost line number for -S
When functions are inlined, for instructions in the inlined body, does -S print the location of the call, or the location of the body? Right now, we do the former. I'd like to do the latter by default, it makes much more sense when reading disassembly. With mid-stack inlining enabled in more cases, this quandry will come up more often. The original behavior is still available with -S=2. Some tests use this mode (so they can find assembly generated by a particular source line). This helped me with understanding what the compiler was doing while fixing #29007. Change-Id: Id14a3a41e1b18901e7c5e460aa4caf6d940ed064 Reviewed-on: https://go-review.googlesource.com/c/153241 Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
ec51004567
commit
01a1eaa10c
8 changed files with 40 additions and 21 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue