aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/debug
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-11-09 21:13:17 -0800
committerRobert Griesemer <gri@golang.org>2009-11-09 21:13:17 -0800
commitbaba292998286e5d9011705a9b4173a2ec99c5e0 (patch)
treee5054185cd21c44ee959a8d432b08874a76507fd /src/pkg/debug
parent1698934194f667c4752bb4dfa8615f146fff5154 (diff)
downloadgo-baba292998286e5d9011705a9b4173a2ec99c5e0.tar.xz
- replaced gofmt expression formatting algorithm with
rsc's algorithm - applied gofmt -w misc src - partial CL (remaining files in other CLs) R=rsc, r http://go/go-review/1026036
Diffstat (limited to 'src/pkg/debug')
-rw-r--r--src/pkg/debug/dwarf/buf.go6
-rw-r--r--src/pkg/debug/dwarf/entry.go16
-rw-r--r--src/pkg/debug/dwarf/type.go4
-rw-r--r--src/pkg/debug/dwarf/unit.go2
-rw-r--r--src/pkg/debug/elf/elf.go18
-rw-r--r--src/pkg/debug/elf/elf_test.go4
-rw-r--r--src/pkg/debug/elf/file.go24
-rw-r--r--src/pkg/debug/gosym/pclntab.go6
-rw-r--r--src/pkg/debug/gosym/pclntab_test.go8
-rw-r--r--src/pkg/debug/gosym/symtab.go16
-rw-r--r--src/pkg/debug/macho/file.go14
-rw-r--r--src/pkg/debug/macho/macho.go6
-rw-r--r--src/pkg/debug/proc/proc_linux.go2
13 files changed, 63 insertions, 63 deletions
diff --git a/src/pkg/debug/dwarf/buf.go b/src/pkg/debug/dwarf/buf.go
index 2838c098fd..10a7e5cb8e 100644
--- a/src/pkg/debug/dwarf/buf.go
+++ b/src/pkg/debug/dwarf/buf.go
@@ -56,7 +56,7 @@ func (b *buf) string() string {
if b.data[i] == 0 {
s := string(b.data[0:i]);
b.data = b.data[i+1 : len(b.data)];
- b.off += Offset(i+1);
+ b.off += Offset(i + 1);
return s;
}
}
@@ -93,10 +93,10 @@ func (b *buf) uint64() uint64 {
func (b *buf) varint() (c uint64, bits uint) {
for i := 0; i < len(b.data); i++ {
byte := b.data[i];
- c |= uint64(byte&0x7F)<<bits;
+ c |= uint64(byte&0x7F) << bits;
bits += 7;
if byte&0x80 == 0 {
- b.off += Offset(i+1);
+ b.off += Offset(i + 1);
b.data = b.data[i+1 : len(b.data)];
return c, bits;
}
diff --git a/src/pkg/debug/dwarf/entry.go b/src/pkg/debug/dwarf/entry.go
index 9b2727b26d..2aec1c17e8 100644
--- a/src/pkg/debug/dwarf/entry.go
+++ b/src/pkg/debug/dwarf/entry.go
@@ -190,15 +190,15 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry {
case formRefAddr:
val = Offset(b.addr())
case formRef1:
- val = Offset(b.uint8())+ubase
+ val = Offset(b.uint8()) + ubase
case formRef2:
- val = Offset(b.uint16())+ubase
+ val = Offset(b.uint16()) + ubase
case formRef4:
- val = Offset(b.uint32())+ubase
+ val = Offset(b.uint32()) + ubase
case formRef8:
- val = Offset(b.uint64())+ubase
+ val = Offset(b.uint64()) + ubase
case formRefUdata:
- val = Offset(b.uint())+ubase
+ val = Offset(b.uint()) + ubase
// string
case formString:
@@ -267,9 +267,9 @@ func (r *Reader) Seek(off Offset) {
var u *unit;
for i = range d.unit {
u = &d.unit[i];
- if u.off <= off && off < u.off + Offset(len(u.data)) {
+ if u.off <= off && off < u.off+Offset(len(u.data)) {
r.unit = i;
- r.b = makeBuf(r.d, "info", off, u.data[off - u.off : len(u.data)], u.addrsize);
+ r.b = makeBuf(r.d, "info", off, u.data[off-u.off:len(u.data)], u.addrsize);
return;
}
}
@@ -278,7 +278,7 @@ func (r *Reader) Seek(off Offset) {
// maybeNextUnit advances to the next unit if this one is finished.
func (r *Reader) maybeNextUnit() {
- for len(r.b.data) == 0 && r.unit + 1 < len(r.d.unit) {
+ for len(r.b.data) == 0 && r.unit+1 < len(r.d.unit) {
r.unit++;
u := &r.d.unit[r.unit];
r.b = makeBuf(r.d, "info", u.off, u.data, u.addrsize);
diff --git a/src/pkg/debug/dwarf/type.go b/src/pkg/debug/dwarf/type.go
index 2cac2e4fb3..bf57fd4bfa 100644
--- a/src/pkg/debug/dwarf/type.go
+++ b/src/pkg/debug/dwarf/type.go
@@ -339,11 +339,11 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
max = -2 // Count == -1, as in x[].
}
if ndim == 0 {
- t.Count = max+1
+ t.Count = max + 1
} else {
// Multidimensional array.
// Create new array type underneath this one.
- t.Type = &ArrayType{Type: t.Type, Count: max+1}
+ t.Type = &ArrayType{Type: t.Type, Count: max + 1}
}
ndim++;
case TagEnumerationType:
diff --git a/src/pkg/debug/dwarf/unit.go b/src/pkg/debug/dwarf/unit.go
index 582fd0cf27..eb4e7656e5 100644
--- a/src/pkg/debug/dwarf/unit.go
+++ b/src/pkg/debug/dwarf/unit.go
@@ -53,7 +53,7 @@ func (d *Data) parseUnits() ([]unit, os.Error) {
u.atable = atable;
u.addrsize = int(b.uint8());
u.off = b.off;
- u.data = b.bytes(int(n-(2+4+1)));
+ u.data = b.bytes(int(n - (2 + 4 + 1)));
}
if b.err != nil {
return nil, b.err
diff --git a/src/pkg/debug/elf/elf.go b/src/pkg/debug/elf/elf.go
index d0f75355ec..70a11f6f65 100644
--- a/src/pkg/debug/elf/elf.go
+++ b/src/pkg/debug/elf/elf.go
@@ -1351,8 +1351,8 @@ type Rela32 struct {
Addend int32; /* Addend. */
}
-func R_SYM32(info uint32) uint32 { return uint32(info>>8) }
-func R_TYPE32(info uint32) uint32 { return uint32(info&0xff) }
+func R_SYM32(info uint32) uint32 { return uint32(info >> 8) }
+func R_TYPE32(info uint32) uint32 { return uint32(info & 0xff) }
func R_INFO32(sym, typ uint32) uint32 { return sym<<8 | typ }
// ELF32 Symbol.
@@ -1367,9 +1367,9 @@ type Sym32 struct {
const Sym32Size = 16
-func ST_BIND(info uint8) SymBind { return SymBind(info>>4) }
+func ST_BIND(info uint8) SymBind { return SymBind(info >> 4) }
func ST_TYPE(bind SymBind, typ SymType) uint8 { return uint8(bind)<<4 | uint8(typ)&0xf }
-func ST_VISIBILITY(other uint8) SymVis { return SymVis(other&3) }
+func ST_VISIBILITY(other uint8) SymVis { return SymVis(other & 3) }
/*
* ELF64
@@ -1454,7 +1454,7 @@ type Rela64 struct {
Addend int64; /* Addend. */
}
-func R_SYM64(info uint64) uint32 { return uint32(info>>32) }
+func R_SYM64(info uint64) uint32 { return uint32(info >> 32) }
func R_TYPE64(info uint64) uint32 { return uint32(info) }
func R_INFO(sym, typ uint32) uint64 { return uint64(sym)<<32 | uint64(typ) }
@@ -1490,14 +1490,14 @@ func stringName(i uint32, names []intName, goSyntax bool) string {
// second pass - look for smaller to add with.
// assume sorted already
- for j := len(names)-1; j >= 0; j-- {
+ for j := len(names) - 1; j >= 0; j-- {
n := names[j];
if n.i < i {
s := n.s;
if goSyntax {
- s = "elf."+s
+ s = "elf." + s
}
- return s + "+" + strconv.Uitoa64(uint64(i - n.i));
+ return s + "+" + strconv.Uitoa64(uint64(i-n.i));
}
}
@@ -1507,7 +1507,7 @@ func stringName(i uint32, names []intName, goSyntax bool) string {
func flagName(i uint32, names []intName, goSyntax bool) string {
s := "";
for _, n := range names {
- if n.i & i == n.i {
+ if n.i&i == n.i {
if len(s) > 0 {
s += "+"
}
diff --git a/src/pkg/debug/elf/elf_test.go b/src/pkg/debug/elf/elf_test.go
index 50827d2bc3..bc2a4f6875 100644
--- a/src/pkg/debug/elf/elf_test.go
+++ b/src/pkg/debug/elf/elf_test.go
@@ -22,7 +22,7 @@ var nameTests = []nameTest{
nameTest{SHT_PROGBITS, "SHT_PROGBITS"},
nameTest{SHF_MERGE + SHF_TLS, "SHF_MERGE+SHF_TLS"},
nameTest{PT_LOAD, "PT_LOAD"},
- nameTest{PF_W+PF_R+0x50, "PF_W+PF_R+0x50"},
+ nameTest{PF_W + PF_R + 0x50, "PF_W+PF_R+0x50"},
nameTest{DT_SYMBOLIC, "DT_SYMBOLIC"},
nameTest{DF_BIND_NOW, "DF_BIND_NOW"},
nameTest{NT_FPREGSET, "NT_FPREGSET"},
@@ -35,7 +35,7 @@ var nameTests = []nameTest{
nameTest{R_386_GOT32, "R_386_GOT32"},
nameTest{R_PPC_GOT16_HI, "R_PPC_GOT16_HI"},
nameTest{R_SPARC_GOT22, "R_SPARC_GOT22"},
- nameTest{ET_LOOS+5, "ET_LOOS+5"},
+ nameTest{ET_LOOS + 5, "ET_LOOS+5"},
nameTest{ProgFlag(0x50), "0x50"},
}
diff --git a/src/pkg/debug/elf/file.go b/src/pkg/debug/elf/file.go
index 3d15f29cec..c9e015ae2e 100644
--- a/src/pkg/debug/elf/file.go
+++ b/src/pkg/debug/elf/file.go
@@ -76,7 +76,7 @@ func (s *Section) Data() ([]byte, os.Error) {
}
// Open returns a new ReadSeeker reading the ELF section.
-func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63 - 1) }
+func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63-1) }
// A ProgHeader represents a single ELF program header.
type ProgHeader struct {
@@ -104,7 +104,7 @@ type Prog struct {
}
// Open returns a new ReadSeeker reading the ELF program body.
-func (p *Prog) Open() io.ReadSeeker { return io.NewSectionReader(p.sr, 0, 1<<63 - 1) }
+func (p *Prog) Open() io.ReadSeeker { return io.NewSectionReader(p.sr, 0, 1<<63-1) }
// A Symbol represents an entry in an ELF symbol table section.
type Symbol struct {
@@ -163,7 +163,7 @@ func (f *File) Close() os.Error {
// NewFile creates a new File for acecssing an ELF binary in an underlying reader.
// The ELF binary is expected to start at position 0 in the ReaderAt.
func NewFile(r io.ReaderAt) (*File, os.Error) {
- sr := io.NewSectionReader(r, 0, 1<<63 - 1);
+ sr := io.NewSectionReader(r, 0, 1<<63-1);
// Read and decode ELF identifier
var ident [16]uint8;
if _, err := r.ReadAt(&ident, 0); err != nil {
@@ -302,7 +302,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
var ok bool;
s.Name, ok = getString(shstrtab, int(names[i]));
if !ok {
- return nil, &FormatError{shoff+int64(i * shentsize), "bad section name index", names[i]}
+ return nil, &FormatError{shoff + int64(i*shentsize), "bad section name index", names[i]}
}
}
@@ -337,7 +337,7 @@ func (f *File) getSymbols64() ([]Symbol, os.Error) {
return nil, os.ErrorString("cannot load symbol section")
}
symtab := bytes.NewBuffer(data);
- if symtab.Len() % Sym64Size != 0 {
+ if symtab.Len()%Sym64Size != 0 {
return nil, os.ErrorString("length of symbol section is not a multiple of Sym64Size")
}
@@ -345,7 +345,7 @@ func (f *File) getSymbols64() ([]Symbol, os.Error) {
var skip [Sym64Size]byte;
symtab.Read(skip[0:len(skip)]);
- symbols := make([]Symbol, symtab.Len() / Sym64Size);
+ symbols := make([]Symbol, symtab.Len()/Sym64Size);
i := 0;
var sym Sym64;
@@ -399,7 +399,7 @@ func (f *File) applyRelocations(dst []byte, rels []byte) os.Error {
}
func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) os.Error {
- if len(rels) % Sym64Size != 0 {
+ if len(rels)%Sym64Size != 0 {
return os.ErrorString("length of relocation section is not a multiple of Sym64Size")
}
@@ -420,22 +420,22 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) os.Error {
continue
}
sym := &symbols[symNo];
- if SymType(sym.Info & 0xf) != STT_SECTION {
+ if SymType(sym.Info&0xf) != STT_SECTION {
// We don't handle non-section relocations for now.
continue
}
switch t {
case R_X86_64_64:
- if rela.Off + 8 >= uint64(len(dst)) || rela.Addend < 0 {
+ if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 {
continue
}
- f.ByteOrder.PutUint64(dst[rela.Off : rela.Off + 8], uint64(rela.Addend));
+ f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], uint64(rela.Addend));
case R_X86_64_32:
- if rela.Off + 4 >= uint64(len(dst)) || rela.Addend < 0 {
+ if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 {
continue
}
- f.ByteOrder.PutUint32(dst[rela.Off : rela.Off + 4], uint32(rela.Addend));
+ f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], uint32(rela.Addend));
}
}
diff --git a/src/pkg/debug/gosym/pclntab.go b/src/pkg/debug/gosym/pclntab.go
index cfda629786..2fd93aa8e4 100644
--- a/src/pkg/debug/gosym/pclntab.go
+++ b/src/pkg/debug/gosym/pclntab.go
@@ -44,9 +44,9 @@ func (t *LineTable) parse(targetPC uint64, targetLine int) (b []byte, pc uint64,
case code <= 64:
line += int(code)
case code <= 128:
- line -= int(code-64)
+ line -= int(code - 64)
default:
- pc += quantum*uint64(code-128);
+ pc += quantum * uint64(code-128);
continue;
}
pc += quantum;
@@ -70,7 +70,7 @@ func (t *LineTable) LineToPC(line int, maxpc uint64) uint64 {
return 0
}
// Subtract quantum from PC to account for post-line increment
- return pc-quantum;
+ return pc - quantum;
}
// NewLineTable returns a new PC/line table
diff --git a/src/pkg/debug/gosym/pclntab_test.go b/src/pkg/debug/gosym/pclntab_test.go
index 79a87f4a2e..c30b37e135 100644
--- a/src/pkg/debug/gosym/pclntab_test.go
+++ b/src/pkg/debug/gosym/pclntab_test.go
@@ -77,7 +77,7 @@ func TestLineFromAline(t *testing.T) {
// Check for end of object
if path == "" {
if final == -1 {
- final = i-1
+ final = i - 1
}
continue;
} else if final != -1 {
@@ -121,7 +121,7 @@ func TestLineAline(t *testing.T) {
}
// cgo files are full of 'Z' symbols, which we don't handle
- if len(path) > 4 && path[len(path)-4 : len(path)] == ".cgo" {
+ if len(path) > 4 && path[len(path)-4:len(path)] == ".cgo" {
continue
}
@@ -167,7 +167,7 @@ func TestPCLine(t *testing.T) {
wantLine += int(textdat[off]);
if fn == nil {
t.Errorf("failed to get line of PC %#x", pc)
- } else if len(file) < 12 || file[len(file)-12 : len(file)] != "pclinetest.s" || line != wantLine || fn != sym {
+ } else if len(file) < 12 || file[len(file)-12:len(file)] != "pclinetest.s" || line != wantLine || fn != sym {
t.Errorf("expected %s:%d (%s) at PC %#x, got %s:%d (%s)", "pclinetest.s", wantLine, sym.Name, pc, file, line, fn.Name)
}
}
@@ -177,7 +177,7 @@ func TestPCLine(t *testing.T) {
lookupline := -1;
wantLine = 0;
off := uint64(0); // TODO(rsc): should not need off; bug in 8g
- for pc := sym.Value; pc < sym.End; pc += 2+uint64(textdat[off]) {
+ for pc := sym.Value; pc < sym.End; pc += 2 + uint64(textdat[off]) {
file, line, fn := tab.PCToLine(pc);
off = pc - text.Addr;
wantLine += int(textdat[off]);
diff --git a/src/pkg/debug/gosym/symtab.go b/src/pkg/debug/gosym/symtab.go
index ba20c7f385..3c2502e0a5 100644
--- a/src/pkg/debug/gosym/symtab.go
+++ b/src/pkg/debug/gosym/symtab.go
@@ -112,7 +112,7 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error {
s.value = binary.BigEndian.Uint32(p[0:4]);
typ := p[4];
if typ&0x80 == 0 {
- return &DecodingError{len(data)-len(p)+4, "bad symbol type", typ}
+ return &DecodingError{len(data) - len(p) + 4, "bad symbol type", typ}
}
typ &^= 0x80;
s.typ = typ;
@@ -240,13 +240,13 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
// Count & copy path symbols
var end int;
- for end = i+1; end < len(t.Syms); end++ {
+ for end = i + 1; end < len(t.Syms); end++ {
if c := t.Syms[end].Type; c != 'Z' && c != 'z' {
break
}
}
obj.Paths = t.Syms[i:end];
- i = end-1; // loop will i++
+ i = end - 1; // loop will i++
// Record file names
depth := 0;
@@ -274,7 +274,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
var np, na int;
var end int;
countloop:
- for end = i+1; end < len(t.Syms); end++ {
+ for end = i + 1; end < len(t.Syms); end++ {
switch t.Syms[end].Type {
case 'T', 't', 'L', 'l', 'Z', 'z':
break countloop
@@ -314,7 +314,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
fn.Locals[n] = s;
}
}
- i = end-1; // loop will i++
+ i = end - 1; // loop will i++
}
}
if obj != nil {
@@ -328,7 +328,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
func (t *Table) PCToFunc(pc uint64) *Func {
funcs := t.Funcs;
for len(funcs) > 0 {
- m := len(funcs)/2;
+ m := len(funcs) / 2;
fn := &funcs[m];
switch {
case pc < fn.Entry:
@@ -486,14 +486,14 @@ func (o *Obj) alineFromLine(path string, line int) (int, os.Error) {
val := int(s.Value);
switch {
case depth == 1 && val >= line:
- return line-1, nil
+ return line - 1, nil
case s.Name == "":
depth--;
if depth == 0 {
break pathloop
} else if depth == 1 {
- line += val-incstart
+ line += val - incstart
}
default:
diff --git a/src/pkg/debug/macho/file.go b/src/pkg/debug/macho/file.go
index 48687849a2..2338710745 100644
--- a/src/pkg/debug/macho/file.go
+++ b/src/pkg/debug/macho/file.go
@@ -75,7 +75,7 @@ func (s *Segment) Data() ([]byte, os.Error) {
}
// Open returns a new ReadSeeker reading the segment.
-func (s *Segment) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63 - 1) }
+func (s *Segment) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63-1) }
type SectionHeader struct {
Name string;
@@ -110,7 +110,7 @@ func (s *Section) Data() ([]byte, os.Error) {
}
// Open returns a new ReadSeeker reading the Mach-O section.
-func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63 - 1) }
+func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63-1) }
/*
@@ -163,7 +163,7 @@ func (f *File) Close() os.Error {
// The Mach-O binary is expected to start at position 0 in the ReaderAt.
func NewFile(r io.ReaderAt) (*File, os.Error) {
f := new(File);
- sr := io.NewSectionReader(r, 0, 1<<63 - 1);
+ sr := io.NewSectionReader(r, 0, 1<<63-1);
// Read and decode Mach magic to determine byte order, size.
// Magic32 and Magic64 differ only in the bottom bit.
@@ -173,11 +173,11 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
}
be := binary.BigEndian.Uint32(&ident);
le := binary.LittleEndian.Uint32(&ident);
- switch Magic32&^1 {
- case be&^1:
+ switch Magic32 &^ 1 {
+ case be &^ 1:
f.ByteOrder = binary.BigEndian;
f.Magic = be;
- case le&^1:
+ case le &^ 1:
f.ByteOrder = binary.LittleEndian;
f.Magic = le;
}
@@ -302,7 +302,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
func (f *File) pushSection(sh *Section, r io.ReaderAt) {
n := len(f.Sections);
if n >= cap(f.Sections) {
- m := (n+1)*2;
+ m := (n + 1) * 2;
new := make([]*Section, n, m);
for i, sh := range f.Sections {
new[i] = sh
diff --git a/src/pkg/debug/macho/macho.go b/src/pkg/debug/macho/macho.go
index fc4924b2f4..abc59c8a6d 100644
--- a/src/pkg/debug/macho/macho.go
+++ b/src/pkg/debug/macho/macho.go
@@ -21,8 +21,8 @@ type FileHeader struct {
}
const (
- fileHeaderSize32 = 7*4;
- fileHeaderSize64 = 8*4;
+ fileHeaderSize32 = 7 * 4;
+ fileHeaderSize64 = 8 * 4;
)
const (
@@ -208,7 +208,7 @@ func stringName(i uint32, names []intName, goSyntax bool) string {
func flagName(i uint32, names []intName, goSyntax bool) string {
s := "";
for _, n := range names {
- if n.i & i == n.i {
+ if n.i&i == n.i {
if len(s) > 0 {
s += "+"
}
diff --git a/src/pkg/debug/proc/proc_linux.go b/src/pkg/debug/proc/proc_linux.go
index be42022d6b..5619550d18 100644
--- a/src/pkg/debug/proc/proc_linux.go
+++ b/src/pkg/debug/proc/proc_linux.go
@@ -1215,7 +1215,7 @@ func (p *process) attachAllThreads() os.Error {
if err != nil {
// There could have been a race, or
// this process could be a zobmie.
- statFile, err2 := io.ReadFile(taskPath+"/"+tidStr+"/stat");
+ statFile, err2 := io.ReadFile(taskPath + "/" + tidStr + "/stat");
if err2 != nil {
switch err2 := err2.(type) {
case *os.PathError: