diff options
author | rsc <devnull@localhost> | 2005-01-23 22:33:04 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-23 22:33:04 +0000 |
commit | dd944ec72a26d0b380ba2af5f6c00310f2f1651e (patch) | |
tree | 2f40332ca2fcf189d347cf4f577cf613af21108f /src/libmach/crack.c | |
parent | a0e8d02d093e01fdadf8a16bc86fe18b0c4e82c3 (diff) | |
download | plan9port-dd944ec72a26d0b380ba2af5f6c00310f2f1651e.tar.gz plan9port-dd944ec72a26d0b380ba2af5f6c00310f2f1651e.tar.bz2 plan9port-dd944ec72a26d0b380ba2af5f6c00310f2f1651e.zip |
Start working through proper handling of pthreads when
debugging Linux core dumps. Pthreads for active processes
is still not supported, nor are other systems.
Diffstat (limited to 'src/libmach/crack.c')
-rw-r--r-- | src/libmach/crack.c | 38 |
1 files changed, 35 insertions, 3 deletions
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 <libc.h> #include <bio.h> #include <mach.h> +#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; i<hdr->nthread; 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; i<fp->nthread; 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; +} + |