Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.

This commit is contained in:
rsc 2006-04-01 19:24:03 +00:00
parent 226d80b821
commit cbeb0b26e4
492 changed files with 3218 additions and 3167 deletions

View file

@ -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;
}

View file

@ -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
{

View file

@ -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 */

View file

@ -104,7 +104,7 @@ enum
FormRef4 = 0x13,
FormRef8 = 0x14,
FormRefUdata = 0x15,
FormIndirect = 0x16,
FormIndirect = 0x16
};
static int parseattrs(DwarfBuf*, ulong, DwarfAbbrev*, DwarfAttrs*);

View file

@ -25,7 +25,7 @@ enum
BasicDwarfBlock = 1<<1,
EndSequence = 1<<2,
PrologueEnd = 1<<3,
EpilogueBegin = 1<<4,
EpilogueBegin = 1<<4
};
typedef struct State State;

View file

@ -125,7 +125,7 @@ enum
ElfNotePrPsinfo = 3,
ElfNotePrTaskstruct = 4,
ElfNotePrAuxv = 6,
ElfNotePrXfpreg = 0x46e62b7f, /* for gdb/386 */
ElfNotePrXfpreg = 0x46e62b7f /* for gdb/386 */
};
struct ElfHdr

View file

@ -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;

View file

@ -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;

View file

@ -44,7 +44,7 @@ enum
DT_PLTREL,
DT_DEBUG,
DT_TEXTREL,
DT_JMPREL,
DT_JMPREL
};
static int

View file

@ -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]=

View file

@ -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*

View file

@ -25,7 +25,7 @@ enum
MachoFileExecutable = 2,
MachoFileFvmlib = 3,
MachoFileCore = 4,
MachoFilePreload = 5,
MachoFilePreload = 5
};
struct MachoCmd

View file

@ -12,7 +12,7 @@ enum
VectorState,
ThreadState64,
ExceptionState64,
ThreadStateNone,
ThreadStateNone
};
typedef struct Lreg Lreg;

View file

@ -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;
}

View file

@ -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));

View file

@ -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;