Commit 8cd2e764 authored by Robert Griesemer's avatar Robert Griesemer

- gofmt'ing of some stragglers, now with correct comment indentation

in special cases
- re-gofmt'ing of some files that are now improved

R=r, rsc
http://go/go-review/1023003
parent 6c13f8f1
...@@ -56,13 +56,13 @@ func (s *Sym) ReceiverName() string { ...@@ -56,13 +56,13 @@ func (s *Sym) ReceiverName() string {
if l == -1 || r == -1 || l == r { if l == -1 || r == -1 || l == r {
return ""; return "";
} }
return s.Name[l+1:r]; return s.Name[l+1 : r];
} }
// BaseName returns the symbol name without the package or receiver name. // BaseName returns the symbol name without the package or receiver name.
func (s *Sym) BaseName() string { func (s *Sym) BaseName() string {
if i := strings.LastIndex(s.Name, "."); i != -1 { if i := strings.LastIndex(s.Name, "."); i != -1 {
return s.Name[i+1:len(s.Name)]; return s.Name[i+1 : len(s.Name)];
} }
return s.Name; return s.Name;
} }
...@@ -95,9 +95,9 @@ type Obj struct { ...@@ -95,9 +95,9 @@ type Obj struct {
type Table struct { type Table struct {
Syms []Sym; Syms []Sym;
Funcs []Func; Funcs []Func;
Files map[string] *Obj; Files map[string]*Obj;
Objs []Obj; Objs []Obj;
// textEnd uint64; // textEnd uint64;
} }
type sym struct { type sym struct {
...@@ -114,7 +114,7 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error { ...@@ -114,7 +114,7 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error {
s.value = binary.BigEndian.Uint32(p[0:4]); s.value = binary.BigEndian.Uint32(p[0:4]);
typ := p[4]; typ := p[4];
if typ&0x80 == 0 { 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; typ &^= 0x80;
s.typ = typ; s.typ = typ;
...@@ -129,7 +129,7 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error { ...@@ -129,7 +129,7 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error {
} }
switch typ { switch typ {
case 'z', 'Z': case 'z', 'Z':
p = p[i+nnul:len(p)]; p = p[i+nnul : len(p)];
for i = 0; i+2 <= len(p); i += 2 { for i = 0; i+2 <= len(p); i += 2 {
if p[i] == 0 && p[i+1] == 0 { if p[i] == 0 && p[i+1] == 0 {
nnul = 2; nnul = 2;
...@@ -142,8 +142,8 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error { ...@@ -142,8 +142,8 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error {
} }
s.name = p[0:i]; s.name = p[0:i];
i += nnul; i += nnul;
s.gotype = binary.BigEndian.Uint32(p[i:i+4]); s.gotype = binary.BigEndian.Uint32(p[i : i+4]);
p = p[i+4:len(p)]; p = p[i+4 : len(p)];
fn(s); fn(s);
} }
return nil; return nil;
...@@ -153,7 +153,10 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error { ...@@ -153,7 +153,10 @@ func walksymtab(data []byte, fn func(sym) os.Error) os.Error {
// returning an in-memory representation. // returning an in-memory representation.
func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
var n int; var n int;
err := walksymtab(symtab, func(s sym) os.Error { n++; return nil }); err := walksymtab(symtab, func(s sym) os.Error {
n++;
return nil;
});
if err != nil { if err != nil {
return nil, err; return nil, err;
} }
...@@ -166,7 +169,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { ...@@ -166,7 +169,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
lasttyp := uint8(0); lasttyp := uint8(0);
err = walksymtab(symtab, func(s sym) os.Error { err = walksymtab(symtab, func(s sym) os.Error {
n := len(t.Syms); n := len(t.Syms);
t.Syms = t.Syms[0:n+1]; t.Syms = t.Syms[0 : n+1];
ts := &t.Syms[n]; ts := &t.Syms[n];
ts.Type = s.typ; ts.Type = s.typ;
ts.Value = uint64(s.value); ts.Value = uint64(s.value);
...@@ -190,7 +193,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { ...@@ -190,7 +193,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
nz++; nz++;
} }
for i := 0; i < len(s.name); i += 2 { for i := 0; i < len(s.name); i += 2 {
eltIdx := binary.BigEndian.Uint16(s.name[i:i+2]); eltIdx := binary.BigEndian.Uint16(s.name[i : i+2]);
elt, ok := fname[eltIdx]; elt, ok := fname[eltIdx];
if !ok { if !ok {
return &DecodingError{-1, "bad filename code", eltIdx}; return &DecodingError{-1, "bad filename code", eltIdx};
...@@ -208,7 +211,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { ...@@ -208,7 +211,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
fname[uint16(s.value)] = ts.Name; fname[uint16(s.value)] = ts.Name;
} }
lasttyp = s.typ; lasttyp = s.typ;
return nil return nil;
}); });
if err != nil { if err != nil {
return nil, err; return nil, err;
...@@ -216,7 +219,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { ...@@ -216,7 +219,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
t.Funcs = make([]Func, 0, nf); t.Funcs = make([]Func, 0, nf);
t.Objs = make([]Obj, 0, nz); t.Objs = make([]Obj, 0, nz);
t.Files = make(map[string] *Obj); t.Files = make(map[string]*Obj);
// Count text symbols and attach frame sizes, parameters, and // Count text symbols and attach frame sizes, parameters, and
// locals to them. Also, find object file boundaries. // locals to them. Also, find object file boundaries.
...@@ -234,7 +237,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { ...@@ -234,7 +237,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
// Start new object // Start new object
n := len(t.Objs); n := len(t.Objs);
t.Objs = t.Objs[0:n+1]; t.Objs = t.Objs[0 : n+1];
obj = &t.Objs[n]; obj = &t.Objs[n];
// Count & copy path symbols // Count & copy path symbols
...@@ -286,7 +289,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { ...@@ -286,7 +289,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
// Fill in the function symbol // Fill in the function symbol
n := len(t.Funcs); n := len(t.Funcs);
t.Funcs = t.Funcs[0:n+1]; t.Funcs = t.Funcs[0 : n+1];
fn := &t.Funcs[n]; fn := &t.Funcs[n];
sym.Func = fn; sym.Func = fn;
fn.Params = make([]*Sym, 0, np); fn.Params = make([]*Sym, 0, np);
...@@ -305,11 +308,11 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) { ...@@ -305,11 +308,11 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
fn.FrameSize = int(s.Value); fn.FrameSize = int(s.Value);
case 'p': case 'p':
n := len(fn.Params); n := len(fn.Params);
fn.Params = fn.Params[0:n+1]; fn.Params = fn.Params[0 : n+1];
fn.Params[n] = s; fn.Params[n] = s;
case 'a': case 'a':
n := len(fn.Locals); n := len(fn.Locals);
fn.Locals = fn.Locals[0:n+1]; fn.Locals = fn.Locals[0 : n+1];
fn.Locals[n] = s; fn.Locals[n] = s;
} }
} }
...@@ -335,7 +338,7 @@ func (t *Table) PCToFunc(pc uint64) *Func { ...@@ -335,7 +338,7 @@ func (t *Table) PCToFunc(pc uint64) *Func {
case fn.Entry <= pc && pc < fn.End: case fn.Entry <= pc && pc < fn.End:
return fn; return fn;
default: default:
funcs = funcs[m+1:len(funcs)]; funcs = funcs[m+1 : len(funcs)];
} }
} }
return nil; return nil;
...@@ -345,7 +348,7 @@ func (t *Table) PCToFunc(pc uint64) *Func { ...@@ -345,7 +348,7 @@ func (t *Table) PCToFunc(pc uint64) *Func {
// If there is no information, it returns fn == nil. // If there is no information, it returns fn == nil.
func (t *Table) PCToLine(pc uint64) (file string, line int, fn *Func) { func (t *Table) PCToLine(pc uint64) (file string, line int, fn *Func) {
if fn = t.PCToFunc(pc); fn == nil { if fn = t.PCToFunc(pc); fn == nil {
return return;
} }
file, line = fn.Obj.lineFromAline(fn.LineTable.PCToLine(pc)); file, line = fn.Obj.lineFromAline(fn.LineTable.PCToLine(pc));
return; return;
...@@ -427,7 +430,7 @@ func (o *Obj) lineFromAline(aline int) (string, int) { ...@@ -427,7 +430,7 @@ func (o *Obj) lineFromAline(aline int) (string, int) {
start int; start int;
offset int; offset int;
prev *stackEnt; prev *stackEnt;
}; }
noPath := &stackEnt{"", 0, 0, nil}; noPath := &stackEnt{"", 0, 0, nil};
tos := noPath; tos := noPath;
...@@ -485,14 +488,14 @@ func (o *Obj) alineFromLine(path string, line int) (int, os.Error) { ...@@ -485,14 +488,14 @@ func (o *Obj) alineFromLine(path string, line int) (int, os.Error) {
val := int(s.Value); val := int(s.Value);
switch { switch {
case depth == 1 && val >= line: case depth == 1 && val >= line:
return line - 1, nil; return line-1, nil;
case s.Name == "": case s.Name == "":
depth--; depth--;
if depth == 0 { if depth == 0 {
break pathloop; break pathloop;
} else if depth == 1 { } else if depth == 1 {
line += val - incstart; line += val-incstart;
} }
default: default:
...@@ -547,4 +550,3 @@ func (e *DecodingError) String() string { ...@@ -547,4 +550,3 @@ func (e *DecodingError) String() string {
msg += fmt.Sprintf(" at byte %#x", e.off); msg += fmt.Sprintf(" at byte %#x", e.off);
return msg; return msg;
} }
This diff is collapsed.
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