Commit 42a915c9 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/obj: convert Debug* Link fields into bools

Change-Id: I9ac274dbfe887675a7820d2f8f87b5887b1c9b0e
Reviewed-on: https://go-review.googlesource.com/38383
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 236ef852
...@@ -35,7 +35,7 @@ func main() { ...@@ -35,7 +35,7 @@ func main() {
ctxt := obj.Linknew(architecture.LinkArch) ctxt := obj.Linknew(architecture.LinkArch)
if *flags.PrintOut { if *flags.PrintOut {
ctxt.Debugasm = 1 ctxt.Debugasm = true
} }
ctxt.Flag_dynlink = *flags.Dynlink ctxt.Flag_dynlink = *flags.Dynlink
ctxt.Flag_shared = *flags.Shared || *flags.Dynlink ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
......
...@@ -32,10 +32,12 @@ var ( ...@@ -32,10 +32,12 @@ var (
var ( var (
Debug_append int Debug_append int
Debug_asm bool
Debug_closure int Debug_closure int
debug_dclstack int debug_dclstack int
Debug_panic int Debug_panic int
Debug_slice int Debug_slice int
Debug_vlog bool
Debug_wb int Debug_wb int
Debug_pctab string Debug_pctab string
) )
...@@ -174,7 +176,7 @@ func Main(archInit func(*Arch)) { ...@@ -174,7 +176,7 @@ func Main(archInit func(*Arch)) {
obj.Flagfn1("I", "add `directory` to import search path", addidir) obj.Flagfn1("I", "add `directory` to import search path", addidir)
obj.Flagcount("K", "debug missing line numbers", &Debug['K']) obj.Flagcount("K", "debug missing line numbers", &Debug['K'])
obj.Flagcount("N", "disable optimizations", &Debug['N']) obj.Flagcount("N", "disable optimizations", &Debug['N'])
obj.Flagcount("S", "print assembly listing", &Debug['S']) flag.BoolVar(&Debug_asm, "S", false, "print assembly listing")
obj.Flagfn0("V", "print compiler version", doversion) obj.Flagfn0("V", "print compiler version", doversion)
obj.Flagcount("W", "debug parse tree after type checking", &Debug['W']) obj.Flagcount("W", "debug parse tree after type checking", &Debug['W'])
flag.StringVar(&asmhdr, "asmhdr", "", "write assembly header to `file`") flag.StringVar(&asmhdr, "asmhdr", "", "write assembly header to `file`")
...@@ -203,7 +205,7 @@ func Main(archInit func(*Arch)) { ...@@ -203,7 +205,7 @@ func Main(archInit func(*Arch)) {
obj.Flagcount("s", "warn about composite literals that can be simplified", &Debug['s']) obj.Flagcount("s", "warn about composite literals that can be simplified", &Debug['s'])
flag.StringVar(&pathPrefix, "trimpath", "", "remove `prefix` from recorded source file paths") flag.StringVar(&pathPrefix, "trimpath", "", "remove `prefix` from recorded source file paths")
flag.BoolVar(&safemode, "u", false, "reject unsafe code") flag.BoolVar(&safemode, "u", false, "reject unsafe code")
obj.Flagcount("v", "increase debug verbosity", &Debug['v']) flag.BoolVar(&Debug_vlog, "v", false, "increase debug verbosity")
obj.Flagcount("w", "debug type checking", &Debug['w']) obj.Flagcount("w", "debug type checking", &Debug['w'])
flag.BoolVar(&use_writebarrier, "wb", true, "enable write barrier") flag.BoolVar(&use_writebarrier, "wb", true, "enable write barrier")
var flag_shared bool var flag_shared bool
...@@ -226,8 +228,8 @@ func Main(archInit func(*Arch)) { ...@@ -226,8 +228,8 @@ func Main(archInit func(*Arch)) {
Ctxt.Flag_dynlink = flag_dynlink Ctxt.Flag_dynlink = flag_dynlink
Ctxt.Flag_optimize = Debug['N'] == 0 Ctxt.Flag_optimize = Debug['N'] == 0
Ctxt.Debugasm = int32(Debug['S']) Ctxt.Debugasm = Debug_asm
Ctxt.Debugvlog = int32(Debug['v']) Ctxt.Debugvlog = Debug_vlog
if flag.NArg() < 1 { if flag.NArg() < 1 {
usage() usage()
......
...@@ -646,7 +646,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -646,7 +646,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
var opc int32 var opc int32
var out [6 + 3]uint32 var out [6 + 3]uint32
for { for {
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("%5.2f span1\n", obj.Cputime()) ctxt.Logf("%5.2f span1\n", obj.Cputime())
} }
bflag = 0 bflag = 0
......
...@@ -355,7 +355,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -355,7 +355,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
} }
if autosize == 0 && cursym.Text.Mark&LEAF == 0 { if autosize == 0 && cursym.Text.Mark&LEAF == 0 {
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("save suppressed in: %s\n", cursym.Name) ctxt.Logf("save suppressed in: %s\n", cursym.Name)
} }
...@@ -549,7 +549,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -549,7 +549,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
if cursym.Text.From3.Offset&obj.NOSPLIT != 0 { if cursym.Text.From3.Offset&obj.NOSPLIT != 0 {
ctxt.Diag("cannot divide in NOSPLIT function") ctxt.Diag("cannot divide in NOSPLIT function")
} }
if ctxt.Debugdivmod != 0 { if ctxt.Debugdivmod {
break break
} }
if p.From.Type != obj.TYPE_REG { if p.From.Type != obj.TYPE_REG {
......
...@@ -587,7 +587,7 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -587,7 +587,7 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
* around jmps to fix. this is rare. * around jmps to fix. this is rare.
*/ */
for bflag != 0 { for bflag != 0 {
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("%5.2f span1\n", obj.Cputime()) ctxt.Logf("%5.2f span1\n", obj.Cputime())
} }
bflag = 0 bflag = 0
...@@ -687,7 +687,7 @@ func checkpool(ctxt *obj.Link, p *obj.Prog, skip int) { ...@@ -687,7 +687,7 @@ func checkpool(ctxt *obj.Link, p *obj.Prog, skip int) {
func flushpool(ctxt *obj.Link, p *obj.Prog, skip int) { func flushpool(ctxt *obj.Link, p *obj.Prog, skip int) {
if ctxt.Blitrl != nil { if ctxt.Blitrl != nil {
if skip != 0 { if skip != 0 {
if ctxt.Debugvlog != 0 && skip == 1 { if ctxt.Debugvlog && skip == 1 {
fmt.Printf("note: flush literal pool at %#x: len=%d ref=%x\n", uint64(p.Pc+4), pool.size, pool.start) fmt.Printf("note: flush literal pool at %#x: len=%d ref=%x\n", uint64(p.Pc+4), pool.size, pool.start)
} }
q := ctxt.NewProg() q := ctxt.NewProg()
......
...@@ -555,7 +555,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -555,7 +555,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
} }
p.To.Offset = int64(ctxt.Autosize) - 8 p.To.Offset = int64(ctxt.Autosize) - 8
if ctxt.Autosize == 0 && !(cursym.Text.Mark&LEAF != 0) { if ctxt.Autosize == 0 && !(cursym.Text.Mark&LEAF != 0) {
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("save suppressed in: %s\n", cursym.Text.From.Sym.Name) ctxt.Logf("save suppressed in: %s\n", cursym.Text.From.Sym.Name)
} }
cursym.Text.Mark |= LEAF cursym.Text.Mark |= LEAF
......
...@@ -719,9 +719,9 @@ type Pcdata struct { ...@@ -719,9 +719,9 @@ type Pcdata struct {
type Link struct { type Link struct {
Headtype HeadType Headtype HeadType
Arch *LinkArch Arch *LinkArch
Debugasm int32 Debugasm bool
Debugvlog int32 Debugvlog bool
Debugdivmod int32 Debugdivmod bool
Debugpcln string Debugpcln string
Flag_shared bool Flag_shared bool
Flag_dynlink bool Flag_dynlink bool
......
...@@ -417,7 +417,7 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -417,7 +417,7 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) {
var otxt int64 var otxt int64
var q *obj.Prog var q *obj.Prog
for bflag != 0 { for bflag != 0 {
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("%5.2f span1\n", obj.Cputime()) ctxt.Logf("%5.2f span1\n", obj.Cputime())
} }
bflag = 0 bflag = 0
......
...@@ -168,7 +168,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -168,7 +168,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
* expand RET * expand RET
* expand BECOME pseudo * expand BECOME pseudo
*/ */
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("%5.2f noops\n", obj.Cputime()) ctxt.Logf("%5.2f noops\n", obj.Cputime())
} }
...@@ -340,7 +340,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -340,7 +340,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
q.Spadj = +autosize q.Spadj = +autosize
} else if cursym.Text.Mark&LEAF == 0 { } else if cursym.Text.Mark&LEAF == 0 {
if cursym.Text.From3.Offset&obj.NOSPLIT != 0 { if cursym.Text.From3.Offset&obj.NOSPLIT != 0 {
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("save suppressed in: %s\n", cursym.Name) ctxt.Logf("save suppressed in: %s\n", cursym.Name)
} }
......
...@@ -380,7 +380,7 @@ func (w *objWriter) writeSymDebug(s *LSym) { ...@@ -380,7 +380,7 @@ func (w *objWriter) writeSymDebug(s *LSym) {
func (w *objWriter) writeSym(s *LSym) { func (w *objWriter) writeSym(s *LSym) {
ctxt := w.ctxt ctxt := w.ctxt
if ctxt.Debugasm != 0 { if ctxt.Debugasm {
w.writeSymDebug(s) w.writeSymDebug(s)
} }
......
...@@ -15,7 +15,7 @@ type Plist struct { ...@@ -15,7 +15,7 @@ type Plist struct {
} }
func Flushplist(ctxt *Link, plist *Plist) { func Flushplist(ctxt *Link, plist *Plist) {
flushplist(ctxt, plist, ctxt.Debugasm == 0) flushplist(ctxt, plist, !ctxt.Debugasm)
} }
func FlushplistNoFree(ctxt *Link, plist *Plist) { func FlushplistNoFree(ctxt *Link, plist *Plist) {
flushplist(ctxt, plist, false) flushplist(ctxt, plist, false)
...@@ -28,7 +28,7 @@ func flushplist(ctxt *Link, plist *Plist, freeProgs bool) { ...@@ -28,7 +28,7 @@ func flushplist(ctxt *Link, plist *Plist, freeProgs bool) {
var plink *Prog var plink *Prog
for p := plist.Firstpc; p != nil; p = plink { for p := plist.Firstpc; p != nil; p = plink {
if ctxt.Debugasm != 0 && ctxt.Debugvlog != 0 { if ctxt.Debugasm && ctxt.Debugvlog {
fmt.Printf("obj: %v\n", p) fmt.Printf("obj: %v\n", p)
} }
plink = p.Link plink = p.Link
......
...@@ -597,7 +597,7 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -597,7 +597,7 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) {
var otxt int64 var otxt int64
var q *obj.Prog var q *obj.Prog
for bflag != 0 { for bflag != 0 {
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("%5.2f span1\n", obj.Cputime()) ctxt.Logf("%5.2f span1\n", obj.Cputime())
} }
bflag = 0 bflag = 0
......
...@@ -274,7 +274,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -274,7 +274,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
* expand RET * expand RET
* expand BECOME pseudo * expand BECOME pseudo
*/ */
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("%5.2f noops\n", obj.Cputime()) ctxt.Logf("%5.2f noops\n", obj.Cputime())
} }
......
...@@ -240,7 +240,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -240,7 +240,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
* strip NOPs * strip NOPs
* expand RET * expand RET
*/ */
if ctxt.Debugvlog != 0 { if ctxt.Debugvlog {
ctxt.Logf("%5.2f noops\n", obj.Cputime()) ctxt.Logf("%5.2f noops\n", obj.Cputime())
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment