diff options
author | rsc <devnull@localhost> | 2006-04-01 19:24:03 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-04-01 19:24:03 +0000 |
commit | cbeb0b26e4c7caa8d1b47de791a7418dc20a4567 (patch) | |
tree | e0f7e445de1aa22a42ef873dc4b1118a8105ae93 /src/libmach | |
parent | 226d80b8213821af0cbf092d1507c52b504fd368 (diff) | |
download | plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.gz plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.bz2 plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.zip |
Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.
Diffstat (limited to 'src/libmach')
-rw-r--r-- | src/libmach/Linux.c | 2 | ||||
-rw-r--r-- | src/libmach/dwarf.h | 66 | ||||
-rw-r--r-- | src/libmach/dwarfeval.c | 60 | ||||
-rw-r--r-- | src/libmach/dwarfinfo.c | 2 | ||||
-rw-r--r-- | src/libmach/dwarfpc.c | 2 | ||||
-rw-r--r-- | src/libmach/elf.h | 2 | ||||
-rw-r--r-- | src/libmach/elfcorefreebsd386.c | 2 | ||||
-rw-r--r-- | src/libmach/elfcorelinux386.c | 6 | ||||
-rw-r--r-- | src/libmach/elfdl386.c | 2 | ||||
-rw-r--r-- | src/libmach/mach386.c | 49 | ||||
-rw-r--r-- | src/libmach/macho.c | 2 | ||||
-rw-r--r-- | src/libmach/macho.h | 2 | ||||
-rw-r--r-- | src/libmach/machocorepower.c | 2 | ||||
-rw-r--r-- | src/libmach/machpower.c | 14 | ||||
-rw-r--r-- | src/libmach/t.c | 6 | ||||
-rw-r--r-- | src/libmach/ureg386.c | 4 |
16 files changed, 111 insertions, 112 deletions
diff --git a/src/libmach/Linux.c b/src/libmach/Linux.c index afe94be1..eb01a6e6 100644 --- a/src/libmach/Linux.c +++ b/src/libmach/Linux.c @@ -433,7 +433,7 @@ ctlproc(int pid, char *msg) } return -1; } -//fprint(2, "got pid %d status %x\n", pid, status); +/*fprint(2, "got pid %d status %x\n", pid, status); */ if(WIFEXITED(status) || WIFSTOPPED(status)) return 0; } diff --git a/src/libmach/dwarf.h b/src/libmach/dwarf.h index 9404a370..bd0fe56d 100644 --- a/src/libmach/dwarf.h +++ b/src/libmach/dwarf.h @@ -102,7 +102,7 @@ enum LangAda95 = 0x000D, LangFortran95 = 0x000E, LangPLI = 0x000F, - // 0x8000-0xFFFF reserved + /* 0x8000-0xFFFF reserved */ IdCaseSensitive = 0x00, IdCaseUpper = 0x01, @@ -112,7 +112,7 @@ enum CallingNormal = 0x01, CallingProgram = 0x02, CallingNocall = 0x03, - // 0x40-0xFF reserved + /* 0x40-0xFF reserved */ InNone = 0x00, InInlined = 0x01, @@ -132,22 +132,22 @@ enum TFlag = 1<<4, TAddress = 1<<5, - OpAddr = 0x03, // 1 op, const addr + 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 + 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 + OpPick = 0x15, /* 1 op, 1 byte stack index */ OpSwap = 0x16, OpRot = 0x17, OpXderef = 0x18, @@ -161,13 +161,13 @@ enum OpNot = 0x20, OpOr = 0x21, OpPlus = 0x22, - OpPlusUconst = 0x23, // 1 op, ULEB128 addend + 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 + OpSkip = 0x2F, /* 1 op, signed 2-byte constant */ + OpBra = 0x28, /* 1 op, signed 2-byte constant */ OpEq = 0x29, OpGe = 0x2A, OpGt = 0x2B, @@ -175,24 +175,24 @@ enum OpLt = 0x2D, OpNe = 0x2E, OpLit0 = 0x30, - // OpLitN = OpLit0 + N for N = 0..31 + /* OpLitN = OpLit0 + N for N = 0..31 */ OpReg0 = 0x50, - // OpRegN = OpReg0 + N for N = 0..31 - 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 + /* OpRegN = OpReg0 + N for N = 0..31 */ + 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, - // next four new in Dwarf v3 + /* 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 - // 0xE0-0xFF reserved for user-specific + 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 */ }; struct DwarfBlock @@ -356,7 +356,7 @@ enum RuleCfaOffset, RuleRegister, RuleRegOff, - RuleLocation, + RuleLocation }; struct DwarfExpr { diff --git a/src/libmach/dwarfeval.c b/src/libmach/dwarfeval.c index 0da7273a..30c227b3 100644 --- a/src/libmach/dwarfeval.c +++ b/src/libmach/dwarfeval.c @@ -1,19 +1,19 @@ - OpAddr = 0x03, // 1 op, const addr + 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 + 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 + OpPick = 0x15, /* 1 op, 1 byte stack index */ OpSwap = 0x16, OpRot = 0x17, OpXderef = 0x18, @@ -27,13 +27,13 @@ OpNot = 0x20, OpOr = 0x21, OpPlus = 0x22, - OpPlusUconst = 0x23, // 1 op, ULEB128 addend + 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 + OpSkip = 0x2F, /* 1 op, signed 2-byte constant */ + OpBra = 0x28, /* 1 op, signed 2-byte constant */ OpEq = 0x29, OpGe = 0x2A, OpGt = 0x2B, @@ -41,22 +41,22 @@ OpLt = 0x2D, OpNe = 0x2E, OpLit0 = 0x30, - // OpLitN = OpLit0 + N for N = 0..31 + /* OpLitN = OpLit0 + N for N = 0..31 */ OpReg0 = 0x50, - // OpRegN = OpReg0 + N for N = 0..31 - 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 + /* OpRegN = OpReg0 + N for N = 0..31 */ + 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, - // next four new in Dwarf v3 + /* 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 - // 0xE0-0xFF reserved for user-specific + 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 */ diff --git a/src/libmach/dwarfinfo.c b/src/libmach/dwarfinfo.c index 61c58dd4..4c0eacd8 100644 --- a/src/libmach/dwarfinfo.c +++ b/src/libmach/dwarfinfo.c @@ -104,7 +104,7 @@ enum FormRef4 = 0x13, FormRef8 = 0x14, FormRefUdata = 0x15, - FormIndirect = 0x16, + FormIndirect = 0x16 }; static int parseattrs(DwarfBuf*, ulong, DwarfAbbrev*, DwarfAttrs*); diff --git a/src/libmach/dwarfpc.c b/src/libmach/dwarfpc.c index 4c8a8a9a..9c36cf08 100644 --- a/src/libmach/dwarfpc.c +++ b/src/libmach/dwarfpc.c @@ -25,7 +25,7 @@ enum BasicDwarfBlock = 1<<1, EndSequence = 1<<2, PrologueEnd = 1<<3, - EpilogueBegin = 1<<4, + EpilogueBegin = 1<<4 }; typedef struct State State; diff --git a/src/libmach/elf.h b/src/libmach/elf.h index f5245099..8ba234e0 100644 --- a/src/libmach/elf.h +++ b/src/libmach/elf.h @@ -125,7 +125,7 @@ enum ElfNotePrPsinfo = 3, ElfNotePrTaskstruct = 4, ElfNotePrAuxv = 6, - ElfNotePrXfpreg = 0x46e62b7f, /* for gdb/386 */ + ElfNotePrXfpreg = 0x46e62b7f /* for gdb/386 */ }; struct ElfHdr diff --git a/src/libmach/elfcorefreebsd386.c b/src/libmach/elfcorefreebsd386.c index 847a93fa..0d01d969 100644 --- a/src/libmach/elfcorefreebsd386.c +++ b/src/libmach/elfcorefreebsd386.c @@ -108,7 +108,7 @@ corecmdfreebsd386(Elf *elf, ElfNote *note, char **pp) return -1; } p = (Psinfo*)note->desc; - // print("elf name %s\nelf args %s\n", p->name, p->psargs); + /* print("elf name %s\nelf args %s\n", p->name, p->psargs); */ t = malloc(80+1); if(t == nil) return -1; diff --git a/src/libmach/elfcorelinux386.c b/src/libmach/elfcorelinux386.c index 4c4aabc4..6cd0a5f9 100644 --- a/src/libmach/elfcorelinux386.c +++ b/src/libmach/elfcorelinux386.c @@ -36,7 +36,7 @@ struct Status }; enum { - StatusSize = sizeof(Status), + StatusSize = sizeof(Status) }; struct Psinfo @@ -57,7 +57,7 @@ struct Psinfo }; enum { - PsinfoSize = sizeof(Psinfo), + PsinfoSize = sizeof(Psinfo) }; int @@ -92,7 +92,7 @@ corecmdlinux386(Elf *elf, ElfNote *note, char **pp) return -1; } p = (Psinfo*)note->desc; - // print("elf name %s\nelf args %s\n", p->fname, p->psargs); + /* print("elf name %s\nelf args %s\n", p->fname, p->psargs); */ t = malloc(80+1); if(t == nil) return -1; diff --git a/src/libmach/elfdl386.c b/src/libmach/elfdl386.c index 5386f1b6..fc4e37fb 100644 --- a/src/libmach/elfdl386.c +++ b/src/libmach/elfdl386.c @@ -44,7 +44,7 @@ enum DT_PLTREL, DT_DEBUG, DT_TEXTREL, - DT_JMPREL, + DT_JMPREL }; static int diff --git a/src/libmach/mach386.c b/src/libmach/mach386.c index 1fffaae5..1f756abf 100644 --- a/src/libmach/mach386.c +++ b/src/libmach/mach386.c @@ -28,9 +28,21 @@ static int i386foll(Map*, Regs*, ulong, ulong*); static int i386hexinst(Map*, ulong, char*, int); static int i386das(Map*, ulong, char, char*, int); static int i386instlen(Map*, ulong); -static char *i386windregs[]; static int i386unwind(Map*, Regs*, ulong*, Symbol*); +static char *i386windregs[] = { + "PC", + "SP", + "BP", + "AX", + "CX", + "DX", + "BX", + "SI", + "DI", + 0, +}; + static Regdesc i386reglist[] = { {"DI", REGOFF(di), RINT, 'X'}, {"SI", REGOFF(si), RINT, 'X'}, @@ -115,19 +127,6 @@ Mach mach386 = i386instlen, /* instruction size calculation */ }; -static char *i386windregs[] = { - "PC", - "SP", - "BP", - "AX", - "CX", - "DX", - "BX", - "SI", - "DI", - 0, -}; - /* * The wrapper code around Linux system calls * saves AX on the stack before calling some calls @@ -158,7 +157,7 @@ i386unwind(Map *map, Regs *regs, ulong *next, Symbol *sym) u32int v; char buf[60], *p; -//print("i386unwind %s\n", sym ? sym->name : nil); +/*print("i386unwind %s\n", sym ? sym->name : nil); */ isp = windindex("SP"); ipc = windindex("PC"); ibp = windindex("BP"); @@ -176,14 +175,14 @@ i386unwind(Map *map, Regs *regs, ulong *next, Symbol *sym) */ if(sym){ pc = sym->loc.addr; -//print("startpc %lux\n", pc); +/*print("startpc %lux\n", pc); */ memset(off, 0xff, sizeof off); spoff = 0; havebp = 0; for(;;){ if((n = i386das(map, pc, 0, buf, sizeof buf)) < 0) break; -//print("%s\n", buf); +/*print("%s\n", buf); */ pc += n; if(strncmp(buf, "PUSHL\t", 6) == 0){ spoff += 4; @@ -193,7 +192,7 @@ i386unwind(Map *map, Regs *regs, ulong *next, Symbol *sym) havebp = 1; }else if(strncmp(buf, "SUBL\t$", 6) == 0){ if((p = strrchr(buf, ',')) && strcmp(p, ",SP") == 0){ -//print("spoff %s\n", buf+6); +/*print("spoff %s\n", buf+6); */ spoff += strtol(buf+6, 0, 16); } break; @@ -209,14 +208,14 @@ i386unwind(Map *map, Regs *regs, ulong *next, Symbol *sym) syscallhack(map, regs, &spoff); if(havebp){ -//print("havebp\n"); +/*print("havebp\n"); */ rget(regs, "BP", &next[isp]); get4(map, next[isp], &v); next[ibp] = v; next[isp] += 4; }else{ rget(regs, "SP", &next[isp]); -//print("old sp %lux + %d\n", next[isp], spoff); +/*print("old sp %lux + %d\n", next[isp], spoff); */ next[isp] += spoff; } for(i=0; i<nelem(off); i++) @@ -227,7 +226,7 @@ i386unwind(Map *map, Regs *regs, ulong *next, Symbol *sym) if(get4(map, next[isp], &v) < 0) return -1; -//print("new pc %lux => %lux\n", next[isp], v); +/*print("new pc %lux => %lux\n", next[isp], v); */ next[ipc] = v; next[isp] += 4; return 0; @@ -248,8 +247,8 @@ i386unwind(Map *map, Regs *regs, ulong *next, Symbol *sym) return 0; } -//static char STARTSYM[] = "_main"; -//static char PROFSYM[] = "_mainp"; +/*static char STARTSYM[] = "_main"; */ +/*static char PROFSYM[] = "_mainp"; */ static char FRAMENAME[] = ".frame"; static char *excname[] = { @@ -348,7 +347,7 @@ enum{ SP, BP, SI, - DI, + DI }; /* Operand Format codes */ /* @@ -404,7 +403,7 @@ enum { PRE, /* Instr Prefix */ SEG, /* Segment Prefix */ OPOVER, /* Operand size override */ - ADDOVER, /* Address size override */ + ADDOVER /* Address size override */ }; static Optable optab0F00[8]= diff --git a/src/libmach/macho.c b/src/libmach/macho.c index 641db598..9d9a1232 100644 --- a/src/libmach/macho.c +++ b/src/libmach/macho.c @@ -4,7 +4,7 @@ #include "macho.h" /* -http://www.channelu.com/NeXT/NeXTStep/3.3/nd/DevTools/14_MachO/MachO.htmld/ +http://www.channelu.com/NeXT/NeXTStep/3.3/nd/DevTools/14_MachO/MachO.htmld/ */ Macho* diff --git a/src/libmach/macho.h b/src/libmach/macho.h index 377e0d2b..d2a1a2e8 100644 --- a/src/libmach/macho.h +++ b/src/libmach/macho.h @@ -25,7 +25,7 @@ enum MachoFileExecutable = 2, MachoFileFvmlib = 3, MachoFileCore = 4, - MachoFilePreload = 5, + MachoFilePreload = 5 }; struct MachoCmd diff --git a/src/libmach/machocorepower.c b/src/libmach/machocorepower.c index 0eb3761d..9cd06afb 100644 --- a/src/libmach/machocorepower.c +++ b/src/libmach/machocorepower.c @@ -12,7 +12,7 @@ enum VectorState, ThreadState64, ExceptionState64, - ThreadStateNone, + ThreadStateNone }; typedef struct Lreg Lreg; diff --git a/src/libmach/machpower.c b/src/libmach/machpower.c index 141645a6..d33651c0 100644 --- a/src/libmach/machpower.c +++ b/src/libmach/machpower.c @@ -78,7 +78,7 @@ powerexcep(Map *map, Regs *regs) #define REGSP 1 /* should come from q.out.h, but there's a clash */ #define REGSB 2 -//static char FRAMENAME[] = ".frame"; +/*static char FRAMENAME[] = ".frame"; */ static Map *mymap; @@ -1348,12 +1348,12 @@ powerunwind(Map *map, Regs *regs, ulong *next, Symbol *sym) * to disassemble the function prologues in order to figure * this out. */ - // evaluate lr - // if in this function, no good - go to saved one. - // set next[sp] to *cur[sp] - // set next[pc] to lr - // set next[lr] to lr - // + /* evaluate lr */ + /* if in this function, no good - go to saved one. */ + /* set next[sp] to *cur[sp] */ + /* set next[pc] to lr */ + /* set next[lr] to lr */ + /* */ werrstr("powerunwind not implemented"); return -1; } diff --git a/src/libmach/t.c b/src/libmach/t.c index 68d2bdfc..37d4b505 100644 --- a/src/libmach/t.c +++ b/src/libmach/t.c @@ -163,9 +163,9 @@ main(int argc, char **argv) attachargs(argc, argv, OREAD); attachdynamic(); -// if(!corpid && !corhdr) -// sysfatal("could not attach to process"); -// +/* if(!corpid && !corhdr) */ +/* sysfatal("could not attach to process"); */ +/* */ p.pid = corpid; if((e = td_ta_new(&p, &ta)) != TD_OK) sysfatal("td_ta_new: %s", terr(e)); diff --git a/src/libmach/ureg386.c b/src/libmach/ureg386.c index 76945030..b2df1fe7 100644 --- a/src/libmach/ureg386.c +++ b/src/libmach/ureg386.c @@ -18,8 +18,8 @@ linux2ureg386(UregLinux386 *l, Ureg *u) u->fs = l->xfs; u->es = l->xes; u->ds = l->xds; - u->trap = ~0; // l->trapno; - u->ecode = ~0; // l->err; + u->trap = ~0; /* l->trapno; */ + u->ecode = ~0; /* l->err; */ u->pc = l->eip; u->cs = l->xcs; u->flags = l->eflags; |