Trivial changes: whitespace and modes.
Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross <cross@gajendra.net>
This commit is contained in:
parent
77a0a5b519
commit
fa325e9b42
1021 changed files with 5688 additions and 6193 deletions
|
|
@ -43,7 +43,7 @@ unmapproc(Map *map)
|
|||
for(i=0; i<map->nseg; i++)
|
||||
while(i<map->nseg && map->seg[i].pid){
|
||||
map->nseg--;
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
(map->nseg-i)*sizeof(map->seg[0]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ unmapproc(Map *map)
|
|||
for(i=0; i<map->nseg; i++)
|
||||
while(i<map->nseg && map->seg[i].pid){
|
||||
map->nseg--;
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
(map->nseg-i)*sizeof(map->seg[0]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* process interface for Linux.
|
||||
*
|
||||
*
|
||||
* Uses ptrace for registers and data,
|
||||
* /proc for some process status.
|
||||
* There's not much point to worrying about
|
||||
|
|
@ -59,7 +59,7 @@ ptraceattach(int pid)
|
|||
werrstr("ptrace attach %d: %r", pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if(ctlproc(pid, "waitstop") < 0){
|
||||
fprint(2, "waitstop: %r");
|
||||
ptrace(PTRACE_DETACH, pid, 0, 0);
|
||||
|
|
@ -79,7 +79,7 @@ unmapproc(Map *map)
|
|||
for(i=0; i<map->nseg; i++)
|
||||
while(i<map->nseg && map->seg[i].pid){
|
||||
map->nseg--;
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
(map->nseg-i)*sizeof(map->seg[0]));
|
||||
}
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ isstopped(int pid)
|
|||
return *p == 'T';
|
||||
}
|
||||
|
||||
/* /proc/pid/stat contains
|
||||
/* /proc/pid/stat contains
|
||||
pid
|
||||
command in parens
|
||||
0. state
|
||||
|
|
@ -456,4 +456,3 @@ proctextfile(int pid)
|
|||
return pbuf;
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ attachargs(int argc, char **argv, int omode, int verbose)
|
|||
mapfile(symhdr, 0, cormap, nil);
|
||||
}
|
||||
|
||||
if(corpid)
|
||||
if(corpid)
|
||||
attachproc(corpid);
|
||||
if(corhdr)
|
||||
attachcore(corhdr);
|
||||
|
|
@ -200,4 +200,3 @@ attachdynamic(int verbose)
|
|||
elfdl386mapdl(verbose);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Mach *mach;
|
|||
extern Mach mach386;
|
||||
extern Mach machpower;
|
||||
|
||||
static Mach *machs[] =
|
||||
static Mach *machs[] =
|
||||
{
|
||||
&mach386,
|
||||
&machpower,
|
||||
|
|
@ -125,7 +125,7 @@ unmapfile(Fhdr *fp, Map *map)
|
|||
for(i=0; i<map->nseg; i++){
|
||||
while(i<map->nseg && map->seg[i].fd == fp->fd){
|
||||
map->nseg--;
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
memmove(&map->seg[i], &map->seg[i+1],
|
||||
(map->nseg-i)*sizeof(map->seg[0]));
|
||||
}
|
||||
}
|
||||
|
|
@ -149,4 +149,3 @@ coreregs(Fhdr *fp, uint id)
|
|||
werrstr("thread not found");
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ static struct
|
|||
uint mtype;
|
||||
Mach *mach;
|
||||
char *name;
|
||||
} mtab[] =
|
||||
} mtab[] =
|
||||
{ /* Font Tab 4 */
|
||||
ElfMachSparc, MSPARC, nil, "sparc",
|
||||
ElfMach386, M386, &mach386, "386",
|
||||
|
|
@ -29,7 +29,7 @@ static struct
|
|||
uint etype;
|
||||
uint atype;
|
||||
char *aname;
|
||||
} atab[] =
|
||||
} atab[] =
|
||||
{ /* Font Tab 4 */
|
||||
ElfAbiSystemV, ALINUX, "linux", /* [sic] */
|
||||
ElfAbiLinux, ALINUX, "linux",
|
||||
|
|
@ -41,7 +41,7 @@ static struct
|
|||
uint mtype;
|
||||
uint atype;
|
||||
void (*elfcore)(Fhdr*, Elf*, ElfNote*);
|
||||
} ctab[] =
|
||||
} ctab[] =
|
||||
{ /* Font Tab 4 */
|
||||
M386, ALINUX, elfcorelinux386,
|
||||
M386, ANONE, elfcorelinux386, /* [sic] */
|
||||
|
|
@ -273,13 +273,13 @@ mapelf(Fhdr *fp, u64int base, Map *map, Regs **regs)
|
|||
if(addseg(map, s) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fp->nthread && regs)
|
||||
*regs = coreregs(fp, fp->thread[0].id);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -301,4 +301,3 @@ unpacknote(Elf *elf, uchar *a, uchar *ea, ElfNote *note, uchar **pa)
|
|||
*pa = a;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ static struct
|
|||
Mach *mach;
|
||||
char *name;
|
||||
int (*coreregs)(Macho*, uchar**);
|
||||
} mtab[] =
|
||||
} mtab[] =
|
||||
{
|
||||
MachoCpuPower, MPOWER, &machpower, "powerpc", coreregsmachopower,
|
||||
};
|
||||
|
|
@ -190,7 +190,7 @@ mapmacho(Fhdr *fp, u64int base, Map *map, Regs **rp)
|
|||
if((r = mallocz(sizeof *r, 1)) == nil)
|
||||
return -1;
|
||||
r->r.rw = _uregrw;
|
||||
r->ureg = u;
|
||||
r->ureg = u;
|
||||
*rp = &r->r;
|
||||
}
|
||||
noregs:
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ main(void)
|
|||
Biobuf b, bout;
|
||||
char *p, *s;
|
||||
char buf[100000];
|
||||
|
||||
|
||||
Binit(&b, 0, OREAD);
|
||||
Binit(&bout, 1, OWRITE);
|
||||
|
||||
|
||||
while((p = Brdline(&b, '\n')) != nil){
|
||||
p[Blinelen(&b)-1] = 0;
|
||||
werrstr("no error");
|
||||
|
|
|
|||
|
|
@ -458,4 +458,3 @@ int dwarfgetinfounit(Dwarf*, ulong, DwarfBlock*);
|
|||
extern int dwarf386nregs;
|
||||
extern char *dwarf386regs[];
|
||||
extern char *dwarf386fp;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "dwarf.h"
|
||||
|
||||
char*
|
||||
dwarf386regs[] =
|
||||
dwarf386regs[] =
|
||||
{
|
||||
"AX",
|
||||
"CX",
|
||||
|
|
@ -18,5 +18,3 @@ dwarf386regs[] =
|
|||
};
|
||||
|
||||
int dwarf386nregs = nelem(dwarf386regs);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Dwarf abbreviation parsing code.
|
||||
*
|
||||
* The convention here is that calling dwarfgetabbrevs relinquishes
|
||||
* access to any abbrevs returned previously. Will have to add
|
||||
* access to any abbrevs returned previously. Will have to add
|
||||
* explicit reference counting if this turns out not to be acceptable.
|
||||
*/
|
||||
|
||||
|
|
@ -129,4 +129,3 @@ dwarfgetabbrev(Dwarf *d, ulong off, ulong num)
|
|||
}
|
||||
return findabbrev(a, na, num);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,4 +60,3 @@ dwarfaddrtounit(Dwarf *d, ulong addr, ulong *unit)
|
|||
werrstr("address 0x%lux is not listed in dwarf debugging symbols", addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
* Dwarf call frame unwinding.
|
||||
*
|
||||
* The call frame unwinding values are encoded using a state machine
|
||||
* like the pc<->line mapping, but it's a different machine.
|
||||
* The expressions to generate the old values are similar in function to the
|
||||
* The call frame unwinding values are encoded using a state machine
|
||||
* like the pc<->line mapping, but it's a different machine.
|
||||
* The expressions to generate the old values are similar in function to the
|
||||
* ``dwarf expressions'' used for locations in the code, but of course not
|
||||
* the same encoding.
|
||||
* the same encoding.
|
||||
*/
|
||||
#include <u.h>
|
||||
#include <libc.h>
|
||||
|
|
@ -97,7 +97,7 @@ out:
|
|||
/*
|
||||
* XXX This turns out to be much more expensive than the actual
|
||||
* running of the machine in dexec. It probably makes sense to
|
||||
* cache the last 10 or so fde's we've found, since stack traces
|
||||
* cache the last 10 or so fde's we've found, since stack traces
|
||||
* will keep asking for the same info over and over.
|
||||
*/
|
||||
static int
|
||||
|
|
@ -167,7 +167,7 @@ findfde(Dwarf *d, ulong pc, State *s, DwarfBuf *fde)
|
|||
}
|
||||
werrstr("cannot find call frame information for pc 0x%lux", pc);
|
||||
return -1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -209,7 +209,7 @@ dexec(DwarfBuf *b, State *s, int locstop)
|
|||
if(locstop)
|
||||
return 0;
|
||||
continue;
|
||||
|
||||
|
||||
case 2: /* offset rule */
|
||||
arg1 = c&0x3F;
|
||||
arg2 = dwarfget128(b);
|
||||
|
|
@ -331,12 +331,12 @@ dexec(DwarfBuf *b, State *s, int locstop)
|
|||
s->cfa->offset = arg2;
|
||||
continue;
|
||||
|
||||
case 0x0D: /* def cfa register */
|
||||
case 0x0D: /* def cfa register */
|
||||
arg1 = dwarfget128(b);
|
||||
if(trace) fprint(2, "cfa reg r%ld\n", arg1);
|
||||
if(s->cfa->type != RuleRegOff){
|
||||
werrstr("change CFA register but CFA not in register+offset form");
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
if(checkreg(s, arg1) < 0)
|
||||
return -1;
|
||||
|
|
@ -390,6 +390,5 @@ dexec(DwarfBuf *b, State *s, int locstop)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
/* not reached */
|
||||
/* not reached */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,4 +59,3 @@
|
|||
OpCall4 = 0x99, /* 4-byte offset of DIE */
|
||||
OpCallRef = 0x9A, /* 4- or 8- byte offset of DIE */
|
||||
/* 0xE0-0xFF reserved for user-specific */
|
||||
|
||||
|
|
|
|||
|
|
@ -215,4 +215,3 @@ dwarfget128s(DwarfBuf *b)
|
|||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ dwarflookupnameinunit(Dwarf *d, ulong unit, char *name, DwarfSym *s)
|
|||
werrstr("symbol '%s' not found", name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
dwarflookupsubname(Dwarf *d, DwarfSym *parent, char *name, DwarfSym *s)
|
||||
|
|
@ -183,7 +183,7 @@ dwarflookupfn(Dwarf *d, ulong unit, ulong pc, DwarfSym *s)
|
|||
continue;
|
||||
if(s->attrs.lowpc <= pc && pc < s->attrs.highpc)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
werrstr("fn containing pc 0x%lux not found", pc);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -291,11 +291,11 @@ dwarfnextsymat(Dwarf *d, DwarfSym *s, int depth)
|
|||
}
|
||||
|
||||
/*
|
||||
* The funny game with t and s make sure that
|
||||
* The funny game with t and s make sure that
|
||||
* if we get to the end of a run of a particular
|
||||
* depth, we leave s so that a call to nextsymat with depth-1
|
||||
* will actually produce the desired guy. We could change
|
||||
* the interface to dwarfnextsym instead, but I'm scared
|
||||
* the interface to dwarfnextsym instead, but I'm scared
|
||||
* to touch it.
|
||||
*/
|
||||
t = *s;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ findsection(Elf *elf, char *name, ulong *off, ulong *len)
|
|||
*len = s->size;
|
||||
return s - elf->sect;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
loadsection(Elf *elf, char *name, DwarfBlock *b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Dwarf pc to source line conversion.
|
||||
*
|
||||
*
|
||||
* Maybe should do the reverse here, but what should the interface look like?
|
||||
* One possibility is to use the Plan 9 line2addr interface:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ unpackhdr(ElfHdr *h, void *v)
|
|||
h->e2 = e2;
|
||||
h->e4 = e4;
|
||||
h->e8 = e8;
|
||||
|
||||
|
||||
if(h->class == ElfClass64)
|
||||
goto b64;
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ unpackprog(ElfHdr *h, ElfProg *p, void *v)
|
|||
|
||||
if(h->class == ElfClass32) {
|
||||
ElfProgBytes *b;
|
||||
|
||||
|
||||
b = v;
|
||||
e4 = h->e4;
|
||||
p->type = e4(b->type);
|
||||
|
|
@ -401,7 +401,7 @@ unpackprog(ElfHdr *h, ElfProg *p, void *v)
|
|||
p->align = e4(b->align);
|
||||
} else {
|
||||
ElfProgBytes64 *b;
|
||||
|
||||
|
||||
b = v;
|
||||
e4 = h->e4;
|
||||
e8 = h->e8;
|
||||
|
|
@ -424,7 +424,7 @@ unpacksect(ElfHdr *h, ElfSect *s, void *v)
|
|||
|
||||
if(h->class == ElfClass32) {
|
||||
ElfSectBytes *b;
|
||||
|
||||
|
||||
b = v;
|
||||
e4 = h->e4;
|
||||
s->name = (char*)(uintptr)e4(b->name);
|
||||
|
|
@ -439,7 +439,7 @@ unpacksect(ElfHdr *h, ElfSect *s, void *v)
|
|||
s->entsize = e4(b->entsize);
|
||||
} else {
|
||||
ElfSectBytes64 *b;
|
||||
|
||||
|
||||
b = v;
|
||||
e4 = h->e4;
|
||||
e8 = h->e8;
|
||||
|
|
@ -554,4 +554,3 @@ elfsym(Elf *elf, int i, ElfSym *sym)
|
|||
werrstr("symbol index out of range");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,4 +117,3 @@ corecmdfreebsd386(Elf *elf, ElfNote *note, char **pp)
|
|||
*pp = t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ elfcorefreebsdamd64(Fhdr *fp, Elf *elf, ElfNote *note)
|
|||
}
|
||||
l = &s->reg;
|
||||
u = malloc(sizeof(Ureg));
|
||||
|
||||
|
||||
/* no byte order problems - just copying and rearranging */
|
||||
u->ax = l->rax;
|
||||
u->bx = l->rbx;
|
||||
|
|
@ -100,12 +100,12 @@ elfcorefreebsdamd64(Fhdr *fp, Elf *elf, ElfNote *note)
|
|||
u->r13 = l->r13;
|
||||
u->r14 = l->r14;
|
||||
u->r15 = l->r15;
|
||||
|
||||
|
||||
u->ds = l->ds;
|
||||
u->es = l->es;
|
||||
u->fs = l->fs;
|
||||
u->gs = l->gs;
|
||||
|
||||
|
||||
u->type = l->trapno;
|
||||
u->error = l->err;
|
||||
u->ip = l->rip;
|
||||
|
|
@ -147,4 +147,3 @@ corecmdfreebsd386(Elf *elf, ElfNote *note, char **pp)
|
|||
*pp = t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ typedef struct Status Status;
|
|||
typedef struct Psinfo Psinfo;
|
||||
|
||||
/*
|
||||
* UregLinux386 is 64-bit aligned within status, so we shouldn't
|
||||
* have any packing problems.
|
||||
* UregLinux386 is 64-bit aligned within status, so we shouldn't
|
||||
* have any packing problems.
|
||||
*/
|
||||
struct Status
|
||||
{
|
||||
|
|
@ -158,7 +158,7 @@ elfcorelinux386(Fhdr *fp, Elf *elf, ElfNote *note)
|
|||
(uint)m->swap4(st->sighold));
|
||||
dprint("pid=%ud ppid=%ud pgrp=%ud sid=%ud\n",
|
||||
(uint)m->swap4(st->pid),
|
||||
(uint)m->swap4(st->ppid),
|
||||
(uint)m->swap4(st->ppid),
|
||||
(uint)m->swap4(st->pgrp),
|
||||
(uint)m->swap4(st->sid));
|
||||
dprint("utime=%ud.%06ud stime=%ud.%06ud cutime=%ud.%06ud cstime=%ud.%06ud\n",
|
||||
|
|
@ -199,4 +199,3 @@ elfcorelinux386(Fhdr *fp, Elf *elf, ElfNote *note)
|
|||
dprint("note %d\n", note->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,4 +131,3 @@ elfdl386mapdl(int verbose)
|
|||
fprint(2, "syminit %s: %r\n", buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
#include "elf.h"
|
||||
|
||||
int
|
||||
elfsym(Elf *elf, ElfSect *symtab, ElfSect *strtab, int ndx, ElfSym *
|
||||
elfsym(Elf *elf, ElfSect *symtab, ElfSect *strtab, int ndx, ElfSym *
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ fpformat(Map *map, Regdesc *rp, char *buf, uint n, uint modif)
|
|||
if (rp->format == 'F')
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
/* treat it like 'f' */
|
||||
if (get1(map, rp->offset, (uchar *)reg, 4) < 0)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ stacktrace(Map *map, Regs *regs, Tracer trace)
|
|||
next = malloc(mach->nwindreg*sizeof(cur[0]));
|
||||
if(cur==nil || next==nil)
|
||||
goto out;
|
||||
|
||||
|
||||
/*
|
||||
* Initialize current registers using regs.
|
||||
*/
|
||||
if(rget(regs, mach->pc, &pc) < 0){
|
||||
werrstr("cannot fetch initial pc: %r");
|
||||
goto out;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for(i=0; i<mach->nwindreg; i++){
|
||||
|
|
|
|||
|
|
@ -17,4 +17,3 @@ _hexify(char *buf, u64int p, int zeros)
|
|||
*buf++ = "0123456789abcdef"[p&0x0f];
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -271,4 +271,3 @@ locsimplify(Map *map, Regs *regs, Loc loc, Loc *newloc)
|
|||
*newloc = loc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,10 +128,10 @@ Mach mach386 =
|
|||
};
|
||||
|
||||
/*
|
||||
* The wrapper code around Linux system calls
|
||||
* The wrapper code around Linux system calls
|
||||
* saves AX on the stack before calling some calls
|
||||
* (at least, __libc_nanosleep), when running in
|
||||
* threaded programs.
|
||||
* (at least, __libc_nanosleep), when running in
|
||||
* threaded programs.
|
||||
*/
|
||||
static void
|
||||
syscallhack(Map *map, Regs *regs, int *spoff)
|
||||
|
|
@ -146,7 +146,7 @@ syscallhack(Map *map, Regs *regs, int *spoff)
|
|||
return;
|
||||
if(i386das(map, pc+2, 0, buf, sizeof buf) != 3 || strcmp(buf, "XCHGL\tAX,0(SP)") != 0)
|
||||
return;
|
||||
*spoff += 4;
|
||||
*spoff += 4;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -1968,14 +1968,14 @@ plocal(Instr *ip)
|
|||
Symbol s;
|
||||
char *name;
|
||||
Loc l, li;
|
||||
|
||||
|
||||
l.type = LOFFSET;
|
||||
l.offset = ip->disp;
|
||||
if(ip->base == SP)
|
||||
l.reg = "SP";
|
||||
else
|
||||
l.reg = "BP";
|
||||
|
||||
|
||||
li.type = LADDR;
|
||||
li.addr = ip->addr;
|
||||
if(findsym(li, CTEXT, &s) < 0)
|
||||
|
|
@ -1989,7 +1989,7 @@ plocal(Instr *ip)
|
|||
|
||||
if(name==nil && findlsym(&s, l, &s) >= 0)
|
||||
name = s.name;
|
||||
|
||||
|
||||
if(name)
|
||||
bprint(ip, "%s+", name);
|
||||
|
||||
|
|
|
|||
|
|
@ -171,10 +171,10 @@ Mach machamd64=
|
|||
4, /* szreg */
|
||||
4, /* szfloat */
|
||||
8, /* szdouble */
|
||||
|
||||
|
||||
amd64windregs, /* locations unwound in stack trace */
|
||||
17,
|
||||
|
||||
|
||||
{0xCC, 0, 0, 0}, /* break point: INT 3 */
|
||||
1, /* break point size */
|
||||
|
||||
|
|
|
|||
|
|
@ -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*
|
||||
|
|
@ -144,7 +144,7 @@ macholoadrel(Macho *m, MachoSect *sect)
|
|||
uchar *buf, *p;
|
||||
int i, n;
|
||||
uint32 v;
|
||||
|
||||
|
||||
if(sect->rel != nil || sect->nreloc == 0)
|
||||
return 0;
|
||||
rel = mallocz(sect->nreloc * sizeof r[0], 1);
|
||||
|
|
@ -165,7 +165,7 @@ macholoadrel(Macho *m, MachoSect *sect)
|
|||
r = &rel[i];
|
||||
p = buf+i*8;
|
||||
r->addr = m->e4(p);
|
||||
|
||||
|
||||
// TODO(rsc): Wrong interpretation for big-endian bitfields?
|
||||
v = m->e4(p+4);
|
||||
r->symnum = v & 0xFFFFFF;
|
||||
|
|
@ -183,7 +183,7 @@ macholoadrel(Macho *m, MachoSect *sect)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
macholoadsym(Macho *m, MachoSymtab *symtab)
|
||||
{
|
||||
char *strbuf;
|
||||
|
|
@ -202,7 +202,7 @@ macholoadsym(Macho *m, MachoSymtab *symtab)
|
|||
free(strbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
symsize = 12;
|
||||
if(m->is64)
|
||||
symsize = 16;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct MachoSect
|
|||
uint32 reloff;
|
||||
uint32 nreloc;
|
||||
uint32 flags;
|
||||
|
||||
|
||||
MachoRel *rel;
|
||||
};
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ struct MachoSymtab
|
|||
uint32 nsym;
|
||||
uint32 stroff;
|
||||
uint32 strsize;
|
||||
|
||||
|
||||
char *str;
|
||||
MachoSym *sym;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -170,4 +170,3 @@ coreregsmachopower(Macho *m, uchar **up)
|
|||
*up = (uchar*)u;
|
||||
return sizeof(*u);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -960,7 +960,7 @@ static Spr sprname[] = {
|
|||
{26, "SRR0"},
|
||||
{27, "SRR1"},
|
||||
{284, "TBLW"},
|
||||
{285, "TBUW"},
|
||||
{285, "TBUW"},
|
||||
{22, "DEC"},
|
||||
{282, "EAR"},
|
||||
{1008, "HID0"},
|
||||
|
|
@ -1213,7 +1213,7 @@ powerfoll(Map *map, Regs *regs, u64int pc, u64int *foll)
|
|||
if(!i.aa)
|
||||
foll[0] += pc;
|
||||
break;
|
||||
|
||||
|
||||
case 16: /* conditional branch */
|
||||
foll[0] = i.bd;
|
||||
if(!i.aa)
|
||||
|
|
@ -1246,7 +1246,7 @@ powerfoll(Map *map, Regs *regs, u64int pc, u64int *foll)
|
|||
#define FP_REG(x) (R31+4+8*(x))
|
||||
|
||||
#define REGSIZE sizeof(struct Ureg)
|
||||
#define FPREGSIZE (8*33)
|
||||
#define FPREGSIZE (8*33)
|
||||
|
||||
Regdesc powerreglist[] =
|
||||
{
|
||||
|
|
@ -1328,7 +1328,7 @@ Regdesc powerreglist[] =
|
|||
{ 0 }
|
||||
};
|
||||
|
||||
static char *powerwindregs[] =
|
||||
static char *powerwindregs[] =
|
||||
{
|
||||
"PC",
|
||||
"SP",
|
||||
|
|
@ -1404,4 +1404,3 @@ Mach machpower =
|
|||
powerhexinst, /* print instruction */
|
||||
powerinstlen, /* instruction size calculation */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@
|
|||
#include <bio.h>
|
||||
#include <mach.h>
|
||||
|
||||
static char *(*demanglers[])(char*, char*) =
|
||||
static char *(*demanglers[])(char*, char*) =
|
||||
{
|
||||
demanglegcc2,
|
||||
demanglegcc3,
|
||||
};
|
||||
|
||||
|
||||
char*
|
||||
demangle(char *s, char *buf, int strip)
|
||||
{
|
||||
char *t;
|
||||
char *r, *w;
|
||||
int i, nangle, nparen;
|
||||
|
||||
|
||||
t = nil;
|
||||
for(i=0; i<nelem(demanglers); i++){
|
||||
t = demanglers[i](s, buf);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ static Chartab modifiertab[] =
|
|||
'S', "signed", /* means static for member functions */
|
||||
'U', "unsigned",
|
||||
'V', "volatile",
|
||||
|
||||
|
||||
'G', "garbage", /* no idea what this is */
|
||||
0, 0
|
||||
};
|
||||
|
|
@ -86,7 +86,7 @@ demanglegcc2(char *s, char *buf)
|
|||
{
|
||||
char *name, *os, *p, *t;
|
||||
int isfn, namelen;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Pick off some cases that seem not to fit the pattern.
|
||||
|
|
@ -119,22 +119,22 @@ demanglegcc2(char *s, char *buf)
|
|||
isfn = 1;
|
||||
name = gdestructor;
|
||||
namelen = strlen(name);
|
||||
s += 13;
|
||||
s += 13;
|
||||
}else if(memcmp(s, "_GLOBAL_.D._", 12) == 0){
|
||||
isfn = 0;
|
||||
name = gdestructor;
|
||||
namelen = strlen(name);
|
||||
s += 12;
|
||||
s += 12;
|
||||
}else if(memcmp(s, "_GLOBAL_.I.__", 13) == 0){
|
||||
isfn = 1;
|
||||
name = gconstructor;
|
||||
namelen = strlen(name);
|
||||
s += 13;
|
||||
s += 13;
|
||||
}else if(memcmp(s, "_GLOBAL_.I._", 12) == 0){
|
||||
isfn = 0;
|
||||
name = gconstructor;
|
||||
namelen = strlen(name);
|
||||
s += 12;
|
||||
s += 12;
|
||||
}else{
|
||||
t = strstr(os, "__");
|
||||
if(t == nil)
|
||||
|
|
@ -144,7 +144,7 @@ demanglegcc2(char *s, char *buf)
|
|||
if(strchr(manglestarts, *(s+2)))
|
||||
break;
|
||||
}while((t = strstr(s+1, "__")) != nil);
|
||||
|
||||
|
||||
name = os;
|
||||
namelen = s - os;
|
||||
if(namelen == 0){
|
||||
|
|
@ -154,14 +154,14 @@ demanglegcc2(char *s, char *buf)
|
|||
}
|
||||
s += 2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Now s points at the mangled crap (maybe).
|
||||
* and name is the final element of the name.
|
||||
*/
|
||||
if(strchr(manglestarts, *s) == nil)
|
||||
return os;
|
||||
|
||||
|
||||
p = buf;
|
||||
if(*s == 'F'){
|
||||
/* global function, no extra name pieces, just types */
|
||||
|
|
@ -173,7 +173,7 @@ demanglegcc2(char *s, char *buf)
|
|||
fprint(2, "parsename %s: %r\n", s);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
/* if we have a constructor or destructor, try to use the C++ name */
|
||||
t = nil;
|
||||
if(name == constructor || name == destructor){
|
||||
|
|
@ -197,7 +197,7 @@ demanglegcc2(char *s, char *buf)
|
|||
p -= 2;
|
||||
memmove(p, name, namelen);
|
||||
p += namelen;
|
||||
|
||||
|
||||
if(*s == 'F'){
|
||||
/* might be from above, or might follow name pieces */
|
||||
s++;
|
||||
|
|
@ -219,8 +219,8 @@ demanglegcc2(char *s, char *buf)
|
|||
|
||||
if(*s == '_'){
|
||||
/* return type (left over from H) */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*p = 0;
|
||||
return buf;
|
||||
}
|
||||
|
|
@ -234,7 +234,7 @@ static char*
|
|||
demanglegcc2a(char *s, char *buf)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
||||
if(*s != '_' || strchr(manglestarts, *(s+1)) == nil)
|
||||
return nil;
|
||||
p = buf;
|
||||
|
|
@ -259,7 +259,7 @@ demanglegcc2b(char *s, char *buf)
|
|||
{
|
||||
char *p;
|
||||
char *t;
|
||||
|
||||
|
||||
if(memcmp(s, "__ti", 4) == 0){
|
||||
t = "$typeinfo";
|
||||
s += 4;
|
||||
|
|
@ -325,7 +325,7 @@ gccnumber(char **ps, int *pn, int many)
|
|||
{
|
||||
char *s;
|
||||
int n, eatunderscore;
|
||||
|
||||
|
||||
s = *ps;
|
||||
eatunderscore = 0;
|
||||
if(!many && *s == '_'){
|
||||
|
|
@ -362,7 +362,7 @@ gccname(char **ps, char **pp)
|
|||
{
|
||||
int i, n, m, val;
|
||||
char *os, *s, *t, *p, *p0, *p1;
|
||||
|
||||
|
||||
s = *ps;
|
||||
os = s;
|
||||
p = *pp;
|
||||
|
|
@ -376,7 +376,7 @@ gccname(char **ps, char **pp)
|
|||
p += strlen(t);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
/* modifiers */
|
||||
if((t = chartabsearch(modifiertab, *s)) != nil){
|
||||
s++;
|
||||
|
|
@ -394,7 +394,7 @@ gccname(char **ps, char **pp)
|
|||
*/
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
switch(*s){
|
||||
default:
|
||||
bad:
|
||||
|
|
@ -546,7 +546,7 @@ gccname(char **ps, char **pp)
|
|||
if(!gccname(&s, &p))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
|
||||
case 'Q': /* qualified name */
|
||||
s++;
|
||||
if(!gccnumber(&s, &n, 0))
|
||||
|
|
@ -601,7 +601,7 @@ gccname(char **ps, char **pp)
|
|||
}
|
||||
*p++ = '>';
|
||||
break;
|
||||
|
||||
|
||||
case 'T': /* once-repeated type */
|
||||
s++;
|
||||
if(!gccnumber(&s, &n, 0))
|
||||
|
|
@ -609,7 +609,7 @@ gccname(char **ps, char **pp)
|
|||
sprint(p, "T%d", n);
|
||||
p += strlen(p);
|
||||
break;
|
||||
|
||||
|
||||
case 'X': /* type parameter in 'H' */
|
||||
if(!isdigit((uchar)*(s+1)) || !isdigit((uchar)*(s+2)))
|
||||
goto bad;
|
||||
|
|
@ -622,9 +622,8 @@ gccname(char **ps, char **pp)
|
|||
USED(p1);
|
||||
USED(p0);
|
||||
|
||||
out:
|
||||
out:
|
||||
*ps = s;
|
||||
*pp = p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ demanglegcc3(char *s, char *buf)
|
|||
{
|
||||
char *p, *os;
|
||||
Gccstate state;
|
||||
|
||||
|
||||
state.nname = 0;
|
||||
os = s;
|
||||
/* mangled names always start with _Z */
|
||||
if(s[0] != '_' || s[1] != 'Z')
|
||||
return s;
|
||||
s += 2;
|
||||
|
||||
|
||||
p = buf;
|
||||
if(!gccname(&s, &p, &state)){
|
||||
if(strchr(os, '@') == nil)
|
||||
|
|
@ -138,7 +138,7 @@ static struct {
|
|||
"rs", ">>", "rsh",
|
||||
"st", "sizeof", "sizeoftype",
|
||||
"sz", "sizeof", "sizeofexpr",
|
||||
|
||||
|
||||
0,0,0
|
||||
};
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ gccname(char **ps, char **pp, Gccstate *state)
|
|||
int i, n;
|
||||
char *os, *s, *t, *p;
|
||||
Gccstate nstate;
|
||||
|
||||
|
||||
s = *ps;
|
||||
os = s;
|
||||
p = *pp;
|
||||
|
|
@ -170,7 +170,7 @@ gccname(char **ps, char **pp, Gccstate *state)
|
|||
goto suffix;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* basic types */
|
||||
if((t = chartabsearch(typetab, *s)) != nil){
|
||||
s++;
|
||||
|
|
@ -178,7 +178,7 @@ gccname(char **ps, char **pp, Gccstate *state)
|
|||
p += strlen(t);
|
||||
goto suffix;
|
||||
}
|
||||
|
||||
|
||||
switch(*s){
|
||||
default:
|
||||
bad:
|
||||
|
|
@ -245,7 +245,7 @@ gccname(char **ps, char **pp, Gccstate *state)
|
|||
p -= 2;
|
||||
s++;
|
||||
break;
|
||||
|
||||
|
||||
case 'P': /* pointer to */
|
||||
s++;
|
||||
if(!gccname(&s, &p, state))
|
||||
|
|
@ -282,7 +282,7 @@ gccname(char **ps, char **pp, Gccstate *state)
|
|||
s += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* standard name */
|
||||
if(*s == 't'){
|
||||
strcpy(p, "std::");
|
||||
|
|
@ -300,7 +300,7 @@ gccname(char **ps, char **pp, Gccstate *state)
|
|||
*p++ = *s++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'T': /* previously-seen type??? T0_ also T_*/
|
||||
t = s;
|
||||
for(; *s != '_'; s++){
|
||||
|
|
@ -312,9 +312,9 @@ gccname(char **ps, char **pp, Gccstate *state)
|
|||
s++;
|
||||
memmove(p, t, s-t);
|
||||
p += s-t;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
suffix:
|
||||
if(*s == 'I'){
|
||||
/* template suffix */
|
||||
|
|
@ -336,4 +336,3 @@ suffix:
|
|||
*pp = p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ fdrw(Map *map, Seg *seg, u64int addr, void *a, uint n, int r)
|
|||
else
|
||||
nn = pwrite(seg->fd, a, n-tot, off+tot);
|
||||
if(nn < 0)
|
||||
return -1;
|
||||
return -1;
|
||||
if(nn == 0){
|
||||
werrstr("partial %s at address 0x%lux in %s",
|
||||
r ? "read" : "write", off+tot, seg->file);
|
||||
|
|
|
|||
|
|
@ -59,4 +59,3 @@ _uregrw(Regs *regs, char *name, u64int *u, int isr)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,4 +51,3 @@ stabsym(Stab *stabs, int i, StabSym *sym)
|
|||
sym->value = stabs->e4(p+8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,4 +114,3 @@ X function return variable
|
|||
*/
|
||||
|
||||
int stabsym(Stab*, int, StabSym*);
|
||||
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ ffindsym(Fhdr *fhdr, Loc loc, uint class)
|
|||
* We want to find the largest index i such that
|
||||
* a[i] <= loc. This cannot be done with a simple
|
||||
* binary search. Instead we binary search to find
|
||||
* where the location should be.
|
||||
* where the location should be.
|
||||
*/
|
||||
lo = 0;
|
||||
hi = n;
|
||||
|
|
@ -529,7 +529,7 @@ symopen(Fhdr *hdr)
|
|||
hdr->byname[i] = &hdr->sym[i];
|
||||
qsort(hdr->byname, hdr->nsym, sizeof(hdr->byname[0]), bynamecmp);
|
||||
}
|
||||
|
||||
|
||||
hdr->byxname = malloc(hdr->nsym*sizeof(hdr->byxname[0]));
|
||||
if(hdr->byxname == nil){
|
||||
fprint(2, "could not allocate table to sort by xname\n");
|
||||
|
|
@ -581,4 +581,3 @@ _addsym(Fhdr *fp, Symbol *sym)
|
|||
*s = *sym;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ top:
|
|||
name, unit, tref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if(ds.attrs.have.bytesize)
|
||||
return ds.attrs.bytesize;
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ dwarftosym(Fhdr *fp, Dwarf *d, DwarfSym *ds, Symbol *s, int infn)
|
|||
{
|
||||
DwarfBuf buf;
|
||||
DwarfBlock b;
|
||||
|
||||
|
||||
memset(s, 0, sizeof *s);
|
||||
s->u.dwarf.uoff = ds->uoff;
|
||||
s->u.dwarf.unit = ds->unit;
|
||||
|
|
@ -356,7 +356,7 @@ dwarfeval(Dwarf *d, Map *map, Regs *regs, ulong cfa, int rno, DwarfExpr e, u64in
|
|||
if(rget(regs, regname(d, e.reg), &uu) < 0)
|
||||
return -1;
|
||||
if(get4(map, uu+e.offset, &u4) < 0)
|
||||
return -1;
|
||||
return -1;
|
||||
*u = u4;
|
||||
return 0;
|
||||
case RuleLocation:
|
||||
|
|
@ -465,4 +465,3 @@ err:
|
|||
free(e);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,4 +118,3 @@ symelf(Fhdr *fhdr)
|
|||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,4 +47,3 @@ symmacho(Fhdr *fp)
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ stabcvtsym(StabSym *stab, Symbol *sym, char *dir, char *file, int i)
|
|||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -209,15 +209,15 @@ stabssyminit(Fhdr *fp)
|
|||
if(fun->u.stabs.frameptr == -1){
|
||||
/*
|
||||
* Try to distinguish functions with a real frame pointer
|
||||
* from functions with a virtual frame pointer, based on
|
||||
* from functions with a virtual frame pointer, based on
|
||||
* whether the first parameter is in the right location and
|
||||
* whether the autos have negative offsets.
|
||||
*
|
||||
* whether the autos have negative offsets.
|
||||
*
|
||||
* This heuristic works most of the time. On the 386, we
|
||||
* cannot distinguish between a v. function with no autos
|
||||
* but a frame of size 4 and a f.p. function with no autos and
|
||||
* no frame. Anything else we'll get right.
|
||||
*
|
||||
*
|
||||
* Another way to go about this would be to have
|
||||
* mach-specific functions to inspect the function
|
||||
* prologues when we're not sure. What we have
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ printparams(Symbol *fn, Regs *regs)
|
|||
int first = 0;
|
||||
ulong pc, sp, bp;
|
||||
|
||||
if(0) print("pc=%lux sp=%lux bp=%lux ",
|
||||
if(0) print("pc=%lux sp=%lux bp=%lux ",
|
||||
(rget(regs, "PC", &pc), pc),
|
||||
(rget(regs, "SP", &sp), sp),
|
||||
(rget(regs, "BP", &bp), bp));
|
||||
|
|
@ -180,7 +180,7 @@ main(int argc, char **argv)
|
|||
if((e = td_thr_get_info(&ts[i], &info)) != TD_OK)
|
||||
sysfatal("td_thr_get_info: %s", terr(e));
|
||||
print("%d: startfunc=%lux stkbase=%lux pc=%lux sp=%lux lid=%d\n",
|
||||
i, info.ti_startfunc, info.ti_stkbase, info.ti_pc, info.ti_sp, info.ti_lid);
|
||||
i, info.ti_startfunc, info.ti_stkbase, info.ti_pc, info.ti_sp, info.ti_lid);
|
||||
if((e = td_thr_getgregs(&ts[i], regs)) != TD_OK)
|
||||
sysfatal("td_thr_getregs: %s", terr(e));
|
||||
print("%d: pc=%lux sp=%lux gs=%lux\n", i, regs[12], regs[15], regs[10]);
|
||||
|
|
@ -233,7 +233,7 @@ td_get_allthreads(td_thragent_t *ta, td_thrhandle_t **pall)
|
|||
a.a = nil;
|
||||
a.n = 0;
|
||||
a.err = 0;
|
||||
if((e = td_ta_thr_iter(ta, thritercb, &a,
|
||||
if((e = td_ta_thr_iter(ta, thritercb, &a,
|
||||
TD_THR_ANY_STATE,
|
||||
TD_THR_LOWEST_PRIORITY,
|
||||
TD_SIGNO_MASK,
|
||||
|
|
@ -251,7 +251,7 @@ td_get_allthreads(td_thragent_t *ta, td_thrhandle_t **pall)
|
|||
return a.n;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
td_err_e td_ta_map_id2thr(const td_thragent_t *ta_p, thread_t tid,td_thrhandle_t *th_p);
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -48,4 +48,3 @@ ureg2linux386(Ureg *u, UregLinux386 *l)
|
|||
l->esp = u->sp;
|
||||
l->xss = u->ss;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue