From dd944ec72a26d0b380ba2af5f6c00310f2f1651e Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 23 Jan 2005 22:33:04 +0000 Subject: Start working through proper handling of pthreads when debugging Linux core dumps. Pthreads for active processes is still not supported, nor are other systems. --- src/libmach/crack.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/libmach/crack.c') diff --git a/src/libmach/crack.c b/src/libmach/crack.c index ffc3b06c..c186456a 100644 --- a/src/libmach/crack.c +++ b/src/libmach/crack.c @@ -2,6 +2,7 @@ #include #include #include +#include "elf.h" static struct { @@ -50,9 +51,18 @@ crackhdr(char *name, int mode) void uncrackhdr(Fhdr *hdr) { - close(hdr->fd); - _delhdr(hdr); - free(hdr->cmd); + int i; + + symclose(hdr); + if(hdr->elf) + elfclose(hdr->elf); + if(hdr->fd >= 0) + close(hdr->fd); + free(hdr->cmdline); + free(hdr->prog); + for(i=0; inthread; i++) + free(hdr->thread[i].ureg); + free(hdr->thread); free(hdr); } @@ -71,6 +81,8 @@ mapfile(Fhdr *fp, ulong base, Map *map, Regs **regs) werrstr("cannot load map for this file type"); return -1; } + if(regs) + *regs = nil; return fp->map(fp, base, map, regs); } @@ -90,3 +102,23 @@ unmapfile(Fhdr *fp, Map *map) } } } + +Regs* +coreregs(Fhdr *fp, uint id) +{ + UregRegs *r; + int i; + + for(i=0; inthread; i++){ + if(fp->thread[i].id == id){ + if((r = mallocz(sizeof *r, 1)) == nil) + return nil; + r->r.rw = _uregrw; + r->ureg = fp->thread[i].ureg; + return &r->r; + } + } + werrstr("thread not found"); + return nil; +} + -- cgit v1.2.3