Commit 6a4940ee authored by Robert Griesemer's avatar Robert Griesemer

gofmt'ed debug

(excluding debug/gosym/symtab.go which has a small issue)

R=rsc
http://go/go-review/1019001
parent 6f762f54
...@@ -416,7 +416,7 @@ const ( ...@@ -416,7 +416,7 @@ const (
opCall2 = 0x98; /* 2-byte offset of DIE */ opCall2 = 0x98; /* 2-byte offset of DIE */
opCall4 = 0x99; /* 4-byte offset of DIE */ opCall4 = 0x99; /* 4-byte offset of DIE */
opCallRef = 0x9A; /* 4- or 8- byte offset of DIE */ opCallRef = 0x9A; /* 4- or 8- byte offset of DIE */
/* 0xE0-0xFF reserved for user-specific */ /* 0xE0-0xFF reserved for user-specific */
) )
// Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry. // Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry.
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
package dwarf_test package dwarf_test
import ( import (
. "debug/dwarf"; . "debug/dwarf";
"debug/elf"; "debug/elf";
"debug/macho"; "debug/macho";
"testing"; "testing";
) )
var typedefTests = map[string]string{ var typedefTests = map[string]string{
......
...@@ -522,42 +522,42 @@ func (i ProgFlag) GoString() string { ...@@ -522,42 +522,42 @@ func (i ProgFlag) GoString() string {
type DynTag int type DynTag int
const ( const (
DT_NULL DynTag = 0; /* Terminating entry. */ DT_NULL DynTag = 0; /* Terminating entry. */
DT_NEEDED DynTag = 1; /* String table offset of a needed shared library. */ DT_NEEDED DynTag = 1; /* String table offset of a needed shared library. */
DT_PLTRELSZ DynTag = 2; /* Total size in bytes of PLT relocations. */ DT_PLTRELSZ DynTag = 2; /* Total size in bytes of PLT relocations. */
DT_PLTGOT DynTag = 3; /* Processor-dependent address. */ DT_PLTGOT DynTag = 3; /* Processor-dependent address. */
DT_HASH DynTag = 4; /* Address of symbol hash table. */ DT_HASH DynTag = 4; /* Address of symbol hash table. */
DT_STRTAB DynTag = 5; /* Address of string table. */ DT_STRTAB DynTag = 5; /* Address of string table. */
DT_SYMTAB DynTag = 6; /* Address of symbol table. */ DT_SYMTAB DynTag = 6; /* Address of symbol table. */
DT_RELA DynTag = 7; /* Address of ElfNN_Rela relocations. */ DT_RELA DynTag = 7; /* Address of ElfNN_Rela relocations. */
DT_RELASZ DynTag = 8; /* Total size of ElfNN_Rela relocations. */ DT_RELASZ DynTag = 8; /* Total size of ElfNN_Rela relocations. */
DT_RELAENT DynTag = 9; /* Size of each ElfNN_Rela relocation entry. */ DT_RELAENT DynTag = 9; /* Size of each ElfNN_Rela relocation entry. */
DT_STRSZ DynTag = 10; /* Size of string table. */ DT_STRSZ DynTag = 10; /* Size of string table. */
DT_SYMENT DynTag = 11; /* Size of each symbol table entry. */ DT_SYMENT DynTag = 11; /* Size of each symbol table entry. */
DT_INIT DynTag = 12; /* Address of initialization function. */ DT_INIT DynTag = 12; /* Address of initialization function. */
DT_FINI DynTag = 13; /* Address of finalization function. */ DT_FINI DynTag = 13; /* Address of finalization function. */
DT_SONAME DynTag = 14; /* String table offset of shared object name. */ DT_SONAME DynTag = 14; /* String table offset of shared object name. */
DT_RPATH DynTag = 15; /* String table offset of library path. [sup] */ DT_RPATH DynTag = 15; /* String table offset of library path. [sup] */
DT_SYMBOLIC DynTag = 16; /* Indicates "symbolic" linking. [sup] */ DT_SYMBOLIC DynTag = 16; /* Indicates "symbolic" linking. [sup] */
DT_REL DynTag = 17; /* Address of ElfNN_Rel relocations. */ DT_REL DynTag = 17; /* Address of ElfNN_Rel relocations. */
DT_RELSZ DynTag = 18; /* Total size of ElfNN_Rel relocations. */ DT_RELSZ DynTag = 18; /* Total size of ElfNN_Rel relocations. */
DT_RELENT DynTag = 19; /* Size of each ElfNN_Rel relocation. */ DT_RELENT DynTag = 19; /* Size of each ElfNN_Rel relocation. */
DT_PLTREL DynTag = 20; /* Type of relocation used for PLT. */ DT_PLTREL DynTag = 20; /* Type of relocation used for PLT. */
DT_DEBUG DynTag = 21; /* Reserved (not used). */ DT_DEBUG DynTag = 21; /* Reserved (not used). */
DT_TEXTREL DynTag = 22; /* Indicates there may be relocations in non-writable segments. [sup] */ DT_TEXTREL DynTag = 22; /* Indicates there may be relocations in non-writable segments. [sup] */
DT_JMPREL DynTag = 23; /* Address of PLT relocations. */ DT_JMPREL DynTag = 23; /* Address of PLT relocations. */
DT_BIND_NOW DynTag = 24; /* [sup] */ DT_BIND_NOW DynTag = 24; /* [sup] */
DT_INIT_ARRAY DynTag = 25; /* Address of the array of pointers to initialization functions */ DT_INIT_ARRAY DynTag = 25; /* Address of the array of pointers to initialization functions */
DT_FINI_ARRAY DynTag = 26; /* Address of the array of pointers to termination functions */ DT_FINI_ARRAY DynTag = 26; /* Address of the array of pointers to termination functions */
DT_INIT_ARRAYSZ DynTag = 27; /* Size in bytes of the array of initialization functions. */ DT_INIT_ARRAYSZ DynTag = 27; /* Size in bytes of the array of initialization functions. */
DT_FINI_ARRAYSZ DynTag = 28; /* Size in bytes of the array of terminationfunctions. */ DT_FINI_ARRAYSZ DynTag = 28; /* Size in bytes of the array of terminationfunctions. */
DT_RUNPATH DynTag = 29; /* String table offset of a null-terminated library search path string. */ DT_RUNPATH DynTag = 29; /* String table offset of a null-terminated library search path string. */
DT_FLAGS DynTag = 30; /* Object specific flag values. */ DT_FLAGS DynTag = 30; /* Object specific flag values. */
DT_ENCODING DynTag = 32; /* Values greater than or equal to DT_ENCODING DT_ENCODING DynTag = 32; /* Values greater than or equal to DT_ENCODING
and less than DT_LOOS follow the rules for and less than DT_LOOS follow the rules for
the interpretation of the d_un union the interpretation of the d_un union
as follows: even == 'd_ptr', even == 'd_val' as follows: even == 'd_ptr', even == 'd_val'
or none */ or none */
DT_PREINIT_ARRAY DynTag = 32; /* Address of the array of pointers to pre-initialization functions. */ DT_PREINIT_ARRAY DynTag = 32; /* Address of the array of pointers to pre-initialization functions. */
DT_PREINIT_ARRAYSZ DynTag = 33; /* Size in bytes of the array of pre-initialization functions. */ DT_PREINIT_ARRAYSZ DynTag = 33; /* Size in bytes of the array of pre-initialization functions. */
DT_LOOS DynTag = 0x6000000d; /* First OS-specific */ DT_LOOS DynTag = 0x6000000d; /* First OS-specific */
...@@ -619,18 +619,18 @@ type DynFlag int ...@@ -619,18 +619,18 @@ type DynFlag int
const ( const (
DF_ORIGIN DynFlag = 0x0001; /* Indicates that the object being loaded may DF_ORIGIN DynFlag = 0x0001; /* Indicates that the object being loaded may
make reference to the $ORIGIN substitution make reference to the $ORIGIN substitution
string */ string */
DF_SYMBOLIC DynFlag = 0x0002; /* Indicates "symbolic" linking. */ DF_SYMBOLIC DynFlag = 0x0002; /* Indicates "symbolic" linking. */
DF_TEXTREL DynFlag = 0x0004; /* Indicates there may be relocations in DF_TEXTREL DynFlag = 0x0004; /* Indicates there may be relocations in
non-writable segments. */ non-writable segments. */
DF_BIND_NOW DynFlag = 0x0008; /* Indicates that the dynamic linker should DF_BIND_NOW DynFlag = 0x0008; /* Indicates that the dynamic linker should
process all relocations for the object process all relocations for the object
containing this entry before transferring containing this entry before transferring
control to the program. */ control to the program. */
DF_STATIC_TLS DynFlag = 0x0010; /* Indicates that the shared object or DF_STATIC_TLS DynFlag = 0x0010; /* Indicates that the shared object or
executable contains code using a static executable contains code using a static
thread-local storage scheme. */ thread-local storage scheme. */
) )
var dflagStrings = []intName{ var dflagStrings = []intName{
...@@ -1393,8 +1393,8 @@ type Header32 struct { ...@@ -1393,8 +1393,8 @@ type Header32 struct {
* ELF32 Section header. * ELF32 Section header.
*/ */
type Section32 struct { type Section32 struct {
Name uint32; /* Section name (index into the Name uint32; /* Section name (index into the
section header string table). */ section header string table). */
Type uint32; /* Section type. */ Type uint32; /* Section type. */
Flags uint32; /* Section flags. */ Flags uint32; /* Section flags. */
Addr uint32; /* Address in memory image. */ Addr uint32; /* Address in memory image. */
...@@ -1507,8 +1507,8 @@ type Header64 struct { ...@@ -1507,8 +1507,8 @@ type Header64 struct {
*/ */
type Section64 struct { type Section64 struct {
Name uint32; /* Section name (index into the Name uint32; /* Section name (index into the
section header string table). */ section header string table). */
Type uint32; /* Section type. */ Type uint32; /* Section type. */
Flags uint64; /* Section flags. */ Flags uint64; /* Section flags. */
Addr uint64; /* Address in memory image. */ Addr uint64; /* Address in memory image. */
......
...@@ -20,38 +20,38 @@ import ( ...@@ -20,38 +20,38 @@ import (
// A File represents an open Mach-O file. // A File represents an open Mach-O file.
type File struct { type File struct {
FileHeader; FileHeader;
ByteOrder binary.ByteOrder; ByteOrder binary.ByteOrder;
Loads []Load; Loads []Load;
Sections []*Section; Sections []*Section;
closer io.Closer; closer io.Closer;
} }
// A Load represents any Mach-O load command. // A Load represents any Mach-O load command.
type Load interface { type Load interface {
Raw() []byte Raw() []byte;
} }
// A LoadBytes is the uninterpreted bytes of a Mach-O load command. // A LoadBytes is the uninterpreted bytes of a Mach-O load command.
type LoadBytes []byte type LoadBytes []byte
func (b LoadBytes) Raw() []byte { func (b LoadBytes) Raw() []byte {
return b return b;
} }
// A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command. // A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.
type SegmentHeader struct { type SegmentHeader struct {
Cmd LoadCmd; Cmd LoadCmd;
Len uint32; Len uint32;
Name string; Name string;
Addr uint64; Addr uint64;
Memsz uint64; Memsz uint64;
Offset uint64; Offset uint64;
Filesz uint64; Filesz uint64;
Maxprot uint32; Maxprot uint32;
Prot uint32; Prot uint32;
Nsect uint32; Nsect uint32;
Flag uint32; Flag uint32;
} }
// A Segment represents a Mach-O 32-bit or 64-bit load segment command. // A Segment represents a Mach-O 32-bit or 64-bit load segment command.
...@@ -66,7 +66,7 @@ type Segment struct { ...@@ -66,7 +66,7 @@ type Segment struct {
// Open() to avoid fighting over the seek offset // Open() to avoid fighting over the seek offset
// with other clients. // with other clients.
io.ReaderAt; io.ReaderAt;
sr *io.SectionReader; sr *io.SectionReader;
} }
// Data reads and returns the contents of the segment. // Data reads and returns the contents of the segment.
...@@ -103,7 +103,7 @@ type Section struct { ...@@ -103,7 +103,7 @@ type Section struct {
// Open() to avoid fighting over the seek offset // Open() to avoid fighting over the seek offset
// with other clients. // with other clients.
io.ReaderAt; io.ReaderAt;
sr *io.SectionReader; sr *io.SectionReader;
} }
// Data reads and returns the contents of the Mach-O section. // Data reads and returns the contents of the Mach-O section.
...@@ -124,9 +124,9 @@ func (s *Section) Open() io.ReadSeeker { ...@@ -124,9 +124,9 @@ func (s *Section) Open() io.ReadSeeker {
*/ */
type FormatError struct { type FormatError struct {
off int64; off int64;
msg string; msg string;
val interface{}; val interface{};
} }
func (e *FormatError) String() string { func (e *FormatError) String() string {
...@@ -315,7 +315,7 @@ func (f *File) pushSection(sh *Section, r io.ReaderAt) { ...@@ -315,7 +315,7 @@ func (f *File) pushSection(sh *Section, r io.ReaderAt) {
} }
f.Sections = new; f.Sections = new;
} }
f.Sections = f.Sections[0:n+1]; f.Sections = f.Sections[0 : n+1];
f.Sections[n] = sh; f.Sections[n] = sh;
sh.sr = io.NewSectionReader(r, int64(sh.Offset), int64(sh.Size)); sh.sr = io.NewSectionReader(r, int64(sh.Offset), int64(sh.Size));
sh.ReaderAt = sh.sr; sh.ReaderAt = sh.sr;
...@@ -323,7 +323,7 @@ func (f *File) pushSection(sh *Section, r io.ReaderAt) { ...@@ -323,7 +323,7 @@ func (f *File) pushSection(sh *Section, r io.ReaderAt) {
func cstring(b []byte) string { func cstring(b []byte) string {
var i int; var i int;
for i=0; i<len(b) && b[i] != 0; i++ { for i = 0; i < len(b) && b[i] != 0; i++ {
} }
return string(b[0:i]); return string(b[0:i]);
} }
......
...@@ -13,15 +13,15 @@ package proc ...@@ -13,15 +13,15 @@ package proc
// and proc_darwin.go do, because deps.bash only looks at // and proc_darwin.go do, because deps.bash only looks at
// this file. // this file.
import ( import (
_ "container/vector"; _ "container/vector";
_ "fmt"; _ "fmt";
_ "io"; _ "io";
"os"; "os";
_ "runtime"; _ "runtime";
"strconv"; "strconv";
_ "strings"; _ "strings";
_ "sync"; _ "sync";
_ "syscall"; _ "syscall";
) )
type Word uint64 type Word uint64
......
...@@ -12,10 +12,10 @@ import ( ...@@ -12,10 +12,10 @@ import (
type amd64Regs struct { type amd64Regs struct {
syscall.PtraceRegs; syscall.PtraceRegs;
setter func (*syscall.PtraceRegs) os.Error; setter func(*syscall.PtraceRegs) os.Error;
} }
var names = [...]string { var names = [...]string{
"rax", "rax",
"rbx", "rbx",
"rcx", "rcx",
...@@ -81,67 +81,115 @@ func (r *amd64Regs) Names() []string { ...@@ -81,67 +81,115 @@ func (r *amd64Regs) Names() []string {
func (r *amd64Regs) Get(i int) Word { func (r *amd64Regs) Get(i int) Word {
switch i { switch i {
case 0: return Word(r.Rax); case 0:
case 1: return Word(r.Rbx); return Word(r.Rax);
case 2: return Word(r.Rcx); case 1:
case 3: return Word(r.Rdx); return Word(r.Rbx);
case 4: return Word(r.Rsi); case 2:
case 5: return Word(r.Rdi); return Word(r.Rcx);
case 6: return Word(r.Rbp); case 3:
case 7: return Word(r.Rsp); return Word(r.Rdx);
case 8: return Word(r.R8); case 4:
case 9: return Word(r.R9); return Word(r.Rsi);
case 10: return Word(r.R10); case 5:
case 11: return Word(r.R11); return Word(r.Rdi);
case 12: return Word(r.R12); case 6:
case 13: return Word(r.R13); return Word(r.Rbp);
case 14: return Word(r.R14); case 7:
case 15: return Word(r.R15); return Word(r.Rsp);
case 16: return Word(r.Rip); case 8:
case 17: return Word(r.Eflags); return Word(r.R8);
case 18: return Word(r.Cs); case 9:
case 19: return Word(r.Ss); return Word(r.R9);
case 20: return Word(r.Ds); case 10:
case 21: return Word(r.Es); return Word(r.R10);
case 22: return Word(r.Fs); case 11:
case 23: return Word(r.Gs); return Word(r.R11);
case 12:
return Word(r.R12);
case 13:
return Word(r.R13);
case 14:
return Word(r.R14);
case 15:
return Word(r.R15);
case 16:
return Word(r.Rip);
case 17:
return Word(r.Eflags);
case 18:
return Word(r.Cs);
case 19:
return Word(r.Ss);
case 20:
return Word(r.Ds);
case 21:
return Word(r.Es);
case 22:
return Word(r.Fs);
case 23:
return Word(r.Gs);
} }
panic("invalid register index ", strconv.Itoa(i)); panic("invalid register index ", strconv.Itoa(i));
} }
func (r *amd64Regs) Set(i int, val Word) os.Error { func (r *amd64Regs) Set(i int, val Word) os.Error {
switch i { switch i {
case 0: r.Rax = uint64(val); case 0:
case 1: r.Rbx = uint64(val); r.Rax = uint64(val);
case 2: r.Rcx = uint64(val); case 1:
case 3: r.Rdx = uint64(val); r.Rbx = uint64(val);
case 4: r.Rsi = uint64(val); case 2:
case 5: r.Rdi = uint64(val); r.Rcx = uint64(val);
case 6: r.Rbp = uint64(val); case 3:
case 7: r.Rsp = uint64(val); r.Rdx = uint64(val);
case 8: r.R8 = uint64(val); case 4:
case 9: r.R9 = uint64(val); r.Rsi = uint64(val);
case 10: r.R10 = uint64(val); case 5:
case 11: r.R11 = uint64(val); r.Rdi = uint64(val);
case 12: r.R12 = uint64(val); case 6:
case 13: r.R13 = uint64(val); r.Rbp = uint64(val);
case 14: r.R14 = uint64(val); case 7:
case 15: r.R15 = uint64(val); r.Rsp = uint64(val);
case 16: r.Rip = uint64(val); case 8:
case 17: r.Eflags = uint64(val); r.R8 = uint64(val);
case 18: r.Cs = uint64(val); case 9:
case 19: r.Ss = uint64(val); r.R9 = uint64(val);
case 20: r.Ds = uint64(val); case 10:
case 21: r.Es = uint64(val); r.R10 = uint64(val);
case 22: r.Fs = uint64(val); case 11:
case 23: r.Gs = uint64(val); r.R11 = uint64(val);
case 12:
r.R12 = uint64(val);
case 13:
r.R13 = uint64(val);
case 14:
r.R14 = uint64(val);
case 15:
r.R15 = uint64(val);
case 16:
r.Rip = uint64(val);
case 17:
r.Eflags = uint64(val);
case 18:
r.Cs = uint64(val);
case 19:
r.Ss = uint64(val);
case 20:
r.Ds = uint64(val);
case 21:
r.Es = uint64(val);
case 22:
r.Fs = uint64(val);
case 23:
r.Gs = uint64(val);
default: default:
panic("invalid register index ", strconv.Itoa(i)); panic("invalid register index ", strconv.Itoa(i));
} }
return r.setter(&r.PtraceRegs); return r.setter(&r.PtraceRegs);
} }
func newRegs(regs *syscall.PtraceRegs, setter func (*syscall.PtraceRegs) os.Error) Regs { func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs {
res := amd64Regs{}; res := amd64Regs{};
res.PtraceRegs = *regs; res.PtraceRegs = *regs;
res.setter = setter; res.setter = setter;
......
...@@ -11,8 +11,7 @@ import ( ...@@ -11,8 +11,7 @@ import (
// TODO(kaib): add support // TODO(kaib): add support
type armRegs struct { type armRegs struct{}
}
func (r *armRegs) PC() Word { func (r *armRegs) PC() Word {
return Word(0); return Word(0);
...@@ -22,35 +21,35 @@ func (r *armRegs) SetPC(val Word) os.Error { ...@@ -22,35 +21,35 @@ func (r *armRegs) SetPC(val Word) os.Error {
return nil; return nil;
} }
func (r * armRegs) Link() Word { func (r *armRegs) Link() Word {
return Word(0); return Word(0);
} }
func (r* armRegs) SetLink(val Word) (os.Error) { func (r *armRegs) SetLink(val Word) os.Error {
return nil; return nil;
} }
func (r* armRegs) SP() Word { func (r *armRegs) SP() Word {
return Word(0); return Word(0);
} }
func (r* armRegs) SetSP(val Word) os.Error { func (r *armRegs) SetSP(val Word) os.Error {
return nil; return nil;
} }
func (r* armRegs) Names() []string { func (r *armRegs) Names() []string {
return nil; return nil;
} }
func (r* armRegs) Get(i int) Word { func (r *armRegs) Get(i int) Word {
return Word(0); return Word(0);
} }
func (r* armRegs) Set(i int, val Word) os.Error { func (r *armRegs) Set(i int, val Word) os.Error {
return nil; return nil;
} }
func newRegs(regs *syscall.PtraceRegs, setter func (*syscall.PtraceRegs) os.Error) Regs { func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs {
res := armRegs{}; res := armRegs{};
return &res; return &res;
} }
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