summaryrefslogtreecommitdiff
path: root/src/pkg/debug
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-12-15 15:27:16 -0800
committerRobert Griesemer <gri@golang.org>2009-12-15 15:27:16 -0800
commit36f2000423b0f8411302eefadbf2f8750cac9c60 (patch)
tree44d5d948e3f27cc7eff15ec8cd7ee5165d9a7e90 /src/pkg/debug
parent52ed78cd2b0f35cd7693878c0c309b9a3c4cbfc3 (diff)
downloadgo-36f2000423b0f8411302eefadbf2f8750cac9c60.tar.gz
1) Change default gofmt default settings for
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 2nd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/179067
Diffstat (limited to 'src/pkg/debug')
-rw-r--r--src/pkg/debug/dwarf/buf.go108
-rw-r--r--src/pkg/debug/dwarf/const.go444
-rw-r--r--src/pkg/debug/dwarf/entry.go172
-rw-r--r--src/pkg/debug/dwarf/open.go40
-rw-r--r--src/pkg/debug/dwarf/type.go370
-rw-r--r--src/pkg/debug/dwarf/type_test.go36
-rw-r--r--src/pkg/debug/dwarf/unit.go50
-rw-r--r--src/pkg/debug/elf/elf.go1246
-rw-r--r--src/pkg/debug/elf/elf_test.go10
-rw-r--r--src/pkg/debug/elf/file.go312
-rw-r--r--src/pkg/debug/elf/file_test.go60
-rw-r--r--src/pkg/debug/gosym/pclntab.go42
-rw-r--r--src/pkg/debug/gosym/pclntab_test.go110
-rw-r--r--src/pkg/debug/gosym/symtab.go334
-rw-r--r--src/pkg/debug/macho/file.go322
-rw-r--r--src/pkg/debug/macho/file_test.go50
-rw-r--r--src/pkg/debug/macho/macho.go234
-rw-r--r--src/pkg/debug/proc/proc.go92
-rw-r--r--src/pkg/debug/proc/proc_linux.go670
-rw-r--r--src/pkg/debug/proc/proc_nacl.go4
-rw-r--r--src/pkg/debug/proc/regs_linux_386.go38
-rw-r--r--src/pkg/debug/proc/regs_linux_amd64.go36
-rw-r--r--src/pkg/debug/proc/regs_linux_arm.go24
23 files changed, 2402 insertions, 2402 deletions
diff --git a/src/pkg/debug/dwarf/buf.go b/src/pkg/debug/dwarf/buf.go
index 2ece903a0..2d29cebdd 100644
--- a/src/pkg/debug/dwarf/buf.go
+++ b/src/pkg/debug/dwarf/buf.go
@@ -7,20 +7,20 @@
package dwarf
import (
- "encoding/binary";
- "os";
- "strconv";
+ "encoding/binary"
+ "os"
+ "strconv"
)
// Data buffer being decoded.
type buf struct {
- dwarf *Data;
- order binary.ByteOrder;
- name string;
- off Offset;
- data []byte;
- addrsize int;
- err os.Error;
+ dwarf *Data
+ order binary.ByteOrder
+ name string
+ off Offset
+ data []byte
+ addrsize int
+ err os.Error
}
func makeBuf(d *Data, name string, off Offset, data []byte, addrsize int) buf {
@@ -29,95 +29,95 @@ func makeBuf(d *Data, name string, off Offset, data []byte, addrsize int) buf {
func (b *buf) uint8() uint8 {
if len(b.data) < 1 {
- b.error("underflow");
- return 0;
+ b.error("underflow")
+ return 0
}
- val := b.data[0];
- b.data = b.data[1:];
- b.off++;
- return val;
+ val := b.data[0]
+ b.data = b.data[1:]
+ b.off++
+ return val
}
func (b *buf) bytes(n int) []byte {
if len(b.data) < n {
- b.error("underflow");
- return nil;
+ b.error("underflow")
+ return nil
}
- data := b.data[0:n];
- b.data = b.data[n:];
- b.off += Offset(n);
- return data;
+ data := b.data[0:n]
+ b.data = b.data[n:]
+ b.off += Offset(n)
+ return data
}
-func (b *buf) skip(n int) { b.bytes(n) }
+func (b *buf) skip(n int) { b.bytes(n) }
func (b *buf) string() string {
for i := 0; i < len(b.data); i++ {
if b.data[i] == 0 {
- s := string(b.data[0:i]);
- b.data = b.data[i+1:];
- b.off += Offset(i + 1);
- return s;
+ s := string(b.data[0:i])
+ b.data = b.data[i+1:]
+ b.off += Offset(i + 1)
+ return s
}
}
- b.error("underflow");
- return "";
+ b.error("underflow")
+ return ""
}
func (b *buf) uint16() uint16 {
- a := b.bytes(2);
+ a := b.bytes(2)
if a == nil {
return 0
}
- return b.order.Uint16(a);
+ return b.order.Uint16(a)
}
func (b *buf) uint32() uint32 {
- a := b.bytes(4);
+ a := b.bytes(4)
if a == nil {
return 0
}
- return b.order.Uint32(a);
+ return b.order.Uint32(a)
}
func (b *buf) uint64() uint64 {
- a := b.bytes(8);
+ a := b.bytes(8)
if a == nil {
return 0
}
- return b.order.Uint64(a);
+ return b.order.Uint64(a)
}
// Read a varint, which is 7 bits per byte, little endian.
// the 0x80 bit means read another byte.
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;
- bits += 7;
+ byte := b.data[i]
+ c |= uint64(byte&0x7F) << bits
+ bits += 7
if byte&0x80 == 0 {
- b.off += Offset(i + 1);
- b.data = b.data[i+1:];
- return c, bits;
+ b.off += Offset(i + 1)
+ b.data = b.data[i+1:]
+ return c, bits
}
}
- return 0, 0;
+ return 0, 0
}
// Unsigned int is just a varint.
func (b *buf) uint() uint64 {
- x, _ := b.varint();
- return x;
+ x, _ := b.varint()
+ return x
}
// Signed int is a sign-extended varint.
func (b *buf) int() int64 {
- ux, bits := b.varint();
- x := int64(ux);
+ ux, bits := b.varint()
+ x := int64(ux)
if x&(1<<(bits-1)) != 0 {
x |= -1 << bits
}
- return x;
+ return x
}
// Address-sized uint.
@@ -132,21 +132,21 @@ func (b *buf) addr() uint64 {
case 8:
return uint64(b.uint64())
}
- b.error("unknown address size");
- return 0;
+ b.error("unknown address size")
+ return 0
}
func (b *buf) error(s string) {
if b.err == nil {
- b.data = nil;
- b.err = DecodeError{b.name, b.off, s};
+ b.data = nil
+ b.err = DecodeError{b.name, b.off, s}
}
}
type DecodeError struct {
- Name string;
- Offset Offset;
- Error string;
+ Name string
+ Offset Offset
+ Error string
}
func (e DecodeError) String() string {
diff --git a/src/pkg/debug/dwarf/const.go b/src/pkg/debug/dwarf/const.go
index 808a80c8a..d73480cb2 100644
--- a/src/pkg/debug/dwarf/const.go
+++ b/src/pkg/debug/dwarf/const.go
@@ -12,78 +12,78 @@ import "strconv"
type Attr uint32
const (
- AttrSibling Attr = 0x01;
- AttrLocation Attr = 0x02;
- AttrName Attr = 0x03;
- AttrOrdering Attr = 0x09;
- AttrByteSize Attr = 0x0B;
- AttrBitOffset Attr = 0x0C;
- AttrBitSize Attr = 0x0D;
- AttrStmtList Attr = 0x10;
- AttrLowpc Attr = 0x11;
- AttrHighpc Attr = 0x12;
- AttrLanguage Attr = 0x13;
- AttrDiscr Attr = 0x15;
- AttrDiscrValue Attr = 0x16;
- AttrVisibility Attr = 0x17;
- AttrImport Attr = 0x18;
- AttrStringLength Attr = 0x19;
- AttrCommonRef Attr = 0x1A;
- AttrCompDir Attr = 0x1B;
- AttrConstValue Attr = 0x1C;
- AttrContainingType Attr = 0x1D;
- AttrDefaultValue Attr = 0x1E;
- AttrInline Attr = 0x20;
- AttrIsOptional Attr = 0x21;
- AttrLowerBound Attr = 0x22;
- AttrProducer Attr = 0x25;
- AttrPrototyped Attr = 0x27;
- AttrReturnAddr Attr = 0x2A;
- AttrStartScope Attr = 0x2C;
- AttrStrideSize Attr = 0x2E;
- AttrUpperBound Attr = 0x2F;
- AttrAbstractOrigin Attr = 0x31;
- AttrAccessibility Attr = 0x32;
- AttrAddrClass Attr = 0x33;
- AttrArtificial Attr = 0x34;
- AttrBaseTypes Attr = 0x35;
- AttrCalling Attr = 0x36;
- AttrCount Attr = 0x37;
- AttrDataMemberLoc Attr = 0x38;
- AttrDeclColumn Attr = 0x39;
- AttrDeclFile Attr = 0x3A;
- AttrDeclLine Attr = 0x3B;
- AttrDeclaration Attr = 0x3C;
- AttrDiscrList Attr = 0x3D;
- AttrEncoding Attr = 0x3E;
- AttrExternal Attr = 0x3F;
- AttrFrameBase Attr = 0x40;
- AttrFriend Attr = 0x41;
- AttrIdentifierCase Attr = 0x42;
- AttrMacroInfo Attr = 0x43;
- AttrNamelistItem Attr = 0x44;
- AttrPriority Attr = 0x45;
- AttrSegment Attr = 0x46;
- AttrSpecification Attr = 0x47;
- AttrStaticLink Attr = 0x48;
- AttrType Attr = 0x49;
- AttrUseLocation Attr = 0x4A;
- AttrVarParam Attr = 0x4B;
- AttrVirtuality Attr = 0x4C;
- AttrVtableElemLoc Attr = 0x4D;
- AttrAllocated Attr = 0x4E;
- AttrAssociated Attr = 0x4F;
- AttrDataLocation Attr = 0x50;
- AttrStride Attr = 0x51;
- AttrEntrypc Attr = 0x52;
- AttrUseUTF8 Attr = 0x53;
- AttrExtension Attr = 0x54;
- AttrRanges Attr = 0x55;
- AttrTrampoline Attr = 0x56;
- AttrCallColumn Attr = 0x57;
- AttrCallFile Attr = 0x58;
- AttrCallLine Attr = 0x59;
- AttrDescription Attr = 0x5A;
+ AttrSibling Attr = 0x01
+ AttrLocation Attr = 0x02
+ AttrName Attr = 0x03
+ AttrOrdering Attr = 0x09
+ AttrByteSize Attr = 0x0B
+ AttrBitOffset Attr = 0x0C
+ AttrBitSize Attr = 0x0D
+ AttrStmtList Attr = 0x10
+ AttrLowpc Attr = 0x11
+ AttrHighpc Attr = 0x12
+ AttrLanguage Attr = 0x13
+ AttrDiscr Attr = 0x15
+ AttrDiscrValue Attr = 0x16
+ AttrVisibility Attr = 0x17
+ AttrImport Attr = 0x18
+ AttrStringLength Attr = 0x19
+ AttrCommonRef Attr = 0x1A
+ AttrCompDir Attr = 0x1B
+ AttrConstValue Attr = 0x1C
+ AttrContainingType Attr = 0x1D
+ AttrDefaultValue Attr = 0x1E
+ AttrInline Attr = 0x20
+ AttrIsOptional Attr = 0x21
+ AttrLowerBound Attr = 0x22
+ AttrProducer Attr = 0x25
+ AttrPrototyped Attr = 0x27
+ AttrReturnAddr Attr = 0x2A
+ AttrStartScope Attr = 0x2C
+ AttrStrideSize Attr = 0x2E
+ AttrUpperBound Attr = 0x2F
+ AttrAbstractOrigin Attr = 0x31
+ AttrAccessibility Attr = 0x32
+ AttrAddrClass Attr = 0x33
+ AttrArtificial Attr = 0x34
+ AttrBaseTypes Attr = 0x35
+ AttrCalling Attr = 0x36
+ AttrCount Attr = 0x37
+ AttrDataMemberLoc Attr = 0x38
+ AttrDeclColumn Attr = 0x39
+ AttrDeclFile Attr = 0x3A
+ AttrDeclLine Attr = 0x3B
+ AttrDeclaration Attr = 0x3C
+ AttrDiscrList Attr = 0x3D
+ AttrEncoding Attr = 0x3E
+ AttrExternal Attr = 0x3F
+ AttrFrameBase Attr = 0x40
+ AttrFriend Attr = 0x41
+ AttrIdentifierCase Attr = 0x42
+ AttrMacroInfo Attr = 0x43
+ AttrNamelistItem Attr = 0x44
+ AttrPriority Attr = 0x45
+ AttrSegment Attr = 0x46
+ AttrSpecification Attr = 0x47
+ AttrStaticLink Attr = 0x48
+ AttrType Attr = 0x49
+ AttrUseLocation Attr = 0x4A
+ AttrVarParam Attr = 0x4B
+ AttrVirtuality Attr = 0x4C
+ AttrVtableElemLoc Attr = 0x4D
+ AttrAllocated Attr = 0x4E
+ AttrAssociated Attr = 0x4F
+ AttrDataLocation Attr = 0x50
+ AttrStride Attr = 0x51
+ AttrEntrypc Attr = 0x52
+ AttrUseUTF8 Attr = 0x53
+ AttrExtension Attr = 0x54
+ AttrRanges Attr = 0x55
+ AttrTrampoline Attr = 0x56
+ AttrCallColumn Attr = 0x57
+ AttrCallFile Attr = 0x58
+ AttrCallLine Attr = 0x59
+ AttrDescription Attr = 0x5A
)
var attrNames = [...]string{
@@ -163,22 +163,22 @@ var attrNames = [...]string{
func (a Attr) String() string {
if int(a) < len(attrNames) {
- s := attrNames[a];
+ s := attrNames[a]
if s != "" {
return s
}
}
- return strconv.Itoa(int(a));
+ return strconv.Itoa(int(a))
}
func (a Attr) GoString() string {
if int(a) < len(attrNames) {
- s := attrNames[a];
+ s := attrNames[a]
if s != "" {
return "dwarf.Attr" + s
}
}
- return "dwarf.Attr(" + strconv.Itoa64(int64(a)) + ")";
+ return "dwarf.Attr(" + strconv.Itoa64(int64(a)) + ")"
}
// A format is a DWARF data encoding format.
@@ -186,89 +186,89 @@ type format uint32
const (
// value formats
- formAddr format = 0x01;
- formDwarfBlock2 format = 0x03;
- formDwarfBlock4 format = 0x04;
- formData2 format = 0x05;
- formData4 format = 0x06;
- formData8 format = 0x07;
- formString format = 0x08;
- formDwarfBlock format = 0x09;
- formDwarfBlock1 format = 0x0A;
- formData1 format = 0x0B;
- formFlag format = 0x0C;
- formSdata format = 0x0D;
- formStrp format = 0x0E;
- formUdata format = 0x0F;
- formRefAddr format = 0x10;
- formRef1 format = 0x11;
- formRef2 format = 0x12;
- formRef4 format = 0x13;
- formRef8 format = 0x14;
- formRefUdata format = 0x15;
- formIndirect format = 0x16;
+ formAddr format = 0x01
+ formDwarfBlock2 format = 0x03
+ formDwarfBlock4 format = 0x04
+ formData2 format = 0x05
+ formData4 format = 0x06
+ formData8 format = 0x07
+ formString format = 0x08
+ formDwarfBlock format = 0x09
+ formDwarfBlock1 format = 0x0A
+ formData1 format = 0x0B
+ formFlag format = 0x0C
+ formSdata format = 0x0D
+ formStrp format = 0x0E
+ formUdata format = 0x0F
+ formRefAddr format = 0x10
+ formRef1 format = 0x11
+ formRef2 format = 0x12
+ formRef4 format = 0x13
+ formRef8 format = 0x14
+ formRefUdata format = 0x15
+ formIndirect format = 0x16
)
// A Tag is the classification (the type) of an Entry.
type Tag uint32
const (
- TagArrayType Tag = 0x01;
- TagClassType Tag = 0x02;
- TagEntryPoint Tag = 0x03;
- TagEnumerationType Tag = 0x04;
- TagFormalParameter Tag = 0x05;
- TagImportedDeclaration Tag = 0x08;
- TagLabel Tag = 0x0A;
- TagLexDwarfBlock Tag = 0x0B;
- TagMember Tag = 0x0D;
- TagPointerType Tag = 0x0F;
- TagReferenceType Tag = 0x10;
- TagCompileUnit Tag = 0x11;
- TagStringType Tag = 0x12;
- TagStructType Tag = 0x13;
- TagSubroutineType Tag = 0x15;
- TagTypedef Tag = 0x16;
- TagUnionType Tag = 0x17;
- TagUnspecifiedParameters Tag = 0x18;
- TagVariant Tag = 0x19;
- TagCommonDwarfBlock Tag = 0x1A;
- TagCommonInclusion Tag = 0x1B;
- TagInheritance Tag = 0x1C;
- TagInlinedSubroutine Tag = 0x1D;
- TagModule Tag = 0x1E;
- TagPtrToMemberType Tag = 0x1F;
- TagSetType Tag = 0x20;
- TagSubrangeType Tag = 0x21;
- TagWithStmt Tag = 0x22;
- TagAccessDeclaration Tag = 0x23;
- TagBaseType Tag = 0x24;
- TagCatchDwarfBlock Tag = 0x25;
- TagConstType Tag = 0x26;
- TagConstant Tag = 0x27;
- TagEnumerator Tag = 0x28;
- TagFileType Tag = 0x29;
- TagFriend Tag = 0x2A;
- TagNamelist Tag = 0x2B;
- TagNamelistItem Tag = 0x2C;
- TagPackedType Tag = 0x2D;
- TagSubprogram Tag = 0x2E;
- TagTemplateTypeParameter Tag = 0x2F;
- TagTemplateValueParameter Tag = 0x30;
- TagThrownType Tag = 0x31;
- TagTryDwarfBlock Tag = 0x32;
- TagVariantPart Tag = 0x33;
- TagVariable Tag = 0x34;
- TagVolatileType Tag = 0x35;
- TagDwarfProcedure Tag = 0x36;
- TagRestrictType Tag = 0x37;
- TagInterfaceType Tag = 0x38;
- TagNamespace Tag = 0x39;
- TagImportedModule Tag = 0x3A;
- TagUnspecifiedType Tag = 0x3B;
- TagPartialUnit Tag = 0x3C;
- TagImportedUnit Tag = 0x3D;
- TagMutableType Tag = 0x3E;
+ TagArrayType Tag = 0x01
+ TagClassType Tag = 0x02
+ TagEntryPoint Tag = 0x03
+ TagEnumerationType Tag = 0x04
+ TagFormalParameter Tag = 0x05
+ TagImportedDeclaration Tag = 0x08
+ TagLabel Tag = 0x0A
+ TagLexDwarfBlock Tag = 0x0B
+ TagMember Tag = 0x0D
+ TagPointerType Tag = 0x0F
+ TagReferenceType Tag = 0x10
+ TagCompileUnit Tag = 0x11
+ TagStringType Tag = 0x12
+ TagStructType Tag = 0x13
+ TagSubroutineType Tag = 0x15
+ TagTypedef Tag = 0x16
+ TagUnionType Tag = 0x17
+ TagUnspecifiedParameters Tag = 0x18
+ TagVariant Tag = 0x19
+ TagCommonDwarfBlock Tag = 0x1A
+ TagCommonInclusion Tag = 0x1B
+ TagInheritance Tag = 0x1C
+ TagInlinedSubroutine Tag = 0x1D
+ TagModule Tag = 0x1E
+ TagPtrToMemberType Tag = 0x1F
+ TagSetType Tag = 0x20
+ TagSubrangeType Tag = 0x21
+ TagWithStmt Tag = 0x22
+ TagAccessDeclaration Tag = 0x23
+ TagBaseType Tag = 0x24
+ TagCatchDwarfBlock Tag = 0x25
+ TagConstType Tag = 0x26
+ TagConstant Tag = 0x27
+ TagEnumerator Tag = 0x28
+ TagFileType Tag = 0x29
+ TagFriend Tag = 0x2A
+ TagNamelist Tag = 0x2B
+ TagNamelistItem Tag = 0x2C
+ TagPackedType Tag = 0x2D
+ TagSubprogram Tag = 0x2E
+ TagTemplateTypeParameter Tag = 0x2F
+ TagTemplateValueParameter Tag = 0x30
+ TagThrownType Tag = 0x31
+ TagTryDwarfBlock Tag = 0x32
+ TagVariantPart Tag = 0x33
+ TagVariable Tag = 0x34
+ TagVolatileType Tag = 0x35
+ TagDwarfProcedure Tag = 0x36
+ TagRestrictType Tag = 0x37
+ TagInterfaceType Tag = 0x38
+ TagNamespace Tag = 0x39
+ TagImportedModule Tag = 0x3A
+ TagUnspecifiedType Tag = 0x3B
+ TagPartialUnit Tag = 0x3C
+ TagImportedUnit Tag = 0x3D
+ TagMutableType Tag = 0x3E
)
var tagNames = [...]string{
@@ -332,22 +332,22 @@ var tagNames = [...]string{
func (t Tag) String() string {
if int(t) < len(tagNames) {
- s := tagNames[t];
+ s := tagNames[t]
if s != "" {
return s
}
}
- return strconv.Itoa(int(t));
+ return strconv.Itoa(int(t))
}
func (t Tag) GoString() string {
if int(t) < len(tagNames) {
- s := tagNames[t];
+ s := tagNames[t]
if s != "" {
return "dwarf.Tag" + s
}
}
- return "dwarf.Tag(" + strconv.Itoa64(int64(t)) + ")";
+ return "dwarf.Tag(" + strconv.Itoa64(int64(t)) + ")"
}
// Location expression operators.
@@ -356,78 +356,78 @@ func (t Tag) GoString() string {
// This package does not implement full expressions;
// the opPlusUconst operator is expected by the type parser.
const (
- opAddr = 0x03; /* 1 op, const addr */
- opDeref = 0x06;
- opConst1u = 0x08; /* 1 op, 1 byte const */
- opConst1s = 0x09; /* " signed */
- opConst2u = 0x0A; /* 1 op, 2 byte const */
- opConst2s = 0x0B; /* " signed */
- opConst4u = 0x0C; /* 1 op, 4 byte const */
- opConst4s = 0x0D; /* " signed */
- opConst8u = 0x0E; /* 1 op, 8 byte const */
- opConst8s = 0x0F; /* " signed */
- opConstu = 0x10; /* 1 op, LEB128 const */
- opConsts = 0x11; /* " signed */
- opDup = 0x12;
- opDrop = 0x13;
- opOver = 0x14;
- opPick = 0x15; /* 1 op, 1 byte stack index */
- opSwap = 0x16;
- opRot = 0x17;
- opXderef = 0x18;
- opAbs = 0x19;
- opAnd = 0x1A;
- opDiv = 0x1B;
- opMinus = 0x1C;
- opMod = 0x1D;
- opMul = 0x1E;
- opNeg = 0x1F;
- opNot = 0x20;
- opOr = 0x21;
- opPlus = 0x22;
- opPlusUconst = 0x23; /* 1 op, ULEB128 addend */
- opShl = 0x24;
- opShr = 0x25;
- opShra = 0x26;
- opXor = 0x27;
- opSkip = 0x2F; /* 1 op, signed 2-byte constant */
- opBra = 0x28; /* 1 op, signed 2-byte constant */
- opEq = 0x29;
- opGe = 0x2A;
- opGt = 0x2B;
- opLe = 0x2C;
- opLt = 0x2D;
- opNe = 0x2E;
- opLit0 = 0x30;
+ opAddr = 0x03 /* 1 op, const addr */
+ opDeref = 0x06
+ opConst1u = 0x08 /* 1 op, 1 byte const */
+ opConst1s = 0x09 /* " signed */
+ opConst2u = 0x0A /* 1 op, 2 byte const */
+ opConst2s = 0x0B /* " signed */
+ opConst4u = 0x0C /* 1 op, 4 byte const */
+ opConst4s = 0x0D /* " signed */
+ opConst8u = 0x0E /* 1 op, 8 byte const */
+ opConst8s = 0x0F /* " signed */
+ opConstu = 0x10 /* 1 op, LEB128 const */
+ opConsts = 0x11 /* " signed */
+ opDup = 0x12
+ opDrop = 0x13
+ opOver = 0x14
+ opPick = 0x15 /* 1 op, 1 byte stack index */
+ opSwap = 0x16
+ opRot = 0x17
+ opXderef = 0x18
+ opAbs = 0x19
+ opAnd = 0x1A
+ opDiv = 0x1B
+ opMinus = 0x1C
+ opMod = 0x1D
+ opMul = 0x1E
+ opNeg = 0x1F
+ opNot = 0x20
+ opOr = 0x21
+ opPlus = 0x22
+ opPlusUconst = 0x23 /* 1 op, ULEB128 addend */
+ opShl = 0x24
+ opShr = 0x25
+ opShra = 0x26
+ opXor = 0x27
+ opSkip = 0x2F /* 1 op, signed 2-byte constant */
+ opBra = 0x28 /* 1 op, signed 2-byte constant */
+ opEq = 0x29
+ opGe = 0x2A
+ opGt = 0x2B
+ opLe = 0x2C
+ opLt = 0x2D
+ opNe = 0x2E
+ opLit0 = 0x30
/* OpLitN = OpLit0 + N for N = 0..31 */
- opReg0 = 0x50;
+ opReg0 = 0x50
/* OpRegN = OpReg0 + N for N = 0..31 */
- opBreg0 = 0x70; /* 1 op, signed LEB128 constant */
+ opBreg0 = 0x70 /* 1 op, signed LEB128 constant */
/* OpBregN = OpBreg0 + N for N = 0..31 */
- opRegx = 0x90; /* 1 op, ULEB128 register */
- opFbreg = 0x91; /* 1 op, SLEB128 offset */
- opBregx = 0x92; /* 2 op, ULEB128 reg; SLEB128 off */
- opPiece = 0x93; /* 1 op, ULEB128 size of piece */
- opDerefSize = 0x94; /* 1-byte size of data retrieved */
- opXderefSize = 0x95; /* 1-byte size of data retrieved */
- opNop = 0x96;
+ opRegx = 0x90 /* 1 op, ULEB128 register */
+ opFbreg = 0x91 /* 1 op, SLEB128 offset */
+ opBregx = 0x92 /* 2 op, ULEB128 reg; SLEB128 off */
+ opPiece = 0x93 /* 1 op, ULEB128 size of piece */
+ opDerefSize = 0x94 /* 1-byte size of data retrieved */
+ opXderefSize = 0x95 /* 1-byte size of data retrieved */
+ opNop = 0x96
/* next four new in Dwarf v3 */
- opPushObjAddr = 0x97;
- opCall2 = 0x98; /* 2-byte offset of DIE */
- opCall4 = 0x99; /* 4-byte offset of DIE */
- opCallRef = 0x9A; /* 4- or 8- byte offset of DIE */
+ opPushObjAddr = 0x97
+ opCall2 = 0x98 /* 2-byte offset of DIE */
+ opCall4 = 0x99 /* 4-byte offset of DIE */
+ opCallRef = 0x9A /* 4- or 8- byte offset of DIE */
/* 0xE0-0xFF reserved for user-specific */
)
// Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry.
const (
- encAddress = 0x01;
- encBoolean = 0x02;
- encComplexFloat = 0x03;
- encFloat = 0x04;
- encSigned = 0x05;
- encSignedChar = 0x06;
- encUnsigned = 0x07;
- encUnsignedChar = 0x08;
- encImaginaryFloat = 0x09;
+ encAddress = 0x01
+ encBoolean = 0x02
+ encComplexFloat = 0x03
+ encFloat = 0x04
+ encSigned = 0x05
+ encSignedChar = 0x06
+ encUnsigned = 0x07
+ encUnsignedChar = 0x08
+ encImaginaryFloat = 0x09
)
diff --git a/src/pkg/debug/dwarf/entry.go b/src/pkg/debug/dwarf/entry.go
index a4f013c39..5f739c426 100644
--- a/src/pkg/debug/dwarf/entry.go
+++ b/src/pkg/debug/dwarf/entry.go
@@ -14,14 +14,14 @@ import "os"
// a single entry's description: a sequence of attributes
type abbrev struct {
- tag Tag;
- children bool;
- field []afield;
+ tag Tag
+ children bool
+ field []afield
}
type afield struct {
- attr Attr;
- fmt format;
+ attr Attr
+ fmt format
}
// a map from entry format ids to their descriptions
@@ -34,74 +34,74 @@ func (d *Data) parseAbbrev(off uint32) (abbrevTable, os.Error) {
return m, nil
}
- data := d.abbrev;
+ data := d.abbrev
if off > uint32(len(data)) {
data = nil
} else {
data = data[off:]
}
- b := makeBuf(d, "abbrev", 0, data, 0);
+ b := makeBuf(d, "abbrev", 0, data, 0)
// Error handling is simplified by the buf getters
// returning an endless stream of 0s after an error.
- m := make(abbrevTable);
+ m := make(abbrevTable)
for {
// Table ends with id == 0.
- id := uint32(b.uint());
+ id := uint32(b.uint())
if id == 0 {
break
}
// Walk over attributes, counting.
- n := 0;
- b1 := b; // Read from copy of b.
- b1.uint();
- b1.uint8();
+ n := 0
+ b1 := b // Read from copy of b.
+ b1.uint()
+ b1.uint8()
for {
- tag := b1.uint();
- fmt := b1.uint();
+ tag := b1.uint()
+ fmt := b1.uint()
if tag == 0 && fmt == 0 {
break
}
- n++;
+ n++
}
if b1.err != nil {
return nil, b1.err
}
// Walk over attributes again, this time writing them down.
- var a abbrev;
- a.tag = Tag(b.uint());
- a.children = b.uint8() != 0;
- a.field = make([]afield, n);
+ var a abbrev
+ a.tag = Tag(b.uint())
+ a.children = b.uint8() != 0
+ a.field = make([]afield, n)
for i := range a.field {
- a.field[i].attr = Attr(b.uint());
- a.field[i].fmt = format(b.uint());
+ a.field[i].attr = Attr(b.uint())
+ a.field[i].fmt = format(b.uint())
}
- b.uint();
- b.uint();
+ b.uint()
+ b.uint()
- m[id] = a;
+ m[id] = a
}
if b.err != nil {
return nil, b.err
}
- d.abbrevCache[off] = m;
- return m, nil;
+ d.abbrevCache[off] = m
+ return m, nil
}
// An entry is a sequence of attribute/value pairs.
type Entry struct {
- Offset Offset; // offset of Entry in DWARF info
- Tag Tag; // tag (kind of Entry)
- Children bool; // whether Entry is followed by children
- Field []Field;
+ Offset Offset // offset of Entry in DWARF info
+ Tag Tag // tag (kind of Entry)
+ Children bool // whether Entry is followed by children
+ Field []Field
}
// A Field is a single attribute/value pair in an Entry.
type Field struct {
- Attr Attr;
- Val interface{};
+ Attr Attr
+ Val interface{}
}
// Val returns the value associated with attribute Attr in Entry,
@@ -117,7 +117,7 @@ func (e *Entry) Val(a Attr) interface{} {
return f.Val
}
}
- return nil;
+ return nil
}
// An Offset represents the location of an Entry within the DWARF info.
@@ -127,25 +127,25 @@ type Offset uint32
// Entry reads a single entry from buf, decoding
// according to the given abbreviation table.
func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry {
- off := b.off;
- id := uint32(b.uint());
+ off := b.off
+ id := uint32(b.uint())
if id == 0 {
return &Entry{}
}
- a, ok := atab[id];
+ a, ok := atab[id]
if !ok {
- b.error("unknown abbreviation table index");
- return nil;
+ b.error("unknown abbreviation table index")
+ return nil
}
e := &Entry{
Offset: off,
Tag: a.tag,
Children: a.children,
Field: make([]Field, len(a.field)),
- };
+ }
for i := range e.Field {
- e.Field[i].Attr = a.field[i].attr;
- fmt := a.field[i].fmt;
+ e.Field[i].Attr = a.field[i].attr
+ fmt := a.field[i].fmt
if fmt == formIndirect {
fmt = format(b.uint())
}
@@ -204,24 +204,24 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry {
case formString:
val = b.string()
case formStrp:
- off := b.uint32(); // offset into .debug_str
+ off := b.uint32() // offset into .debug_str
if b.err != nil {
return nil
}
- b1 := makeBuf(b.dwarf, "str", 0, b.dwarf.str, 0);
- b1.skip(int(off));
- val = b1.string();
+ b1 := makeBuf(b.dwarf, "str", 0, b.dwarf.str, 0)
+ b1.skip(int(off))
+ val = b1.string()
if b1.err != nil {
- b.err = b1.err;
- return nil;
+ b.err = b1.err
+ return nil
}
}
- e.Field[i].Val = val;
+ e.Field[i].Val = val
}
if b.err != nil {
return nil
}
- return e;
+ return e
}
// A Reader allows reading Entry structures from a DWARF ``info'' section.
@@ -230,58 +230,58 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry {
// If an entry has children, its Children field will be true, and the children
// follow, terminated by an Entry with Tag 0.
type Reader struct {
- b buf;
- d *Data;
- err os.Error;
- unit int;
- lastChildren bool; // .Children of last entry returned by Next
- lastSibling Offset; // .Val(AttrSibling) of last entry returned by Next
+ b buf
+ d *Data
+ err os.Error
+ unit int
+ lastChildren bool // .Children of last entry returned by Next
+ lastSibling Offset // .Val(AttrSibling) of last entry returned by Next
}
// Reader returns a new Reader for Data.
// The reader is positioned at byte offset 0 in the DWARF ``info'' section.
func (d *Data) Reader() *Reader {
- r := &Reader{d: d};
- r.Seek(0);
- return r;
+ r := &Reader{d: d}
+ r.Seek(0)
+ return r
}
// Seek positions the Reader at offset off in the encoded entry stream.
// Offset 0 can be used to denote the first entry.
func (r *Reader) Seek(off Offset) {
- d := r.d;
- r.err = nil;
- r.lastChildren = false;
+ d := r.d
+ r.err = nil
+ r.lastChildren = false
if off == 0 {
if len(d.unit) == 0 {
return
}
- u := &d.unit[0];
- r.unit = 0;
- r.b = makeBuf(r.d, "info", u.off, u.data, u.addrsize);
- return;
+ u := &d.unit[0]
+ r.unit = 0
+ r.b = makeBuf(r.d, "info", u.off, u.data, u.addrsize)
+ return
}
// TODO(rsc): binary search (maybe a new package)
- var i int;
- var u *unit;
+ var i int
+ var u *unit
for i = range d.unit {
- u = &d.unit[i];
+ u = &d.unit[i]
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:], u.addrsize);
- return;
+ r.unit = i
+ r.b = makeBuf(r.d, "info", off, u.data[off-u.off:], u.addrsize)
+ return
}
}
- r.err = os.NewError("offset out of range");
+ r.err = os.NewError("offset out of range")
}
// 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) {
- r.unit++;
- u := &r.d.unit[r.unit];
- r.b = makeBuf(r.d, "info", u.off, u.data, u.addrsize);
+ r.unit++
+ u := &r.d.unit[r.unit]
+ r.b = makeBuf(r.d, "info", u.off, u.data, u.addrsize)
}
}
@@ -293,25 +293,25 @@ func (r *Reader) Next() (*Entry, os.Error) {
if r.err != nil {
return nil, r.err
}
- r.maybeNextUnit();
+ r.maybeNextUnit()
if len(r.b.data) == 0 {
return nil, nil
}
- u := &r.d.unit[r.unit];
- e := r.b.entry(u.atable, u.base);
+ u := &r.d.unit[r.unit]
+ e := r.b.entry(u.atable, u.base)
if r.b.err != nil {
- r.err = r.b.err;
- return nil, r.err;
+ r.err = r.b.err
+ return nil, r.err
}
if e != nil {
- r.lastChildren = e.Children;
+ r.lastChildren = e.Children
if r.lastChildren {
r.lastSibling, _ = e.Val(AttrSibling).(Offset)
}
} else {
r.lastChildren = false
}
- return e, nil;
+ return e, nil
}
// SkipChildren skips over the child entries associated with
@@ -327,12 +327,12 @@ func (r *Reader) SkipChildren() {
// sibling, so we can avoid decoding the
// child subtrees.
if r.lastSibling >= r.b.off {
- r.Seek(r.lastSibling);
- return;
+ r.Seek(r.lastSibling)
+ return
}
for {
- e, err := r.Next();
+ e, err := r.Next()
if err != nil || e == nil || e.Tag == 0 {
break
}
diff --git a/src/pkg/debug/dwarf/open.go b/src/pkg/debug/dwarf/open.go
index a5cb1a103..3a1b00311 100644
--- a/src/pkg/debug/dwarf/open.go
+++ b/src/pkg/debug/dwarf/open.go
@@ -8,29 +8,29 @@
package dwarf
import (
- "encoding/binary";
- "os";
+ "encoding/binary"
+ "os"
)
// Data represents the DWARF debugging information
// loaded from an executable file (for example, an ELF or Mach-O executable).
type Data struct {
// raw data
- abbrev []byte;
- aranges []byte;
- frame []byte;
- info []byte;
- line []byte;
- pubnames []byte;
- ranges []byte;
- str []byte;
+ abbrev []byte
+ aranges []byte
+ frame []byte
+ info []byte
+ line []byte
+ pubnames []byte
+ ranges []byte
+ str []byte
// parsed data
- abbrevCache map[uint32]abbrevTable;
- addrsize int;
- order binary.ByteOrder;
- typeCache map[Offset]Type;
- unit []unit;
+ abbrevCache map[uint32]abbrevTable
+ addrsize int
+ order binary.ByteOrder
+ typeCache map[Offset]Type
+ unit []unit
}
// New returns a new Data object initialized from the given parameters.
@@ -52,14 +52,14 @@ func New(abbrev, aranges, frame, info, line, pubnames, ranges, str []byte) (*Dat
str: str,
abbrevCache: make(map[uint32]abbrevTable),
typeCache: make(map[Offset]Type),
- };
+ }
// Sniff .debug_info to figure out byte order.
// bytes 4:6 are the version, a tiny 16-bit number (1, 2, 3).
if len(d.info) < 6 {
return nil, DecodeError{"info", Offset(len(d.info)), "too short"}
}
- x, y := d.info[4], d.info[5];
+ x, y := d.info[4], d.info[5]
switch {
case x == 0 && y == 0:
return nil, DecodeError{"info", 4, "unsupported version 0"}
@@ -71,10 +71,10 @@ func New(abbrev, aranges, frame, info, line, pubnames, ranges, str []byte) (*Dat
return nil, DecodeError{"info", 4, "cannot determine byte order"}
}
- u, err := d.parseUnits();
+ u, err := d.parseUnits()
if err != nil {
return nil, err
}
- d.unit = u;
- return d, nil;
+ d.unit = u
+ return d, nil
}
diff --git a/src/pkg/debug/dwarf/type.go b/src/pkg/debug/dwarf/type.go
index bf57fd4bf..5d4a51653 100644
--- a/src/pkg/debug/dwarf/type.go
+++ b/src/pkg/debug/dwarf/type.go
@@ -9,259 +9,259 @@
package dwarf
import (
- "os";
- "strconv";
+ "os"
+ "strconv"
)
// A Type conventionally represents a pointer to any of the
// specific Type structures (CharType, StructType, etc.).
type Type interface {
- Common() *CommonType;
- String() string;
- Size() int64;
+ Common() *CommonType
+ String() string
+ Size() int64
}
// A CommonType holds fields common to multiple types.
// If a field is not known or not applicable for a given type,
// the zero value is used.
type CommonType struct {
- ByteSize int64; // size of value of this type, in bytes
- Name string; // name that can be used to refer to type
+ ByteSize int64 // size of value of this type, in bytes
+ Name string // name that can be used to refer to type
}
-func (c *CommonType) Common() *CommonType { return c }
+func (c *CommonType) Common() *CommonType { return c }
-func (c *CommonType) Size() int64 { return c.ByteSize }
+func (c *CommonType) Size() int64 { return c.ByteSize }
// Basic types
// A BasicType holds fields common to all basic types.
type BasicType struct {
- CommonType;
- BitSize int64;
- BitOffset int64;
+ CommonType
+ BitSize int64
+ BitOffset int64
}
-func (b *BasicType) Basic() *BasicType { return b }
+func (b *BasicType) Basic() *BasicType { return b }
func (t *BasicType) String() string {
if t.Name != "" {
return t.Name
}
- return "?";
+ return "?"
}
// A CharType represents a signed character type.
type CharType struct {
- BasicType;
+ BasicType
}
// A UcharType represents an unsigned character type.
type UcharType struct {
- BasicType;
+ BasicType
}
// An IntType represents a signed integer type.
type IntType struct {
- BasicType;
+ BasicType
}
// A UintType represents an unsigned integer type.
type UintType struct {
- BasicType;
+ BasicType
}
// A FloatType represents a floating point type.
type FloatType struct {
- BasicType;
+ BasicType
}
// A ComplexType represents a complex floating point type.
type ComplexType struct {
- BasicType;
+ BasicType
}
// A BoolType represents a boolean type.
type BoolType struct {
- BasicType;
+ BasicType
}
// An AddrType represents a machine address type.
type AddrType struct {
- BasicType;
+ BasicType
}
// qualifiers
// A QualType represents a type that has the C/C++ "const", "restrict", or "volatile" qualifier.
type QualType struct {
- CommonType;
- Qual string;
- Type Type;
+ CommonType
+ Qual string
+ Type Type
}
-func (t *QualType) String() string { return t.Qual + " " + t.Type.String() }
+func (t *QualType) String() string { return t.Qual + " " + t.Type.String() }
-func (t *QualType) Size() int64 { return t.Type.Size() }
+func (t *QualType) Size() int64 { return t.Type.Size() }
// An ArrayType represents a fixed size array type.
type ArrayType struct {
- CommonType;
- Type Type;
- StrideBitSize int64; // if > 0, number of bits to hold each element
- Count int64; // if == -1, an incomplete array, like char x[].
+ CommonType
+ Type Type
+ StrideBitSize int64 // if > 0, number of bits to hold each element
+ Count int64 // if == -1, an incomplete array, like char x[].
}
func (t *ArrayType) String() string {
return "[" + strconv.Itoa64(t.Count) + "]" + t.Type.String()
}
-func (t *ArrayType) Size() int64 { return t.Count * t.Type.Size() }
+func (t *ArrayType) Size() int64 { return t.Count * t.Type.Size() }
// A VoidType represents the C void type.
type VoidType struct {
- CommonType;
+ CommonType
}
-func (t *VoidType) String() string { return "void" }
+func (t *VoidType) String() string { return "void" }
// A PtrType represents a pointer type.
type PtrType struct {
- CommonType;
- Type Type;
+ CommonType
+ Type Type
}
-func (t *PtrType) String() string { return "*" + t.Type.String() }
+func (t *PtrType) String() string { return "*" + t.Type.String() }
// A StructType represents a struct, union, or C++ class type.
type StructType struct {
- CommonType;
- StructName string;
- Kind string; // "struct", "union", or "class".
- Field []*StructField;
- Incomplete bool; // if true, struct, union, class is declared but not defined
+ CommonType
+ StructName string
+ Kind string // "struct", "union", or "class".
+ Field []*StructField
+ Incomplete bool // if true, struct, union, class is declared but not defined
}
// A StructField represents a field in a struct, union, or C++ class type.
type StructField struct {
- Name string;
- Type Type;
- ByteOffset int64;
- ByteSize int64;
- BitOffset int64; // within the ByteSize bytes at ByteOffset
- BitSize int64; // zero if not a bit field
+ Name string
+ Type Type
+ ByteOffset int64
+ ByteSize int64
+ BitOffset int64 // within the ByteSize bytes at ByteOffset
+ BitSize int64 // zero if not a bit field
}
func (t *StructType) String() string {
if t.StructName != "" {
return t.Kind + " " + t.StructName
}
- return t.Defn();
+ return t.Defn()
}
func (t *StructType) Defn() string {
- s := t.Kind;
+ s := t.Kind
if t.StructName != "" {
s += " " + t.StructName
}
if t.Incomplete {
- s += " /*incomplete*/";
- return s;
+ s += " /*incomplete*/"
+ return s
}
- s += " {";
+ s += " {"
for i, f := range t.Field {
if i > 0 {
s += "; "
}
- s += f.Name + " " + f.Type.String();
- s += "@" + strconv.Itoa64(f.ByteOffset);
+ s += f.Name + " " + f.Type.String()
+ s += "@" + strconv.Itoa64(f.ByteOffset)
if f.BitSize > 0 {
- s += " : " + strconv.Itoa64(f.BitSize);
- s += "@" + strconv.Itoa64(f.BitOffset);
+ s += " : " + strconv.Itoa64(f.BitSize)
+ s += "@" + strconv.Itoa64(f.BitOffset)
}
}
- s += "}";
- return s;
+ s += "}"
+ return s
}
// An EnumType represents an enumerated type.
// The only indication of its native integer type is its ByteSize
// (inside CommonType).
type EnumType struct {
- CommonType;
- EnumName string;
- Val []*EnumValue;
+ CommonType
+ EnumName string
+ Val []*EnumValue
}
// An EnumValue represents a single enumeration value.
type EnumValue struct {
- Name string;
- Val int64;
+ Name string
+ Val int64
}
func (t *EnumType) String() string {
- s := "enum";
+ s := "enum"
if t.EnumName != "" {
s += " " + t.EnumName
}
- s += " {";
+ s += " {"
for i, v := range t.Val {
if i > 0 {
s += "; "
}
- s += v.Name + "=" + strconv.Itoa64(v.Val);
+ s += v.Name + "=" + strconv.Itoa64(v.Val)
}
- s += "}";
- return s;
+ s += "}"
+ return s
}
// A FuncType represents a function type.
type FuncType struct {
- CommonType;
- ReturnType Type;
- ParamType []Type;
+ CommonType
+ ReturnType Type
+ ParamType []Type
}
func (t *FuncType) String() string {
- s := "func(";
+ s := "func("
for i, t := range t.ParamType {
if i > 0 {
s += ", "
}
- s += t.String();
+ s += t.String()
}
- s += ")";
+ s += ")"
if t.ReturnType != nil {
s += " " + t.ReturnType.String()
}
- return s;
+ return s
}
// A DotDotDotType represents the variadic ... function parameter.
type DotDotDotType struct {
- CommonType;
+ CommonType
}
-func (t *DotDotDotType) String() string { return "..." }
+func (t *DotDotDotType) String() string { return "..." }
// A TypedefType represents a named type.
type TypedefType struct {
- CommonType;
- Type Type;
+ CommonType
+ Type Type
}
-func (t *TypedefType) String() string { return t.Name }
+func (t *TypedefType) String() string { return t.Name }
-func (t *TypedefType) Size() int64 { return t.Type.Size() }
+func (t *TypedefType) Size() int64 { return t.Type.Size() }
func (d *Data) Type(off Offset) (Type, os.Error) {
if t, ok := d.typeCache[off]; ok {
return t, nil
}
- r := d.Reader();
- r.Seek(off);
- e, err := r.Next();
+ r := d.Reader()
+ r.Seek(off)
+ e, err := r.Next()
if err != nil {
return nil, err
}
@@ -272,42 +272,42 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// Parse type from Entry.
// Must always set d.typeCache[off] before calling
// d.Type recursively, to handle circular types correctly.
- var typ Type;
+ var typ Type
// Get next child; set err if error happens.
next := func() *Entry {
if !e.Children {
return nil
}
- kid, err1 := r.Next();
+ kid, err1 := r.Next()
if err1 != nil {
- err = err1;
- return nil;
+ err = err1
+ return nil
}
if kid == nil {
- err = DecodeError{"info", r.b.off, "unexpected end of DWARF entries"};
- return nil;
+ err = DecodeError{"info", r.b.off, "unexpected end of DWARF entries"}
+ return nil
}
if kid.Tag == 0 {
return nil
}
- return kid;
- };
+ return kid
+ }
// Get Type referred to by Entry's AttrType field.
// Set err if error happens. Not having a type is an error.
typeOf := func(e *Entry) Type {
- toff, ok := e.Val(AttrType).(Offset);
+ toff, ok := e.Val(AttrType).(Offset)
if !ok {
// It appears that no Type means "void".
return new(VoidType)
}
- var t Type;
+ var t Type
if t, err = d.Type(toff); err != nil {
return nil
}
- return t;
- };
+ return t
+ }
switch e.Tag {
case TagArrayType:
@@ -319,24 +319,24 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// Children:
// TagSubrangeType or TagEnumerationType giving one dimension.
// dimensions are in left to right order.
- t := new(ArrayType);
- typ = t;
- d.typeCache[off] = t;
+ t := new(ArrayType)
+ typ = t
+ d.typeCache[off] = t
if t.Type = typeOf(e); err != nil {
goto Error
}
- t.StrideBitSize, _ = e.Val(AttrStrideSize).(int64);
+ t.StrideBitSize, _ = e.Val(AttrStrideSize).(int64)
// Accumulate dimensions,
- ndim := 0;
+ ndim := 0
for kid := next(); kid != nil; kid = next() {
// TODO(rsc): Can also be TagEnumerationType
// but haven't seen that in the wild yet.
switch kid.Tag {
case TagSubrangeType:
- max, ok := kid.Val(AttrUpperBound).(int64);
+ max, ok := kid.Val(AttrUpperBound).(int64)
if !ok {
- max = -2 // Count == -1, as in x[].
+ max = -2 // Count == -1, as in x[].
}
if ndim == 0 {
t.Count = max + 1
@@ -345,15 +345,15 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// Create new array type underneath this one.
t.Type = &ArrayType{Type: t.Type, Count: max + 1}
}
- ndim++;
+ ndim++
case TagEnumerationType:
- err = DecodeError{"info", kid.Offset, "cannot handle enumeration type as array bound"};
- goto Error;
+ err = DecodeError{"info", kid.Offset, "cannot handle enumeration type as array bound"}
+ goto Error
}
}
if ndim == 0 {
- err = DecodeError{"info", e.Offset, "missing dimension for array"};
- goto Error;
+ err = DecodeError{"info", e.Offset, "missing dimension for array"}
+ goto Error
}
case TagBaseType:
@@ -364,16 +364,16 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// AttrByteSize: size of type in bytes [required]
// AttrBitOffset: for sub-byte types, size in bits
// AttrBitSize: for sub-byte types, bit offset of high order bit in the AttrByteSize bytes
- name, _ := e.Val(AttrName).(string);
- enc, ok := e.Val(AttrEncoding).(int64);
+ name, _ := e.Val(AttrName).(string)
+ enc, ok := e.Val(AttrEncoding).(int64)
if !ok {
- err = DecodeError{"info", e.Offset, "missing encoding attribute for " + name};
- goto Error;
+ err = DecodeError{"info", e.Offset, "missing encoding attribute for " + name}
+ goto Error
}
switch enc {
default:
- err = DecodeError{"info", e.Offset, "unrecognized encoding attribute value"};
- goto Error;
+ err = DecodeError{"info", e.Offset, "unrecognized encoding attribute value"}
+ goto Error
case encAddress:
typ = new(AddrType)
@@ -392,13 +392,13 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
case encUnsignedChar:
typ = new(UcharType)
}
- d.typeCache[off] = typ;
+ d.typeCache[off] = typ
t := typ.(interface {
- Basic() *BasicType;
- }).Basic();
- t.Name = name;
- t.BitSize, _ = e.Val(AttrBitSize).(int64);
- t.BitOffset, _ = e.Val(AttrBitOffset).(int64);
+ Basic() *BasicType
+ }).Basic()
+ t.Name = name
+ t.BitSize, _ = e.Val(AttrBitSize).(int64)
+ t.BitOffset, _ = e.Val(AttrBitOffset).(int64)
case TagClassType, TagStructType, TagUnionType:
// Structure, union, or class type. (DWARF v2 §5.5)
@@ -415,9 +415,9 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// AttrBitSize: bit size for bit fields
// AttrDataMemberLoc: location within struct [required for struct, class]
// There is much more to handle C++, all ignored for now.
- t := new(StructType);
- typ = t;
- d.typeCache[off] = t;
+ t := new(StructType)
+ typ = t
+ d.typeCache[off] = t
switch e.Tag {
case TagClassType:
t.Kind = "class"
@@ -426,41 +426,41 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
case TagUnionType:
t.Kind = "union"
}
- t.StructName, _ = e.Val(AttrName).(string);
- t.Incomplete = e.Val(AttrDeclaration) != nil;
- t.Field = make([]*StructField, 0, 8);
+ t.StructName, _ = e.Val(AttrName).(string)
+ t.Incomplete = e.Val(AttrDeclaration) != nil
+ t.Field = make([]*StructField, 0, 8)
for kid := next(); kid != nil; kid = next() {
if kid.Tag == TagMember {
- f := new(StructField);
+ f := new(StructField)
if f.Type = typeOf(kid); err != nil {
goto Error
}
if loc, ok := kid.Val(AttrDataMemberLoc).([]byte); ok {
- b := makeBuf(d, "location", 0, loc, d.addrsize);
+ b := makeBuf(d, "location", 0, loc, d.addrsize)
if b.uint8() != opPlusUconst {
- err = DecodeError{"info", kid.Offset, "unexpected opcode"};
- goto Error;
+ err = DecodeError{"info", kid.Offset, "unexpected opcode"}
+ goto Error
}
- f.ByteOffset = int64(b.uint());
+ f.ByteOffset = int64(b.uint())
if b.err != nil {
- err = b.err;
- goto Error;
+ err = b.err
+ goto Error
}
}
- f.Name, _ = kid.Val(AttrName).(string);
- f.ByteSize, _ = kid.Val(AttrByteSize).(int64);
- f.BitOffset, _ = kid.Val(AttrBitOffset).(int64);
- f.BitSize, _ = kid.Val(AttrBitSize).(int64);
- n := len(t.Field);
+ f.Name, _ = kid.Val(AttrName).(string)
+ f.ByteSize, _ = kid.Val(AttrByteSize).(int64)
+ f.BitOffset, _ = kid.Val(AttrBitOffset).(int64)
+ f.BitSize, _ = kid.Val(AttrBitSize).(int64)
+ n := len(t.Field)
if n >= cap(t.Field) {
- fld := make([]*StructField, n, n*2);
+ fld := make([]*StructField, n, n*2)
for i, f := range t.Field {
fld[i] = f
}
- t.Field = fld;
+ t.Field = fld
}
- t.Field = t.Field[0 : n+1];
- t.Field[n] = f;
+ t.Field = t.Field[0 : n+1]
+ t.Field[n] = f
}
}
@@ -468,9 +468,9 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// Type modifier (DWARF v2 §5.2)
// Attributes:
// AttrType: subtype
- t := new(QualType);
- typ = t;
- d.typeCache[off] = t;
+ t := new(QualType)
+ typ = t
+ d.typeCache[off] = t
if t.Type = typeOf(e); err != nil {
goto Error
}
@@ -492,26 +492,26 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// TagEnumerator:
// AttrName: name of constant
// AttrConstValue: value of constant
- t := new(EnumType);
- typ = t;
- d.typeCache[off] = t;
- t.EnumName, _ = e.Val(AttrName).(string);
- t.Val = make([]*EnumValue, 0, 8);
+ t := new(EnumType)
+ typ = t
+ d.typeCache[off] = t
+ t.EnumName, _ = e.Val(AttrName).(string)
+ t.Val = make([]*EnumValue, 0, 8)
for kid := next(); kid != nil; kid = next() {
if kid.Tag == TagEnumerator {
- f := new(EnumValue);
- f.Name, _ = kid.Val(AttrName).(string);
- f.Val, _ = kid.Val(AttrConstValue).(int64);
- n := len(t.Val);
+ f := new(EnumValue)
+ f.Name, _ = kid.Val(AttrName).(string)
+ f.Val, _ = kid.Val(AttrConstValue).(int64)
+ n := len(t.Val)
if n >= cap(t.Val) {
- val := make([]*EnumValue, n, n*2);
+ val := make([]*EnumValue, n, n*2)
for i, f := range t.Val {
val[i] = f
}
- t.Val = val;
+ t.Val = val
}
- t.Val = t.Val[0 : n+1];
- t.Val[n] = f;
+ t.Val = t.Val[0 : n+1]
+ t.Val[n] = f
}
}
@@ -520,14 +520,14 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// Attributes:
// AttrType: subtype [not required! void* has no AttrType]
// AttrAddrClass: address class [ignored]
- t := new(PtrType);
- typ = t;
- d.typeCache[off] = t;
+ t := new(PtrType)
+ typ = t
+ d.typeCache[off] = t
if e.Val(AttrType) == nil {
- t.Type = &VoidType{};
- break;
+ t.Type = &VoidType{}
+ break
}
- t.Type = typeOf(e);
+ t.Type = typeOf(e)
case TagSubroutineType:
// Subroutine type. (DWARF v2 §5.7)
@@ -539,15 +539,15 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// TagFormalParameter: typed parameter
// AttrType: type of parameter
// TagUnspecifiedParameter: final ...
- t := new(FuncType);
- typ = t;
- d.typeCache[off] = t;
+ t := new(FuncType)
+ typ = t
+ d.typeCache[off] = t
if t.ReturnType = typeOf(e); err != nil {
goto Error
}
- t.ParamType = make([]Type, 0, 8);
+ t.ParamType = make([]Type, 0, 8)
for kid := next(); kid != nil; kid = next() {
- var tkid Type;
+ var tkid Type
switch kid.Tag {
default:
continue
@@ -558,16 +558,16 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
case TagUnspecifiedParameters:
tkid = &DotDotDotType{}
}
- n := len(t.ParamType);
+ n := len(t.ParamType)
if n >= cap(t.ParamType) {
- param := make([]Type, n, n*2);
+ param := make([]Type, n, n*2)
for i, t := range t.ParamType {
param[i] = t
}
- t.ParamType = param;
+ t.ParamType = param
}
- t.ParamType = t.ParamType[0 : n+1];
- t.ParamType[n] = tkid;
+ t.ParamType = t.ParamType[0 : n+1]
+ t.ParamType[n] = tkid
}
case TagTypedef:
@@ -575,29 +575,29 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
// Attributes:
// AttrName: name [required]
// AttrType: type definition [required]
- t := new(TypedefType);
- typ = t;
- d.typeCache[off] = t;
- t.Name, _ = e.Val(AttrName).(string);
- t.Type = typeOf(e);
+ t := new(TypedefType)
+ typ = t
+ d.typeCache[off] = t
+ t.Name, _ = e.Val(AttrName).(string)
+ t.Type = typeOf(e)
}
if err != nil {
goto Error
}
- b, ok := e.Val(AttrByteSize).(int64);
+ b, ok := e.Val(AttrByteSize).(int64)
if !ok {
b = -1
}
- typ.Common().ByteSize = b;
+ typ.Common().ByteSize = b
- return typ, nil;
+ return typ, nil
Error:
// If the parse fails, take the type out of the cache
// so that the next call with this offset doesn't hit
// the cache and return success.
- d.typeCache[off] = nil, false;
- return nil, err;
+ d.typeCache[off] = nil, false
+ return nil, err
}
diff --git a/src/pkg/debug/dwarf/type_test.go b/src/pkg/debug/dwarf/type_test.go
index 629f0fb16..2c5aabd39 100644
--- a/src/pkg/debug/dwarf/type_test.go
+++ b/src/pkg/debug/dwarf/type_test.go
@@ -5,10 +5,10 @@
package dwarf_test
import (
- . "debug/dwarf";
- "debug/elf";
- "debug/macho";
- "testing";
+ . "debug/dwarf"
+ "debug/elf"
+ "debug/macho"
+ "testing"
)
var typedefTests = map[string]string{
@@ -30,43 +30,43 @@ var typedefTests = map[string]string{
}
func elfData(t *testing.T, name string) *Data {
- f, err := elf.Open(name);
+ f, err := elf.Open(name)
if err != nil {
t.Fatal(err)
}
- d, err := f.DWARF();
+ d, err := f.DWARF()
if err != nil {
t.Fatal(err)
}
- return d;
+ return d
}
func machoData(t *testing.T, name string) *Data {
- f, err := macho.Open(name);
+ f, err := macho.Open(name)
if err != nil {
t.Fatal(err)
}
- d, err := f.DWARF();
+ d, err := f.DWARF()
if err != nil {
t.Fatal(err)
}
- return d;
+ return d
}
-func TestTypedefsELF(t *testing.T) { testTypedefs(t, elfData(t, "testdata/typedef.elf")) }
+func TestTypedefsELF(t *testing.T) { testTypedefs(t, elfData(t, "testdata/typedef.elf")) }
func TestTypedefsMachO(t *testing.T) {
testTypedefs(t, machoData(t, "testdata/typedef.macho"))
}
func testTypedefs(t *testing.T, d *Data) {
- r := d.Reader();
- seen := make(map[string]bool);
+ r := d.Reader()
+ seen := make(map[string]bool)
for {
- e, err := r.Next();
+ e, err := r.Next()
if err != nil {
t.Fatal("r.Next:", err)
}
@@ -74,12 +74,12 @@ func testTypedefs(t *testing.T, d *Data) {
break
}
if e.Tag == TagTypedef {
- typ, err := d.Type(e.Offset);
+ typ, err := d.Type(e.Offset)
if err != nil {
t.Fatal("d.Type:", err)
}
- t1 := typ.(*TypedefType);
- var typstr string;
+ t1 := typ.(*TypedefType)
+ var typstr string
if ts, ok := t1.Type.(*StructType); ok {
typstr = ts.Defn()
} else {
@@ -90,7 +90,7 @@ func testTypedefs(t *testing.T, d *Data) {
if _, ok := seen[t1.Name]; ok {
t.Errorf("multiple definitions for %s", t1.Name)
}
- seen[t1.Name] = true;
+ seen[t1.Name] = true
if typstr != want {
t.Errorf("%s:\n\thave %s\n\twant %s", t1.Name, typstr, want)
}
diff --git a/src/pkg/debug/dwarf/unit.go b/src/pkg/debug/dwarf/unit.go
index eb4e7656e..02cb363b4 100644
--- a/src/pkg/debug/dwarf/unit.go
+++ b/src/pkg/debug/dwarf/unit.go
@@ -5,58 +5,58 @@
package dwarf
import (
- "os";
- "strconv";
+ "os"
+ "strconv"
)
// DWARF debug info is split into a sequence of compilation units.
// Each unit has its own abbreviation table and address size.
type unit struct {
- base Offset; // byte offset of header within the aggregate info
- off Offset; // byte offset of data within the aggregate info
- data []byte;
- atable abbrevTable;
- addrsize int;
+ base Offset // byte offset of header within the aggregate info
+ off Offset // byte offset of data within the aggregate info
+ data []byte
+ atable abbrevTable
+ addrsize int
}
func (d *Data) parseUnits() ([]unit, os.Error) {
// Count units.
- nunit := 0;
- b := makeBuf(d, "info", 0, d.info, 0);
+ nunit := 0
+ b := makeBuf(d, "info", 0, d.info, 0)
for len(b.data) > 0 {
- b.skip(int(b.uint32()));
- nunit++;
+ b.skip(int(b.uint32()))
+ nunit++
}
if b.err != nil {
return nil, b.err
}
// Again, this time writing them down.
- b = makeBuf(d, "info", 0, d.info, 0);
- units := make([]unit, nunit);
+ b = makeBuf(d, "info", 0, d.info, 0)
+ units := make([]unit, nunit)
for i := range units {
- u := &units[i];
- u.base = b.off;
- n := b.uint32();
+ u := &units[i]
+ u.base = b.off
+ n := b.uint32()
if vers := b.uint16(); vers != 2 {
- b.error("unsupported DWARF version " + strconv.Itoa(int(vers)));
- break;
+ b.error("unsupported DWARF version " + strconv.Itoa(int(vers)))
+ break
}
- atable, err := d.parseAbbrev(b.uint32());
+ atable, err := d.parseAbbrev(b.uint32())
if err != nil {
if b.err == nil {
b.err = err
}
- break;
+ break
}
- u.atable = atable;
- u.addrsize = int(b.uint8());
- u.off = b.off;
- u.data = b.bytes(int(n - (2 + 4 + 1)));
+ u.atable = atable
+ u.addrsize = int(b.uint8())
+ u.off = b.off
+ u.data = b.bytes(int(n - (2 + 4 + 1)))
}
if b.err != nil {
return nil, b.err
}
- return units, nil;
+ return units, nil
}
diff --git a/src/pkg/debug/elf/elf.go b/src/pkg/debug/elf/elf.go
index 70a11f6f6..f0e49851b 100644
--- a/src/pkg/debug/elf/elf.go
+++ b/src/pkg/debug/elf/elf.go
@@ -48,13 +48,13 @@ import "strconv"
// Indexes into the Header.Ident array.
const (
- EI_CLASS = 4; /* Class of machine. */
- EI_DATA = 5; /* Data format. */
- EI_VERSION = 6; /* ELF format version. */
- EI_OSABI = 7; /* Operating system / ABI identification */
- EI_ABIVERSION = 8; /* ABI version */
- EI_PAD = 9; /* Start of padding (per SVR4 ABI). */
- EI_NIDENT = 16; /* Size of e_ident array. */
+ EI_CLASS = 4 /* Class of machine. */
+ EI_DATA = 5 /* Data format. */
+ EI_VERSION = 6 /* ELF format version. */
+ EI_OSABI = 7 /* Operating system / ABI identification */
+ EI_ABIVERSION = 8 /* ABI version */
+ EI_PAD = 9 /* Start of padding (per SVR4 ABI). */
+ EI_NIDENT = 16 /* Size of e_ident array. */
)
// Initial magic number for ELF files.
@@ -64,8 +64,8 @@ const ELFMAG = "\177ELF"
type Version byte
const (
- EV_NONE Version = 0;
- EV_CURRENT Version = 1;
+ EV_NONE Version = 0
+ EV_CURRENT Version = 1
)
var versionStrings = []intName{
@@ -73,16 +73,16 @@ var versionStrings = []intName{
intName{1, "EV_CURRENT"},
}
-func (i Version) String() string { return stringName(uint32(i), versionStrings, false) }
-func (i Version) GoString() string { return stringName(uint32(i), versionStrings, true) }
+func (i Version) String() string { return stringName(uint32(i), versionStrings, false) }
+func (i Version) GoString() string { return stringName(uint32(i), versionStrings, true) }
// Class is found in Header.Ident[EI_CLASS] and Header.Class.
type Class byte
const (
- ELFCLASSNONE Class = 0; /* Unknown class. */
- ELFCLASS32 Class = 1; /* 32-bit architecture. */
- ELFCLASS64 Class = 2; /* 64-bit architecture. */
+ ELFCLASSNONE Class = 0 /* Unknown class. */
+ ELFCLASS32 Class = 1 /* 32-bit architecture. */
+ ELFCLASS64 Class = 2 /* 64-bit architecture. */
)
var classStrings = []intName{
@@ -91,16 +91,16 @@ var classStrings = []intName{
intName{2, "ELFCLASS64"},
}
-func (i Class) String() string { return stringName(uint32(i), classStrings, false) }
-func (i Class) GoString() string { return stringName(uint32(i), classStrings, true) }
+func (i Class) String() string { return stringName(uint32(i), classStrings, false) }
+func (i Class) GoString() string { return stringName(uint32(i), classStrings, true) }
// Data is found in Header.Ident[EI_DATA] and Header.Data.
type Data byte
const (
- ELFDATANONE Data = 0; /* Unknown data format. */
- ELFDATA2LSB Data = 1; /* 2's complement little-endian. */
- ELFDATA2MSB Data = 2; /* 2's complement big-endian. */
+ ELFDATANONE Data = 0 /* Unknown data format. */
+ ELFDATA2LSB Data = 1 /* 2's complement little-endian. */
+ ELFDATA2MSB Data = 2 /* 2's complement big-endian. */
)
var dataStrings = []intName{
@@ -109,30 +109,30 @@ var dataStrings = []intName{
intName{2, "ELFDATA2MSB"},
}
-func (i Data) String() string { return stringName(uint32(i), dataStrings, false) }
-func (i Data) GoString() string { return stringName(uint32(i), dataStrings, true) }
+func (i Data) String() string { return stringName(uint32(i), dataStrings, false) }
+func (i Data) GoString() string { return stringName(uint32(i), dataStrings, true) }
// OSABI is found in Header.Ident[EI_OSABI] and Header.OSABI.
type OSABI byte
const (
- ELFOSABI_NONE OSABI = 0; /* UNIX System V ABI */
- ELFOSABI_HPUX OSABI = 1; /* HP-UX operating system */
- ELFOSABI_NETBSD OSABI = 2; /* NetBSD */
- ELFOSABI_LINUX OSABI = 3; /* GNU/Linux */
- ELFOSABI_HURD OSABI = 4; /* GNU/Hurd */
- ELFOSABI_86OPEN OSABI = 5; /* 86Open common IA32 ABI */
- ELFOSABI_SOLARIS OSABI = 6; /* Solaris */
- ELFOSABI_AIX OSABI = 7; /* AIX */
- ELFOSABI_IRIX OSABI = 8; /* IRIX */
- ELFOSABI_FREEBSD OSABI = 9; /* FreeBSD */
- ELFOSABI_TRU64 OSABI = 10; /* TRU64 UNIX */
- ELFOSABI_MODESTO OSABI = 11; /* Novell Modesto */
- ELFOSABI_OPENBSD OSABI = 12; /* OpenBSD */
- ELFOSABI_OPENVMS OSABI = 13; /* Open VMS */
- ELFOSABI_NSK OSABI = 14; /* HP Non-Stop Kernel */
- ELFOSABI_ARM OSABI = 97; /* ARM */
- ELFOSABI_STANDALONE OSABI = 255; /* Standalone (embedded) application */
+ ELFOSABI_NONE OSABI = 0 /* UNIX System V ABI */
+ ELFOSABI_HPUX OSABI = 1 /* HP-UX operating system */
+ ELFOSABI_NETBSD OSABI = 2 /* NetBSD */
+ ELFOSABI_LINUX OSABI = 3 /* GNU/Linux */
+ ELFOSABI_HURD OSABI = 4 /* GNU/Hurd */
+ ELFOSABI_86OPEN OSABI = 5 /* 86Open common IA32 ABI */
+ ELFOSABI_SOLARIS OSABI = 6 /* Solaris */
+ ELFOSABI_AIX OSABI = 7 /* AIX */
+ ELFOSABI_IRIX OSABI = 8 /* IRIX */
+ ELFOSABI_FREEBSD OSABI = 9 /* FreeBSD */
+ ELFOSABI_TRU64 OSABI = 10 /* TRU64 UNIX */
+ ELFOSABI_MODESTO OSABI = 11 /* Novell Modesto */
+ ELFOSABI_OPENBSD OSABI = 12 /* OpenBSD */
+ ELFOSABI_OPENVMS OSABI = 13 /* Open VMS */
+ ELFOSABI_NSK OSABI = 14 /* HP Non-Stop Kernel */
+ ELFOSABI_ARM OSABI = 97 /* ARM */
+ ELFOSABI_STANDALONE OSABI = 255 /* Standalone (embedded) application */
)
var osabiStrings = []intName{
@@ -155,22 +155,22 @@ var osabiStrings = []intName{
intName{255, "ELFOSABI_STANDALONE"},
}
-func (i OSABI) String() string { return stringName(uint32(i), osabiStrings, false) }
-func (i OSABI) GoString() string { return stringName(uint32(i), osabiStrings, true) }
+func (i OSABI) String() string { return stringName(uint32(i), osabiStrings, false) }
+func (i OSABI) GoString() string { return stringName(uint32(i), osabiStrings, true) }
// Type is found in Header.Type.
type Type uint16
const (
- ET_NONE Type = 0; /* Unknown type. */
- ET_REL Type = 1; /* Relocatable. */
- ET_EXEC Type = 2; /* Executable. */
- ET_DYN Type = 3; /* Shared object. */
- ET_CORE Type = 4; /* Core file. */
- ET_LOOS Type = 0xfe00; /* First operating system specific. */
- ET_HIOS Type = 0xfeff; /* Last operating system-specific. */
- ET_LOPROC Type = 0xff00; /* First processor-specific. */
- ET_HIPROC Type = 0xffff; /* Last processor-specific. */
+ ET_NONE Type = 0 /* Unknown type. */
+ ET_REL Type = 1 /* Relocatable. */
+ ET_EXEC Type = 2 /* Executable. */
+ ET_DYN Type = 3 /* Shared object. */
+ ET_CORE Type = 4 /* Core file. */
+ ET_LOOS Type = 0xfe00 /* First operating system specific. */
+ ET_HIOS Type = 0xfeff /* Last operating system-specific. */
+ ET_LOPROC Type = 0xff00 /* First processor-specific. */
+ ET_HIPROC Type = 0xffff /* Last processor-specific. */
)
var typeStrings = []intName{
@@ -185,62 +185,62 @@ var typeStrings = []intName{
intName{0xffff, "ET_HIPROC"},
}
-func (i Type) String() string { return stringName(uint32(i), typeStrings, false) }
-func (i Type) GoString() string { return stringName(uint32(i), typeStrings, true) }
+func (i Type) String() string { return stringName(uint32(i), typeStrings, false) }
+func (i Type) GoString() string { return stringName(uint32(i), typeStrings, true) }
// Machine is found in Header.Machine.
type Machine uint16
const (
- EM_NONE Machine = 0; /* Unknown machine. */
- EM_M32 Machine = 1; /* AT&T WE32100. */
- EM_SPARC Machine = 2; /* Sun SPARC. */
- EM_386 Machine = 3; /* Intel i386. */
- EM_68K Machine = 4; /* Motorola 68000. */
- EM_88K Machine = 5; /* Motorola 88000. */
- EM_860 Machine = 7; /* Intel i860. */
- EM_MIPS Machine = 8; /* MIPS R3000 Big-Endian only. */
- EM_S370 Machine = 9; /* IBM System/370. */
- EM_MIPS_RS3_LE Machine = 10; /* MIPS R3000 Little-Endian. */
- EM_PARISC Machine = 15; /* HP PA-RISC. */
- EM_VPP500 Machine = 17; /* Fujitsu VPP500. */
- EM_SPARC32PLUS Machine = 18; /* SPARC v8plus. */
- EM_960 Machine = 19; /* Intel 80960. */
- EM_PPC Machine = 20; /* PowerPC 32-bit. */
- EM_PPC64 Machine = 21; /* PowerPC 64-bit. */
- EM_S390 Machine = 22; /* IBM System/390. */
- EM_V800 Machine = 36; /* NEC V800. */
- EM_FR20 Machine = 37; /* Fujitsu FR20. */
- EM_RH32 Machine = 38; /* TRW RH-32. */
- EM_RCE Machine = 39; /* Motorola RCE. */
- EM_ARM Machine = 40; /* ARM. */
- EM_SH Machine = 42; /* Hitachi SH. */
- EM_SPARCV9 Machine = 43; /* SPARC v9 64-bit. */
- EM_TRICORE Machine = 44; /* Siemens TriCore embedded processor. */
- EM_ARC Machine = 45; /* Argonaut RISC Core. */
- EM_H8_300 Machine = 46; /* Hitachi H8/300. */
- EM_H8_300H Machine = 47; /* Hitachi H8/300H. */
- EM_H8S Machine = 48; /* Hitachi H8S. */
- EM_H8_500 Machine = 49; /* Hitachi H8/500. */
- EM_IA_64 Machine = 50; /* Intel IA-64 Processor. */
- EM_MIPS_X Machine = 51; /* Stanford MIPS-X. */
- EM_COLDFIRE Machine = 52; /* Motorola ColdFire. */
- EM_68HC12 Machine = 53; /* Motorola M68HC12. */
- EM_MMA Machine = 54; /* Fujitsu MMA. */
- EM_PCP Machine = 55; /* Siemens PCP. */
- EM_NCPU Machine = 56; /* Sony nCPU. */
- EM_NDR1 Machine = 57; /* Denso NDR1 microprocessor. */
- EM_STARCORE Machine = 58; /* Motorola Star*Core processor. */
- EM_ME16 Machine = 59; /* Toyota ME16 processor. */
- EM_ST100 Machine = 60; /* STMicroelectronics ST100 processor. */
- EM_TINYJ Machine = 61; /* Advanced Logic Corp. TinyJ processor. */
- EM_X86_64 Machine = 62; /* Advanced Micro Devices x86-64 */
+ EM_NONE Machine = 0 /* Unknown machine. */
+ EM_M32 Machine = 1 /* AT&T WE32100. */
+ EM_SPARC Machine = 2 /* Sun SPARC. */
+ EM_386 Machine = 3 /* Intel i386. */
+ EM_68K Machine = 4 /* Motorola 68000. */
+ EM_88K Machine = 5 /* Motorola 88000. */
+ EM_860 Machine = 7 /* Intel i860. */
+ EM_MIPS Machine = 8 /* MIPS R3000 Big-Endian only. */
+ EM_S370 Machine = 9 /* IBM System/370. */
+ EM_MIPS_RS3_LE Machine = 10 /* MIPS R3000 Little-Endian. */
+ EM_PARISC Machine = 15 /* HP PA-RISC. */
+ EM_VPP500 Machine = 17 /* Fujitsu VPP500. */
+ EM_SPARC32PLUS Machine = 18 /* SPARC v8plus. */
+ EM_960 Machine = 19 /* Intel 80960. */
+ EM_PPC Machine = 20 /* PowerPC 32-bit. */
+ EM_PPC64 Machine = 21 /* PowerPC 64-bit. */
+ EM_S390 Machine = 22 /* IBM System/390. */
+ EM_V800 Machine = 36 /* NEC V800. */
+ EM_FR20 Machine = 37 /* Fujitsu FR20. */
+ EM_RH32 Machine = 38 /* TRW RH-32. */
+ EM_RCE Machine = 39 /* Motorola RCE. */
+ EM_ARM Machine = 40 /* ARM. */
+ EM_SH Machine = 42 /* Hitachi SH. */
+ EM_SPARCV9 Machine = 43 /* SPARC v9 64-bit. */
+ EM_TRICORE Machine = 44 /* Siemens TriCore embedded processor. */
+ EM_ARC Machine = 45 /* Argonaut RISC Core. */
+ EM_H8_300 Machine = 46 /* Hitachi H8/300. */
+ EM_H8_300H Machine = 47 /* Hitachi H8/300H. */
+ EM_H8S Machine = 48 /* Hitachi H8S. */
+ EM_H8_500 Machine = 49 /* Hitachi H8/500. */
+ EM_IA_64 Machine = 50 /* Intel IA-64 Processor. */
+ EM_MIPS_X Machine = 51 /* Stanford MIPS-X. */
+ EM_COLDFIRE Machine = 52 /* Motorola ColdFire. */
+ EM_68HC12 Machine = 53 /* Motorola M68HC12. */
+ EM_MMA Machine = 54 /* Fujitsu MMA. */
+ EM_PCP Machine = 55 /* Siemens PCP. */
+ EM_NCPU Machine = 56 /* Sony nCPU. */
+ EM_NDR1 Machine = 57 /* Denso NDR1 microprocessor. */
+ EM_STARCORE Machine = 58 /* Motorola Star*Core processor. */
+ EM_ME16 Machine = 59 /* Toyota ME16 processor. */
+ EM_ST100 Machine = 60 /* STMicroelectronics ST100 processor. */
+ EM_TINYJ Machine = 61 /* Advanced Logic Corp. TinyJ processor. */
+ EM_X86_64 Machine = 62 /* Advanced Micro Devices x86-64 */
/* Non-standard or deprecated. */
- EM_486 Machine = 6; /* Intel i486. */
- EM_MIPS_RS4_BE Machine = 10; /* MIPS R4000 Big-Endian */
- EM_ALPHA_STD Machine = 41; /* Digital Alpha (standard value). */
- EM_ALPHA Machine = 0x9026; /* Alpha (written in the absence of an ABI) */
+ EM_486 Machine = 6 /* Intel i486. */
+ EM_MIPS_RS4_BE Machine = 10 /* MIPS R4000 Big-Endian */
+ EM_ALPHA_STD Machine = 41 /* Digital Alpha (standard value). */
+ EM_ALPHA Machine = 0x9026 /* Alpha (written in the absence of an ABI) */
)
var machineStrings = []intName{
@@ -295,23 +295,23 @@ var machineStrings = []intName{
intName{0x9026, "EM_ALPHA"},
}
-func (i Machine) String() string { return stringName(uint32(i), machineStrings, false) }
-func (i Machine) GoString() string { return stringName(uint32(i), machineStrings, true) }
+func (i Machine) String() string { return stringName(uint32(i), machineStrings, false) }
+func (i Machine) GoString() string { return stringName(uint32(i), machineStrings, true) }
// Special section indices.
type SectionIndex int
const (
- SHN_UNDEF SectionIndex = 0; /* Undefined, missing, irrelevant. */
- SHN_LORESERVE SectionIndex = 0xff00; /* First of reserved range. */
- SHN_LOPROC SectionIndex = 0xff00; /* First processor-specific. */
- SHN_HIPROC SectionIndex = 0xff1f; /* Last processor-specific. */
- SHN_LOOS SectionIndex = 0xff20; /* First operating system-specific. */
- SHN_HIOS SectionIndex = 0xff3f; /* Last operating system-specific. */
- SHN_ABS SectionIndex = 0xfff1; /* Absolute values. */
- SHN_COMMON SectionIndex = 0xfff2; /* Common data. */
- SHN_XINDEX SectionIndex = 0xffff; /* Escape -- index stored elsewhere. */
- SHN_HIRESERVE SectionIndex = 0xffff; /* Last of reserved range. */
+ SHN_UNDEF SectionIndex = 0 /* Undefined, missing, irrelevant. */
+ SHN_LORESERVE SectionIndex = 0xff00 /* First of reserved range. */
+ SHN_LOPROC SectionIndex = 0xff00 /* First processor-specific. */
+ SHN_HIPROC SectionIndex = 0xff1f /* Last processor-specific. */
+ SHN_LOOS SectionIndex = 0xff20 /* First operating system-specific. */
+ SHN_HIOS SectionIndex = 0xff3f /* Last operating system-specific. */
+ SHN_ABS SectionIndex = 0xfff1 /* Absolute values. */
+ SHN_COMMON SectionIndex = 0xfff2 /* Common data. */
+ SHN_XINDEX SectionIndex = 0xffff /* Escape -- index stored elsewhere. */
+ SHN_HIRESERVE SectionIndex = 0xffff /* Last of reserved range. */
)
var shnStrings = []intName{
@@ -323,36 +323,36 @@ var shnStrings = []intName{
intName{0xffff, "SHN_XINDEX"},
}
-func (i SectionIndex) String() string { return stringName(uint32(i), shnStrings, false) }
-func (i SectionIndex) GoString() string { return stringName(uint32(i), shnStrings, true) }
+func (i SectionIndex) String() string { return stringName(uint32(i), shnStrings, false) }
+func (i SectionIndex) GoString() string { return stringName(uint32(i), shnStrings, true) }
// Section type.
type SectionType uint32
const (
- SHT_NULL SectionType = 0; /* inactive */
- SHT_PROGBITS SectionType = 1; /* program defined information */
- SHT_SYMTAB SectionType = 2; /* symbol table section */
- SHT_STRTAB SectionType = 3; /* string table section */
- SHT_RELA SectionType = 4; /* relocation section with addends */
- SHT_HASH SectionType = 5; /* symbol hash table section */
- SHT_DYNAMIC SectionType = 6; /* dynamic section */
- SHT_NOTE SectionType = 7; /* note section */
- SHT_NOBITS SectionType = 8; /* no space section */
- SHT_REL SectionType = 9; /* relocation section - no addends */
- SHT_SHLIB SectionType = 10; /* reserved - purpose unknown */
- SHT_DYNSYM SectionType = 11; /* dynamic symbol table section */
- SHT_INIT_ARRAY SectionType = 14; /* Initialization function pointers. */
- SHT_FINI_ARRAY SectionType = 15; /* Termination function pointers. */
- SHT_PREINIT_ARRAY SectionType = 16; /* Pre-initialization function ptrs. */
- SHT_GROUP SectionType = 17; /* Section group. */
- SHT_SYMTAB_SHNDX SectionType = 18; /* Section indexes (see SHN_XINDEX). */
- SHT_LOOS SectionType = 0x60000000; /* First of OS specific semantics */
- SHT_HIOS SectionType = 0x6fffffff; /* Last of OS specific semantics */
- SHT_LOPROC SectionType = 0x70000000; /* reserved range for processor */
- SHT_HIPROC SectionType = 0x7fffffff; /* specific section header types */
- SHT_LOUSER SectionType = 0x80000000; /* reserved range for application */
- SHT_HIUSER SectionType = 0xffffffff; /* specific indexes */
+ SHT_NULL SectionType = 0 /* inactive */
+ SHT_PROGBITS SectionType = 1 /* program defined information */
+ SHT_SYMTAB SectionType = 2 /* symbol table section */
+ SHT_STRTAB SectionType = 3 /* string table section */
+ SHT_RELA SectionType = 4 /* relocation section with addends */
+ SHT_HASH SectionType = 5 /* symbol hash table section */
+ SHT_DYNAMIC SectionType = 6 /* dynamic section */
+ SHT_NOTE SectionType = 7 /* note section */
+ SHT_NOBITS SectionType = 8 /* no space section */
+ SHT_REL SectionType = 9 /* relocation section - no addends */
+ SHT_SHLIB SectionType = 10 /* reserved - purpose unknown */
+ SHT_DYNSYM SectionType = 11 /* dynamic symbol table section */
+ SHT_INIT_ARRAY SectionType = 14 /* Initialization function pointers. */
+ SHT_FINI_ARRAY SectionType = 15 /* Termination function pointers. */
+ SHT_PREINIT_ARRAY SectionType = 16 /* Pre-initialization function ptrs. */
+ SHT_GROUP SectionType = 17 /* Section group. */
+ SHT_SYMTAB_SHNDX SectionType = 18 /* Section indexes (see SHN_XINDEX). */
+ SHT_LOOS SectionType = 0x60000000 /* First of OS specific semantics */
+ SHT_HIOS SectionType = 0x6fffffff /* Last of OS specific semantics */
+ SHT_LOPROC SectionType = 0x70000000 /* reserved range for processor */
+ SHT_HIPROC SectionType = 0x7fffffff /* specific section header types */
+ SHT_LOUSER SectionType = 0x80000000 /* reserved range for application */
+ SHT_HIUSER SectionType = 0xffffffff /* specific indexes */
)
var shtStrings = []intName{
@@ -381,25 +381,25 @@ var shtStrings = []intName{
intName{0xffffffff, "SHT_HIUSER"},
}
-func (i SectionType) String() string { return stringName(uint32(i), shtStrings, false) }
-func (i SectionType) GoString() string { return stringName(uint32(i), shtStrings, true) }
+func (i SectionType) String() string { return stringName(uint32(i), shtStrings, false) }
+func (i SectionType) GoString() string { return stringName(uint32(i), shtStrings, true) }
// Section flags.
type SectionFlag uint32
const (
- SHF_WRITE SectionFlag = 0x1; /* Section contains writable data. */
- SHF_ALLOC SectionFlag = 0x2; /* Section occupies memory. */
- SHF_EXECINSTR SectionFlag = 0x4; /* Section contains instructions. */
- SHF_MERGE SectionFlag = 0x10; /* Section may be merged. */
- SHF_STRINGS SectionFlag = 0x20; /* Section contains strings. */
- SHF_INFO_LINK SectionFlag = 0x40; /* sh_info holds section index. */
- SHF_LINK_ORDER SectionFlag = 0x80; /* Special ordering requirements. */
- SHF_OS_NONCONFORMING SectionFlag = 0x100; /* OS-specific processing required. */
- SHF_GROUP SectionFlag = 0x200; /* Member of section group. */
- SHF_TLS SectionFlag = 0x400; /* Section contains TLS data. */
- SHF_MASKOS SectionFlag = 0x0ff00000; /* OS-specific semantics. */
- SHF_MASKPROC SectionFlag = 0xf0000000; /* Processor-specific semantics. */
+ SHF_WRITE SectionFlag = 0x1 /* Section contains writable data. */
+ SHF_ALLOC SectionFlag = 0x2 /* Section occupies memory. */
+ SHF_EXECINSTR SectionFlag = 0x4 /* Section contains instructions. */
+ SHF_MERGE SectionFlag = 0x10 /* Section may be merged. */
+ SHF_STRINGS SectionFlag = 0x20 /* Section contains strings. */
+ SHF_INFO_LINK SectionFlag = 0x40 /* sh_info holds section index. */
+ SHF_LINK_ORDER SectionFlag = 0x80 /* Special ordering requirements. */
+ SHF_OS_NONCONFORMING SectionFlag = 0x100 /* OS-specific processing required. */
+ SHF_GROUP SectionFlag = 0x200 /* Member of section group. */
+ SHF_TLS SectionFlag = 0x400 /* Section contains TLS data. */
+ SHF_MASKOS SectionFlag = 0x0ff00000 /* OS-specific semantics. */
+ SHF_MASKPROC SectionFlag = 0xf0000000 /* Processor-specific semantics. */
)
var shfStrings = []intName{
@@ -415,25 +415,25 @@ var shfStrings = []intName{
intName{0x400, "SHF_TLS"},
}
-func (i SectionFlag) String() string { return flagName(uint32(i), shfStrings, false) }
-func (i SectionFlag) GoString() string { return flagName(uint32(i), shfStrings, true) }
+func (i SectionFlag) String() string { return flagName(uint32(i), shfStrings, false) }
+func (i SectionFlag) GoString() string { return flagName(uint32(i), shfStrings, true) }
// Prog.Type
type ProgType int
const (
- PT_NULL ProgType = 0; /* Unused entry. */
- PT_LOAD ProgType = 1; /* Loadable segment. */
- PT_DYNAMIC ProgType = 2; /* Dynamic linking information segment. */
- PT_INTERP ProgType = 3; /* Pathname of interpreter. */
- PT_NOTE ProgType = 4; /* Auxiliary information. */
- PT_SHLIB ProgType = 5; /* Reserved (not used). */
- PT_PHDR ProgType = 6; /* Location of program header itself. */
- PT_TLS ProgType = 7; /* Thread local storage segment */
- PT_LOOS ProgType = 0x60000000; /* First OS-specific. */
- PT_HIOS ProgType = 0x6fffffff; /* Last OS-specific. */
- PT_LOPROC ProgType = 0x70000000; /* First processor-specific type. */
- PT_HIPROC ProgType = 0x7fffffff; /* Last processor-specific type. */
+ PT_NULL ProgType = 0 /* Unused entry. */
+ PT_LOAD ProgType = 1 /* Loadable segment. */
+ PT_DYNAMIC ProgType = 2 /* Dynamic linking information segment. */
+ PT_INTERP ProgType = 3 /* Pathname of interpreter. */
+ PT_NOTE ProgType = 4 /* Auxiliary information. */
+ PT_SHLIB ProgType = 5 /* Reserved (not used). */
+ PT_PHDR ProgType = 6 /* Location of program header itself. */
+ PT_TLS ProgType = 7 /* Thread local storage segment */
+ PT_LOOS ProgType = 0x60000000 /* First OS-specific. */
+ PT_HIOS ProgType = 0x6fffffff /* Last OS-specific. */
+ PT_LOPROC ProgType = 0x70000000 /* First processor-specific type. */
+ PT_HIPROC ProgType = 0x7fffffff /* Last processor-specific type. */
)
var ptStrings = []intName{
@@ -451,18 +451,18 @@ var ptStrings = []intName{
intName{0x7fffffff, "PT_HIPROC"},
}
-func (i ProgType) String() string { return stringName(uint32(i), ptStrings, false) }
-func (i ProgType) GoString() string { return stringName(uint32(i), ptStrings, true) }
+func (i ProgType) String() string { return stringName(uint32(i), ptStrings, false) }
+func (i ProgType) GoString() string { return stringName(uint32(i), ptStrings, true) }
// Prog.Flag
type ProgFlag uint32
const (
- PF_X ProgFlag = 0x1; /* Executable. */
- PF_W ProgFlag = 0x2; /* Writable. */
- PF_R ProgFlag = 0x4; /* Readable. */
- PF_MASKOS ProgFlag = 0x0ff00000; /* Operating system-specific. */
- PF_MASKPROC ProgFlag = 0xf0000000; /* Processor-specific. */
+ PF_X ProgFlag = 0x1 /* Executable. */
+ PF_W ProgFlag = 0x2 /* Writable. */
+ PF_R ProgFlag = 0x4 /* Readable. */
+ PF_MASKOS ProgFlag = 0x0ff00000 /* Operating system-specific. */
+ PF_MASKPROC ProgFlag = 0xf0000000 /* Processor-specific. */
)
var pfStrings = []intName{
@@ -471,55 +471,55 @@ var pfStrings = []intName{
intName{0x4, "PF_R"},
}
-func (i ProgFlag) String() string { return flagName(uint32(i), pfStrings, false) }
-func (i ProgFlag) GoString() string { return flagName(uint32(i), pfStrings, true) }
+func (i ProgFlag) String() string { return flagName(uint32(i), pfStrings, false) }
+func (i ProgFlag) GoString() string { return flagName(uint32(i), pfStrings, true) }
// Dyn.Tag
type DynTag int
const (
- DT_NULL DynTag = 0; /* Terminating entry. */
- DT_NEEDED DynTag = 1; /* String table offset of a needed shared library. */
- DT_PLTRELSZ DynTag = 2; /* Total size in bytes of PLT relocations. */
- DT_PLTGOT DynTag = 3; /* Processor-dependent address. */
- DT_HASH DynTag = 4; /* Address of symbol hash table. */
- DT_STRTAB DynTag = 5; /* Address of string table. */
- DT_SYMTAB DynTag = 6; /* Address of symbol table. */
- DT_RELA DynTag = 7; /* Address 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_STRSZ DynTag = 10; /* Size of string table. */
- DT_SYMENT DynTag = 11; /* Size of each symbol table entry. */
- DT_INIT DynTag = 12; /* Address of initialization function. */
- DT_FINI DynTag = 13; /* Address of finalization function. */
- DT_SONAME DynTag = 14; /* String table offset of shared object name. */
- DT_RPATH DynTag = 15; /* String table offset of library path. [sup] */
- DT_SYMBOLIC DynTag = 16; /* Indicates "symbolic" linking. [sup] */
- DT_REL DynTag = 17; /* Address 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_PLTREL DynTag = 20; /* Type of relocation used for PLT. */
- DT_DEBUG DynTag = 21; /* Reserved (not used). */
- DT_TEXTREL DynTag = 22; /* Indicates there may be relocations in non-writable segments. [sup] */
- DT_JMPREL DynTag = 23; /* Address of PLT relocations. */
- DT_BIND_NOW DynTag = 24; /* [sup] */
- 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_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_RUNPATH DynTag = 29; /* String table offset of a null-terminated library search path string. */
- DT_FLAGS DynTag = 30; /* Object specific flag values. */
- DT_ENCODING DynTag = 32; /* Values greater than or equal to DT_ENCODING
+ DT_NULL DynTag = 0 /* Terminating entry. */
+ DT_NEEDED DynTag = 1 /* String table offset of a needed shared library. */
+ DT_PLTRELSZ DynTag = 2 /* Total size in bytes of PLT relocations. */
+ DT_PLTGOT DynTag = 3 /* Processor-dependent address. */
+ DT_HASH DynTag = 4 /* Address of symbol hash table. */
+ DT_STRTAB DynTag = 5 /* Address of string table. */
+ DT_SYMTAB DynTag = 6 /* Address of symbol table. */
+ DT_RELA DynTag = 7 /* Address 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_STRSZ DynTag = 10 /* Size of string table. */
+ DT_SYMENT DynTag = 11 /* Size of each symbol table entry. */
+ DT_INIT DynTag = 12 /* Address of initialization function. */
+ DT_FINI DynTag = 13 /* Address of finalization function. */
+ DT_SONAME DynTag = 14 /* String table offset of shared object name. */
+ DT_RPATH DynTag = 15 /* String table offset of library path. [sup] */
+ DT_SYMBOLIC DynTag = 16 /* Indicates "symbolic" linking. [sup] */
+ DT_REL DynTag = 17 /* Address 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_PLTREL DynTag = 20 /* Type of relocation used for PLT. */
+ DT_DEBUG DynTag = 21 /* Reserved (not used). */
+ DT_TEXTREL DynTag = 22 /* Indicates there may be relocations in non-writable segments. [sup] */
+ DT_JMPREL DynTag = 23 /* Address of PLT relocations. */
+ DT_BIND_NOW DynTag = 24 /* [sup] */
+ 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_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_RUNPATH DynTag = 29 /* String table offset of a null-terminated library search path string. */
+ DT_FLAGS DynTag = 30 /* Object specific flag values. */
+ DT_ENCODING DynTag = 32 /* Values greater than or equal to DT_ENCODING
and less than DT_LOOS follow the rules for
the interpretation of the d_un union
as follows: even == 'd_ptr', even == 'd_val'
or none */
- 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_LOOS DynTag = 0x6000000d; /* First OS-specific */
- DT_HIOS DynTag = 0x6ffff000; /* Last OS-specific */
- DT_LOPROC DynTag = 0x70000000; /* First processor-specific type. */
- DT_HIPROC DynTag = 0x7fffffff; /* Last processor-specific type. */
+ 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_LOOS DynTag = 0x6000000d /* First OS-specific */
+ DT_HIOS DynTag = 0x6ffff000 /* Last OS-specific */
+ DT_LOPROC DynTag = 0x70000000 /* First processor-specific type. */
+ DT_HIPROC DynTag = 0x7fffffff /* Last processor-specific type. */
)
var dtStrings = []intName{
@@ -563,23 +563,23 @@ var dtStrings = []intName{
intName{0x7fffffff, "DT_HIPROC"},
}
-func (i DynTag) String() string { return stringName(uint32(i), dtStrings, false) }
-func (i DynTag) GoString() string { return stringName(uint32(i), dtStrings, true) }
+func (i DynTag) String() string { return stringName(uint32(i), dtStrings, false) }
+func (i DynTag) GoString() string { return stringName(uint32(i), dtStrings, true) }
// DT_FLAGS values.
type DynFlag int
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 string */
- DF_SYMBOLIC DynFlag = 0x0002; /* Indicates "symbolic" linking. */
- DF_TEXTREL DynFlag = 0x0004; /* Indicates there may be relocations in non-writable segments. */
- DF_BIND_NOW DynFlag = 0x0008; /* Indicates that the dynamic linker should
+ DF_SYMBOLIC DynFlag = 0x0002 /* Indicates "symbolic" linking. */
+ DF_TEXTREL DynFlag = 0x0004 /* Indicates there may be relocations in non-writable segments. */
+ DF_BIND_NOW DynFlag = 0x0008 /* Indicates that the dynamic linker should
process all relocations for the object
containing this entry before transferring
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
thread-local storage scheme. */
)
@@ -592,16 +592,16 @@ var dflagStrings = []intName{
intName{0x0010, "DF_STATIC_TLS"},
}
-func (i DynFlag) String() string { return flagName(uint32(i), dflagStrings, false) }
-func (i DynFlag) GoString() string { return flagName(uint32(i), dflagStrings, true) }
+func (i DynFlag) String() string { return flagName(uint32(i), dflagStrings, false) }
+func (i DynFlag) GoString() string { return flagName(uint32(i), dflagStrings, true) }
// NType values; used in core files.
type NType int
const (
- NT_PRSTATUS NType = 1; /* Process status. */
- NT_FPREGSET NType = 2; /* Floating point registers. */
- NT_PRPSINFO NType = 3; /* Process state info. */
+ NT_PRSTATUS NType = 1 /* Process status. */
+ NT_FPREGSET NType = 2 /* Floating point registers. */
+ NT_PRPSINFO NType = 3 /* Process state info. */
)
var ntypeStrings = []intName{
@@ -610,20 +610,20 @@ var ntypeStrings = []intName{
intName{3, "NT_PRPSINFO"},
}
-func (i NType) String() string { return stringName(uint32(i), ntypeStrings, false) }
-func (i NType) GoString() string { return stringName(uint32(i), ntypeStrings, true) }
+func (i NType) String() string { return stringName(uint32(i), ntypeStrings, false) }
+func (i NType) GoString() string { return stringName(uint32(i), ntypeStrings, true) }
/* Symbol Binding - ELFNN_ST_BIND - st_info */
type SymBind int
const (
- STB_LOCAL SymBind = 0; /* Local symbol */
- STB_GLOBAL SymBind = 1; /* Global symbol */
- STB_WEAK SymBind = 2; /* like global - lower precedence */
- STB_LOOS SymBind = 10; /* Reserved range for operating system */
- STB_HIOS SymBind = 12; /* specific semantics. */
- STB_LOPROC SymBind = 13; /* reserved range for processor */
- STB_HIPROC SymBind = 15; /* specific semantics. */
+ STB_LOCAL SymBind = 0 /* Local symbol */
+ STB_GLOBAL SymBind = 1 /* Global symbol */
+ STB_WEAK SymBind = 2 /* like global - lower precedence */
+ STB_LOOS SymBind = 10 /* Reserved range for operating system */
+ STB_HIOS SymBind = 12 /* specific semantics. */
+ STB_LOPROC SymBind = 13 /* reserved range for processor */
+ STB_HIPROC SymBind = 15 /* specific semantics. */
)
var stbStrings = []intName{
@@ -636,24 +636,24 @@ var stbStrings = []intName{
intName{15, "STB_HIPROC"},
}
-func (i SymBind) String() string { return stringName(uint32(i), stbStrings, false) }
-func (i SymBind) GoString() string { return stringName(uint32(i), stbStrings, true) }
+func (i SymBind) String() string { return stringName(uint32(i), stbStrings, false) }
+func (i SymBind) GoString() string { return stringName(uint32(i), stbStrings, true) }
/* Symbol type - ELFNN_ST_TYPE - st_info */
type SymType int
const (
- STT_NOTYPE SymType = 0; /* Unspecified type. */
- STT_OBJECT SymType = 1; /* Data object. */
- STT_FUNC SymType = 2; /* Function. */
- STT_SECTION SymType = 3; /* Section. */
- STT_FILE SymType = 4; /* Source file. */
- STT_COMMON SymType = 5; /* Uninitialized common block. */
- STT_TLS SymType = 6; /* TLS object. */
- STT_LOOS SymType = 10; /* Reserved range for operating system */
- STT_HIOS SymType = 12; /* specific semantics. */
- STT_LOPROC SymType = 13; /* reserved range for processor */
- STT_HIPROC SymType = 15; /* specific semantics. */
+ STT_NOTYPE SymType = 0 /* Unspecified type. */
+ STT_OBJECT SymType = 1 /* Data object. */
+ STT_FUNC SymType = 2 /* Function. */
+ STT_SECTION SymType = 3 /* Section. */
+ STT_FILE SymType = 4 /* Source file. */
+ STT_COMMON SymType = 5 /* Uninitialized common block. */
+ STT_TLS SymType = 6 /* TLS object. */
+ STT_LOOS SymType = 10 /* Reserved range for operating system */
+ STT_HIOS SymType = 12 /* specific semantics. */
+ STT_LOPROC SymType = 13 /* reserved range for processor */
+ STT_HIPROC SymType = 15 /* specific semantics. */
)
var sttStrings = []intName{
@@ -670,17 +670,17 @@ var sttStrings = []intName{
intName{15, "STT_HIPROC"},
}
-func (i SymType) String() string { return stringName(uint32(i), sttStrings, false) }
-func (i SymType) GoString() string { return stringName(uint32(i), sttStrings, true) }
+func (i SymType) String() string { return stringName(uint32(i), sttStrings, false) }
+func (i SymType) GoString() string { return stringName(uint32(i), sttStrings, true) }
/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */
type SymVis int
const (
- STV_DEFAULT SymVis = 0x0; /* Default visibility (see binding). */
- STV_INTERNAL SymVis = 0x1; /* Special meaning in relocatable objects. */
- STV_HIDDEN SymVis = 0x2; /* Not visible. */
- STV_PROTECTED SymVis = 0x3; /* Visible but not preemptible. */
+ STV_DEFAULT SymVis = 0x0 /* Default visibility (see binding). */
+ STV_INTERNAL SymVis = 0x1 /* Special meaning in relocatable objects. */
+ STV_HIDDEN SymVis = 0x2 /* Not visible. */
+ STV_PROTECTED SymVis = 0x3 /* Visible but not preemptible. */
)
var stvStrings = []intName{
@@ -690,8 +690,8 @@ var stvStrings = []intName{
intName{0x3, "STV_PROTECTED"},
}
-func (i SymVis) String() string { return stringName(uint32(i), stvStrings, false) }
-func (i SymVis) GoString() string { return stringName(uint32(i), stvStrings, true) }
+func (i SymVis) String() string { return stringName(uint32(i), stvStrings, false) }
+func (i SymVis) GoString() string { return stringName(uint32(i), stvStrings, true) }
/*
* Relocation types.
@@ -701,30 +701,30 @@ func (i SymVis) GoString() string { return stringName(uint32(i), stvStrings, tru
type R_X86_64 int
const (
- R_X86_64_NONE R_X86_64 = 0; /* No relocation. */
- R_X86_64_64 R_X86_64 = 1; /* Add 64 bit symbol value. */
- R_X86_64_PC32 R_X86_64 = 2; /* PC-relative 32 bit signed sym value. */
- R_X86_64_GOT32 R_X86_64 = 3; /* PC-relative 32 bit GOT offset. */
- R_X86_64_PLT32 R_X86_64 = 4; /* PC-relative 32 bit PLT offset. */
- R_X86_64_COPY R_X86_64 = 5; /* Copy data from shared object. */
- R_X86_64_GLOB_DAT R_X86_64 = 6; /* Set GOT entry to data address. */
- R_X86_64_JMP_SLOT R_X86_64 = 7; /* Set GOT entry to code address. */
- R_X86_64_RELATIVE R_X86_64 = 8; /* Add load address of shared object. */
- R_X86_64_GOTPCREL R_X86_64 = 9; /* Add 32 bit signed pcrel offset to GOT. */
- R_X86_64_32 R_X86_64 = 10; /* Add 32 bit zero extended symbol value */
- R_X86_64_32S R_X86_64 = 11; /* Add 32 bit sign extended symbol value */
- R_X86_64_16 R_X86_64 = 12; /* Add 16 bit zero extended symbol value */
- R_X86_64_PC16 R_X86_64 = 13; /* Add 16 bit signed extended pc relative symbol value */
- R_X86_64_8 R_X86_64 = 14; /* Add 8 bit zero extended symbol value */
- R_X86_64_PC8 R_X86_64 = 15; /* Add 8 bit signed extended pc relative symbol value */
- R_X86_64_DTPMOD64 R_X86_64 = 16; /* ID of module containing symbol */
- R_X86_64_DTPOFF64 R_X86_64 = 17; /* Offset in TLS block */
- R_X86_64_TPOFF64 R_X86_64 = 18; /* Offset in static TLS block */
- R_X86_64_TLSGD R_X86_64 = 19; /* PC relative offset to GD GOT entry */
- R_X86_64_TLSLD R_X86_64 = 20; /* PC relative offset to LD GOT entry */
- R_X86_64_DTPOFF32 R_X86_64 = 21; /* Offset in TLS block */
- R_X86_64_GOTTPOFF R_X86_64 = 22; /* PC relative offset to IE GOT entry */
- R_X86_64_TPOFF32 R_X86_64 = 23; /* Offset in static TLS block */
+ R_X86_64_NONE R_X86_64 = 0 /* No relocation. */
+ R_X86_64_64 R_X86_64 = 1 /* Add 64 bit symbol value. */
+ R_X86_64_PC32 R_X86_64 = 2 /* PC-relative 32 bit signed sym value. */
+ R_X86_64_GOT32 R_X86_64 = 3 /* PC-relative 32 bit GOT offset. */
+ R_X86_64_PLT32 R_X86_64 = 4 /* PC-relative 32 bit PLT offset. */
+ R_X86_64_COPY R_X86_64 = 5 /* Copy data from shared object. */
+ R_X86_64_GLOB_DAT R_X86_64 = 6 /* Set GOT entry to data address. */
+ R_X86_64_JMP_SLOT R_X86_64 = 7 /* Set GOT entry to code address. */
+ R_X86_64_RELATIVE R_X86_64 = 8 /* Add load address of shared object. */
+ R_X86_64_GOTPCREL R_X86_64 = 9 /* Add 32 bit signed pcrel offset to GOT. */
+ R_X86_64_32 R_X86_64 = 10 /* Add 32 bit zero extended symbol value */
+ R_X86_64_32S R_X86_64 = 11 /* Add 32 bit sign extended symbol value */
+ R_X86_64_16 R_X86_64 = 12 /* Add 16 bit zero extended symbol value */
+ R_X86_64_PC16 R_X86_64 = 13 /* Add 16 bit signed extended pc relative symbol value */
+ R_X86_64_8 R_X86_64 = 14 /* Add 8 bit zero extended symbol value */
+ R_X86_64_PC8 R_X86_64 = 15 /* Add 8 bit signed extended pc relative symbol value */
+ R_X86_64_DTPMOD64 R_X86_64 = 16 /* ID of module containing symbol */
+ R_X86_64_DTPOFF64 R_X86_64 = 17 /* Offset in TLS block */
+ R_X86_64_TPOFF64 R_X86_64 = 18 /* Offset in static TLS block */
+ R_X86_64_TLSGD R_X86_64 = 19 /* PC relative offset to GD GOT entry */
+ R_X86_64_TLSLD R_X86_64 = 20 /* PC relative offset to LD GOT entry */
+ R_X86_64_DTPOFF32 R_X86_64 = 21 /* Offset in TLS block */
+ R_X86_64_GOTTPOFF R_X86_64 = 22 /* PC relative offset to IE GOT entry */
+ R_X86_64_TPOFF32 R_X86_64 = 23 /* Offset in static TLS block */
)
var rx86_64Strings = []intName{
@@ -754,41 +754,41 @@ var rx86_64Strings = []intName{
intName{23, "R_X86_64_TPOFF32"},
}
-func (i R_X86_64) String() string { return stringName(uint32(i), rx86_64Strings, false) }
-func (i R_X86_64) GoString() string { return stringName(uint32(i), rx86_64Strings, true) }
+func (i R_X86_64) String() string { return stringName(uint32(i), rx86_64Strings, false) }
+func (i R_X86_64) GoString() string { return stringName(uint32(i), rx86_64Strings, true) }
// Relocation types for Alpha.
type R_ALPHA int
const (
- R_ALPHA_NONE R_ALPHA = 0; /* No reloc */
- R_ALPHA_REFLONG R_ALPHA = 1; /* Direct 32 bit */
- R_ALPHA_REFQUAD R_ALPHA = 2; /* Direct 64 bit */
- R_ALPHA_GPREL32 R_ALPHA = 3; /* GP relative 32 bit */
- R_ALPHA_LITERAL R_ALPHA = 4; /* GP relative 16 bit w/optimization */
- R_ALPHA_LITUSE R_ALPHA = 5; /* Optimization hint for LITERAL */
- R_ALPHA_GPDISP R_ALPHA = 6; /* Add displacement to GP */
- R_ALPHA_BRADDR R_ALPHA = 7; /* PC+4 relative 23 bit shifted */
- R_ALPHA_HINT R_ALPHA = 8; /* PC+4 relative 16 bit shifted */
- R_ALPHA_SREL16 R_ALPHA = 9; /* PC relative 16 bit */
- R_ALPHA_SREL32 R_ALPHA = 10; /* PC relative 32 bit */
- R_ALPHA_SREL64 R_ALPHA = 11; /* PC relative 64 bit */
- R_ALPHA_OP_PUSH R_ALPHA = 12; /* OP stack push */
- R_ALPHA_OP_STORE R_ALPHA = 13; /* OP stack pop and store */
- R_ALPHA_OP_PSUB R_ALPHA = 14; /* OP stack subtract */
- R_ALPHA_OP_PRSHIFT R_ALPHA = 15; /* OP stack right shift */
- R_ALPHA_GPVALUE R_ALPHA = 16;
- R_ALPHA_GPRELHIGH R_ALPHA = 17;
- R_ALPHA_GPRELLOW R_ALPHA = 18;
- R_ALPHA_IMMED_GP_16 R_ALPHA = 19;
- R_ALPHA_IMMED_GP_HI32 R_ALPHA = 20;
- R_ALPHA_IMMED_SCN_HI32 R_ALPHA = 21;
- R_ALPHA_IMMED_BR_HI32 R_ALPHA = 22;
- R_ALPHA_IMMED_LO32 R_ALPHA = 23;
- R_ALPHA_COPY R_ALPHA = 24; /* Copy symbol at runtime */
- R_ALPHA_GLOB_DAT R_ALPHA = 25; /* Create GOT entry */
- R_ALPHA_JMP_SLOT R_ALPHA = 26; /* Create PLT entry */
- R_ALPHA_RELATIVE R_ALPHA = 27; /* Adjust by program base */
+ R_ALPHA_NONE R_ALPHA = 0 /* No reloc */
+ R_ALPHA_REFLONG R_ALPHA = 1 /* Direct 32 bit */
+ R_ALPHA_REFQUAD R_ALPHA = 2 /* Direct 64 bit */
+ R_ALPHA_GPREL32 R_ALPHA = 3 /* GP relative 32 bit */
+ R_ALPHA_LITERAL R_ALPHA = 4 /* GP relative 16 bit w/optimization */
+ R_ALPHA_LITUSE R_ALPHA = 5 /* Optimization hint for LITERAL */
+ R_ALPHA_GPDISP R_ALPHA = 6 /* Add displacement to GP */
+ R_ALPHA_BRADDR R_ALPHA = 7 /* PC+4 relative 23 bit shifted */
+ R_ALPHA_HINT R_ALPHA = 8 /* PC+4 relative 16 bit shifted */
+ R_ALPHA_SREL16 R_ALPHA = 9 /* PC relative 16 bit */
+ R_ALPHA_SREL32 R_ALPHA = 10 /* PC relative 32 bit */
+ R_ALPHA_SREL64 R_ALPHA = 11 /* PC relative 64 bit */
+ R_ALPHA_OP_PUSH R_ALPHA = 12 /* OP stack push */
+ R_ALPHA_OP_STORE R_ALPHA = 13 /* OP stack pop and store */
+ R_ALPHA_OP_PSUB R_ALPHA = 14 /* OP stack subtract */
+ R_ALPHA_OP_PRSHIFT R_ALPHA = 15 /* OP stack right shift */
+ R_ALPHA_GPVALUE R_ALPHA = 16
+ R_ALPHA_GPRELHIGH R_ALPHA = 17
+ R_ALPHA_GPRELLOW R_ALPHA = 18
+ R_ALPHA_IMMED_GP_16 R_ALPHA = 19
+ R_ALPHA_IMMED_GP_HI32 R_ALPHA = 20
+ R_ALPHA_IMMED_SCN_HI32 R_ALPHA = 21
+ R_ALPHA_IMMED_BR_HI32 R_ALPHA = 22
+ R_ALPHA_IMMED_LO32 R_ALPHA = 23
+ R_ALPHA_COPY R_ALPHA = 24 /* Copy symbol at runtime */
+ R_ALPHA_GLOB_DAT R_ALPHA = 25 /* Create GOT entry */
+ R_ALPHA_JMP_SLOT R_ALPHA = 26 /* Create PLT entry */
+ R_ALPHA_RELATIVE R_ALPHA = 27 /* Adjust by program base */
)
var ralphaStrings = []intName{
@@ -822,46 +822,46 @@ var ralphaStrings = []intName{
intName{27, "R_ALPHA_RELATIVE"},
}
-func (i R_ALPHA) String() string { return stringName(uint32(i), ralphaStrings, false) }
-func (i R_ALPHA) GoString() string { return stringName(uint32(i), ralphaStrings, true) }
+func (i R_ALPHA) String() string { return stringName(uint32(i), ralphaStrings, false) }
+func (i R_ALPHA) GoString() string { return stringName(uint32(i), ralphaStrings, true) }
// Relocation types for ARM.
type R_ARM int
const (
- R_ARM_NONE R_ARM = 0; /* No relocation. */
- R_ARM_PC24 R_ARM = 1;
- R_ARM_ABS32 R_ARM = 2;
- R_ARM_REL32 R_ARM = 3;
- R_ARM_PC13 R_ARM = 4;
- R_ARM_ABS16 R_ARM = 5;
- R_ARM_ABS12 R_ARM = 6;
- R_ARM_THM_ABS5 R_ARM = 7;
- R_ARM_ABS8 R_ARM = 8;
- R_ARM_SBREL32 R_ARM = 9;
- R_ARM_THM_PC22 R_ARM = 10;
- R_ARM_THM_PC8 R_ARM = 11;
- R_ARM_AMP_VCALL9 R_ARM = 12;
- R_ARM_SWI24 R_ARM = 13;
- R_ARM_THM_SWI8 R_ARM = 14;
- R_ARM_XPC25 R_ARM = 15;
- R_ARM_THM_XPC22 R_ARM = 16;
- R_ARM_COPY R_ARM = 20; /* Copy data from shared object. */
- R_ARM_GLOB_DAT R_ARM = 21; /* Set GOT entry to data address. */
- R_ARM_JUMP_SLOT R_ARM = 22; /* Set GOT entry to code address. */
- R_ARM_RELATIVE R_ARM = 23; /* Add load address of shared object. */
- R_ARM_GOTOFF R_ARM = 24; /* Add GOT-relative symbol address. */
- R_ARM_GOTPC R_ARM = 25; /* Add PC-relative GOT table address. */
- R_ARM_GOT32 R_ARM = 26; /* Add PC-relative GOT offset. */
- R_ARM_PLT32 R_ARM = 27; /* Add PC-relative PLT offset. */
- R_ARM_GNU_VTENTRY R_ARM = 100;
- R_ARM_GNU_VTINHERIT R_ARM = 101;
- R_ARM_RSBREL32 R_ARM = 250;
- R_ARM_THM_RPC22 R_ARM = 251;
- R_ARM_RREL32 R_ARM = 252;
- R_ARM_RABS32 R_ARM = 253;
- R_ARM_RPC24 R_ARM = 254;
- R_ARM_RBASE R_ARM = 255;
+ R_ARM_NONE R_ARM = 0 /* No relocation. */
+ R_ARM_PC24 R_ARM = 1
+ R_ARM_ABS32 R_ARM = 2
+ R_ARM_REL32 R_ARM = 3
+ R_ARM_PC13 R_ARM = 4
+ R_ARM_ABS16 R_ARM = 5
+ R_ARM_ABS12 R_ARM = 6
+ R_ARM_THM_ABS5 R_ARM = 7
+ R_ARM_ABS8 R_ARM = 8
+ R_ARM_SBREL32 R_ARM = 9
+ R_ARM_THM_PC22 R_ARM = 10
+ R_ARM_THM_PC8 R_ARM = 11
+ R_ARM_AMP_VCALL9 R_ARM = 12
+ R_ARM_SWI24 R_ARM = 13
+ R_ARM_THM_SWI8 R_ARM = 14
+ R_ARM_XPC25 R_ARM = 15
+ R_ARM_THM_XPC22 R_ARM = 16
+ R_ARM_COPY R_ARM = 20 /* Copy data from shared object. */
+ R_ARM_GLOB_DAT R_ARM = 21 /* Set GOT entry to data address. */
+ R_ARM_JUMP_SLOT R_ARM = 22 /* Set GOT entry to code address. */
+ R_ARM_RELATIVE R_ARM = 23 /* Add load address of shared object. */
+ R_ARM_GOTOFF R_ARM = 24 /* Add GOT-relative symbol address. */
+ R_ARM_GOTPC R_ARM = 25 /* Add PC-relative GOT table address. */
+ R_ARM_GOT32 R_ARM = 26 /* Add PC-relative GOT offset. */
+ R_ARM_PLT32 R_ARM = 27 /* Add PC-relative PLT offset. */
+ R_ARM_GNU_VTENTRY R_ARM = 100
+ R_ARM_GNU_VTINHERIT R_ARM = 101
+ R_ARM_RSBREL32 R_ARM = 250
+ R_ARM_THM_RPC22 R_ARM = 251
+ R_ARM_RREL32 R_ARM = 252
+ R_ARM_RABS32 R_ARM = 253
+ R_ARM_RPC24 R_ARM = 254
+ R_ARM_RBASE R_ARM = 255
)
var rarmStrings = []intName{
@@ -900,44 +900,44 @@ var rarmStrings = []intName{
intName{255, "R_ARM_RBASE"},
}
-func (i R_ARM) String() string { return stringName(uint32(i), rarmStrings, false) }
-func (i R_ARM) GoString() string { return stringName(uint32(i), rarmStrings, true) }
+func (i R_ARM) String() string { return stringName(uint32(i), rarmStrings, false) }
+func (i R_ARM) GoString() string { return stringName(uint32(i), rarmStrings, true) }
// Relocation types for 386.
type R_386 int
const (
- R_386_NONE R_386 = 0; /* No relocation. */
- R_386_32 R_386 = 1; /* Add symbol value. */
- R_386_PC32 R_386 = 2; /* Add PC-relative symbol value. */
- R_386_GOT32 R_386 = 3; /* Add PC-relative GOT offset. */
- R_386_PLT32 R_386 = 4; /* Add PC-relative PLT offset. */
- R_386_COPY R_386 = 5; /* Copy data from shared object. */
- R_386_GLOB_DAT R_386 = 6; /* Set GOT entry to data address. */
- R_386_JMP_SLOT R_386 = 7; /* Set GOT entry to code address. */
- R_386_RELATIVE R_386 = 8; /* Add load address of shared object. */
- R_386_GOTOFF R_386 = 9; /* Add GOT-relative symbol address. */
- R_386_GOTPC R_386 = 10; /* Add PC-relative GOT table address. */
- R_386_TLS_TPOFF R_386 = 14; /* Negative offset in static TLS block */
- R_386_TLS_IE R_386 = 15; /* Absolute address of GOT for -ve static TLS */
- R_386_TLS_GOTIE R_386 = 16; /* GOT entry for negative static TLS block */
- R_386_TLS_LE R_386 = 17; /* Negative offset relative to static TLS */
- R_386_TLS_GD R_386 = 18; /* 32 bit offset to GOT (index,off) pair */
- R_386_TLS_LDM R_386 = 19; /* 32 bit offset to GOT (index,zero) pair */
- R_386_TLS_GD_32 R_386 = 24; /* 32 bit offset to GOT (index,off) pair */
- R_386_TLS_GD_PUSH R_386 = 25; /* pushl instruction for Sun ABI GD sequence */
- R_386_TLS_GD_CALL R_386 = 26; /* call instruction for Sun ABI GD sequence */
- R_386_TLS_GD_POP R_386 = 27; /* popl instruction for Sun ABI GD sequence */
- R_386_TLS_LDM_32 R_386 = 28; /* 32 bit offset to GOT (index,zero) pair */
- R_386_TLS_LDM_PUSH R_386 = 29; /* pushl instruction for Sun ABI LD sequence */
- R_386_TLS_LDM_CALL R_386 = 30; /* call instruction for Sun ABI LD sequence */
- R_386_TLS_LDM_POP R_386 = 31; /* popl instruction for Sun ABI LD sequence */
- R_386_TLS_LDO_32 R_386 = 32; /* 32 bit offset from start of TLS block */
- R_386_TLS_IE_32 R_386 = 33; /* 32 bit offset to GOT static TLS offset entry */
- R_386_TLS_LE_32 R_386 = 34; /* 32 bit offset within static TLS block */
- R_386_TLS_DTPMOD32 R_386 = 35; /* GOT entry containing TLS index */
- R_386_TLS_DTPOFF32 R_386 = 36; /* GOT entry containing TLS offset */
- R_386_TLS_TPOFF32 R_386 = 37; /* GOT entry of -ve static TLS offset */
+ R_386_NONE R_386 = 0 /* No relocation. */
+ R_386_32 R_386 = 1 /* Add symbol value. */
+ R_386_PC32 R_386 = 2 /* Add PC-relative symbol value. */
+ R_386_GOT32 R_386 = 3 /* Add PC-relative GOT offset. */
+ R_386_PLT32 R_386 = 4 /* Add PC-relative PLT offset. */
+ R_386_COPY R_386 = 5 /* Copy data from shared object. */
+ R_386_GLOB_DAT R_386 = 6 /* Set GOT entry to data address. */
+ R_386_JMP_SLOT R_386 = 7 /* Set GOT entry to code address. */
+ R_386_RELATIVE R_386 = 8 /* Add load address of shared object. */
+ R_386_GOTOFF R_386 = 9 /* Add GOT-relative symbol address. */
+ R_386_GOTPC R_386 = 10 /* Add PC-relative GOT table address. */
+ R_386_TLS_TPOFF R_386 = 14 /* Negative offset in static TLS block */
+ R_386_TLS_IE R_386 = 15 /* Absolute address of GOT for -ve static TLS */
+ R_386_TLS_GOTIE R_386 = 16 /* GOT entry for negative static TLS block */
+ R_386_TLS_LE R_386 = 17 /* Negative offset relative to static TLS */
+ R_386_TLS_GD R_386 = 18 /* 32 bit offset to GOT (index,off) pair */
+ R_386_TLS_LDM R_386 = 19 /* 32 bit offset to GOT (index,zero) pair */
+ R_386_TLS_GD_32 R_386 = 24 /* 32 bit offset to GOT (index,off) pair */
+ R_386_TLS_GD_PUSH R_386 = 25 /* pushl instruction for Sun ABI GD sequence */
+ R_386_TLS_GD_CALL R_386 = 26 /* call instruction for Sun ABI GD sequence */
+ R_386_TLS_GD_POP R_386 = 27 /* popl instruction for Sun ABI GD sequence */
+ R_386_TLS_LDM_32 R_386 = 28 /* 32 bit offset to GOT (index,zero) pair */
+ R_386_TLS_LDM_PUSH R_386 = 29 /* pushl instruction for Sun ABI LD sequence */
+ R_386_TLS_LDM_CALL R_386 = 30 /* call instruction for Sun ABI LD sequence */
+ R_386_TLS_LDM_POP R_386 = 31 /* popl instruction for Sun ABI LD sequence */
+ R_386_TLS_LDO_32 R_386 = 32 /* 32 bit offset from start of TLS block */
+ R_386_TLS_IE_32 R_386 = 33 /* 32 bit offset to GOT static TLS offset entry */
+ R_386_TLS_LE_32 R_386 = 34 /* 32 bit offset within static TLS block */
+ R_386_TLS_DTPMOD32 R_386 = 35 /* GOT entry containing TLS index */
+ R_386_TLS_DTPOFF32 R_386 = 36 /* GOT entry containing TLS offset */
+ R_386_TLS_TPOFF32 R_386 = 37 /* GOT entry of -ve static TLS offset */
)
var r386Strings = []intName{
@@ -974,90 +974,90 @@ var r386Strings = []intName{
intName{37, "R_386_TLS_TPOFF32"},
}
-func (i R_386) String() string { return stringName(uint32(i), r386Strings, false) }
-func (i R_386) GoString() string { return stringName(uint32(i), r386Strings, true) }
+func (i R_386) String() string { return stringName(uint32(i), r386Strings, false) }
+func (i R_386) GoString() string { return stringName(uint32(i), r386Strings, true) }
// Relocation types for PowerPC.
type R_PPC int
const (
- R_PPC_NONE R_PPC = 0; /* No relocation. */
- R_PPC_ADDR32 R_PPC = 1;
- R_PPC_ADDR24 R_PPC = 2;
- R_PPC_ADDR16 R_PPC = 3;
- R_PPC_ADDR16_LO R_PPC = 4;
- R_PPC_ADDR16_HI R_PPC = 5;
- R_PPC_ADDR16_HA R_PPC = 6;
- R_PPC_ADDR14 R_PPC = 7;
- R_PPC_ADDR14_BRTAKEN R_PPC = 8;
- R_PPC_ADDR14_BRNTAKEN R_PPC = 9;
- R_PPC_REL24 R_PPC = 10;
- R_PPC_REL14 R_PPC = 11;
- R_PPC_REL14_BRTAKEN R_PPC = 12;
- R_PPC_REL14_BRNTAKEN R_PPC = 13;
- R_PPC_GOT16 R_PPC = 14;
- R_PPC_GOT16_LO R_PPC = 15;
- R_PPC_GOT16_HI R_PPC = 16;
- R_PPC_GOT16_HA R_PPC = 17;
- R_PPC_PLTREL24 R_PPC = 18;
- R_PPC_COPY R_PPC = 19;
- R_PPC_GLOB_DAT R_PPC = 20;
- R_PPC_JMP_SLOT R_PPC = 21;
- R_PPC_RELATIVE R_PPC = 22;
- R_PPC_LOCAL24PC R_PPC = 23;
- R_PPC_UADDR32 R_PPC = 24;
- R_PPC_UADDR16 R_PPC = 25;
- R_PPC_REL32 R_PPC = 26;
- R_PPC_PLT32 R_PPC = 27;
- R_PPC_PLTREL32 R_PPC = 28;
- R_PPC_PLT16_LO R_PPC = 29;
- R_PPC_PLT16_HI R_PPC = 30;
- R_PPC_PLT16_HA R_PPC = 31;
- R_PPC_SDAREL16 R_PPC = 32;
- R_PPC_SECTOFF R_PPC = 33;
- R_PPC_SECTOFF_LO R_PPC = 34;
- R_PPC_SECTOFF_HI R_PPC = 35;
- R_PPC_SECTOFF_HA R_PPC = 36;
- R_PPC_TLS R_PPC = 67;
- R_PPC_DTPMOD32 R_PPC = 68;
- R_PPC_TPREL16 R_PPC = 69;
- R_PPC_TPREL16_LO R_PPC = 70;
- R_PPC_TPREL16_HI R_PPC = 71;
- R_PPC_TPREL16_HA R_PPC = 72;
- R_PPC_TPREL32 R_PPC = 73;
- R_PPC_DTPREL16 R_PPC = 74;
- R_PPC_DTPREL16_LO R_PPC = 75;
- R_PPC_DTPREL16_HI R_PPC = 76;
- R_PPC_DTPREL16_HA R_PPC = 77;
- R_PPC_DTPREL32 R_PPC = 78;
- R_PPC_GOT_TLSGD16 R_PPC = 79;
- R_PPC_GOT_TLSGD16_LO R_PPC = 80;
- R_PPC_GOT_TLSGD16_HI R_PPC = 81;
- R_PPC_GOT_TLSGD16_HA R_PPC = 82;
- R_PPC_GOT_TLSLD16 R_PPC = 83;
- R_PPC_GOT_TLSLD16_LO R_PPC = 84;
- R_PPC_GOT_TLSLD16_HI R_PPC = 85;
- R_PPC_GOT_TLSLD16_HA R_PPC = 86;
- R_PPC_GOT_TPREL16 R_PPC = 87;
- R_PPC_GOT_TPREL16_LO R_PPC = 88;
- R_PPC_GOT_TPREL16_HI R_PPC = 89;
- R_PPC_GOT_TPREL16_HA R_PPC = 90;
- R_PPC_EMB_NADDR32 R_PPC = 101;
- R_PPC_EMB_NADDR16 R_PPC = 102;
- R_PPC_EMB_NADDR16_LO R_PPC = 103;
- R_PPC_EMB_NADDR16_HI R_PPC = 104;
- R_PPC_EMB_NADDR16_HA R_PPC = 105;
- R_PPC_EMB_SDAI16 R_PPC = 106;
- R_PPC_EMB_SDA2I16 R_PPC = 107;
- R_PPC_EMB_SDA2REL R_PPC = 108;
- R_PPC_EMB_SDA21 R_PPC = 109;
- R_PPC_EMB_MRKREF R_PPC = 110;
- R_PPC_EMB_RELSEC16 R_PPC = 111;
- R_PPC_EMB_RELST_LO R_PPC = 112;
- R_PPC_EMB_RELST_HI R_PPC = 113;
- R_PPC_EMB_RELST_HA R_PPC = 114;
- R_PPC_EMB_BIT_FLD R_PPC = 115;
- R_PPC_EMB_RELSDA R_PPC = 116;
+ R_PPC_NONE R_PPC = 0 /* No relocation. */
+ R_PPC_ADDR32 R_PPC = 1
+ R_PPC_ADDR24 R_PPC = 2
+ R_PPC_ADDR16 R_PPC = 3
+ R_PPC_ADDR16_LO R_PPC = 4
+ R_PPC_ADDR16_HI R_PPC = 5
+ R_PPC_ADDR16_HA R_PPC = 6
+ R_PPC_ADDR14 R_PPC = 7
+ R_PPC_ADDR14_BRTAKEN R_PPC = 8
+ R_PPC_ADDR14_BRNTAKEN R_PPC = 9
+ R_PPC_REL24 R_PPC = 10
+ R_PPC_REL14 R_PPC = 11
+ R_PPC_REL14_BRTAKEN R_PPC = 12
+ R_PPC_REL14_BRNTAKEN R_PPC = 13
+ R_PPC_GOT16 R_PPC = 14
+ R_PPC_GOT16_LO R_PPC = 15
+ R_PPC_GOT16_HI R_PPC = 16
+ R_PPC_GOT16_HA R_PPC = 17
+ R_PPC_PLTREL24 R_PPC = 18
+ R_PPC_COPY R_PPC = 19
+ R_PPC_GLOB_DAT R_PPC = 20
+ R_PPC_JMP_SLOT R_PPC = 21
+ R_PPC_RELATIVE R_PPC = 22
+ R_PPC_LOCAL24PC R_PPC = 23
+ R_PPC_UADDR32 R_PPC = 24
+ R_PPC_UADDR16 R_PPC = 25
+ R_PPC_REL32 R_PPC = 26
+ R_PPC_PLT32 R_PPC = 27
+ R_PPC_PLTREL32 R_PPC = 28
+ R_PPC_PLT16_LO R_PPC = 29
+ R_PPC_PLT16_HI R_PPC = 30
+ R_PPC_PLT16_HA R_PPC = 31
+ R_PPC_SDAREL16 R_PPC = 32
+ R_PPC_SECTOFF R_PPC = 33
+ R_PPC_SECTOFF_LO R_PPC = 34
+ R_PPC_SECTOFF_HI R_PPC = 35
+ R_PPC_SECTOFF_HA R_PPC = 36
+ R_PPC_TLS R_PPC = 67
+ R_PPC_DTPMOD32 R_PPC = 68
+ R_PPC_TPREL16 R_PPC = 69
+ R_PPC_TPREL16_LO R_PPC = 70
+ R_PPC_TPREL16_HI R_PPC = 71
+ R_PPC_TPREL16_HA R_PPC = 72
+ R_PPC_TPREL32 R_PPC = 73
+ R_PPC_DTPREL16 R_PPC = 74
+ R_PPC_DTPREL16_LO R_PPC = 75
+ R_PPC_DTPREL16_HI R_PPC = 76
+ R_PPC_DTPREL16_HA R_PPC = 77
+ R_PPC_DTPREL32 R_PPC = 78
+ R_PPC_GOT_TLSGD16 R_PPC = 79
+ R_PPC_GOT_TLSGD16_LO R_PPC = 80
+ R_PPC_GOT_TLSGD16_HI R_PPC = 81
+ R_PPC_GOT_TLSGD16_HA R_PPC = 82
+ R_PPC_GOT_TLSLD16 R_PPC = 83
+ R_PPC_GOT_TLSLD16_LO R_PPC = 84
+ R_PPC_GOT_TLSLD16_HI R_PPC = 85
+ R_PPC_GOT_TLSLD16_HA R_PPC = 86
+ R_PPC_GOT_TPREL16 R_PPC = 87
+ R_PPC_GOT_TPREL16_LO R_PPC = 88
+ R_PPC_GOT_TPREL16_HI R_PPC = 89
+ R_PPC_GOT_TPREL16_HA R_PPC = 90
+ R_PPC_EMB_NADDR32 R_PPC = 101
+ R_PPC_EMB_NADDR16 R_PPC = 102
+ R_PPC_EMB_NADDR16_LO R_PPC = 103
+ R_PPC_EMB_NADDR16_HI R_PPC = 104
+ R_PPC_EMB_NADDR16_HA R_PPC = 105
+ R_PPC_EMB_SDAI16 R_PPC = 106
+ R_PPC_EMB_SDA2I16 R_PPC = 107
+ R_PPC_EMB_SDA2REL R_PPC = 108
+ R_PPC_EMB_SDA21 R_PPC = 109
+ R_PPC_EMB_MRKREF R_PPC = 110
+ R_PPC_EMB_RELSEC16 R_PPC = 111
+ R_PPC_EMB_RELST_LO R_PPC = 112
+ R_PPC_EMB_RELST_HI R_PPC = 113
+ R_PPC_EMB_RELST_HA R_PPC = 114
+ R_PPC_EMB_BIT_FLD R_PPC = 115
+ R_PPC_EMB_RELSDA R_PPC = 116
)
var rppcStrings = []intName{
@@ -1142,69 +1142,69 @@ var rppcStrings = []intName{
intName{116, "R_PPC_EMB_RELSDA"},
}
-func (i R_PPC) String() string { return stringName(uint32(i), rppcStrings, false) }
-func (i R_PPC) GoString() string { return stringName(uint32(i), rppcStrings, true) }
+func (i R_PPC) String() string { return stringName(uint32(i), rppcStrings, false) }
+func (i R_PPC) GoString() string { return stringName(uint32(i), rppcStrings, true) }
// Relocation types for SPARC.
type R_SPARC int
const (
- R_SPARC_NONE R_SPARC = 0;
- R_SPARC_8 R_SPARC = 1;
- R_SPARC_16 R_SPARC = 2;
- R_SPARC_32 R_SPARC = 3;
- R_SPARC_DISP8 R_SPARC = 4;
- R_SPARC_DISP16 R_SPARC = 5;
- R_SPARC_DISP32 R_SPARC = 6;
- R_SPARC_WDISP30 R_SPARC = 7;
- R_SPARC_WDISP22 R_SPARC = 8;
- R_SPARC_HI22 R_SPARC = 9;
- R_SPARC_22 R_SPARC = 10;
- R_SPARC_13 R_SPARC = 11;
- R_SPARC_LO10 R_SPARC = 12;
- R_SPARC_GOT10 R_SPARC = 13;
- R_SPARC_GOT13 R_SPARC = 14;
- R_SPARC_GOT22 R_SPARC = 15;
- R_SPARC_PC10 R_SPARC = 16;
- R_SPARC_PC22 R_SPARC = 17;
- R_SPARC_WPLT30 R_SPARC = 18;
- R_SPARC_COPY R_SPARC = 19;
- R_SPARC_GLOB_DAT R_SPARC = 20;
- R_SPARC_JMP_SLOT R_SPARC = 21;
- R_SPARC_RELATIVE R_SPARC = 22;
- R_SPARC_UA32 R_SPARC = 23;
- R_SPARC_PLT32 R_SPARC = 24;
- R_SPARC_HIPLT22 R_SPARC = 25;
- R_SPARC_LOPLT10 R_SPARC = 26;
- R_SPARC_PCPLT32 R_SPARC = 27;
- R_SPARC_PCPLT22 R_SPARC = 28;
- R_SPARC_PCPLT10 R_SPARC = 29;
- R_SPARC_10 R_SPARC = 30;
- R_SPARC_11 R_SPARC = 31;
- R_SPARC_64 R_SPARC = 32;
- R_SPARC_OLO10 R_SPARC = 33;
- R_SPARC_HH22 R_SPARC = 34;
- R_SPARC_HM10 R_SPARC = 35;
- R_SPARC_LM22 R_SPARC = 36;
- R_SPARC_PC_HH22 R_SPARC = 37;
- R_SPARC_PC_HM10 R_SPARC = 38;
- R_SPARC_PC_LM22 R_SPARC = 39;
- R_SPARC_WDISP16 R_SPARC = 40;
- R_SPARC_WDISP19 R_SPARC = 41;
- R_SPARC_GLOB_JMP R_SPARC = 42;
- R_SPARC_7 R_SPARC = 43;
- R_SPARC_5 R_SPARC = 44;
- R_SPARC_6 R_SPARC = 45;
- R_SPARC_DISP64 R_SPARC = 46;
- R_SPARC_PLT64 R_SPARC = 47;
- R_SPARC_HIX22 R_SPARC = 48;
- R_SPARC_LOX10 R_SPARC = 49;
- R_SPARC_H44 R_SPARC = 50;
- R_SPARC_M44 R_SPARC = 51;
- R_SPARC_L44 R_SPARC = 52;
- R_SPARC_REGISTER R_SPARC = 53;
- R_SPARC_UA64 R_SPARC = 54;
- R_SPARC_UA16 R_SPARC = 55;
+ R_SPARC_NONE R_SPARC = 0
+ R_SPARC_8 R_SPARC = 1
+ R_SPARC_16 R_SPARC = 2
+ R_SPARC_32 R_SPARC = 3
+ R_SPARC_DISP8 R_SPARC = 4
+ R_SPARC_DISP16 R_SPARC = 5
+ R_SPARC_DISP32 R_SPARC = 6
+ R_SPARC_WDISP30 R_SPARC = 7
+ R_SPARC_WDISP22 R_SPARC = 8
+ R_SPARC_HI22 R_SPARC = 9
+ R_SPARC_22 R_SPARC = 10
+ R_SPARC_13 R_SPARC = 11
+ R_SPARC_LO10 R_SPARC = 12
+ R_SPARC_GOT10 R_SPARC = 13
+ R_SPARC_GOT13 R_SPARC = 14
+ R_SPARC_GOT22 R_SPARC = 15
+ R_SPARC_PC10 R_SPARC = 16
+ R_SPARC_PC22 R_SPARC = 17
+ R_SPARC_WPLT30 R_SPARC = 18
+ R_SPARC_COPY R_SPARC = 19
+ R_SPARC_GLOB_DAT R_SPARC = 20
+ R_SPARC_JMP_SLOT R_SPARC = 21
+ R_SPARC_RELATIVE R_SPARC = 22
+ R_SPARC_UA32 R_SPARC = 23
+ R_SPARC_PLT32 R_SPARC = 24
+ R_SPARC_HIPLT22 R_SPARC = 25
+ R_SPARC_LOPLT10 R_SPARC = 26
+ R_SPARC_PCPLT32 R_SPARC = 27
+ R_SPARC_PCPLT22 R_SPARC = 28
+ R_SPARC_PCPLT10 R_SPARC = 29
+ R_SPARC_10 R_SPARC = 30
+ R_SPARC_11 R_SPARC = 31
+ R_SPARC_64 R_SPARC = 32
+ R_SPARC_OLO10 R_SPARC = 33
+ R_SPARC_HH22 R_SPARC = 34
+ R_SPARC_HM10 R_SPARC = 35
+ R_SPARC_LM22 R_SPARC = 36
+ R_SPARC_PC_HH22 R_SPARC = 37
+ R_SPARC_PC_HM10 R_SPARC = 38
+ R_SPARC_PC_LM22 R_SPARC = 39
+ R_SPARC_WDISP16 R_SPARC = 40
+ R_SPARC_WDISP19 R_SPARC = 41
+ R_SPARC_GLOB_JMP R_SPARC = 42
+ R_SPARC_7 R_SPARC = 43
+ R_SPARC_5 R_SPARC = 44
+ R_SPARC_6 R_SPARC = 45
+ R_SPARC_DISP64 R_SPARC = 46
+ R_SPARC_PLT64 R_SPARC = 47
+ R_SPARC_HIX22 R_SPARC = 48
+ R_SPARC_LOX10 R_SPARC = 49
+ R_SPARC_H44 R_SPARC = 50
+ R_SPARC_M44 R_SPARC = 51
+ R_SPARC_L44 R_SPARC = 52
+ R_SPARC_REGISTER R_SPARC = 53
+ R_SPARC_UA64 R_SPARC = 54
+ R_SPARC_UA16 R_SPARC = 55
)
var rsparcStrings = []intName{
@@ -1266,8 +1266,8 @@ var rsparcStrings = []intName{
intName{55, "R_SPARC_UA16"},
}
-func (i R_SPARC) String() string { return stringName(uint32(i), rsparcStrings, false) }
-func (i R_SPARC) GoString() string { return stringName(uint32(i), rsparcStrings, true) }
+func (i R_SPARC) String() string { return stringName(uint32(i), rsparcStrings, false) }
+func (i R_SPARC) GoString() string { return stringName(uint32(i), rsparcStrings, true) }
/*
* Magic number for the elf trampoline, chosen wisely to be an immediate
@@ -1280,58 +1280,58 @@ const ARM_MAGIC_TRAMP_NUMBER = 0x5c000003
* ELF32 File header.
*/
type Header32 struct {
- Ident [EI_NIDENT]byte; /* File identification. */
- Type uint16; /* File type. */
- Machine uint16; /* Machine architecture. */
- Version uint32; /* ELF format version. */
- Entry uint32; /* Entry point. */
- Phoff uint32; /* Program header file offset. */
- Shoff uint32; /* Section header file offset. */
- Flags uint32; /* Architecture-specific flags. */
- Ehsize uint16; /* Size of ELF header in bytes. */
- Phentsize uint16; /* Size of program header entry. */
- Phnum uint16; /* Number of program header entries. */
- Shentsize uint16; /* Size of section header entry. */
- Shnum uint16; /* Number of section header entries. */
- Shstrndx uint16; /* Section name strings section. */
+ Ident [EI_NIDENT]byte /* File identification. */
+ Type uint16 /* File type. */
+ Machine uint16 /* Machine architecture. */
+ Version uint32 /* ELF format version. */
+ Entry uint32 /* Entry point. */
+ Phoff uint32 /* Program header file offset. */
+ Shoff uint32 /* Section header file offset. */
+ Flags uint32 /* Architecture-specific flags. */
+ Ehsize uint16 /* Size of ELF header in bytes. */
+ Phentsize uint16 /* Size of program header entry. */
+ Phnum uint16 /* Number of program header entries. */
+ Shentsize uint16 /* Size of section header entry. */
+ Shnum uint16 /* Number of section header entries. */
+ Shstrndx uint16 /* Section name strings section. */
}
/*
* ELF32 Section header.
*/
type Section32 struct {
- Name uint32; /* Section name (index into the section header string table). */
- Type uint32; /* Section type. */
- Flags uint32; /* Section flags. */
- Addr uint32; /* Address in memory image. */
- Off uint32; /* Offset in file. */
- Size uint32; /* Size in bytes. */
- Link uint32; /* Index of a related section. */
- Info uint32; /* Depends on section type. */
- Addralign uint32; /* Alignment in bytes. */
- Entsize uint32; /* Size of each entry in section. */
+ Name uint32 /* Section name (index into the section header string table). */
+ Type uint32 /* Section type. */
+ Flags uint32 /* Section flags. */
+ Addr uint32 /* Address in memory image. */
+ Off uint32 /* Offset in file. */
+ Size uint32 /* Size in bytes. */
+ Link uint32 /* Index of a related section. */
+ Info uint32 /* Depends on section type. */
+ Addralign uint32 /* Alignment in bytes. */
+ Entsize uint32 /* Size of each entry in section. */
}
/*
* ELF32 Program header.
*/
type Prog32 struct {
- Type uint32; /* Entry type. */
- Off uint32; /* File offset of contents. */
- Vaddr uint32; /* Virtual address in memory image. */
- Paddr uint32; /* Physical address (not used). */
- Filesz uint32; /* Size of contents in file. */
- Memsz uint32; /* Size of contents in memory. */
- Flags uint32; /* Access permission flags. */
- Align uint32; /* Alignment in memory and file. */
+ Type uint32 /* Entry type. */
+ Off uint32 /* File offset of contents. */
+ Vaddr uint32 /* Virtual address in memory image. */
+ Paddr uint32 /* Physical address (not used). */
+ Filesz uint32 /* Size of contents in file. */
+ Memsz uint32 /* Size of contents in memory. */
+ Flags uint32 /* Access permission flags. */
+ Align uint32 /* Alignment in memory and file. */
}
/*
* ELF32 Dynamic structure. The ".dynamic" section contains an array of them.
*/
type Dyn32 struct {
- Tag int32; /* Entry type. */
- Val uint32; /* Integer/Address value. */
+ Tag int32 /* Entry type. */
+ Val uint32 /* Integer/Address value. */
}
/*
@@ -1340,36 +1340,36 @@ type Dyn32 struct {
// ELF32 Relocations that don't need an addend field.
type Rel32 struct {
- Off uint32; /* Location to be relocated. */
- Info uint32; /* Relocation type and symbol index. */
+ Off uint32 /* Location to be relocated. */
+ Info uint32 /* Relocation type and symbol index. */
}
// ELF32 Relocations that need an addend field.
type Rela32 struct {
- Off uint32; /* Location to be relocated. */
- Info uint32; /* Relocation type and symbol index. */
- Addend int32; /* Addend. */
+ Off uint32 /* Location to be relocated. */
+ Info uint32 /* Relocation type and symbol index. */
+ 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_INFO32(sym, typ uint32) uint32 { return sym<<8 | typ }
+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.
type Sym32 struct {
- Name uint32;
- Value uint32;
- Size uint32;
- Info uint8;
- Other uint8;
- Shndx uint16;
+ Name uint32
+ Value uint32
+ Size uint32
+ Info uint8
+ Other uint8
+ Shndx uint16
}
const Sym32Size = 16
-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_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) }
/*
* ELF64
@@ -1380,20 +1380,20 @@ func ST_VISIBILITY(other uint8) SymVis { return SymVis(other & 3) }
*/
type Header64 struct {
- Ident [EI_NIDENT]byte; /* File identification. */
- Type uint16; /* File type. */
- Machine uint16; /* Machine architecture. */
- Version uint32; /* ELF format version. */
- Entry uint64; /* Entry point. */
- Phoff uint64; /* Program header file offset. */
- Shoff uint64; /* Section header file offset. */
- Flags uint32; /* Architecture-specific flags. */
- Ehsize uint16; /* Size of ELF header in bytes. */
- Phentsize uint16; /* Size of program header entry. */
- Phnum uint16; /* Number of program header entries. */
- Shentsize uint16; /* Size of section header entry. */
- Shnum uint16; /* Number of section header entries. */
- Shstrndx uint16; /* Section name strings section. */
+ Ident [EI_NIDENT]byte /* File identification. */
+ Type uint16 /* File type. */
+ Machine uint16 /* Machine architecture. */
+ Version uint32 /* ELF format version. */
+ Entry uint64 /* Entry point. */
+ Phoff uint64 /* Program header file offset. */
+ Shoff uint64 /* Section header file offset. */
+ Flags uint32 /* Architecture-specific flags. */
+ Ehsize uint16 /* Size of ELF header in bytes. */
+ Phentsize uint16 /* Size of program header entry. */
+ Phnum uint16 /* Number of program header entries. */
+ Shentsize uint16 /* Size of section header entry. */
+ Shnum uint16 /* Number of section header entries. */
+ Shstrndx uint16 /* Section name strings section. */
}
/*
@@ -1401,16 +1401,16 @@ type Header64 struct {
*/
type Section64 struct {
- Name uint32; /* Section name (index into the section header string table). */
- Type uint32; /* Section type. */
- Flags uint64; /* Section flags. */
- Addr uint64; /* Address in memory image. */
- Off uint64; /* Offset in file. */
- Size uint64; /* Size in bytes. */
- Link uint32; /* Index of a related section. */
- Info uint32; /* Depends on section type. */
- Addralign uint64; /* Alignment in bytes. */
- Entsize uint64; /* Size of each entry in section. */
+ Name uint32 /* Section name (index into the section header string table). */
+ Type uint32 /* Section type. */
+ Flags uint64 /* Section flags. */
+ Addr uint64 /* Address in memory image. */
+ Off uint64 /* Offset in file. */
+ Size uint64 /* Size in bytes. */
+ Link uint32 /* Index of a related section. */
+ Info uint32 /* Depends on section type. */
+ Addralign uint64 /* Alignment in bytes. */
+ Entsize uint64 /* Size of each entry in section. */
}
/*
@@ -1418,14 +1418,14 @@ type Section64 struct {
*/
type Prog64 struct {
- Type uint32; /* Entry type. */
- Flags uint32; /* Access permission flags. */
- Off uint64; /* File offset of contents. */
- Vaddr uint64; /* Virtual address in memory image. */
- Paddr uint64; /* Physical address (not used). */
- Filesz uint64; /* Size of contents in file. */
- Memsz uint64; /* Size of contents in memory. */
- Align uint64; /* Alignment in memory and file. */
+ Type uint32 /* Entry type. */
+ Flags uint32 /* Access permission flags. */
+ Off uint64 /* File offset of contents. */
+ Vaddr uint64 /* Virtual address in memory image. */
+ Paddr uint64 /* Physical address (not used). */
+ Filesz uint64 /* Size of contents in file. */
+ Memsz uint64 /* Size of contents in memory. */
+ Align uint64 /* Alignment in memory and file. */
}
/*
@@ -1433,8 +1433,8 @@ type Prog64 struct {
*/
type Dyn64 struct {
- Tag int64; /* Entry type. */
- Val uint64; /* Integer/address value */
+ Tag int64 /* Entry type. */
+ Val uint64 /* Integer/address value */
}
/*
@@ -1443,39 +1443,39 @@ type Dyn64 struct {
/* ELF64 relocations that don't need an addend field. */
type Rel64 struct {
- Off uint64; /* Location to be relocated. */
- Info uint64; /* Relocation type and symbol index. */
+ Off uint64 /* Location to be relocated. */
+ Info uint64 /* Relocation type and symbol index. */
}
/* ELF64 relocations that need an addend field. */
type Rela64 struct {
- Off uint64; /* Location to be relocated. */
- Info uint64; /* Relocation type and symbol index. */
- Addend int64; /* Addend. */
+ Off uint64 /* Location to be relocated. */
+ Info uint64 /* Relocation type and symbol index. */
+ Addend int64 /* Addend. */
}
-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) }
+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) }
/*
* ELF64 symbol table entries.
*/
type Sym64 struct {
- Name uint32; /* String table index of name. */
- Info uint8; /* Type and binding information. */
- Other uint8; /* Reserved (not used). */
- Shndx uint16; /* Section index of symbol. */
- Value uint64; /* Symbol value. */
- Size uint64; /* Size of associated object. */
+ Name uint32 /* String table index of name. */
+ Info uint8 /* Type and binding information. */
+ Other uint8 /* Reserved (not used). */
+ Shndx uint16 /* Section index of symbol. */
+ Value uint64 /* Symbol value. */
+ Size uint64 /* Size of associated object. */
}
const Sym64Size = 24
type intName struct {
- i uint32;
- s string;
+ i uint32
+ s string
}
func stringName(i uint32, names []intName, goSyntax bool) string {
@@ -1484,28 +1484,28 @@ func stringName(i uint32, names []intName, goSyntax bool) string {
if goSyntax {
return "elf." + n.s
}
- return n.s;
+ return n.s
}
}
// second pass - look for smaller to add with.
// assume sorted already
for j := len(names) - 1; j >= 0; j-- {
- n := names[j];
+ n := names[j]
if n.i < i {
- s := n.s;
+ s := n.s
if goSyntax {
s = "elf." + s
}
- return s + "+" + strconv.Uitoa64(uint64(i-n.i));
+ return s + "+" + strconv.Uitoa64(uint64(i-n.i))
}
}
- return strconv.Uitoa64(uint64(i));
+ return strconv.Uitoa64(uint64(i))
}
func flagName(i uint32, names []intName, goSyntax bool) string {
- s := "";
+ s := ""
for _, n := range names {
if n.i&i == n.i {
if len(s) > 0 {
@@ -1514,8 +1514,8 @@ func flagName(i uint32, names []intName, goSyntax bool) string {
if goSyntax {
s += "elf."
}
- s += n.s;
- i -= n.i;
+ s += n.s
+ i -= n.i
}
}
if len(s) == 0 {
@@ -1524,5 +1524,5 @@ func flagName(i uint32, names []intName, goSyntax bool) string {
if i != 0 {
s += "+0x" + strconv.Uitob64(uint64(i), 16)
}
- return s;
+ return s
}
diff --git a/src/pkg/debug/elf/elf_test.go b/src/pkg/debug/elf/elf_test.go
index bc2a4f687..6f827faf0 100644
--- a/src/pkg/debug/elf/elf_test.go
+++ b/src/pkg/debug/elf/elf_test.go
@@ -5,13 +5,13 @@
package elf
import (
- "fmt";
- "testing";
+ "fmt"
+ "testing"
)
type nameTest struct {
- val interface{};
- str string;
+ val interface{}
+ str string
}
var nameTests = []nameTest{
@@ -41,7 +41,7 @@ var nameTests = []nameTest{
func TestNames(t *testing.T) {
for i, tt := range nameTests {
- s := fmt.Sprint(tt.val);
+ s := fmt.Sprint(tt.val)
if s != tt.str {
t.Errorf("#%d: want %q have %q", i, s, tt.str)
}
diff --git a/src/pkg/debug/elf/file.go b/src/pkg/debug/elf/file.go
index e610bc2eb..c7ef955e6 100644
--- a/src/pkg/debug/elf/file.go
+++ b/src/pkg/debug/elf/file.go
@@ -6,12 +6,12 @@
package elf
import (
- "bytes";
- "debug/dwarf";
- "encoding/binary";
- "fmt";
- "io";
- "os";
+ "bytes"
+ "debug/dwarf"
+ "encoding/binary"
+ "fmt"
+ "io"
+ "os"
)
// TODO: error reporting detail
@@ -22,41 +22,41 @@ import (
// A FileHeader represents an ELF file header.
type FileHeader struct {
- Class Class;
- Data Data;
- Version Version;
- OSABI OSABI;
- ABIVersion uint8;
- ByteOrder binary.ByteOrder;
- Type Type;
- Machine Machine;
+ Class Class
+ Data Data
+ Version Version
+ OSABI OSABI
+ ABIVersion uint8
+ ByteOrder binary.ByteOrder
+ Type Type
+ Machine Machine
}
// A File represents an open ELF file.
type File struct {
- FileHeader;
- Sections []*Section;
- Progs []*Prog;
- closer io.Closer;
+ FileHeader
+ Sections []*Section
+ Progs []*Prog
+ closer io.Closer
}
// A SectionHeader represents a single ELF section header.
type SectionHeader struct {
- Name string;
- Type SectionType;
- Flags SectionFlag;
- Addr uint64;
- Offset uint64;
- Size uint64;
- Link uint32;
- Info uint32;
- Addralign uint64;
- Entsize uint64;
+ Name string
+ Type SectionType
+ Flags SectionFlag
+ Addr uint64
+ Offset uint64
+ Size uint64
+ Link uint32
+ Info uint32
+ Addralign uint64
+ Entsize uint64
}
// A Section represents a single section in an ELF file.
type Section struct {
- SectionHeader;
+ SectionHeader
// Embed ReaderAt for ReadAt method.
// Do not embed SectionReader directly
@@ -64,34 +64,34 @@ type Section struct {
// If a client wants Read and Seek it must use
// Open() to avoid fighting over the seek offset
// with other clients.
- io.ReaderAt;
- sr *io.SectionReader;
+ io.ReaderAt
+ sr *io.SectionReader
}
// Data reads and returns the contents of the ELF section.
func (s *Section) Data() ([]byte, os.Error) {
- dat := make([]byte, s.sr.Size());
- n, err := s.sr.ReadAt(dat, 0);
- return dat[0:n], err;
+ dat := make([]byte, s.sr.Size())
+ n, err := s.sr.ReadAt(dat, 0)
+ return dat[0:n], err
}
// 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 {
- Type ProgType;
- Flags ProgFlag;
- Vaddr uint64;
- Paddr uint64;
- Filesz uint64;
- Memsz uint64;
- Align uint64;
+ Type ProgType
+ Flags ProgFlag
+ Vaddr uint64
+ Paddr uint64
+ Filesz uint64
+ Memsz uint64
+ Align uint64
}
// A Prog represents a single ELF program header in an ELF binary.
type Prog struct {
- ProgHeader;
+ ProgHeader
// Embed ReaderAt for ReadAt method.
// Do not embed SectionReader directly
@@ -99,19 +99,19 @@ type Prog struct {
// If a client wants Read and Seek it must use
// Open() to avoid fighting over the seek offset
// with other clients.
- io.ReaderAt;
- sr *io.SectionReader;
+ io.ReaderAt
+ sr *io.SectionReader
}
// 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 {
- Name uint32;
- Info, Other byte;
- Section uint32;
- Value, Size uint64;
+ Name uint32
+ Info, Other byte
+ Section uint32
+ Value, Size uint64
}
/*
@@ -119,53 +119,53 @@ type Symbol struct {
*/
type FormatError struct {
- off int64;
- msg string;
- val interface{};
+ off int64
+ msg string
+ val interface{}
}
func (e *FormatError) String() string {
- msg := e.msg;
+ msg := e.msg
if e.val != nil {
msg += fmt.Sprintf(" '%v' ", e.val)
}
- msg += fmt.Sprintf("in record at byte %#x", e.off);
- return msg;
+ msg += fmt.Sprintf("in record at byte %#x", e.off)
+ return msg
}
// Open opens the named file using os.Open and prepares it for use as an ELF binary.
func Open(name string) (*File, os.Error) {
- f, err := os.Open(name, os.O_RDONLY, 0);
+ f, err := os.Open(name, os.O_RDONLY, 0)
if err != nil {
return nil, err
}
- ff, err := NewFile(f);
+ ff, err := NewFile(f)
if err != nil {
- f.Close();
- return nil, err;
+ f.Close()
+ return nil, err
}
- ff.closer = f;
- return ff, nil;
+ ff.closer = f
+ return ff, nil
}
// Close closes the File.
// If the File was created using NewFile directly instead of Open,
// Close has no effect.
func (f *File) Close() os.Error {
- var err os.Error;
+ var err os.Error
if f.closer != nil {
- err = f.closer.Close();
- f.closer = nil;
+ err = f.closer.Close()
+ f.closer = nil
}
- return err;
+ return err
}
// 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;
+ var ident [16]uint8
if _, err := r.ReadAt(&ident, 0); err != nil {
return nil, err
}
@@ -173,8 +173,8 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
return nil, &FormatError{0, "bad magic number", ident[0:4]}
}
- f := new(File);
- f.Class = Class(ident[EI_CLASS]);
+ f := new(File)
+ f.Class = Class(ident[EI_CLASS])
switch f.Class {
case ELFCLASS32:
case ELFCLASS64:
@@ -183,7 +183,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
return nil, &FormatError{0, "unknown ELF class", f.Class}
}
- f.Data = Data(ident[EI_DATA]);
+ f.Data = Data(ident[EI_DATA])
switch f.Data {
case ELFDATA2LSB:
f.ByteOrder = binary.LittleEndian
@@ -193,49 +193,49 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
return nil, &FormatError{0, "unknown ELF data encoding", f.Data}
}
- f.Version = Version(ident[EI_VERSION]);
+ f.Version = Version(ident[EI_VERSION])
if f.Version != EV_CURRENT {
return nil, &FormatError{0, "unknown ELF version", f.Version}
}
- f.OSABI = OSABI(ident[EI_OSABI]);
- f.ABIVersion = ident[EI_ABIVERSION];
+ f.OSABI = OSABI(ident[EI_OSABI])
+ f.ABIVersion = ident[EI_ABIVERSION]
// Read ELF file header
- var shoff int64;
- var shentsize, shnum, shstrndx int;
- shstrndx = -1;
+ var shoff int64
+ var shentsize, shnum, shstrndx int
+ shstrndx = -1
switch f.Class {
case ELFCLASS32:
- hdr := new(Header32);
- sr.Seek(0, 0);
+ hdr := new(Header32)
+ sr.Seek(0, 0)
if err := binary.Read(sr, f.ByteOrder, hdr); err != nil {
return nil, err
}
- f.Type = Type(hdr.Type);
- f.Machine = Machine(hdr.Machine);
+ f.Type = Type(hdr.Type)
+ f.Machine = Machine(hdr.Machine)
if v := Version(hdr.Version); v != f.Version {
return nil, &FormatError{0, "mismatched ELF version", v}
}
- shoff = int64(hdr.Shoff);
- shentsize = int(hdr.Shentsize);
- shnum = int(hdr.Shnum);
- shstrndx = int(hdr.Shstrndx);
+ shoff = int64(hdr.Shoff)
+ shentsize = int(hdr.Shentsize)
+ shnum = int(hdr.Shnum)
+ shstrndx = int(hdr.Shstrndx)
case ELFCLASS64:
- hdr := new(Header64);
- sr.Seek(0, 0);
+ hdr := new(Header64)
+ sr.Seek(0, 0)
if err := binary.Read(sr, f.ByteOrder, hdr); err != nil {
return nil, err
}
- f.Type = Type(hdr.Type);
- f.Machine = Machine(hdr.Machine);
+ f.Type = Type(hdr.Type)
+ f.Machine = Machine(hdr.Machine)
if v := Version(hdr.Version); v != f.Version {
return nil, &FormatError{0, "mismatched ELF version", v}
}
- shoff = int64(hdr.Shoff);
- shentsize = int(hdr.Shentsize);
- shnum = int(hdr.Shnum);
- shstrndx = int(hdr.Shstrndx);
+ shoff = int64(hdr.Shoff)
+ shentsize = int(hdr.Shentsize)
+ shnum = int(hdr.Shnum)
+ shstrndx = int(hdr.Shstrndx)
}
if shstrndx < 0 || shstrndx >= shnum {
return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx}
@@ -245,19 +245,19 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
// TODO
// Read section headers
- f.Sections = make([]*Section, shnum);
- names := make([]uint32, shnum);
+ f.Sections = make([]*Section, shnum)
+ names := make([]uint32, shnum)
for i := 0; i < shnum; i++ {
- off := shoff + int64(i)*int64(shentsize);
- sr.Seek(off, 0);
- s := new(Section);
+ off := shoff + int64(i)*int64(shentsize)
+ sr.Seek(off, 0)
+ s := new(Section)
switch f.Class {
case ELFCLASS32:
- sh := new(Section32);
+ sh := new(Section32)
if err := binary.Read(sr, f.ByteOrder, sh); err != nil {
return nil, err
}
- names[i] = sh.Name;
+ names[i] = sh.Name
s.SectionHeader = SectionHeader{
Type: SectionType(sh.Type),
Flags: SectionFlag(sh.Flags),
@@ -268,13 +268,13 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
Info: uint32(sh.Info),
Addralign: uint64(sh.Addralign),
Entsize: uint64(sh.Entsize),
- };
+ }
case ELFCLASS64:
- sh := new(Section64);
+ sh := new(Section64)
if err := binary.Read(sr, f.ByteOrder, sh); err != nil {
return nil, err
}
- names[i] = sh.Name;
+ names[i] = sh.Name
s.SectionHeader = SectionHeader{
Type: SectionType(sh.Type),
Flags: SectionFlag(sh.Flags),
@@ -285,28 +285,28 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
Info: uint32(sh.Info),
Addralign: uint64(sh.Addralign),
Entsize: uint64(sh.Entsize),
- };
+ }
}
- s.sr = io.NewSectionReader(r, int64(s.Offset), int64(s.Size));
- s.ReaderAt = s.sr;
- f.Sections[i] = s;
+ s.sr = io.NewSectionReader(r, int64(s.Offset), int64(s.Size))
+ s.ReaderAt = s.sr
+ f.Sections[i] = s
}
// Load section header string table.
- s := f.Sections[shstrndx];
- shstrtab := make([]byte, s.Size);
+ s := f.Sections[shstrndx]
+ shstrtab := make([]byte, s.Size)
if _, err := r.ReadAt(shstrtab, int64(s.Offset)); err != nil {
return nil, err
}
for i, s := range f.Sections {
- var ok bool;
- s.Name, ok = getString(shstrtab, int(names[i]));
+ 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 f, nil;
+ return f, nil
}
func (f *File) getSymbols() ([]Symbol, os.Error) {
@@ -315,16 +315,16 @@ func (f *File) getSymbols() ([]Symbol, os.Error) {
return f.getSymbols64()
}
- return nil, os.ErrorString("not implemented");
+ return nil, os.ErrorString("not implemented")
}
// GetSymbols returns a slice of Symbols from parsing the symbol table.
func (f *File) getSymbols64() ([]Symbol, os.Error) {
- var symtabSection *Section;
+ var symtabSection *Section
for _, section := range f.Sections {
if section.Type == SHT_SYMTAB {
- symtabSection = section;
- break;
+ symtabSection = section
+ break
}
}
@@ -332,35 +332,35 @@ func (f *File) getSymbols64() ([]Symbol, os.Error) {
return nil, os.ErrorString("no symbol section")
}
- data, err := symtabSection.Data();
+ data, err := symtabSection.Data()
if err != nil {
return nil, os.ErrorString("cannot load symbol section")
}
- symtab := bytes.NewBuffer(data);
+ symtab := bytes.NewBuffer(data)
if symtab.Len()%Sym64Size != 0 {
return nil, os.ErrorString("length of symbol section is not a multiple of Sym64Size")
}
// The first entry is all zeros.
- var skip [Sym64Size]byte;
- symtab.Read(skip[0:]);
+ var skip [Sym64Size]byte
+ symtab.Read(skip[0:])
- symbols := make([]Symbol, symtab.Len()/Sym64Size);
+ symbols := make([]Symbol, symtab.Len()/Sym64Size)
- i := 0;
- var sym Sym64;
+ i := 0
+ var sym Sym64
for symtab.Len() > 0 {
- binary.Read(symtab, f.ByteOrder, &sym);
- symbols[i].Name = sym.Name;
- symbols[i].Info = sym.Info;
- symbols[i].Other = sym.Other;
- symbols[i].Section = uint32(sym.Shndx);
- symbols[i].Value = sym.Value;
- symbols[i].Size = sym.Size;
- i++;
+ binary.Read(symtab, f.ByteOrder, &sym)
+ symbols[i].Name = sym.Name
+ symbols[i].Info = sym.Info
+ symbols[i].Other = sym.Other
+ symbols[i].Section = uint32(sym.Shndx)
+ symbols[i].Value = sym.Value
+ symbols[i].Size = sym.Size
+ i++
}
- return symbols, nil;
+ return symbols, nil
}
// getString extracts a string from an ELF string table.
@@ -374,7 +374,7 @@ func getString(section []byte, start int) (string, bool) {
return string(section[start:end]), true
}
}
- return "", false;
+ return "", false
}
// Section returns a section with the given name, or nil if no such
@@ -385,7 +385,7 @@ func (f *File) Section(name string) *Section {
return s
}
}
- return nil;
+ return nil
}
// applyRelocations applies relocations to dst. rels is a relocations section
@@ -395,7 +395,7 @@ func (f *File) applyRelocations(dst []byte, rels []byte) os.Error {
return f.applyRelocationsAMD64(dst, rels)
}
- return os.ErrorString("not implemented");
+ return os.ErrorString("not implemented")
}
func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) os.Error {
@@ -403,23 +403,23 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) os.Error {
return os.ErrorString("length of relocation section is not a multiple of Sym64Size")
}
- symbols, err := f.getSymbols();
+ symbols, err := f.getSymbols()
if err != nil {
return err
}
- b := bytes.NewBuffer(rels);
- var rela Rela64;
+ b := bytes.NewBuffer(rels)
+ var rela Rela64
for b.Len() > 0 {
- binary.Read(b, f.ByteOrder, &rela);
- symNo := rela.Info >> 32;
- t := R_X86_64(rela.Info & 0xffff);
+ binary.Read(b, f.ByteOrder, &rela)
+ symNo := rela.Info >> 32
+ t := R_X86_64(rela.Info & 0xffff)
if symNo >= uint64(len(symbols)) {
continue
}
- sym := &symbols[symNo];
+ sym := &symbols[symNo]
if SymType(sym.Info&0xf) != STT_SECTION {
// We don't handle non-section relocations for now.
continue
@@ -430,51 +430,51 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) os.Error {
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 {
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))
}
}
- return nil;
+ return nil
}
func (f *File) DWARF() (*dwarf.Data, os.Error) {
// There are many other DWARF sections, but these
// are the required ones, and the debug/dwarf package
// does not use the others, so don't bother loading them.
- var names = [...]string{"abbrev", "info", "str"};
- var dat [len(names)][]byte;
+ var names = [...]string{"abbrev", "info", "str"}
+ var dat [len(names)][]byte
for i, name := range names {
- name = ".debug_" + name;
- s := f.Section(name);
+ name = ".debug_" + name
+ s := f.Section(name)
if s == nil {
continue
}
- b, err := s.Data();
+ b, err := s.Data()
if err != nil && uint64(len(b)) < s.Size {
return nil, err
}
- dat[i] = b;
+ dat[i] = b
}
// If there's a relocation table for .debug_info, we have to process it
// now otherwise the data in .debug_info is invalid for x86-64 objects.
- rela := f.Section(".rela.debug_info");
+ rela := f.Section(".rela.debug_info")
if rela != nil && rela.Type == SHT_RELA && f.Machine == EM_X86_64 {
- data, err := rela.Data();
+ data, err := rela.Data()
if err != nil {
return nil, err
}
- err = f.applyRelocations(dat[1], data);
+ err = f.applyRelocations(dat[1], data)
if err != nil {
return nil, err
}
}
- abbrev, info, str := dat[0], dat[1], dat[2];
- return dwarf.New(abbrev, nil, nil, info, nil, nil, nil, str);
+ abbrev, info, str := dat[0], dat[1], dat[2]
+ return dwarf.New(abbrev, nil, nil, info, nil, nil, nil, str)
}
diff --git a/src/pkg/debug/elf/file_test.go b/src/pkg/debug/elf/file_test.go
index 9cd15fbd3..49adc4dc7 100644
--- a/src/pkg/debug/elf/file_test.go
+++ b/src/pkg/debug/elf/file_test.go
@@ -5,16 +5,16 @@
package elf
import (
- "debug/dwarf";
- "encoding/binary";
- "reflect";
- "testing";
+ "debug/dwarf"
+ "encoding/binary"
+ "reflect"
+ "testing"
)
type fileTest struct {
- file string;
- hdr FileHeader;
- sections []SectionHeader;
+ file string
+ hdr FileHeader
+ sections []SectionHeader
}
var fileTests = []fileTest{
@@ -101,28 +101,28 @@ var fileTests = []fileTest{
func TestOpen(t *testing.T) {
for i := range fileTests {
- tt := &fileTests[i];
+ tt := &fileTests[i]
- f, err := Open(tt.file);
+ f, err := Open(tt.file)
if err != nil {
- t.Error(err);
- continue;
+ t.Error(err)
+ continue
}
if !reflect.DeepEqual(f.FileHeader, tt.hdr) {
- t.Errorf("open %s:\n\thave %#v\n\twant %#v\n", tt.file, f.FileHeader, tt.hdr);
- continue;
+ t.Errorf("open %s:\n\thave %#v\n\twant %#v\n", tt.file, f.FileHeader, tt.hdr)
+ continue
}
for i, s := range f.Sections {
if i >= len(tt.sections) {
break
}
- sh := &tt.sections[i];
+ sh := &tt.sections[i]
if !reflect.DeepEqual(&s.SectionHeader, sh) {
t.Errorf("open %s, section %d:\n\thave %#v\n\twant %#v\n", tt.file, i, &s.SectionHeader, sh)
}
}
- tn := len(tt.sections);
- fn := len(f.Sections);
+ tn := len(tt.sections)
+ fn := len(f.Sections)
if tn != fn {
t.Errorf("open %s: len(Sections) = %d, want %d", tt.file, fn, tn)
}
@@ -130,8 +130,8 @@ func TestOpen(t *testing.T) {
}
type relocationTest struct {
- file string;
- firstEntry *dwarf.Entry;
+ file string
+ firstEntry *dwarf.Entry
}
var relocationTests = []relocationTest{
@@ -151,30 +151,30 @@ var relocationTests = []relocationTest{
func TestDWARFRelocations(t *testing.T) {
for i, test := range relocationTests {
- f, err := Open(test.file);
+ f, err := Open(test.file)
if err != nil {
- t.Error(err);
- continue;
+ t.Error(err)
+ continue
}
- dwarf, err := f.DWARF();
+ dwarf, err := f.DWARF()
if err != nil {
- t.Error(err);
- continue;
+ t.Error(err)
+ continue
}
- reader := dwarf.Reader();
+ reader := dwarf.Reader()
// Checking only the first entry is sufficient since it has
// many different strings. If the relocation had failed, all
// the string offsets would be zero and all the strings would
// end up being the same.
- firstEntry, err := reader.Next();
+ firstEntry, err := reader.Next()
if err != nil {
- t.Error(err);
- continue;
+ t.Error(err)
+ continue
}
if !reflect.DeepEqual(test.firstEntry, firstEntry) {
- t.Errorf("#%d: mismatch: got:%#v want:%#v", i, firstEntry, test.firstEntry);
- continue;
+ t.Errorf("#%d: mismatch: got:%#v want:%#v", i, firstEntry, test.firstEntry)
+ continue
}
}
}
diff --git a/src/pkg/debug/gosym/pclntab.go b/src/pkg/debug/gosym/pclntab.go
index 6c6a18868..9d7b0d15f 100644
--- a/src/pkg/debug/gosym/pclntab.go
+++ b/src/pkg/debug/gosym/pclntab.go
@@ -11,9 +11,9 @@ package gosym
import "encoding/binary"
type LineTable struct {
- Data []byte;
- PC uint64;
- Line int;
+ Data []byte
+ PC uint64
+ Line int
}
// TODO(rsc): Need to pull in quantum from architecture definition.
@@ -28,49 +28,49 @@ func (t *LineTable) parse(targetPC uint64, targetLine int) (b []byte, pc uint64,
//
// Here we process each update individually, which simplifies
// the code, but makes the corner cases more confusing.
- b, pc, line = t.Data, t.PC, t.Line;
+ b, pc, line = t.Data, t.PC, t.Line
for pc <= targetPC && line != targetLine && len(b) > 0 {
- code := b[0];
- b = b[1:];
+ code := b[0]
+ b = b[1:]
switch {
case code == 0:
if len(b) < 4 {
- b = b[0:0];
- break;
+ b = b[0:0]
+ break
}
- val := binary.BigEndian.Uint32(b);
- b = b[4:];
- line += int(val);
+ val := binary.BigEndian.Uint32(b)
+ b = b[4:]
+ line += int(val)
case code <= 64:
line += int(code)
case code <= 128:
line -= int(code - 64)
default:
- pc += quantum * uint64(code-128);
- continue;
+ pc += quantum * uint64(code-128)
+ continue
}
- pc += quantum;
+ pc += quantum
}
- return b, pc, line;
+ return b, pc, line
}
func (t *LineTable) slice(pc uint64) *LineTable {
- data, pc, line := t.parse(pc, -1);
- return &LineTable{data, pc, line};
+ data, pc, line := t.parse(pc, -1)
+ return &LineTable{data, pc, line}
}
func (t *LineTable) PCToLine(pc uint64) int {
- _, _, line := t.parse(pc, -1);
- return line;
+ _, _, line := t.parse(pc, -1)
+ return line
}
func (t *LineTable) LineToPC(line int, maxpc uint64) uint64 {
- _, pc, line1 := t.parse(maxpc, line);
+ _, pc, line1 := t.parse(maxpc, line)
if line1 != line {
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 66609d9cf..9ab493d59 100644
--- a/src/pkg/debug/gosym/pclntab_test.go
+++ b/src/pkg/debug/gosym/pclntab_test.go
@@ -5,10 +5,10 @@
package gosym
import (
- "debug/elf";
- "os";
- "testing";
- "syscall";
+ "debug/elf"
+ "os"
+ "testing"
+ "syscall"
)
func dotest() bool {
@@ -17,40 +17,40 @@ func dotest() bool {
}
func getTable(t *testing.T) *Table {
- f, tab := crack(os.Args[0], t);
- f.Close();
- return tab;
+ f, tab := crack(os.Args[0], t)
+ f.Close()
+ return tab
}
func crack(file string, t *testing.T) (*elf.File, *Table) {
// Open self
- f, err := elf.Open(file);
+ f, err := elf.Open(file)
if err != nil {
t.Fatal(err)
}
- return parse(file, f, t);
+ return parse(file, f, t)
}
func parse(file string, f *elf.File, t *testing.T) (*elf.File, *Table) {
- symdat, err := f.Section(".gosymtab").Data();
+ symdat, err := f.Section(".gosymtab").Data()
if err != nil {
- f.Close();
- t.Fatalf("reading %s gosymtab: %v", file, err);
+ f.Close()
+ t.Fatalf("reading %s gosymtab: %v", file, err)
}
- pclndat, err := f.Section(".gopclntab").Data();
+ pclndat, err := f.Section(".gopclntab").Data()
if err != nil {
- f.Close();
- t.Fatalf("reading %s gopclntab: %v", file, err);
+ f.Close()
+ t.Fatalf("reading %s gopclntab: %v", file, err)
}
- pcln := NewLineTable(pclndat, f.Section(".text").Addr);
- tab, err := NewTable(symdat, pcln);
+ pcln := NewLineTable(pclndat, f.Section(".text").Addr)
+ tab, err := NewTable(symdat, pcln)
if err != nil {
- f.Close();
- t.Fatalf("parsing %s gosymtab: %v", file, err);
+ f.Close()
+ t.Fatalf("parsing %s gosymtab: %v", file, err)
}
- return f, tab;
+ return f, tab
}
var goarch = os.Getenv("O")
@@ -60,42 +60,42 @@ func TestLineFromAline(t *testing.T) {
return
}
- tab := getTable(t);
+ tab := getTable(t)
// Find the sym package
- pkg := tab.LookupFunc("gosym.TestLineFromAline").Obj;
+ pkg := tab.LookupFunc("gosym.TestLineFromAline").Obj
if pkg == nil {
t.Fatalf("nil pkg")
}
// Walk every absolute line and ensure that we hit every
// source line monotonically
- lastline := make(map[string]int);
- final := -1;
+ lastline := make(map[string]int)
+ final := -1
for i := 0; i < 10000; i++ {
- path, line := pkg.lineFromAline(i);
+ path, line := pkg.lineFromAline(i)
// Check for end of object
if path == "" {
if final == -1 {
final = i - 1
}
- continue;
+ continue
} else if final != -1 {
t.Fatalf("reached end of package at absolute line %d, but absolute line %d mapped to %s:%d", final, i, path, line)
}
// It's okay to see files multiple times (e.g., sys.a)
if line == 1 {
- lastline[path] = 1;
- continue;
+ lastline[path] = 1
+ continue
}
// Check that the is the next line in path
- ll, ok := lastline[path];
+ ll, ok := lastline[path]
if !ok {
t.Errorf("file %s starts on line %d", path, line)
} else if line != ll+1 {
t.Errorf("expected next line of file %s to be %d, got %d", path, ll+1, line)
}
- lastline[path] = line;
+ lastline[path] = line
}
if final == -1 {
t.Errorf("never reached end of object")
@@ -107,15 +107,15 @@ func TestLineAline(t *testing.T) {
return
}
- tab := getTable(t);
+ tab := getTable(t)
for _, o := range tab.Files {
// A source file can appear multiple times in a
// object. alineFromLine will always return alines in
// the first file, so track which lines we've seen.
- found := make(map[string]int);
+ found := make(map[string]int)
for i := 0; i < 1000; i++ {
- path, line := o.lineFromAline(i);
+ path, line := o.lineFromAline(i)
if path == "" {
break
}
@@ -131,9 +131,9 @@ func TestLineAline(t *testing.T) {
continue
}
}
- found[path] = line;
+ found[path] = line
- a, err := o.alineFromLine(path, line);
+ a, err := o.alineFromLine(path, line)
if err != nil {
t.Errorf("absolute line %d in object %s maps to %s:%d, but mapping that back gives error %s", i, o.Paths[0].Name, path, line, err)
} else if a != i {
@@ -151,20 +151,20 @@ func TestPCLine(t *testing.T) {
return
}
- f, tab := crack("_test/pclinetest", t);
- text := f.Section(".text");
- textdat, err := text.Data();
+ f, tab := crack("_test/pclinetest", t)
+ text := f.Section(".text")
+ textdat, err := text.Data()
if err != nil {
t.Fatalf("reading .text: %v", err)
}
// Test PCToLine
- sym := tab.LookupFunc("linefrompc");
- wantLine := 0;
+ sym := tab.LookupFunc("linefrompc")
+ wantLine := 0
for pc := sym.Entry; pc < sym.End; pc++ {
- file, line, fn := tab.PCToLine(pc);
- off := pc - text.Addr; // TODO(rsc): should not need off; bug in 8g
- wantLine += int(textdat[off]);
+ file, line, fn := tab.PCToLine(pc)
+ off := pc - text.Addr // TODO(rsc): should not need off; bug in 8g
+ 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:] != "pclinetest.s" || line != wantLine || fn != sym {
@@ -173,24 +173,24 @@ func TestPCLine(t *testing.T) {
}
// Test LineToPC
- sym = tab.LookupFunc("pcfromline");
- lookupline := -1;
- wantLine = 0;
- off := uint64(0); // TODO(rsc): should not need off; bug in 8g
+ sym = tab.LookupFunc("pcfromline")
+ 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]) {
- file, line, fn := tab.PCToLine(pc);
- off = pc - text.Addr;
- wantLine += int(textdat[off]);
+ file, line, fn := tab.PCToLine(pc)
+ off = pc - text.Addr
+ wantLine += int(textdat[off])
if line != wantLine {
- t.Errorf("expected line %d at PC %#x in pcfromline, got %d", wantLine, pc, line);
- off = pc + 1 - text.Addr;
- continue;
+ t.Errorf("expected line %d at PC %#x in pcfromline, got %d", wantLine, pc, line)
+ off = pc + 1 - text.Addr
+ continue
}
if lookupline == -1 {
lookupline = line
}
for ; lookupline <= line; lookupline++ {
- pc2, fn2, err := tab.LineToPC(file, lookupline);
+ pc2, fn2, err := tab.LineToPC(file, lookupline)
if lookupline != line {
// Should be nothing on this line
if err == nil {
@@ -202,6 +202,6 @@ func TestPCLine(t *testing.T) {
t.Errorf("expected PC %#x (%s) at line %d, got PC %#x (%s)", pc, fn.Name, line, pc2, fn2.Name)
}
}
- off = pc + 1 - text.Addr;
+ off = pc + 1 - text.Addr
}
}
diff --git a/src/pkg/debug/gosym/symtab.go b/src/pkg/debug/gosym/symtab.go
index 39e397ece..dea460d71 100644
--- a/src/pkg/debug/gosym/symtab.go
+++ b/src/pkg/debug/gosym/symtab.go
@@ -13,11 +13,11 @@ package gosym
// and the Go format is the runtime source, specifically ../../runtime/symtab.c.
import (
- "encoding/binary";
- "fmt";
- "os";
- "strconv";
- "strings";
+ "encoding/binary"
+ "fmt"
+ "os"
+ "strconv"
+ "strings"
)
/*
@@ -26,16 +26,16 @@ import (
// A Sym represents a single symbol table entry.
type Sym struct {
- Value uint64;
- Type byte;
- Name string;
- GoType uint64;
+ Value uint64
+ Type byte
+ Name string
+ GoType uint64
// If this symbol if a function symbol, the corresponding Func
- Func *Func;
+ Func *Func
}
// Static returns whether this symbol is static (not visible outside its file).
-func (s *Sym) Static() bool { return s.Type >= 'a' }
+func (s *Sym) Static() bool { return s.Type >= 'a' }
// PackageName returns the package part of the symbol name,
// or the empty string if there is none.
@@ -43,18 +43,18 @@ func (s *Sym) PackageName() string {
if i := strings.Index(s.Name, "."); i != -1 {
return s.Name[0:i]
}
- return "";
+ return ""
}
// ReceiverName returns the receiver type name of this symbol,
// or the empty string if there is none.
func (s *Sym) ReceiverName() string {
- l := strings.Index(s.Name, ".");
- r := strings.LastIndex(s.Name, ".");
+ l := strings.Index(s.Name, ".")
+ r := strings.LastIndex(s.Name, ".")
if l == -1 || r == -1 || l == r {
return ""
}
- return s.Name[l+1 : r];
+ return s.Name[l+1 : r]
}
// BaseName returns the symbol name without the package or receiver name.
@@ -62,25 +62,25 @@ func (s *Sym) BaseName() string {
if i := strings.LastIndex(s.Name, "."); i != -1 {
return s.Name[i+1:]
}
- return s.Name;
+ return s.Name
}
// A Func collects information about a single function.
type Func struct {
- Entry uint64;
- *Sym;
- End uint64;
- Params []*Sym;
- Locals []*Sym;
- FrameSize int;
- LineTable *LineTable;
- Obj *Obj;
+ Entry uint64
+ *Sym
+ End uint64
+ Params []*Sym
+ Locals []*Sym
+ FrameSize int
+ LineTable *LineTable
+ Obj *Obj
}
// An Obj represents a single object file.
type Obj struct {
- Funcs []Func;
- Paths []Sym;
+ Funcs []Func
+ Paths []Sym
}
/*
@@ -91,115 +91,115 @@ type Obj struct {
// symbols decoded from the program and provides methods to translate
// between symbols, names, and addresses.
type Table struct {
- Syms []Sym;
- Funcs []Func;
- Files map[string]*Obj;
- Objs []Obj;
+ Syms []Sym
+ Funcs []Func
+ Files map[string]*Obj
+ Objs []Obj
// textEnd uint64;
}
type sym struct {
- value uint32;
- gotype uint32;
- typ byte;
- name []byte;
+ value uint32
+ gotype uint32
+ typ byte
+ name []byte
}
func walksymtab(data []byte, fn func(sym) os.Error) os.Error {
- var s sym;
- p := data;
+ var s sym
+ p := data
for len(p) >= 6 {
- s.value = binary.BigEndian.Uint32(p[0:4]);
- typ := p[4];
+ 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}
}
- typ &^= 0x80;
- s.typ = typ;
- p = p[5:];
- var i int;
- var nnul int;
+ typ &^= 0x80
+ s.typ = typ
+ p = p[5:]
+ var i int
+ var nnul int
for i = 0; i < len(p); i++ {
if p[i] == 0 {
- nnul = 1;
- break;
+ nnul = 1
+ break
}
}
switch typ {
case 'z', 'Z':
- p = p[i+nnul:];
+ p = p[i+nnul:]
for i = 0; i+2 <= len(p); i += 2 {
if p[i] == 0 && p[i+1] == 0 {
- nnul = 2;
- break;
+ nnul = 2
+ break
}
}
}
if i+nnul+4 > len(p) {
return &DecodingError{len(data), "unexpected EOF", nil}
}
- s.name = p[0:i];
- i += nnul;
- s.gotype = binary.BigEndian.Uint32(p[i : i+4]);
- p = p[i+4:];
- fn(s);
+ s.name = p[0:i]
+ i += nnul
+ s.gotype = binary.BigEndian.Uint32(p[i : i+4])
+ p = p[i+4:]
+ fn(s)
}
- return nil;
+ return nil
}
// NewTable decodes the Go symbol table in data,
// returning an in-memory representation.
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;
- });
+ n++
+ return nil
+ })
if err != nil {
return nil, err
}
- var t Table;
- fname := make(map[uint16]string);
- t.Syms = make([]Sym, 0, n);
- nf := 0;
- nz := 0;
- lasttyp := uint8(0);
+ var t Table
+ fname := make(map[uint16]string)
+ t.Syms = make([]Sym, 0, n)
+ nf := 0
+ nz := 0
+ lasttyp := uint8(0)
err = walksymtab(symtab, func(s sym) os.Error {
- n := len(t.Syms);
- t.Syms = t.Syms[0 : n+1];
- ts := &t.Syms[n];
- ts.Type = s.typ;
- ts.Value = uint64(s.value);
- ts.GoType = uint64(s.gotype);
+ n := len(t.Syms)
+ t.Syms = t.Syms[0 : n+1]
+ ts := &t.Syms[n]
+ ts.Type = s.typ
+ ts.Value = uint64(s.value)
+ ts.GoType = uint64(s.gotype)
switch s.typ {
default:
// rewrite name to use . instead of · (c2 b7)
- w := 0;
- b := s.name;
+ w := 0
+ b := s.name
for i := 0; i < len(b); i++ {
if b[i] == 0xc2 && i+1 < len(b) && b[i+1] == 0xb7 {
- i++;
- b[i] = '.';
+ i++
+ b[i] = '.'
}
- b[w] = b[i];
- w++;
+ b[w] = b[i]
+ w++
}
- ts.Name = string(s.name[0:w]);
+ ts.Name = string(s.name[0:w])
case 'z', 'Z':
if lasttyp != 'z' && lasttyp != 'Z' {
nz++
}
for i := 0; i < len(s.name); i += 2 {
- eltIdx := binary.BigEndian.Uint16(s.name[i : i+2]);
- elt, ok := fname[eltIdx];
+ eltIdx := binary.BigEndian.Uint16(s.name[i : i+2])
+ elt, ok := fname[eltIdx]
if !ok {
return &DecodingError{-1, "bad filename code", eltIdx}
}
if n := len(ts.Name); n > 0 && ts.Name[n-1] != '/' {
ts.Name += "/"
}
- ts.Name += elt;
+ ts.Name += elt
}
}
switch s.typ {
@@ -208,61 +208,61 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
case 'f':
fname[uint16(s.value)] = ts.Name
}
- lasttyp = s.typ;
- return nil;
- });
+ lasttyp = s.typ
+ return nil
+ })
if err != nil {
return nil, err
}
- t.Funcs = make([]Func, 0, nf);
- t.Objs = make([]Obj, 0, nz);
- t.Files = make(map[string]*Obj);
+ t.Funcs = make([]Func, 0, nf)
+ t.Objs = make([]Obj, 0, nz)
+ t.Files = make(map[string]*Obj)
// Count text symbols and attach frame sizes, parameters, and
// locals to them. Also, find object file boundaries.
- var obj *Obj;
- lastf := 0;
+ var obj *Obj
+ lastf := 0
for i := 0; i < len(t.Syms); i++ {
- sym := &t.Syms[i];
+ sym := &t.Syms[i]
switch sym.Type {
- case 'Z', 'z': // path symbol
+ case 'Z', 'z': // path symbol
// Finish the current object
if obj != nil {
obj.Funcs = t.Funcs[lastf:]
}
- lastf = len(t.Funcs);
+ lastf = len(t.Funcs)
// Start new object
- n := len(t.Objs);
- t.Objs = t.Objs[0 : n+1];
- obj = &t.Objs[n];
+ n := len(t.Objs)
+ t.Objs = t.Objs[0 : n+1]
+ obj = &t.Objs[n]
// Count & copy path symbols
- var end int;
+ var end int
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++
+ obj.Paths = t.Syms[i:end]
+ i = end - 1 // loop will i++
// Record file names
- depth := 0;
+ depth := 0
for j := range obj.Paths {
- s := &obj.Paths[j];
+ s := &obj.Paths[j]
if s.Name == "" {
depth--
} else {
if depth == 0 {
t.Files[s.Name] = obj
}
- depth++;
+ depth++
}
}
- case 'T', 't', 'L', 'l': // text symbol
+ case 'T', 't', 'L', 'l': // text symbol
if n := len(t.Funcs); n > 0 {
t.Funcs[n-1].End = sym.Value
}
@@ -271,8 +271,8 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
}
// Count parameter and local (auto) syms
- var np, na int;
- var end int;
+ var np, na int
+ var end int
countloop:
for end = i + 1; end < len(t.Syms); end++ {
switch t.Syms[end].Type {
@@ -286,50 +286,50 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, os.Error) {
}
// Fill in the function symbol
- n := len(t.Funcs);
- t.Funcs = t.Funcs[0 : n+1];
- fn := &t.Funcs[n];
- sym.Func = fn;
- fn.Params = make([]*Sym, 0, np);
- fn.Locals = make([]*Sym, 0, na);
- fn.Sym = sym;
- fn.Entry = sym.Value;
- fn.Obj = obj;
+ n := len(t.Funcs)
+ t.Funcs = t.Funcs[0 : n+1]
+ fn := &t.Funcs[n]
+ sym.Func = fn
+ fn.Params = make([]*Sym, 0, np)
+ fn.Locals = make([]*Sym, 0, na)
+ fn.Sym = sym
+ fn.Entry = sym.Value
+ fn.Obj = obj
if pcln != nil {
- fn.LineTable = pcln.slice(fn.Entry);
- pcln = fn.LineTable;
+ fn.LineTable = pcln.slice(fn.Entry)
+ pcln = fn.LineTable
}
for j := i; j < end; j++ {
- s := &t.Syms[j];
+ s := &t.Syms[j]
switch s.Type {
case 'm':
fn.FrameSize = int(s.Value)
case 'p':
- n := len(fn.Params);
- fn.Params = fn.Params[0 : n+1];
- fn.Params[n] = s;
+ n := len(fn.Params)
+ fn.Params = fn.Params[0 : n+1]
+ fn.Params[n] = s
case 'a':
- n := len(fn.Locals);
- fn.Locals = fn.Locals[0 : n+1];
- fn.Locals[n] = s;
+ n := len(fn.Locals)
+ fn.Locals = fn.Locals[0 : n+1]
+ fn.Locals[n] = s
}
}
- i = end - 1; // loop will i++
+ i = end - 1 // loop will i++
}
}
if obj != nil {
obj.Funcs = t.Funcs[lastf:]
}
- return &t, nil;
+ return &t, nil
}
// PCToFunc returns the function containing the program counter pc,
// or nil if there is no such function.
func (t *Table) PCToFunc(pc uint64) *Func {
- funcs := t.Funcs;
+ funcs := t.Funcs
for len(funcs) > 0 {
- m := len(funcs) / 2;
- fn := &funcs[m];
+ m := len(funcs) / 2
+ fn := &funcs[m]
switch {
case pc < fn.Entry:
funcs = funcs[0:m]
@@ -339,7 +339,7 @@ func (t *Table) PCToFunc(pc uint64) *Func {
funcs = funcs[m+1:]
}
}
- return nil;
+ return nil
}
// PCToLine looks up line number information for a program counter.
@@ -348,30 +348,30 @@ func (t *Table) PCToLine(pc uint64) (file string, line int, fn *Func) {
if fn = t.PCToFunc(pc); fn == nil {
return
}
- file, line = fn.Obj.lineFromAline(fn.LineTable.PCToLine(pc));
- return;
+ file, line = fn.Obj.lineFromAline(fn.LineTable.PCToLine(pc))
+ return
}
// LineToPC looks up the first program counter on the given line in
// the named file. Returns UnknownPathError or UnknownLineError if
// there is an error looking up this line.
func (t *Table) LineToPC(file string, line int) (pc uint64, fn *Func, err os.Error) {
- obj, ok := t.Files[file];
+ obj, ok := t.Files[file]
if !ok {
return 0, nil, UnknownFileError(file)
}
- abs, err := obj.alineFromLine(file, line);
+ abs, err := obj.alineFromLine(file, line)
if err != nil {
return
}
for i := range obj.Funcs {
- f := &obj.Funcs[i];
- pc := f.LineTable.LineToPC(abs, f.End);
+ f := &obj.Funcs[i]
+ pc := f.LineTable.LineToPC(abs, f.End)
if pc != 0 {
return pc, f, nil
}
}
- return 0, nil, &UnknownLineError{file, line};
+ return 0, nil, &UnknownLineError{file, line}
}
// LookupSym returns the text, data, or bss symbol with the given name,
@@ -379,7 +379,7 @@ func (t *Table) LineToPC(file string, line int) (pc uint64, fn *Func, err os.Err
func (t *Table) LookupSym(name string) *Sym {
// TODO(austin) Maybe make a map
for i := range t.Syms {
- s := &t.Syms[i];
+ s := &t.Syms[i]
switch s.Type {
case 'T', 't', 'L', 'l', 'D', 'd', 'B', 'b':
if s.Name == name {
@@ -387,19 +387,19 @@ func (t *Table) LookupSym(name string) *Sym {
}
}
}
- return nil;
+ return nil
}
// LookupFunc returns the text, data, or bss symbol with the given name,
// or nil if no such symbol is found.
func (t *Table) LookupFunc(name string) *Func {
for i := range t.Funcs {
- f := &t.Funcs[i];
+ f := &t.Funcs[i]
if f.Sym.Name == name {
return f
}
}
- return nil;
+ return nil
}
// SymByAddr returns the text, data, or bss symbol starting at the given address.
@@ -407,7 +407,7 @@ func (t *Table) LookupFunc(name string) *Func {
func (t *Table) SymByAddr(addr uint64) *Sym {
// TODO(austin) Maybe make a map
for i := range t.Syms {
- s := &t.Syms[i];
+ s := &t.Syms[i]
switch s.Type {
case 'T', 't', 'L', 'l', 'D', 'd', 'B', 'b':
if s.Value == addr {
@@ -415,7 +415,7 @@ func (t *Table) SymByAddr(addr uint64) *Sym {
}
}
}
- return nil;
+ return nil
}
/*
@@ -424,20 +424,20 @@ func (t *Table) SymByAddr(addr uint64) *Sym {
func (o *Obj) lineFromAline(aline int) (string, int) {
type stackEnt struct {
- path string;
- start int;
- offset int;
- prev *stackEnt;
+ path string
+ start int
+ offset int
+ prev *stackEnt
}
- noPath := &stackEnt{"", 0, 0, nil};
- tos := noPath;
+ noPath := &stackEnt{"", 0, 0, nil}
+ tos := noPath
// TODO(austin) I have no idea how 'Z' symbols work, except
// that they pop the stack.
pathloop:
for _, s := range o.Paths {
- val := int(s.Value);
+ val := int(s.Value)
switch {
case val > aline:
break pathloop
@@ -451,8 +451,8 @@ pathloop:
if tos == noPath {
return "<malformed symbol table>", 0
}
- tos.prev.offset += val - tos.start;
- tos = tos.prev;
+ tos.prev.offset += val - tos.start
+ tos = tos.prev
default:
// Push
@@ -463,7 +463,7 @@ pathloop:
if tos == noPath {
return "", 0
}
- return tos.path, aline - tos.start - tos.offset + 1;
+ return tos.path, aline - tos.start - tos.offset + 1
}
func (o *Obj) alineFromLine(path string, line int) (int, os.Error) {
@@ -478,18 +478,18 @@ func (o *Obj) alineFromLine(path string, line int) (int, os.Error) {
}
// Find this line at this stack level
- depth := 0;
- var incstart int;
- line += int(s.Value);
+ depth := 0
+ var incstart int
+ line += int(s.Value)
pathloop:
for _, s := range o.Paths[i:] {
- val := int(s.Value);
+ val := int(s.Value)
switch {
case depth == 1 && val >= line:
return line - 1, nil
case s.Name == "":
- depth--;
+ depth--
if depth == 0 {
break pathloop
} else if depth == 1 {
@@ -500,12 +500,12 @@ func (o *Obj) alineFromLine(path string, line int) (int, os.Error) {
if depth == 1 {
incstart = val
}
- depth++;
+ depth++
}
}
- return 0, &UnknownLineError{path, line};
+ return 0, &UnknownLineError{path, line}
}
- return 0, UnknownFileError(path);
+ return 0, UnknownFileError(path)
}
/*
@@ -516,14 +516,14 @@ func (o *Obj) alineFromLine(path string, line int) (int, os.Error) {
// the symbol table.
type UnknownFileError string
-func (e UnknownFileError) String() string { return "unknown file: " + string(e) }
+func (e UnknownFileError) String() string { return "unknown file: " + string(e) }
// UnknownLineError represents a failure to map a line to a program
// counter, either because the line is beyond the bounds of the file
// or because there is no code on the given line.
type UnknownLineError struct {
- File string;
- Line int;
+ File string
+ Line int
}
func (e *UnknownLineError) String() string {
@@ -533,16 +533,16 @@ func (e *UnknownLineError) String() string {
// DecodingError represents an error during the decoding of
// the symbol table.
type DecodingError struct {
- off int;
- msg string;
- val interface{};
+ off int
+ msg string
+ val interface{}
}
func (e *DecodingError) String() string {
- msg := e.msg;
+ msg := e.msg
if e.val != nil {
msg += fmt.Sprintf(" '%v'", e.val)
}
- msg += fmt.Sprintf(" at byte %#x", e.off);
- return msg;
+ msg += fmt.Sprintf(" at byte %#x", e.off)
+ return msg
}
diff --git a/src/pkg/debug/macho/file.go b/src/pkg/debug/macho/file.go
index 233490c83..7c492ef52 100644
--- a/src/pkg/debug/macho/file.go
+++ b/src/pkg/debug/macho/file.go
@@ -9,53 +9,53 @@ package macho
// High level access to low level data structures.
import (
- "bytes";
- "debug/dwarf";
- "encoding/binary";
- "fmt";
- "io";
- "os";
+ "bytes"
+ "debug/dwarf"
+ "encoding/binary"
+ "fmt"
+ "io"
+ "os"
)
// A File represents an open Mach-O file.
type File struct {
- FileHeader;
- ByteOrder binary.ByteOrder;
- Loads []Load;
- Sections []*Section;
+ FileHeader
+ ByteOrder binary.ByteOrder
+ Loads []Load
+ Sections []*Section
- closer io.Closer;
+ closer io.Closer
}
// A Load represents any Mach-O load command.
type Load interface {
- Raw() []byte;
+ Raw() []byte
}
// A LoadBytes is the uninterpreted bytes of a Mach-O load command.
type LoadBytes []byte
-func (b LoadBytes) Raw() []byte { return b }
+func (b LoadBytes) Raw() []byte { return b }
// A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.
type SegmentHeader struct {
- Cmd LoadCmd;
- Len uint32;
- Name string;
- Addr uint64;
- Memsz uint64;
- Offset uint64;
- Filesz uint64;
- Maxprot uint32;
- Prot uint32;
- Nsect uint32;
- Flag uint32;
+ Cmd LoadCmd
+ Len uint32
+ Name string
+ Addr uint64
+ Memsz uint64
+ Offset uint64
+ Filesz uint64
+ Maxprot uint32
+ Prot uint32
+ Nsect uint32
+ Flag uint32
}
// A Segment represents a Mach-O 32-bit or 64-bit load segment command.
type Segment struct {
- LoadBytes;
- SegmentHeader;
+ LoadBytes
+ SegmentHeader
// Embed ReaderAt for ReadAt method.
// Do not embed SectionReader directly
@@ -63,34 +63,34 @@ type Segment struct {
// If a client wants Read and Seek it must use
// Open() to avoid fighting over the seek offset
// with other clients.
- io.ReaderAt;
- sr *io.SectionReader;
+ io.ReaderAt
+ sr *io.SectionReader
}
// Data reads and returns the contents of the segment.
func (s *Segment) Data() ([]byte, os.Error) {
- dat := make([]byte, s.sr.Size());
- n, err := s.sr.ReadAt(dat, 0);
- return dat[0:n], err;
+ dat := make([]byte, s.sr.Size())
+ n, err := s.sr.ReadAt(dat, 0)
+ return dat[0:n], err
}
// 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;
- Seg string;
- Addr uint64;
- Size uint64;
- Offset uint32;
- Align uint32;
- Reloff uint32;
- Nreloc uint32;
- Flags uint32;
+ Name string
+ Seg string
+ Addr uint64
+ Size uint64
+ Offset uint32
+ Align uint32
+ Reloff uint32
+ Nreloc uint32
+ Flags uint32
}
type Section struct {
- SectionHeader;
+ SectionHeader
// Embed ReaderAt for ReadAt method.
// Do not embed SectionReader directly
@@ -98,19 +98,19 @@ type Section struct {
// If a client wants Read and Seek it must use
// Open() to avoid fighting over the seek offset
// with other clients.
- io.ReaderAt;
- sr *io.SectionReader;
+ io.ReaderAt
+ sr *io.SectionReader
}
// Data reads and returns the contents of the Mach-O section.
func (s *Section) Data() ([]byte, os.Error) {
- dat := make([]byte, s.sr.Size());
- n, err := s.sr.ReadAt(dat, 0);
- return dat[0:n], err;
+ dat := make([]byte, s.sr.Size())
+ n, err := s.sr.ReadAt(dat, 0)
+ return dat[0:n], err
}
// 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) }
/*
@@ -118,68 +118,68 @@ func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<
*/
type FormatError struct {
- off int64;
- msg string;
- val interface{};
+ off int64
+ msg string
+ val interface{}
}
func (e *FormatError) String() string {
- msg := e.msg;
+ msg := e.msg
if e.val != nil {
msg += fmt.Sprintf(" '%v' ", e.val)
}
- msg += fmt.Sprintf("in record at byte %#x", e.off);
- return msg;
+ msg += fmt.Sprintf("in record at byte %#x", e.off)
+ return msg
}
// Open opens the named file using os.Open and prepares it for use as a Mach-O binary.
func Open(name string) (*File, os.Error) {
- f, err := os.Open(name, os.O_RDONLY, 0);
+ f, err := os.Open(name, os.O_RDONLY, 0)
if err != nil {
return nil, err
}
- ff, err := NewFile(f);
+ ff, err := NewFile(f)
if err != nil {
- f.Close();
- return nil, err;
+ f.Close()
+ return nil, err
}
- ff.closer = f;
- return ff, nil;
+ ff.closer = f
+ return ff, nil
}
// Close closes the File.
// If the File was created using NewFile directly instead of Open,
// Close has no effect.
func (f *File) Close() os.Error {
- var err os.Error;
+ var err os.Error
if f.closer != nil {
- err = f.closer.Close();
- f.closer = nil;
+ err = f.closer.Close()
+ f.closer = nil
}
- return err;
+ return err
}
// NewFile creates a new File for acecssing a Mach-O binary in an underlying reader.
// 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);
+ f := new(File)
+ 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.
- var ident [4]uint8;
+ var ident [4]uint8
if _, err := r.ReadAt(&ident, 0); err != nil {
return nil, err
}
- be := binary.BigEndian.Uint32(&ident);
- le := binary.LittleEndian.Uint32(&ident);
+ be := binary.BigEndian.Uint32(&ident)
+ le := binary.LittleEndian.Uint32(&ident)
switch Magic32 &^ 1 {
case be &^ 1:
- f.ByteOrder = binary.BigEndian;
- f.Magic = be;
+ f.ByteOrder = binary.BigEndian
+ f.Magic = be
case le &^ 1:
- f.ByteOrder = binary.LittleEndian;
- f.Magic = le;
+ f.ByteOrder = binary.LittleEndian
+ f.Magic = le
}
// Read entire file header.
@@ -188,138 +188,138 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
}
// Then load commands.
- offset := int64(fileHeaderSize32);
+ offset := int64(fileHeaderSize32)
if f.Magic == Magic64 {
offset = fileHeaderSize64
}
- dat := make([]byte, f.Cmdsz);
+ dat := make([]byte, f.Cmdsz)
if _, err := r.ReadAt(dat, offset); err != nil {
return nil, err
}
- f.Loads = make([]Load, f.Ncmd);
- bo := f.ByteOrder;
+ f.Loads = make([]Load, f.Ncmd)
+ bo := f.ByteOrder
for i := range f.Loads {
// Each load command begins with uint32 command and length.
if len(dat) < 8 {
return nil, &FormatError{offset, "command block too small", nil}
}
- cmd, siz := LoadCmd(bo.Uint32(dat[0:4])), bo.Uint32(dat[4:8]);
+ cmd, siz := LoadCmd(bo.Uint32(dat[0:4])), bo.Uint32(dat[4:8])
if siz < 8 || siz > uint32(len(dat)) {
return nil, &FormatError{offset, "invalid command block size", nil}
}
- var cmddat []byte;
- cmddat, dat = dat[0:siz], dat[siz:];
- offset += int64(siz);
- var s *Segment;
+ var cmddat []byte
+ cmddat, dat = dat[0:siz], dat[siz:]
+ offset += int64(siz)
+ var s *Segment
switch cmd {
default:
f.Loads[i] = LoadBytes(cmddat)
case LoadCmdSegment:
- var seg32 Segment32;
- b := bytes.NewBuffer(cmddat);
+ var seg32 Segment32
+ b := bytes.NewBuffer(cmddat)
if err := binary.Read(b, bo, &seg32); err != nil {
return nil, err
}
- s = new(Segment);
- s.LoadBytes = cmddat;
- s.Cmd = cmd;
- s.Len = siz;
- s.Name = cstring(&seg32.Name);
- s.Addr = uint64(seg32.Addr);
- s.Memsz = uint64(seg32.Memsz);
- s.Offset = uint64(seg32.Offset);
- s.Filesz = uint64(seg32.Filesz);
- s.Maxprot = seg32.Maxprot;
- s.Prot = seg32.Prot;
- s.Nsect = seg32.Nsect;
- s.Flag = seg32.Flag;
- f.Loads[i] = s;
+ s = new(Segment)
+ s.LoadBytes = cmddat
+ s.Cmd = cmd
+ s.Len = siz
+ s.Name = cstring(&seg32.Name)
+ s.Addr = uint64(seg32.Addr)
+ s.Memsz = uint64(seg32.Memsz)
+ s.Offset = uint64(seg32.Offset)
+ s.Filesz = uint64(seg32.Filesz)
+ s.Maxprot = seg32.Maxprot
+ s.Prot = seg32.Prot
+ s.Nsect = seg32.Nsect
+ s.Flag = seg32.Flag
+ f.Loads[i] = s
for i := 0; i < int(s.Nsect); i++ {
- var sh32 Section32;
+ var sh32 Section32
if err := binary.Read(b, bo, &sh32); err != nil {
return nil, err
}
- sh := new(Section);
- sh.Name = cstring(&sh32.Name);
- sh.Seg = cstring(&sh32.Seg);
- sh.Addr = uint64(sh32.Addr);
- sh.Size = uint64(sh32.Size);
- sh.Offset = sh32.Offset;
- sh.Align = sh32.Align;
- sh.Reloff = sh32.Reloff;
- sh.Nreloc = sh32.Nreloc;
- sh.Flags = sh32.Flags;
- f.pushSection(sh, r);
+ sh := new(Section)
+ sh.Name = cstring(&sh32.Name)
+ sh.Seg = cstring(&sh32.Seg)
+ sh.Addr = uint64(sh32.Addr)
+ sh.Size = uint64(sh32.Size)
+ sh.Offset = sh32.Offset
+ sh.Align = sh32.Align
+ sh.Reloff = sh32.Reloff
+ sh.Nreloc = sh32.Nreloc
+ sh.Flags = sh32.Flags
+ f.pushSection(sh, r)
}
case LoadCmdSegment64:
- var seg64 Segment64;
- b := bytes.NewBuffer(cmddat);
+ var seg64 Segment64
+ b := bytes.NewBuffer(cmddat)
if err := binary.Read(b, bo, &seg64); err != nil {
return nil, err
}
- s = new(Segment);
- s.LoadBytes = cmddat;
- s.Cmd = cmd;
- s.Len = siz;
- s.Name = cstring(&seg64.Name);
- s.Addr = seg64.Addr;
- s.Memsz = seg64.Memsz;
- s.Offset = seg64.Offset;
- s.Filesz = seg64.Filesz;
- s.Maxprot = seg64.Maxprot;
- s.Prot = seg64.Prot;
- s.Nsect = seg64.Nsect;
- s.Flag = seg64.Flag;
- f.Loads[i] = s;
+ s = new(Segment)
+ s.LoadBytes = cmddat
+ s.Cmd = cmd
+ s.Len = siz
+ s.Name = cstring(&seg64.Name)
+ s.Addr = seg64.Addr
+ s.Memsz = seg64.Memsz
+ s.Offset = seg64.Offset
+ s.Filesz = seg64.Filesz
+ s.Maxprot = seg64.Maxprot
+ s.Prot = seg64.Prot
+ s.Nsect = seg64.Nsect
+ s.Flag = seg64.Flag
+ f.Loads[i] = s
for i := 0; i < int(s.Nsect); i++ {
- var sh64 Section64;
+ var sh64 Section64
if err := binary.Read(b, bo, &sh64); err != nil {
return nil, err
}
- sh := new(Section);
- sh.Name = cstring(&sh64.Name);
- sh.Seg = cstring(&sh64.Seg);
- sh.Addr = sh64.Addr;
- sh.Size = sh64.Size;
- sh.Offset = sh64.Offset;
- sh.Align = sh64.Align;
- sh.Reloff = sh64.Reloff;
- sh.Nreloc = sh64.Nreloc;
- sh.Flags = sh64.Flags;
- f.pushSection(sh, r);
+ sh := new(Section)
+ sh.Name = cstring(&sh64.Name)
+ sh.Seg = cstring(&sh64.Seg)
+ sh.Addr = sh64.Addr
+ sh.Size = sh64.Size
+ sh.Offset = sh64.Offset
+ sh.Align = sh64.Align
+ sh.Reloff = sh64.Reloff
+ sh.Nreloc = sh64.Nreloc
+ sh.Flags = sh64.Flags
+ f.pushSection(sh, r)
}
}
if s != nil {
- s.sr = io.NewSectionReader(r, int64(s.Offset), int64(s.Filesz));
- s.ReaderAt = s.sr;
+ s.sr = io.NewSectionReader(r, int64(s.Offset), int64(s.Filesz))
+ s.ReaderAt = s.sr
}
}
- return f, nil;
+ return f, nil
}
func (f *File) pushSection(sh *Section, r io.ReaderAt) {
- n := len(f.Sections);
+ n := len(f.Sections)
if n >= cap(f.Sections) {
- m := (n + 1) * 2;
- new := make([]*Section, n, m);
+ m := (n + 1) * 2
+ new := make([]*Section, n, m)
for i, sh := range f.Sections {
new[i] = sh
}
- f.Sections = new;
+ f.Sections = new
}
- f.Sections = f.Sections[0 : n+1];
- f.Sections[n] = sh;
- sh.sr = io.NewSectionReader(r, int64(sh.Offset), int64(sh.Size));
- sh.ReaderAt = sh.sr;
+ f.Sections = f.Sections[0 : n+1]
+ f.Sections[n] = sh
+ sh.sr = io.NewSectionReader(r, int64(sh.Offset), int64(sh.Size))
+ sh.ReaderAt = sh.sr
}
func cstring(b []byte) string {
- var i int;
+ var i int
for i = 0; i < len(b) && b[i] != 0; i++ {
}
- return string(b[0:i]);
+ return string(b[0:i])
}
// Segment returns the first Segment with the given name, or nil if no such segment exists.
@@ -329,7 +329,7 @@ func (f *File) Segment(name string) *Segment {
return s
}
}
- return nil;
+ return nil
}
// Section returns the first section with the given name, or nil if no such
@@ -340,7 +340,7 @@ func (f *File) Section(name string) *Section {
return s
}
}
- return nil;
+ return nil
}
// DWARF returns the DWARF debug information for the Mach-O file.
@@ -348,21 +348,21 @@ func (f *File) DWARF() (*dwarf.Data, os.Error) {
// There are many other DWARF sections, but these
// are the required ones, and the debug/dwarf package
// does not use the others, so don't bother loading them.
- var names = [...]string{"abbrev", "info", "str"};
- var dat [len(names)][]byte;
+ var names = [...]string{"abbrev", "info", "str"}
+ var dat [len(names)][]byte
for i, name := range names {
- name = "__debug_" + name;
- s := f.Section(name);
+ name = "__debug_" + name
+ s := f.Section(name)
if s == nil {
return nil, os.NewError("missing Mach-O section " + name)
}
- b, err := s.Data();
+ b, err := s.Data()
if err != nil && uint64(len(b)) < s.Size {
return nil, err
}
- dat[i] = b;
+ dat[i] = b
}
- abbrev, info, str := dat[0], dat[1], dat[2];
- return dwarf.New(abbrev, nil, nil, info, nil, nil, nil, str);
+ abbrev, info, str := dat[0], dat[1], dat[2]
+ return dwarf.New(abbrev, nil, nil, info, nil, nil, nil, str)
}
diff --git a/src/pkg/debug/macho/file_test.go b/src/pkg/debug/macho/file_test.go
index e1d75da15..d69e49cbf 100644
--- a/src/pkg/debug/macho/file_test.go
+++ b/src/pkg/debug/macho/file_test.go
@@ -5,15 +5,15 @@
package macho
import (
- "reflect";
- "testing";
+ "reflect"
+ "testing"
)
type fileTest struct {
- file string;
- hdr FileHeader;
- segments []*SegmentHeader;
- sections []*SectionHeader;
+ file string
+ hdr FileHeader
+ segments []*SegmentHeader
+ sections []*SectionHeader
}
var fileTests = []fileTest{
@@ -100,41 +100,41 @@ var fileTests = []fileTest{
func TestOpen(t *testing.T) {
for i := range fileTests {
- tt := &fileTests[i];
+ tt := &fileTests[i]
- f, err := Open(tt.file);
+ f, err := Open(tt.file)
if err != nil {
- t.Error(err);
- continue;
+ t.Error(err)
+ continue
}
if !reflect.DeepEqual(f.FileHeader, tt.hdr) {
- t.Errorf("open %s:\n\thave %#v\n\twant %#v\n", tt.file, f.FileHeader, tt.hdr);
- continue;
+ t.Errorf("open %s:\n\thave %#v\n\twant %#v\n", tt.file, f.FileHeader, tt.hdr)
+ continue
}
for i, l := range f.Loads {
if i >= len(tt.segments) {
break
}
- sh := tt.segments[i];
- s, ok := l.(*Segment);
+ sh := tt.segments[i]
+ s, ok := l.(*Segment)
if sh == nil {
if ok {
t.Errorf("open %s, section %d: skipping %#v\n", tt.file, i, &s.SegmentHeader)
}
- continue;
+ continue
}
if !ok {
- t.Errorf("open %s, section %d: not *Segment\n", tt.file, i);
- continue;
+ t.Errorf("open %s, section %d: not *Segment\n", tt.file, i)
+ continue
}
- have := &s.SegmentHeader;
- want := sh;
+ have := &s.SegmentHeader
+ want := sh
if !reflect.DeepEqual(have, want) {
t.Errorf("open %s, segment %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
}
}
- tn := len(tt.segments);
- fn := len(f.Loads);
+ tn := len(tt.segments)
+ fn := len(f.Loads)
if tn != fn {
t.Errorf("open %s: len(Loads) = %d, want %d", tt.file, fn, tn)
}
@@ -143,14 +143,14 @@ func TestOpen(t *testing.T) {
if i >= len(tt.sections) {
break
}
- have := &sh.SectionHeader;
- want := tt.sections[i];
+ have := &sh.SectionHeader
+ want := tt.sections[i]
if !reflect.DeepEqual(have, want) {
t.Errorf("open %s, section %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
}
}
- tn = len(tt.sections);
- fn = len(f.Sections);
+ tn = len(tt.sections)
+ fn = len(f.Sections)
if tn != fn {
t.Errorf("open %s: len(Sections) = %d, want %d", tt.file, fn, tn)
}
diff --git a/src/pkg/debug/macho/macho.go b/src/pkg/debug/macho/macho.go
index abc59c8a6..41962d562 100644
--- a/src/pkg/debug/macho/macho.go
+++ b/src/pkg/debug/macho/macho.go
@@ -11,39 +11,39 @@ import "strconv"
// A FileHeader represents a Mach-O file header.
type FileHeader struct {
- Magic uint32;
- Cpu Cpu;
- SubCpu uint32;
- Type Type;
- Ncmd uint32;
- Cmdsz uint32;
- Flags uint32;
+ Magic uint32
+ Cpu Cpu
+ SubCpu uint32
+ Type Type
+ Ncmd uint32
+ Cmdsz uint32
+ Flags uint32
}
const (
- fileHeaderSize32 = 7 * 4;
- fileHeaderSize64 = 8 * 4;
+ fileHeaderSize32 = 7 * 4
+ fileHeaderSize64 = 8 * 4
)
const (
- Magic32 uint32 = 0xfeedface;
- Magic64 uint32 = 0xfeedfacf;
+ Magic32 uint32 = 0xfeedface
+ Magic64 uint32 = 0xfeedfacf
)
// A Type is a Mach-O file type, either an object or an executable.
type Type uint32
const (
- TypeObj Type = 1;
- TypeExec Type = 2;
+ TypeObj Type = 1
+ TypeExec Type = 2
)
// A Cpu is a Mach-O cpu type.
type Cpu uint32
const (
- Cpu386 Cpu = 7;
- CpuAmd64 Cpu = Cpu386 + 1<<24;
+ Cpu386 Cpu = 7
+ CpuAmd64 Cpu = Cpu386 + 1<<24
)
var cpuStrings = []intName{
@@ -51,17 +51,17 @@ var cpuStrings = []intName{
intName{uint32(CpuAmd64), "CpuAmd64"},
}
-func (i Cpu) String() string { return stringName(uint32(i), cpuStrings, false) }
-func (i Cpu) GoString() string { return stringName(uint32(i), cpuStrings, true) }
+func (i Cpu) String() string { return stringName(uint32(i), cpuStrings, false) }
+func (i Cpu) GoString() string { return stringName(uint32(i), cpuStrings, true) }
// A LoadCmd is a Mach-O load command.
type LoadCmd uint32
const (
- LoadCmdSegment LoadCmd = 1;
- LoadCmdSegment64 LoadCmd = 25;
- LoadCmdThread LoadCmd = 4;
- LoadCmdUnixThread LoadCmd = 5; // thread+stack
+ LoadCmdSegment LoadCmd = 1
+ LoadCmdSegment64 LoadCmd = 25
+ LoadCmdThread LoadCmd = 4
+ LoadCmdUnixThread LoadCmd = 5 // thread+stack
)
var cmdStrings = []intName{
@@ -71,126 +71,126 @@ var cmdStrings = []intName{
intName{uint32(LoadCmdUnixThread), "LoadCmdUnixThread"},
}
-func (i LoadCmd) String() string { return stringName(uint32(i), cmdStrings, false) }
-func (i LoadCmd) GoString() string { return stringName(uint32(i), cmdStrings, true) }
+func (i LoadCmd) String() string { return stringName(uint32(i), cmdStrings, false) }
+func (i LoadCmd) GoString() string { return stringName(uint32(i), cmdStrings, true) }
// A Segment64 is a 64-bit Mach-O segment load command.
type Segment64 struct {
- Cmd LoadCmd;
- Len uint32;
- Name [16]byte;
- Addr uint64;
- Memsz uint64;
- Offset uint64;
- Filesz uint64;
- Maxprot uint32;
- Prot uint32;
- Nsect uint32;
- Flag uint32;
+ Cmd LoadCmd
+ Len uint32
+ Name [16]byte
+ Addr uint64
+ Memsz uint64
+ Offset uint64
+ Filesz uint64
+ Maxprot uint32
+ Prot uint32
+ Nsect uint32
+ Flag uint32
}
// A Segment32 is a 32-bit Mach-O segment load command.
type Segment32 struct {
- Cmd LoadCmd;
- Len uint32;
- Name [16]byte;
- Addr uint32;
- Memsz uint32;
- Offset uint32;
- Filesz uint32;
- Maxprot uint32;
- Prot uint32;
- Nsect uint32;
- Flag uint32;
+ Cmd LoadCmd
+ Len uint32
+ Name [16]byte
+ Addr uint32
+ Memsz uint32
+ Offset uint32
+ Filesz uint32
+ Maxprot uint32
+ Prot uint32
+ Nsect uint32
+ Flag uint32
}
// A Section32 is a 32-bit Mach-O section header.
type Section32 struct {
- Name [16]byte;
- Seg [16]byte;
- Addr uint32;
- Size uint32;
- Offset uint32;
- Align uint32;
- Reloff uint32;
- Nreloc uint32;
- Flags uint32;
- Reserve1 uint32;
- Reserve2 uint32;
+ Name [16]byte
+ Seg [16]byte
+ Addr uint32
+ Size uint32
+ Offset uint32
+ Align uint32
+ Reloff uint32
+ Nreloc uint32
+ Flags uint32
+ Reserve1 uint32
+ Reserve2 uint32
}
// A Section32 is a 64-bit Mach-O section header.
type Section64 struct {
- Name [16]byte;
- Seg [16]byte;
- Addr uint64;
- Size uint64;
- Offset uint32;
- Align uint32;
- Reloff uint32;
- Nreloc uint32;
- Flags uint32;
- Reserve1 uint32;
- Reserve2 uint32;
- Reserve3 uint32;
+ Name [16]byte
+ Seg [16]byte
+ Addr uint64
+ Size uint64
+ Offset uint32
+ Align uint32
+ Reloff uint32
+ Nreloc uint32
+ Flags uint32
+ Reserve1 uint32
+ Reserve2 uint32
+ Reserve3 uint32
}
// A Thread is a Mach-O thread state command.
type Thread struct {
- Cmd LoadCmd;
- Len uint32;
- Type uint32;
- Data []uint32;
+ Cmd LoadCmd
+ Len uint32
+ Type uint32
+ Data []uint32
}
// Regs386 is the Mach-O 386 register structure.
type Regs386 struct {
- AX uint32;
- BX uint32;
- CX uint32;
- DX uint32;
- DI uint32;
- SI uint32;
- BP uint32;
- SP uint32;
- SS uint32;
- FLAGS uint32;
- IP uint32;
- CS uint32;
- DS uint32;
- ES uint32;
- FS uint32;
- GS uint32;
+ AX uint32
+ BX uint32
+ CX uint32
+ DX uint32
+ DI uint32
+ SI uint32
+ BP uint32
+ SP uint32
+ SS uint32
+ FLAGS uint32
+ IP uint32
+ CS uint32
+ DS uint32
+ ES uint32
+ FS uint32
+ GS uint32
}
// RegsAMD64 is the Mach-O AMD64 register structure.
type RegsAMD64 struct {
- AX uint64;
- BX uint64;
- CX uint64;
- DX uint64;
- DI uint64;
- SI uint64;
- BP uint64;
- SP uint64;
- R8 uint64;
- R9 uint64;
- R10 uint64;
- R11 uint64;
- R12 uint64;
- R13 uint64;
- R14 uint64;
- R15 uint64;
- IP uint64;
- FLAGS uint64;
- CS uint64;
- FS uint64;
- GS uint64;
+ AX uint64
+ BX uint64
+ CX uint64
+ DX uint64
+ DI uint64
+ SI uint64
+ BP uint64
+ SP uint64
+ R8 uint64
+ R9 uint64
+ R10 uint64
+ R11 uint64
+ R12 uint64
+ R13 uint64
+ R14 uint64
+ R15 uint64
+ IP uint64
+ FLAGS uint64
+ CS uint64
+ FS uint64
+ GS uint64
}
type intName struct {
- i uint32;
- s string;
+ i uint32
+ s string
}
func stringName(i uint32, names []intName, goSyntax bool) string {
@@ -199,14 +199,14 @@ func stringName(i uint32, names []intName, goSyntax bool) string {
if goSyntax {
return "macho." + n.s
}
- return n.s;
+ return n.s
}
}
- return strconv.Uitoa64(uint64(i));
+ return strconv.Uitoa64(uint64(i))
}
func flagName(i uint32, names []intName, goSyntax bool) string {
- s := "";
+ s := ""
for _, n := range names {
if n.i&i == n.i {
if len(s) > 0 {
@@ -215,8 +215,8 @@ func flagName(i uint32, names []intName, goSyntax bool) string {
if goSyntax {
s += "macho."
}
- s += n.s;
- i -= n.i;
+ s += n.s
+ i -= n.i
}
}
if len(s) == 0 {
@@ -225,5 +225,5 @@ func flagName(i uint32, names []intName, goSyntax bool) string {
if i != 0 {
s += "+0x" + strconv.Uitob64(uint64(i), 16)
}
- return s;
+ return s
}
diff --git a/src/pkg/debug/proc/proc.go b/src/pkg/debug/proc/proc.go
index 7f8e778c6..d5341a745 100644
--- a/src/pkg/debug/proc/proc.go
+++ b/src/pkg/debug/proc/proc.go
@@ -13,22 +13,22 @@ package proc
// and proc_darwin.go do, because deps.bash only looks at
// this file.
import (
- _ "container/vector";
- _ "fmt";
- _ "io";
- "os";
- _ "runtime";
- "strconv";
- _ "strings";
- _ "sync";
- _ "syscall";
+ _ "container/vector"
+ _ "fmt"
+ _ "io"
+ "os"
+ _ "runtime"
+ "strconv"
+ _ "strings"
+ _ "sync"
+ _ "syscall"
)
type Word uint64
// A Cause explains why a thread is stopped.
type Cause interface {
- String() string;
+ String() string
}
// Regs is a set of named machine registers, including a program
@@ -42,33 +42,33 @@ type Cause interface {
// other per-register information like how to print it.
type Regs interface {
// PC returns the value of the program counter.
- PC() Word;
+ PC() Word
// SetPC sets the program counter to val.
- SetPC(val Word) os.Error;
+ SetPC(val Word) os.Error
// Link returns the link register, if any.
- Link() Word;
+ Link() Word
// SetLink sets the link register to val.
- SetLink(val Word) os.Error;
+ SetLink(val Word) os.Error
// SP returns the value of the stack pointer.
- SP() Word;
+ SP() Word
// SetSP sets the stack pointer register to val.
- SetSP(val Word) os.Error;
+ SetSP(val Word) os.Error
// Names returns the names of all of the registers.
- Names() []string;
+ Names() []string
// Get returns the value of a register, where i corresponds to
// the index of the register's name in the array returned by
// Names.
- Get(i int) Word;
+ Get(i int) Word
// Set sets the value of a register.
- Set(i int, val Word) os.Error;
+ Set(i int, val Word) os.Error
}
// Thread is a thread in the process being traced.
@@ -78,15 +78,15 @@ type Thread interface {
// breakpoint, this will step over the breakpoint.
//
// XXX What if it's stopped because of a signal?
- Step() os.Error;
+ Step() os.Error
// Stopped returns the reason that this thread is stopped. It
// is an error is the thread not stopped.
- Stopped() (Cause, os.Error);
+ Stopped() (Cause, os.Error)
// Regs retrieves the current register values from this
// thread. The thread must be stopped.
- Regs() (Regs, os.Error);
+ Regs() (Regs, os.Error)
// Peek reads len(out) bytes from the address addr in this
// thread into out. The thread must be stopped. It returns
@@ -95,7 +95,7 @@ type Thread interface {
// could be short and an error will be returned. If this does
// encounter unmapped memory, it will read up to the byte
// preceding the unmapped area.
- Peek(addr Word, out []byte) (int, os.Error);
+ Peek(addr Word, out []byte) (int, os.Error)
// Poke writes b to the address addr in this thread. The
// thread must be stopped. It returns the number of bytes
@@ -104,7 +104,7 @@ type Thread interface {
// short and an error will be returned. If this does
// encounter unmapped memory, it will write up to the byte
// preceding the unmapped area.
- Poke(addr Word, b []byte) (int, os.Error);
+ Poke(addr Word, b []byte) (int, os.Error)
}
// Process is a process being traced. It consists of a set of
@@ -112,37 +112,37 @@ type Thread interface {
// process's state extends to all of its threads.
type Process interface {
// Threads returns an array of all threads in this process.
- Threads() []Thread;
+ Threads() []Thread
// AddBreakpoint creates a new breakpoint at program counter
// pc. Breakpoints can only be created when the process is
// stopped. It is an error if a breakpoint already exists at
// pc.
- AddBreakpoint(pc Word) os.Error;
+ AddBreakpoint(pc Word) os.Error
// RemoveBreakpoint removes the breakpoint at the program
// counter pc. It is an error if no breakpoint exists at pc.
- RemoveBreakpoint(pc Word) os.Error;
+ RemoveBreakpoint(pc Word) os.Error
// Stop stops all running threads in this process before
// returning.
- Stop() os.Error;
+ Stop() os.Error
// Continue resumes execution of all threads in this process.
// Any thread that is stopped on a breakpoint will be stepped
// over that breakpoint. Any thread that is stopped because
// of a signal (other than SIGSTOP or SIGTRAP) will receive
// the pending signal.
- Continue() os.Error;
+ Continue() os.Error
// WaitStop waits until all threads in process p are stopped
// as a result of some thread hitting a breakpoint, receiving
// a signal, creating a new thread, or exiting.
- WaitStop() os.Error;
+ WaitStop() os.Error
// Detach detaches from this process. All stopped threads
// will be resumed.
- Detach() os.Error;
+ Detach() os.Error
}
// Stopped is a stop cause used for threads that are stopped either by
@@ -151,14 +151,14 @@ type Process interface {
// stop.
type Stopped struct{}
-func (c Stopped) String() string { return "stopped" }
+func (c Stopped) String() string { return "stopped" }
// Breakpoint is a stop cause resulting from a thread reaching a set
// breakpoint.
type Breakpoint Word
// PC returns the program counter that the program is stopped at.
-func (c Breakpoint) PC() Word { return Word(c) }
+func (c Breakpoint) PC() Word { return Word(c) }
func (c Breakpoint) String() string {
return "breakpoint at 0x" + strconv.Uitob64(uint64(c.PC()), 16)
@@ -169,47 +169,47 @@ func (c Breakpoint) String() string {
type Signal string
// Signal returns the signal being delivered to the thread.
-func (c Signal) Name() string { return string(c) }
+func (c Signal) Name() string { return string(c) }
-func (c Signal) String() string { return c.Name() }
+func (c Signal) String() string { return c.Name() }
// ThreadCreate is a stop cause returned from an existing thread when
// it creates a new thread. The new thread exists in a primordial
// form at this point and will begin executing in earnest when the
// process is continued.
type ThreadCreate struct {
- thread Thread;
+ thread Thread
}
-func (c *ThreadCreate) NewThread() Thread { return c.thread }
+func (c *ThreadCreate) NewThread() Thread { return c.thread }
-func (c *ThreadCreate) String() string { return "thread create" }
+func (c *ThreadCreate) String() string { return "thread create" }
// ThreadExit is a stop cause resulting from a thread exiting. When
// this cause first arises, the thread will still be in the list of
// process threads and its registers and memory will still be
// accessible.
type ThreadExit struct {
- exitStatus int;
- signal string;
+ exitStatus int
+ signal string
}
// Exited returns true if the thread exited normally.
-func (c *ThreadExit) Exited() bool { return c.exitStatus != -1 }
+func (c *ThreadExit) Exited() bool { return c.exitStatus != -1 }
// ExitStatus returns the exit status of the thread if it exited
// normally or -1 otherwise.
-func (c *ThreadExit) ExitStatus() int { return c.exitStatus }
+func (c *ThreadExit) ExitStatus() int { return c.exitStatus }
// Signaled returns true if the thread was terminated by a signal.
-func (c *ThreadExit) Signaled() bool { return c.exitStatus == -1 }
+func (c *ThreadExit) Signaled() bool { return c.exitStatus == -1 }
// StopSignal returns the signal that terminated the thread, or "" if
// it was not terminated by a signal.
-func (c *ThreadExit) StopSignal() string { return c.signal }
+func (c *ThreadExit) StopSignal() string { return c.signal }
func (c *ThreadExit) String() string {
- res := "thread exited ";
+ res := "thread exited "
switch {
case c.Exited():
res += "with status " + strconv.Itoa(c.ExitStatus())
@@ -218,5 +218,5 @@ func (c *ThreadExit) String() string {
default:
res += "from unknown cause"
}
- return res;
+ return res
}
diff --git a/src/pkg/debug/proc/proc_linux.go b/src/pkg/debug/proc/proc_linux.go
index b7192580d..7273e97d8 100644
--- a/src/pkg/debug/proc/proc_linux.go
+++ b/src/pkg/debug/proc/proc_linux.go
@@ -7,15 +7,15 @@ package proc
// TODO(rsc): Imports here after to be in proc.go too in order
// for deps.bash to get the right answer.
import (
- "container/vector";
- "fmt";
- "io/ioutil";
- "os";
- "runtime";
- "strconv";
- "strings";
- "sync";
- "syscall";
+ "container/vector"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "runtime"
+ "strconv"
+ "strings"
+ "sync"
+ "syscall"
)
// This is an implementation of the process tracing interface using
@@ -35,9 +35,9 @@ import (
// as well as experimentation and examination of gdb's behavior.
const (
- trace = false;
- traceIP = false;
- traceMem = false;
+ trace = false
+ traceIP = false
+ traceMem = false
)
/*
@@ -63,17 +63,17 @@ const (
type threadState string
const (
- running threadState = "Running";
- singleStepping threadState = "SingleStepping"; // Transient
- stopping threadState = "Stopping"; // Transient
- stopped threadState = "Stopped";
- stoppedBreakpoint threadState = "StoppedBreakpoint";
- stoppedSignal threadState = "StoppedSignal";
- stoppedThreadCreate threadState = "StoppedThreadCreate";
- stoppedExiting threadState = "StoppedExiting";
- exiting threadState = "Exiting"; // Transient (except main thread)
- exited threadState = "Exited";
- detached threadState = "Detached";
+ running threadState = "Running"
+ singleStepping threadState = "SingleStepping" // Transient
+ stopping threadState = "Stopping" // Transient
+ stopped threadState = "Stopped"
+ stoppedBreakpoint threadState = "StoppedBreakpoint"
+ stoppedSignal threadState = "StoppedSignal"
+ stoppedThreadCreate threadState = "StoppedThreadCreate"
+ stoppedExiting threadState = "StoppedExiting"
+ exiting threadState = "Exiting" // Transient (except main thread)
+ exited threadState = "Exited"
+ detached threadState = "Detached"
)
func (ts threadState) isRunning() bool {
@@ -84,11 +84,11 @@ func (ts threadState) isStopped() bool {
return ts == stopped || ts == stoppedBreakpoint || ts == stoppedSignal || ts == stoppedThreadCreate || ts == stoppedExiting
}
-func (ts threadState) isZombie() bool { return ts == exiting }
+func (ts threadState) isZombie() bool { return ts == exiting }
-func (ts threadState) isTerminal() bool { return ts == exited || ts == detached }
+func (ts threadState) isTerminal() bool { return ts == exited || ts == detached }
-func (ts threadState) String() string { return string(ts) }
+func (ts threadState) String() string { return string(ts) }
/*
* Basic types
@@ -98,15 +98,15 @@ func (ts threadState) String() string { return string(ts) }
// including its program counter, the overwritten text if the
// breakpoint is installed.
type breakpoint struct {
- pc uintptr;
- olddata []byte;
+ pc uintptr
+ olddata []byte
}
func (bp *breakpoint) String() string {
if bp == nil {
return "<nil>"
}
- return fmt.Sprintf("%#x", bp.pc);
+ return fmt.Sprintf("%#x", bp.pc)
}
// bpinst386 is the breakpoint instruction used on 386 and amd64.
@@ -114,15 +114,15 @@ var bpinst386 = []byte{0xcc}
// A debugEvent represents a reason a thread stopped or a wait error.
type debugEvent struct {
- *os.Waitmsg;
- t *thread;
- err os.Error;
+ *os.Waitmsg
+ t *thread
+ err os.Error
}
// A debugReq is a request to execute a closure in the monitor thread.
type debugReq struct {
- f func() os.Error;
- res chan os.Error;
+ f func() os.Error
+ res chan os.Error
}
// A transitionHandler specifies a function to be called when a thread
@@ -131,8 +131,8 @@ type debugReq struct {
// invokes a handler, it removes the handler from the handler queue.
// The handler should re-add itself if needed.
type transitionHandler struct {
- handle func(*thread, threadState, threadState);
- onErr func(os.Error);
+ handle func(*thread, threadState, threadState)
+ onErr func(os.Error)
}
// A process is a Linux process, which consists of a set of threads.
@@ -146,36 +146,36 @@ type transitionHandler struct {
// returns false, the monitor is not running (the ready channel has
// been closed), and the reason it is not running will be stored in err.
type process struct {
- pid int;
- threads map[int]*thread;
- breakpoints map[uintptr]*breakpoint;
- ready chan bool;
- debugEvents chan *debugEvent;
- debugReqs chan *debugReq;
- stopReq chan os.Error;
- transitionHandlers *vector.Vector;
- err os.Error;
+ pid int
+ threads map[int]*thread
+ breakpoints map[uintptr]*breakpoint
+ ready chan bool
+ debugEvents chan *debugEvent
+ debugReqs chan *debugReq
+ stopReq chan os.Error
+ transitionHandlers *vector.Vector
+ err os.Error
}
// A thread represents a Linux thread in another process that is being
// debugged. Each running thread has an associated goroutine that
// waits for thread updates and sends them to the process monitor.
type thread struct {
- tid int;
- proc *process;
+ tid int
+ proc *process
// Whether to ignore the next SIGSTOP received by wait.
- ignoreNextSigstop bool;
+ ignoreNextSigstop bool
// Thread state. Only modified via setState.
- state threadState;
+ state threadState
// If state == StoppedBreakpoint
- breakpoint *breakpoint;
+ breakpoint *breakpoint
// If state == StoppedSignal or state == Exited
- signal int;
+ signal int
// If state == StoppedThreadCreate
- newThread *thread;
+ newThread *thread
// If state == Exited
- exitStatus int;
+ exitStatus int
}
/*
@@ -183,9 +183,9 @@ type thread struct {
*/
type badState struct {
- thread *thread;
- message string;
- state threadState;
+ thread *thread
+ message string
+ state threadState
}
func (e *badState) String() string {
@@ -200,12 +200,12 @@ func (e breakpointExistsError) String() string {
type noBreakpointError Word
-func (e noBreakpointError) String() string { return fmt.Sprintf("no breakpoint at PC %#x", e) }
+func (e noBreakpointError) String() string { return fmt.Sprintf("no breakpoint at PC %#x", e) }
type newThreadError struct {
- *os.Waitmsg;
- wantPid int;
- wantSig int;
+ *os.Waitmsg
+ wantPid int
+ wantSig int
}
func (e *newThreadError) String() string {
@@ -214,66 +214,66 @@ func (e *newThreadError) String() string {
type ProcessExited struct{}
-func (p ProcessExited) String() string { return "process exited" }
+func (p ProcessExited) String() string { return "process exited" }
/*
* Ptrace wrappers
*/
func (t *thread) ptracePeekText(addr uintptr, out []byte) (int, os.Error) {
- c, err := syscall.PtracePeekText(t.tid, addr, out);
+ c, err := syscall.PtracePeekText(t.tid, addr, out)
if traceMem {
fmt.Printf("peek(%#x) => %v, %v\n", addr, out, err)
}
- return c, os.NewSyscallError("ptrace(PEEKTEXT)", err);
+ return c, os.NewSyscallError("ptrace(PEEKTEXT)", err)
}
func (t *thread) ptracePokeText(addr uintptr, out []byte) (int, os.Error) {
- c, err := syscall.PtracePokeText(t.tid, addr, out);
+ c, err := syscall.PtracePokeText(t.tid, addr, out)
if traceMem {
fmt.Printf("poke(%#x, %v) => %v\n", addr, out, err)
}
- return c, os.NewSyscallError("ptrace(POKETEXT)", err);
+ return c, os.NewSyscallError("ptrace(POKETEXT)", err)
}
func (t *thread) ptraceGetRegs(regs *syscall.PtraceRegs) os.Error {
- err := syscall.PtraceGetRegs(t.tid, regs);
- return os.NewSyscallError("ptrace(GETREGS)", err);
+ err := syscall.PtraceGetRegs(t.tid, regs)
+ return os.NewSyscallError("ptrace(GETREGS)", err)
}
func (t *thread) ptraceSetRegs(regs *syscall.PtraceRegs) os.Error {
- err := syscall.PtraceSetRegs(t.tid, regs);
- return os.NewSyscallError("ptrace(SETREGS)", err);
+ err := syscall.PtraceSetRegs(t.tid, regs)
+ return os.NewSyscallError("ptrace(SETREGS)", err)
}
func (t *thread) ptraceSetOptions(options int) os.Error {
- err := syscall.PtraceSetOptions(t.tid, options);
- return os.NewSyscallError("ptrace(SETOPTIONS)", err);
+ err := syscall.PtraceSetOptions(t.tid, options)
+ return os.NewSyscallError("ptrace(SETOPTIONS)", err)
}
func (t *thread) ptraceGetEventMsg() (uint, os.Error) {
- msg, err := syscall.PtraceGetEventMsg(t.tid);
- return msg, os.NewSyscallError("ptrace(GETEVENTMSG)", err);
+ msg, err := syscall.PtraceGetEventMsg(t.tid)
+ return msg, os.NewSyscallError("ptrace(GETEVENTMSG)", err)
}
func (t *thread) ptraceCont() os.Error {
- err := syscall.PtraceCont(t.tid, 0);
- return os.NewSyscallError("ptrace(CONT)", err);
+ err := syscall.PtraceCont(t.tid, 0)
+ return os.NewSyscallError("ptrace(CONT)", err)
}
func (t *thread) ptraceContWithSignal(sig int) os.Error {
- err := syscall.PtraceCont(t.tid, sig);
- return os.NewSyscallError("ptrace(CONT)", err);
+ err := syscall.PtraceCont(t.tid, sig)
+ return os.NewSyscallError("ptrace(CONT)", err)
}
func (t *thread) ptraceStep() os.Error {
- err := syscall.PtraceSingleStep(t.tid);
- return os.NewSyscallError("ptrace(SINGLESTEP)", err);
+ err := syscall.PtraceSingleStep(t.tid)
+ return os.NewSyscallError("ptrace(SINGLESTEP)", err)
}
func (t *thread) ptraceDetach() os.Error {
- err := syscall.PtraceDetach(t.tid);
- return os.NewSyscallError("ptrace(DETACH)", err);
+ err := syscall.PtraceDetach(t.tid)
+ return os.NewSyscallError("ptrace(DETACH)", err)
}
/*
@@ -286,38 +286,38 @@ func (t *thread) logTrace(format string, args ...) {
if !trace {
return
}
- logLock.Lock();
- defer logLock.Unlock();
- fmt.Fprintf(os.Stderr, "Thread %d", t.tid);
+ logLock.Lock()
+ defer logLock.Unlock()
+ fmt.Fprintf(os.Stderr, "Thread %d", t.tid)
if traceIP {
- var regs syscall.PtraceRegs;
- err := t.ptraceGetRegs(&regs);
+ var regs syscall.PtraceRegs
+ err := t.ptraceGetRegs(&regs)
if err == nil {
fmt.Fprintf(os.Stderr, "@%x", regs.PC())
}
}
- fmt.Fprint(os.Stderr, ": ");
- fmt.Fprintf(os.Stderr, format, args);
- fmt.Fprint(os.Stderr, "\n");
+ fmt.Fprint(os.Stderr, ": ")
+ fmt.Fprintf(os.Stderr, format, args)
+ fmt.Fprint(os.Stderr, "\n")
}
func (t *thread) warn(format string, args ...) {
- logLock.Lock();
- defer logLock.Unlock();
- fmt.Fprintf(os.Stderr, "Thread %d: WARNING ", t.tid);
- fmt.Fprintf(os.Stderr, format, args);
- fmt.Fprint(os.Stderr, "\n");
+ logLock.Lock()
+ defer logLock.Unlock()
+ fmt.Fprintf(os.Stderr, "Thread %d: WARNING ", t.tid)
+ fmt.Fprintf(os.Stderr, format, args)
+ fmt.Fprint(os.Stderr, "\n")
}
func (p *process) logTrace(format string, args ...) {
if !trace {
return
}
- logLock.Lock();
- defer logLock.Unlock();
- fmt.Fprintf(os.Stderr, "Process %d: ", p.pid);
- fmt.Fprintf(os.Stderr, format, args);
- fmt.Fprint(os.Stderr, "\n");
+ logLock.Lock()
+ defer logLock.Unlock()
+ fmt.Fprintf(os.Stderr, "Process %d: ", p.pid)
+ fmt.Fprintf(os.Stderr, format, args)
+ fmt.Fprint(os.Stderr, "\n")
}
/*
@@ -334,7 +334,7 @@ func (p *process) someStoppedThread() *thread {
return t
}
}
- return nil;
+ return nil
}
// someRunningThread returns a running thread from the process.
@@ -347,7 +347,7 @@ func (p *process) someRunningThread() *thread {
return t
}
}
- return nil;
+ return nil
}
/*
@@ -358,32 +358,32 @@ func (p *process) someRunningThread() *thread {
//
// Must be called from the monitor thread.
func (p *process) installBreakpoints() os.Error {
- n := 0;
- main := p.someStoppedThread();
+ n := 0
+ main := p.someStoppedThread()
for _, b := range p.breakpoints {
if b.olddata != nil {
continue
}
- b.olddata = make([]byte, len(bpinst386));
- _, err := main.ptracePeekText(uintptr(b.pc), b.olddata);
+ b.olddata = make([]byte, len(bpinst386))
+ _, err := main.ptracePeekText(uintptr(b.pc), b.olddata)
if err != nil {
- b.olddata = nil;
- return err;
+ b.olddata = nil
+ return err
}
- _, err = main.ptracePokeText(uintptr(b.pc), bpinst386);
+ _, err = main.ptracePokeText(uintptr(b.pc), bpinst386)
if err != nil {
- b.olddata = nil;
- return err;
+ b.olddata = nil
+ return err
}
- n++;
+ n++
}
if n > 0 {
p.logTrace("installed %d/%d breakpoints", n, len(p.breakpoints))
}
- return nil;
+ return nil
}
// uninstallBreakpoints removes the installed breakpoints from p.
@@ -393,25 +393,25 @@ func (p *process) uninstallBreakpoints() os.Error {
if len(p.threads) == 0 {
return nil
}
- n := 0;
- main := p.someStoppedThread();
+ n := 0
+ main := p.someStoppedThread()
for _, b := range p.breakpoints {
if b.olddata == nil {
continue
}
- _, err := main.ptracePokeText(uintptr(b.pc), b.olddata);
+ _, err := main.ptracePokeText(uintptr(b.pc), b.olddata)
if err != nil {
return err
}
- b.olddata = nil;
- n++;
+ b.olddata = nil
+ n++
}
if n > 0 {
p.logTrace("uninstalled %d/%d breakpoints", n, len(p.breakpoints))
}
- return nil;
+ return nil
}
/*
@@ -425,17 +425,17 @@ func (p *process) uninstallBreakpoints() os.Error {
// event.
func (t *thread) wait() {
for {
- var ev debugEvent;
- ev.t = t;
- t.logTrace("beginning wait");
- ev.Waitmsg, ev.err = os.Wait(t.tid, syscall.WALL);
+ var ev debugEvent
+ ev.t = t
+ t.logTrace("beginning wait")
+ ev.Waitmsg, ev.err = os.Wait(t.tid, syscall.WALL)
if ev.err == nil && ev.Pid != t.tid {
panic("Wait returned pid ", ev.Pid, " wanted ", t.tid)
}
if ev.StopSignal() == syscall.SIGSTOP && t.ignoreNextSigstop {
// Spurious SIGSTOP. See Thread.Stop().
- t.ignoreNextSigstop = false;
- err := t.ptraceCont();
+ t.ignoreNextSigstop = false
+ err := t.ptraceCont()
if err == nil {
continue
}
@@ -447,8 +447,8 @@ func (t *thread) wait() {
// The monitor exited
break
}
- t.proc.debugEvents <- &ev;
- break;
+ t.proc.debugEvents <- &ev
+ break
}
}
@@ -457,9 +457,9 @@ func (t *thread) wait() {
//
// Must be called from the monitor thread.
func (t *thread) setState(newState threadState) {
- oldState := t.state;
- t.state = newState;
- t.logTrace("state %v -> %v", oldState, newState);
+ oldState := t.state
+ t.state = newState
+ t.logTrace("state %v -> %v", oldState, newState)
if !oldState.isRunning() && (newState.isRunning() || newState.isZombie()) {
// Start waiting on this thread
@@ -467,23 +467,23 @@ func (t *thread) setState(newState threadState) {
}
// Invoke state change handlers
- handlers := t.proc.transitionHandlers;
+ handlers := t.proc.transitionHandlers
if handlers.Len() == 0 {
return
}
- t.proc.transitionHandlers = new(vector.Vector);
+ t.proc.transitionHandlers = new(vector.Vector)
for _, h := range handlers.Data() {
- h := h.(*transitionHandler);
- h.handle(t, oldState, newState);
+ h := h.(*transitionHandler)
+ h.handle(t, oldState, newState)
}
}
// sendSigstop sends a SIGSTOP to this thread.
func (t *thread) sendSigstop() os.Error {
- t.logTrace("sending SIGSTOP");
- err := syscall.Tgkill(t.proc.pid, t.tid, syscall.SIGSTOP);
- return os.NewSyscallError("tgkill", err);
+ t.logTrace("sending SIGSTOP")
+ err := syscall.Tgkill(t.proc.pid, t.tid, syscall.SIGSTOP)
+ return os.NewSyscallError("tgkill", err)
}
// stopAsync sends SIGSTOP to all threads in state 'running'.
@@ -492,14 +492,14 @@ func (t *thread) sendSigstop() os.Error {
func (p *process) stopAsync() os.Error {
for _, t := range p.threads {
if t.state == running {
- err := t.sendSigstop();
+ err := t.sendSigstop()
if err != nil {
return err
}
- t.setState(stopping);
+ t.setState(stopping)
}
}
- return nil;
+ return nil
}
// doTrap handles SIGTRAP debug events with a cause of 0. These can
@@ -508,7 +508,7 @@ func (p *process) stopAsync() os.Error {
//
// TODO(austin) I think we also get this on an execve syscall.
func (ev *debugEvent) doTrap() (threadState, os.Error) {
- t := ev.t;
+ t := ev.t
if t.state == singleStepping {
return stopped, nil
@@ -517,13 +517,13 @@ func (ev *debugEvent) doTrap() (threadState, os.Error) {
// Hit a breakpoint. Linux leaves the program counter after
// the breakpoint. If this is an installed breakpoint, we
// need to back the PC up to the breakpoint PC.
- var regs syscall.PtraceRegs;
- err := t.ptraceGetRegs(&regs);
+ var regs syscall.PtraceRegs
+ err := t.ptraceGetRegs(&regs)
if err != nil {
return stopped, err
}
- b, ok := t.proc.breakpoints[uintptr(regs.PC())-uintptr(len(bpinst386))];
+ b, ok := t.proc.breakpoints[uintptr(regs.PC())-uintptr(len(bpinst386))]
if !ok {
// We must have hit a breakpoint that was actually in
// the program. Leave the IP where it is so we don't
@@ -532,38 +532,38 @@ func (ev *debugEvent) doTrap() (threadState, os.Error) {
return stoppedSignal, nil
}
- t.breakpoint = b;
- t.logTrace("at breakpoint %v, backing up PC from %#x", b, regs.PC());
+ t.breakpoint = b
+ t.logTrace("at breakpoint %v, backing up PC from %#x", b, regs.PC())
- regs.SetPC(uint64(b.pc));
- err = t.ptraceSetRegs(&regs);
+ regs.SetPC(uint64(b.pc))
+ err = t.ptraceSetRegs(&regs)
if err != nil {
return stopped, err
}
- return stoppedBreakpoint, nil;
+ return stoppedBreakpoint, nil
}
// doPtraceClone handles SIGTRAP debug events with a PTRACE_EVENT_CLONE
// cause. It initializes the new thread, adds it to the process, and
// returns the appropriate thread state for the existing thread.
func (ev *debugEvent) doPtraceClone() (threadState, os.Error) {
- t := ev.t;
+ t := ev.t
// Get the TID of the new thread
- tid, err := t.ptraceGetEventMsg();
+ tid, err := t.ptraceGetEventMsg()
if err != nil {
return stopped, err
}
- nt, err := t.proc.newThread(int(tid), syscall.SIGSTOP, true);
+ nt, err := t.proc.newThread(int(tid), syscall.SIGSTOP, true)
if err != nil {
return stopped, err
}
// Remember the thread
- t.newThread = nt;
+ t.newThread = nt
- return stoppedThreadCreate, nil;
+ return stoppedThreadCreate, nil
}
// doPtraceExit handles SIGTRAP debug events with a PTRACE_EVENT_EXIT
@@ -571,15 +571,15 @@ func (ev *debugEvent) doPtraceClone() (threadState, os.Error) {
// the process. A later WIFEXITED debug event will remove it from the
// process.
func (ev *debugEvent) doPtraceExit() (threadState, os.Error) {
- t := ev.t;
+ t := ev.t
// Get exit status
- exitStatus, err := t.ptraceGetEventMsg();
+ exitStatus, err := t.ptraceGetEventMsg()
if err != nil {
return stopped, err
}
- ws := syscall.WaitStatus(exitStatus);
- t.logTrace("exited with %v", ws);
+ ws := syscall.WaitStatus(exitStatus)
+ t.logTrace("exited with %v", ws)
switch {
case ws.Exited():
t.exitStatus = ws.ExitStatus()
@@ -589,7 +589,7 @@ func (ev *debugEvent) doPtraceExit() (threadState, os.Error) {
// We still need to continue this thread and wait on this
// thread's WIFEXITED event. We'll delete it then.
- return stoppedExiting, nil;
+ return stoppedExiting, nil
}
// process handles a debug event. It modifies any thread or process
@@ -600,20 +600,20 @@ func (ev *debugEvent) process() os.Error {
return ev.err
}
- t := ev.t;
- t.exitStatus = -1;
- t.signal = -1;
+ t := ev.t
+ t.exitStatus = -1
+ t.signal = -1
// Decode wait status.
- var state threadState;
+ var state threadState
switch {
case ev.Stopped():
- state = stoppedSignal;
- t.signal = ev.StopSignal();
- t.logTrace("stopped with %v", ev);
+ state = stoppedSignal
+ t.signal = ev.StopSignal()
+ t.logTrace("stopped with %v", ev)
if ev.StopSignal() == syscall.SIGTRAP {
// What caused the debug trap?
- var err os.Error;
+ var err os.Error
switch cause := ev.TrapCause(); cause {
case 0:
// Breakpoint or single stepping
@@ -630,25 +630,25 @@ func (ev *debugEvent) process() os.Error {
}
if err != nil {
- t.setState(stopped);
- t.warn("failed to handle trap %v: %v", ev, err);
+ t.setState(stopped)
+ t.warn("failed to handle trap %v: %v", ev, err)
}
}
case ev.Exited():
- state = exited;
- t.proc.threads[t.tid] = nil, false;
- t.logTrace("exited %v", ev);
+ state = exited
+ t.proc.threads[t.tid] = nil, false
+ t.logTrace("exited %v", ev)
// We should have gotten the exit status in
// PTRACE_EVENT_EXIT, but just in case.
- t.exitStatus = ev.ExitStatus();
+ t.exitStatus = ev.ExitStatus()
case ev.Signaled():
- state = exited;
- t.proc.threads[t.tid] = nil, false;
- t.logTrace("signaled %v", ev);
+ state = exited
+ t.proc.threads[t.tid] = nil, false
+ t.logTrace("signaled %v", ev)
// Again, this should be redundant.
- t.signal = ev.Signal();
+ t.signal = ev.Signal()
default:
panic(fmt.Sprintf("Unexpected wait status %v", ev.Waitmsg))
@@ -666,14 +666,14 @@ func (ev *debugEvent) process() os.Error {
// TODO(austin) If we're in state stopping and get a SIGSTOP,
// set state stopped instead of stoppedSignal.
- t.setState(state);
+ t.setState(state)
if t.proc.someRunningThread() == nil {
// Nothing is running, uninstall breakpoints
return t.proc.uninstallBreakpoints()
}
// Stop any other running threads
- return t.proc.stopAsync();
+ return t.proc.stopAsync()
}
// onStop adds a handler for state transitions from running to
@@ -686,15 +686,15 @@ func (t *thread) onStop(handle func(), onErr func(os.Error)) {
// stepping all threads during a continue. Maybe move
// transitionHandlers to the thread, or have both per-thread
// and per-process transition handlers.
- h := &transitionHandler{nil, onErr};
+ h := &transitionHandler{nil, onErr}
h.handle = func(st *thread, old, new threadState) {
if t == st && old.isRunning() && !new.isRunning() {
handle()
} else {
t.proc.transitionHandlers.Push(h)
}
- };
- t.proc.transitionHandlers.Push(h);
+ }
+ t.proc.transitionHandlers.Push(h)
}
/*
@@ -704,17 +704,17 @@ func (t *thread) onStop(handle func(), onErr func(os.Error)) {
// monitor handles debug events and debug requests for p, exiting when
// there are no threads left in p.
func (p *process) monitor() {
- var err os.Error;
+ var err os.Error
// Linux requires that all ptrace calls come from the thread
// that originally attached. Prevent the Go scheduler from
// migrating us to other OS threads.
- runtime.LockOSThread();
- defer runtime.UnlockOSThread();
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
- hadThreads := false;
+ hadThreads := false
for err == nil {
- p.ready <- true;
+ p.ready <- true
select {
case event := <-p.debugEvents:
err = event.process()
@@ -728,8 +728,8 @@ func (p *process) monitor() {
if len(p.threads) == 0 {
if err == nil && hadThreads {
- p.logTrace("no more threads; monitor exiting");
- err = ProcessExited{};
+ p.logTrace("no more threads; monitor exiting")
+ err = ProcessExited{}
}
} else {
hadThreads = true
@@ -739,13 +739,13 @@ func (p *process) monitor() {
// Abort waiting handlers
// TODO(austin) How do I stop the wait threads?
for _, h := range p.transitionHandlers.Data() {
- h := h.(*transitionHandler);
- h.onErr(err);
+ h := h.(*transitionHandler)
+ h.onErr(err)
}
// Indicate that the monitor cannot receive any more messages
- p.err = err;
- close(p.ready);
+ p.err = err
+ close(p.ready)
}
// do executes f in the monitor thread (and, thus, atomically with
@@ -756,9 +756,9 @@ func (p *process) do(f func() os.Error) os.Error {
if !<-p.ready {
return p.err
}
- req := &debugReq{f, make(chan os.Error)};
- p.debugReqs <- req;
- return <-req.res;
+ req := &debugReq{f, make(chan os.Error)}
+ p.debugReqs <- req
+ return <-req.res
}
// stopMonitor stops the monitor with the given error. If the monitor
@@ -777,14 +777,14 @@ func (p *process) stopMonitor(err os.Error) {
*/
func (t *thread) Regs() (Regs, os.Error) {
- var regs syscall.PtraceRegs;
+ var regs syscall.PtraceRegs
err := t.proc.do(func() os.Error {
if !t.state.isStopped() {
return &badState{t, "cannot get registers", t.state}
}
- return t.ptraceGetRegs(&regs);
- });
+ return t.ptraceGetRegs(&regs)
+ })
if err != nil {
return nil, err
}
@@ -794,42 +794,42 @@ func (t *thread) Regs() (Regs, os.Error) {
if !t.state.isStopped() {
return &badState{t, "cannot get registers", t.state}
}
- return t.ptraceSetRegs(r);
+ return t.ptraceSetRegs(r)
})
- };
- return newRegs(&regs, setter), nil;
+ }
+ return newRegs(&regs, setter), nil
}
func (t *thread) Peek(addr Word, out []byte) (int, os.Error) {
- var c int;
+ var c int
err := t.proc.do(func() os.Error {
if !t.state.isStopped() {
return &badState{t, "cannot peek text", t.state}
}
- var err os.Error;
- c, err = t.ptracePeekText(uintptr(addr), out);
- return err;
- });
+ var err os.Error
+ c, err = t.ptracePeekText(uintptr(addr), out)
+ return err
+ })
- return c, err;
+ return c, err
}
func (t *thread) Poke(addr Word, out []byte) (int, os.Error) {
- var c int;
+ var c int
err := t.proc.do(func() os.Error {
if !t.state.isStopped() {
return &badState{t, "cannot poke text", t.state}
}
- var err os.Error;
- c, err = t.ptracePokeText(uintptr(addr), out);
- return err;
- });
+ var err os.Error
+ c, err = t.ptracePokeText(uintptr(addr), out)
+ return err
+ })
- return c, err;
+ return c, err
}
// stepAsync starts this thread single stepping. When the single step
@@ -841,30 +841,30 @@ func (t *thread) stepAsync(ready chan os.Error) os.Error {
if err := t.ptraceStep(); err != nil {
return err
}
- t.setState(singleStepping);
+ t.setState(singleStepping)
t.onStop(func() { ready <- nil },
- func(err os.Error) { ready <- err });
- return nil;
+ func(err os.Error) { ready <- err })
+ return nil
}
func (t *thread) Step() os.Error {
- t.logTrace("Step {");
- defer t.logTrace("}");
+ t.logTrace("Step {")
+ defer t.logTrace("}")
- ready := make(chan os.Error);
+ ready := make(chan os.Error)
err := t.proc.do(func() os.Error {
if !t.state.isStopped() {
return &badState{t, "cannot single step", t.state}
}
- return t.stepAsync(ready);
- });
+ return t.stepAsync(ready)
+ })
if err != nil {
return err
}
- err = <-ready;
- return err;
+ err = <-ready
+ return err
}
// TODO(austin) We should probably get this via C's strsignal.
@@ -884,11 +884,11 @@ func sigName(signal int) string {
if signal < 0 || signal >= len(sigNames) {
return "<invalid>"
}
- return sigNames[signal];
+ return sigNames[signal]
}
func (t *thread) Stopped() (Cause, os.Error) {
- var c Cause;
+ var c Cause
err := t.proc.do(func() os.Error {
switch t.state {
case stopped:
@@ -913,35 +913,35 @@ func (t *thread) Stopped() (Cause, os.Error) {
default:
return &badState{t, "cannot get stop cause", t.state}
}
- return nil;
- });
+ return nil
+ })
if err != nil {
return nil, err
}
- return c, nil;
+ return c, nil
}
func (p *process) Threads() []Thread {
- var res []Thread;
+ var res []Thread
p.do(func() os.Error {
- res = make([]Thread, len(p.threads));
- i := 0;
+ res = make([]Thread, len(p.threads))
+ i := 0
for _, t := range p.threads {
// Exclude zombie threads.
- st := t.state;
+ st := t.state
if st == exiting || st == exited || st == detached {
continue
}
- res[i] = t;
- i++;
+ res[i] = t
+ i++
}
- res = res[0:i];
- return nil;
- });
- return res;
+ res = res[0:i]
+ return nil
+ })
+ return res
}
func (p *process) AddBreakpoint(pc Word) os.Error {
@@ -952,8 +952,8 @@ func (p *process) AddBreakpoint(pc Word) os.Error {
if _, ok := p.breakpoints[uintptr(pc)]; ok {
return breakpointExistsError(pc)
}
- p.breakpoints[uintptr(pc)] = &breakpoint{pc: uintptr(pc)};
- return nil;
+ p.breakpoints[uintptr(pc)] = &breakpoint{pc: uintptr(pc)}
+ return nil
})
}
@@ -965,22 +965,22 @@ func (p *process) RemoveBreakpoint(pc Word) os.Error {
if _, ok := p.breakpoints[uintptr(pc)]; !ok {
return noBreakpointError(pc)
}
- p.breakpoints[uintptr(pc)] = nil, false;
- return nil;
+ p.breakpoints[uintptr(pc)] = nil, false
+ return nil
})
}
func (p *process) Continue() os.Error {
// Single step any threads that are stopped at breakpoints so
// we can reinstall breakpoints.
- var ready chan os.Error;
- count := 0;
+ var ready chan os.Error
+ count := 0
err := p.do(func() os.Error {
// We make the ready channel big enough to hold all
// ready message so we don't jam up the monitor if we
// stop listening (e.g., if there's an error).
- ready = make(chan os.Error, len(p.threads));
+ ready = make(chan os.Error, len(p.threads))
for _, t := range p.threads {
if !t.state.isStopped() {
@@ -992,34 +992,34 @@ func (p *process) Continue() os.Error {
// it could have been stopped at a breakpoint
// for some other reason, or the breakpoint
// could have been added since it was stopped.
- var regs syscall.PtraceRegs;
- err := t.ptraceGetRegs(&regs);
+ var regs syscall.PtraceRegs
+ err := t.ptraceGetRegs(&regs)
if err != nil {
return err
}
if b, ok := p.breakpoints[uintptr(regs.PC())]; ok {
- t.logTrace("stepping over breakpoint %v", b);
+ t.logTrace("stepping over breakpoint %v", b)
if err := t.stepAsync(ready); err != nil {
return err
}
- count++;
+ count++
}
}
- return nil;
- });
+ return nil
+ })
if err != nil {
- p.stopMonitor(err);
- return err;
+ p.stopMonitor(err)
+ return err
}
// Wait for single stepping threads
for count > 0 {
- err = <-ready;
+ err = <-ready
if err != nil {
- p.stopMonitor(err);
- return err;
+ p.stopMonitor(err)
+ return err
}
- count--;
+ count--
}
// Continue all threads
@@ -1029,18 +1029,18 @@ func (p *process) Continue() os.Error {
}
for _, t := range p.threads {
- var err os.Error;
+ var err os.Error
switch {
case !t.state.isStopped():
continue
case t.state == stoppedSignal && t.signal != syscall.SIGSTOP && t.signal != syscall.SIGTRAP:
- t.logTrace("continuing with signal %d", t.signal);
- err = t.ptraceContWithSignal(t.signal);
+ t.logTrace("continuing with signal %d", t.signal)
+ err = t.ptraceContWithSignal(t.signal)
default:
- t.logTrace("continuing");
- err = t.ptraceCont();
+ t.logTrace("continuing")
+ err = t.ptraceCont()
}
if err != nil {
return err
@@ -1051,59 +1051,59 @@ func (p *process) Continue() os.Error {
t.setState(running)
}
}
- return nil;
- });
+ return nil
+ })
if err != nil {
// TODO(austin) Do we need to stop the monitor with
// this error atomically with the do-routine above?
- p.stopMonitor(err);
- return err;
+ p.stopMonitor(err)
+ return err
}
- return nil;
+ return nil
}
func (p *process) WaitStop() os.Error {
// We need a non-blocking ready channel for the case where all
// threads are already stopped.
- ready := make(chan os.Error, 1);
+ ready := make(chan os.Error, 1)
err := p.do(func() os.Error {
// Are all of the threads already stopped?
if p.someRunningThread() == nil {
- ready <- nil;
- return nil;
+ ready <- nil
+ return nil
}
// Monitor state transitions
- h := &transitionHandler{};
+ h := &transitionHandler{}
h.handle = func(st *thread, old, new threadState) {
if !new.isRunning() {
if p.someRunningThread() == nil {
- ready <- nil;
- return;
+ ready <- nil
+ return
}
}
- p.transitionHandlers.Push(h);
- };
- h.onErr = func(err os.Error) { ready <- err };
- p.transitionHandlers.Push(h);
- return nil;
- });
+ p.transitionHandlers.Push(h)
+ }
+ h.onErr = func(err os.Error) { ready <- err }
+ p.transitionHandlers.Push(h)
+ return nil
+ })
if err != nil {
return err
}
- return <-ready;
+ return <-ready
}
func (p *process) Stop() os.Error {
- err := p.do(func() os.Error { return p.stopAsync() });
+ err := p.do(func() os.Error { return p.stopAsync() })
if err != nil {
return err
}
- return p.WaitStop();
+ return p.WaitStop()
}
func (p *process) Detach() os.Error {
@@ -1123,13 +1123,13 @@ func (p *process) Detach() os.Error {
return err
}
}
- t.setState(detached);
- p.threads[pid] = nil, false;
+ t.setState(detached)
+ p.threads[pid] = nil, false
}
- return nil;
- });
+ return nil
+ })
// TODO(austin) Wait for monitor thread to exit?
- return err;
+ return err
}
// newThread creates a new thread object and waits for its initial
@@ -1138,11 +1138,11 @@ func (p *process) Detach() os.Error {
//
// Must be run from the monitor thread.
func (p *process) newThread(tid int, signal int, cloned bool) (*thread, os.Error) {
- t := &thread{tid: tid, proc: p, state: stopped};
+ t := &thread{tid: tid, proc: p, state: stopped}
// Get the signal from the thread
// TODO(austin) Thread might already be stopped if we're attaching.
- w, err := os.Wait(tid, syscall.WALL);
+ w, err := os.Wait(tid, syscall.WALL)
if err != nil {
return nil, err
}
@@ -1151,59 +1151,59 @@ func (p *process) newThread(tid int, signal int, cloned bool) (*thread, os.Error
}
if !cloned {
- err = t.ptraceSetOptions(syscall.PTRACE_O_TRACECLONE | syscall.PTRACE_O_TRACEEXIT);
+ err = t.ptraceSetOptions(syscall.PTRACE_O_TRACECLONE | syscall.PTRACE_O_TRACEEXIT)
if err != nil {
return nil, err
}
}
- p.threads[tid] = t;
+ p.threads[tid] = t
- return t, nil;
+ return t, nil
}
// attachThread attaches a running thread to the process.
//
// Must NOT be run from the monitor thread.
func (p *process) attachThread(tid int) (*thread, os.Error) {
- p.logTrace("attaching to thread %d", tid);
- var thr *thread;
+ p.logTrace("attaching to thread %d", tid)
+ var thr *thread
err := p.do(func() os.Error {
- errno := syscall.PtraceAttach(tid);
+ errno := syscall.PtraceAttach(tid)
if errno != 0 {
return os.NewSyscallError("ptrace(ATTACH)", errno)
}
- var err os.Error;
- thr, err = p.newThread(tid, syscall.SIGSTOP, false);
- return err;
- });
- return thr, err;
+ var err os.Error
+ thr, err = p.newThread(tid, syscall.SIGSTOP, false)
+ return err
+ })
+ return thr, err
}
// attachAllThreads attaches to all threads in a process.
func (p *process) attachAllThreads() os.Error {
- taskPath := "/proc/" + strconv.Itoa(p.pid) + "/task";
- taskDir, err := os.Open(taskPath, os.O_RDONLY, 0);
+ taskPath := "/proc/" + strconv.Itoa(p.pid) + "/task"
+ taskDir, err := os.Open(taskPath, os.O_RDONLY, 0)
if err != nil {
return err
}
- defer taskDir.Close();
+ defer taskDir.Close()
// We stop threads as we attach to them; however, because new
// threads can appear while we're looping over all of them, we
// have to repeatly scan until we know we're attached to all
// of them.
for again := true; again; {
- again = false;
+ again = false
- tids, err := taskDir.Readdirnames(-1);
+ tids, err := taskDir.Readdirnames(-1)
if err != nil {
return err
}
for _, tidStr := range tids {
- tid, err := strconv.Atoi(tidStr);
+ tid, err := strconv.Atoi(tidStr)
if err != nil {
return err
}
@@ -1211,39 +1211,39 @@ func (p *process) attachAllThreads() os.Error {
continue
}
- _, err = p.attachThread(tid);
+ _, err = p.attachThread(tid)
if err != nil {
// There could have been a race, or
// this process could be a zobmie.
- statFile, err2 := ioutil.ReadFile(taskPath + "/" + tidStr + "/stat");
+ statFile, err2 := ioutil.ReadFile(taskPath + "/" + tidStr + "/stat")
if err2 != nil {
switch err2 := err2.(type) {
case *os.PathError:
if err2.Error == os.ENOENT {
// Raced with thread exit
- p.logTrace("raced with thread %d exit", tid);
- continue;
+ p.logTrace("raced with thread %d exit", tid)
+ continue
}
}
// Return the original error
- return err;
+ return err
}
- statParts := strings.Split(string(statFile), " ", 4);
+ statParts := strings.Split(string(statFile), " ", 4)
if len(statParts) > 2 && statParts[2] == "Z" {
// tid is a zombie
- p.logTrace("thread %d is a zombie", tid);
- continue;
+ p.logTrace("thread %d is a zombie", tid)
+ continue
}
// Return the original error
- return err;
+ return err
}
- again = true;
+ again = true
}
}
- return nil;
+ return nil
}
// newProcess creates a new process object and starts its monitor thread.
@@ -1257,37 +1257,37 @@ func newProcess(pid int) *process {
debugReqs: make(chan *debugReq),
stopReq: make(chan os.Error),
transitionHandlers: new(vector.Vector),
- };
+ }
- go p.monitor();
+ go p.monitor()
- return p;
+ return p
}
// Attach attaches to process pid and stops all of its threads.
func Attach(pid int) (Process, os.Error) {
- p := newProcess(pid);
+ p := newProcess(pid)
// Attach to all threads
- err := p.attachAllThreads();
+ err := p.attachAllThreads()
if err != nil {
- p.Detach();
+ p.Detach()
// TODO(austin) Detach stopped the monitor already
//p.stopMonitor(err);
- return nil, err;
+ return nil, err
}
- return p, nil;
+ return p, nil
}
// ForkExec forks the current process and execs argv0, stopping the
// new process after the exec syscall. See os.ForkExec for additional
// details.
func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) {
- p := newProcess(-1);
+ p := newProcess(-1)
// Create array of integer (system) fds.
- intfd := make([]int, len(fd));
+ intfd := make([]int, len(fd))
for i, f := range fd {
if f == nil {
intfd[i] = -1
@@ -1298,20 +1298,20 @@ func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.F
// Fork from the monitor thread so we get the right tracer pid.
err := p.do(func() os.Error {
- pid, errno := syscall.PtraceForkExec(argv0, argv, envv, dir, intfd);
+ pid, errno := syscall.PtraceForkExec(argv0, argv, envv, dir, intfd)
if errno != 0 {
return &os.PathError{"fork/exec", argv0, os.Errno(errno)}
}
- p.pid = pid;
+ p.pid = pid
// The process will raise SIGTRAP when it reaches execve.
- _, err := p.newThread(pid, syscall.SIGTRAP, false);
- return err;
- });
+ _, err := p.newThread(pid, syscall.SIGTRAP, false)
+ return err
+ })
if err != nil {
- p.stopMonitor(err);
- return nil, err;
+ p.stopMonitor(err)
+ return nil, err
}
- return p, nil;
+ return p, nil
}
diff --git a/src/pkg/debug/proc/proc_nacl.go b/src/pkg/debug/proc/proc_nacl.go
index c4f606739..be26bbf18 100644
--- a/src/pkg/debug/proc/proc_nacl.go
+++ b/src/pkg/debug/proc/proc_nacl.go
@@ -5,8 +5,8 @@
package proc
import (
- "os";
- "syscall";
+ "os"
+ "syscall"
)
// Process tracing is not supported on Native Client.
diff --git a/src/pkg/debug/proc/regs_linux_386.go b/src/pkg/debug/proc/regs_linux_386.go
index abeb45f4b..7c5478d86 100644
--- a/src/pkg/debug/proc/regs_linux_386.go
+++ b/src/pkg/debug/proc/regs_linux_386.go
@@ -5,14 +5,14 @@
package proc
import (
- "os";
- "strconv";
- "syscall";
+ "os"
+ "strconv"
+ "syscall"
)
type _386Regs struct {
- syscall.PtraceRegs;
- setter func(*syscall.PtraceRegs) os.Error;
+ syscall.PtraceRegs
+ setter func(*syscall.PtraceRegs) os.Error
}
var names = [...]string{
@@ -34,11 +34,11 @@ var names = [...]string{
"gs",
}
-func (r *_386Regs) PC() Word { return Word(r.Eip) }
+func (r *_386Regs) PC() Word { return Word(r.Eip) }
func (r *_386Regs) SetPC(val Word) os.Error {
- r.Eip = int32(val);
- return r.setter(&r.PtraceRegs);
+ r.Eip = int32(val)
+ return r.setter(&r.PtraceRegs)
}
func (r *_386Regs) Link() Word {
@@ -46,16 +46,16 @@ func (r *_386Regs) Link() Word {
panic("No link register")
}
-func (r *_386Regs) SetLink(val Word) os.Error { panic("No link register") }
+func (r *_386Regs) SetLink(val Word) os.Error { panic("No link register") }
-func (r *_386Regs) SP() Word { return Word(r.Esp) }
+func (r *_386Regs) SP() Word { return Word(r.Esp) }
func (r *_386Regs) SetSP(val Word) os.Error {
- r.Esp = int32(val);
- return r.setter(&r.PtraceRegs);
+ r.Esp = int32(val)
+ return r.setter(&r.PtraceRegs)
}
-func (r *_386Regs) Names() []string { return &names }
+func (r *_386Regs) Names() []string { return &names }
func (r *_386Regs) Get(i int) Word {
switch i {
@@ -92,7 +92,7 @@ func (r *_386Regs) Get(i int) Word {
case 15:
return Word(r.Gs)
}
- panic("invalid register index ", strconv.Itoa(i));
+ panic("invalid register index ", strconv.Itoa(i))
}
func (r *_386Regs) Set(i int, val Word) os.Error {
@@ -132,12 +132,12 @@ func (r *_386Regs) Set(i int, val Word) os.Error {
default:
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 {
- res := _386Regs{};
- res.PtraceRegs = *regs;
- res.setter = setter;
- return &res;
+ res := _386Regs{}
+ res.PtraceRegs = *regs
+ res.setter = setter
+ return &res
}
diff --git a/src/pkg/debug/proc/regs_linux_amd64.go b/src/pkg/debug/proc/regs_linux_amd64.go
index 63083a948..b070b7714 100644
--- a/src/pkg/debug/proc/regs_linux_amd64.go
+++ b/src/pkg/debug/proc/regs_linux_amd64.go
@@ -5,14 +5,14 @@
package proc
import (
- "os";
- "strconv";
- "syscall";
+ "os"
+ "strconv"
+ "syscall"
)
type amd64Regs struct {
- syscall.PtraceRegs;
- setter func(*syscall.PtraceRegs) os.Error;
+ syscall.PtraceRegs
+ setter func(*syscall.PtraceRegs) os.Error
}
var names = [...]string{
@@ -48,11 +48,11 @@ var names = [...]string{
//"gs_base",
}
-func (r *amd64Regs) PC() Word { return Word(r.Rip) }
+func (r *amd64Regs) PC() Word { return Word(r.Rip) }
func (r *amd64Regs) SetPC(val Word) os.Error {
- r.Rip = uint64(val);
- return r.setter(&r.PtraceRegs);
+ r.Rip = uint64(val)
+ return r.setter(&r.PtraceRegs)
}
func (r *amd64Regs) Link() Word {
@@ -64,14 +64,14 @@ func (r *amd64Regs) SetLink(val Word) os.Error {
panic("No link register")
}
-func (r *amd64Regs) SP() Word { return Word(r.Rsp) }
+func (r *amd64Regs) SP() Word { return Word(r.Rsp) }
func (r *amd64Regs) SetSP(val Word) os.Error {
- r.Rsp = uint64(val);
- return r.setter(&r.PtraceRegs);
+ r.Rsp = uint64(val)
+ return r.setter(&r.PtraceRegs)
}
-func (r *amd64Regs) Names() []string { return &names }
+func (r *amd64Regs) Names() []string { return &names }
func (r *amd64Regs) Get(i int) Word {
switch i {
@@ -124,7 +124,7 @@ func (r *amd64Regs) Get(i int) Word {
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 {
@@ -180,12 +180,12 @@ func (r *amd64Regs) Set(i int, val Word) os.Error {
default:
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 {
- res := amd64Regs{};
- res.PtraceRegs = *regs;
- res.setter = setter;
- return &res;
+ res := amd64Regs{}
+ res.PtraceRegs = *regs
+ res.setter = setter
+ return &res
}
diff --git a/src/pkg/debug/proc/regs_linux_arm.go b/src/pkg/debug/proc/regs_linux_arm.go
index e58ab388b..ec78cbcf2 100644
--- a/src/pkg/debug/proc/regs_linux_arm.go
+++ b/src/pkg/debug/proc/regs_linux_arm.go
@@ -5,35 +5,35 @@
package proc
import (
- "os";
- "syscall";
+ "os"
+ "syscall"
)
// TODO(kaib): add support
type armRegs struct{}
-func (r *armRegs) PC() Word { return Word(0) }
+func (r *armRegs) PC() Word { return Word(0) }
-func (r *armRegs) SetPC(val Word) os.Error { return nil }
+func (r *armRegs) SetPC(val Word) os.Error { return nil }
-func (r *armRegs) Link() Word { return Word(0) }
+func (r *armRegs) Link() Word { return Word(0) }
-func (r *armRegs) SetLink(val Word) os.Error { return nil }
+func (r *armRegs) SetLink(val Word) os.Error { return nil }
-func (r *armRegs) SP() Word { return Word(0) }
+func (r *armRegs) SP() Word { return Word(0) }
-func (r *armRegs) SetSP(val Word) os.Error { return nil }
+func (r *armRegs) SetSP(val Word) os.Error { return nil }
-func (r *armRegs) Names() []string { return nil }
+func (r *armRegs) Names() []string { return nil }
-func (r *armRegs) Get(i int) Word { return Word(0) }
+func (r *armRegs) Get(i int) Word { return Word(0) }
func (r *armRegs) Set(i int, val Word) os.Error {
return nil
}
func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs {
- res := armRegs{};
- return &res;
+ res := armRegs{}
+ return &res
}