diff options
author | rsc <devnull@localhost> | 2005-02-11 02:02:56 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-02-11 02:02:56 +0000 |
commit | ed9fe82834e2546bff03bef38644de95ffbeaba0 (patch) | |
tree | 75db3ba1db086523382a4705622116c9496488b9 /src/libmach | |
parent | 281c90a5be6b1ab2280ffa23885fe41e7af80bce (diff) | |
download | plan9port-ed9fe82834e2546bff03bef38644de95ffbeaba0.tar.gz plan9port-ed9fe82834e2546bff03bef38644de95ffbeaba0.tar.bz2 plan9port-ed9fe82834e2546bff03bef38644de95ffbeaba0.zip |
Remove libthread_db nonsense.
Diffstat (limited to 'src/libmach')
-rw-r--r-- | src/libmach/Linux.c | 95 | ||||
-rw-r--r-- | src/libmach/mkfile | 1 | ||||
-rw-r--r-- | src/libmach/pthread.c | 238 |
3 files changed, 0 insertions, 334 deletions
diff --git a/src/libmach/Linux.c b/src/libmach/Linux.c index 893ef6b4..530150d8 100644 --- a/src/libmach/Linux.c +++ b/src/libmach/Linux.c @@ -447,98 +447,3 @@ proctextfile(int pid) return nil; } -int -sys_ps_lgetregs(struct ps_prochandle *ph, uint tid, void *regs) -{ - int i, oldpid; - uint u, *uregs; - - oldpid = corpid; - ptraceattach(tid); - uregs = (uint*)regs; - for(i=0; i<sizeof(UregLinux386)/sizeof(uint); i++){ - errno = 0; - u = ptrace(PTRACE_PEEKUSER, tid, 4*i, 0); - if(errno) - return 1; - uregs[i] = u; - } - ptraceattach(oldpid); - return 0; -} - -int -sys_ps_lsetregs(struct ps_prochandle *ph, uint tid, void *regs) -{ - return 1; -} - -int -sys_ps_lgetfpregs(struct ps_prochandle *ph, uint tid, void *regs) -{ - return 1; -} - - -int -sys_ps_lsetfpregs(struct ps_prochandle *ph, uint tid, void *regs) -{ - return 1; -} - - - - -#if 0 - snprint(buf, sizeof buf, "/proc/%d/maps", pid); - if((b = Bopen(buf, OREAD)) == nil){ - werrstr("open %s: %r", buf); - return -1; - } - -/* - 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm - 08056000-08058000 rw-p 0000d000 03:0c 64593 /usr/sbin/gpm - 08058000-0805b000 rwxp 00000000 00:00 0 - 40000000-40013000 r-xp 00000000 03:0c 4165 /lib/ld-2.2.4.so - 40013000-40015000 rw-p 00012000 03:0c 4165 /lib/ld-2.2.4.so - 4001f000-40135000 r-xp 00000000 03:0c 45494 /lib/libc-2.2.4.so - 40135000-4013e000 rw-p 00115000 03:0c 45494 /lib/libc-2.2.4.so - 4013e000-40142000 rw-p 00000000 00:00 0 - bffff000-c0000000 rwxp 00000000 00:00 0 -*/ - - file = nil; - while((p = Brdline(b, '\n')) != nil){ - p[Blinelen(b)-1] = 0; - memset(f, 0, sizeof f); - if((nf = getfields(p, f, 6, 1, " ")) < 5) - continue; - base = strtoul(f[0], &p, 16); - if(*p != '-') - continue; - end = strtoul(p+1, &p, 16); - if(*p != 0) - continue; - offset = strtoul(f[2], &p, 16); - if(*p != 0) - continue; - if(nf == 6) - file = f[5]; - zero = atoi(f[4]) == 0; - print("%lux-%lux %lux %s %s\n", base, end, offset, zero ? "data" : "text", file ? file : ""); - s.base = base; - s.size = end - base; - s.offset = offset; - s.name = zero ? "data" : "text"; - s.file = strdup(file); - s.rw = ptracerw; - s.pid = pid; - if(addseg(map, s) < 0){ - Bterm(b); - ptrace(PTRACE_DETACH, pid, 0, 0); - return -1; - } - } - Bterm(b); -#endif diff --git a/src/libmach/mkfile b/src/libmach/mkfile index 470f7454..a6d6507e 100644 --- a/src/libmach/mkfile +++ b/src/libmach/mkfile @@ -33,7 +33,6 @@ OFILES=\ machocorepower.$O\ machpower.$O\ map.$O\ - pthread.$O\ regs.$O\ stabs.$O\ swap.$O\ diff --git a/src/libmach/pthread.c b/src/libmach/pthread.c deleted file mode 100644 index 010887d3..00000000 --- a/src/libmach/pthread.c +++ /dev/null @@ -1,238 +0,0 @@ -#include <u.h> -#include <thread_db.h> -#include <sys/ptrace.h> -#include <errno.h> -#include <sys/procfs.h> /* psaddr_t */ -#include <libc.h> -#include <mach.h> -#include "ureg386.h" -#include "elf.h" - -static char *terr(int); - -static char *tderrstr[] = -{ -[TD_OK] "no error", -[TD_ERR] "some error", -[TD_NOTHR] "no matching thread found", -[TD_NOSV] "no matching synchronization handle found", -[TD_NOLWP] "no matching light-weight process found", -[TD_BADPH] "invalid process handle", -[TD_BADTH] "invalid thread handle", -[TD_BADSH] "invalid synchronization handle", -[TD_BADTA] "invalid thread agent", -[TD_BADKEY] "invalid key", -[TD_NOMSG] "no event available", -[TD_NOFPREGS] "no floating-point register content available", -[TD_NOLIBTHREAD] "application not linked with thread library", -[TD_NOEVENT] "requested event is not supported", -[TD_NOEVENT] "requested event is not supported", -[TD_NOCAPAB] "capability not available", -[TD_DBERR] "internal debug library error", -[TD_NOAPLIC] "operation is not applicable", -[TD_NOTSD] "no thread-specific data available", -[TD_MALLOC] "out of memory", -[TD_PARTIALREG] "not entire register set was read or written", -[TD_NOXREGS] "X register set not available for given threads", -[TD_TLSDEFER] "thread has not yet allocated TLS for given module", -[TD_VERSION] "version mismatch twixt libpthread and libthread_db", -[TD_NOTLS] "there is no TLS segment in the given module", -}; - -static td_thragent_t *ta; - -static char* -terr(int e) -{ - static char buf[50]; - - if(e < 0 || e >= nelem(tderrstr) || tderrstr[e] == nil){ - snprint(buf, sizeof buf, "thread err %d", e); - return buf; - } - return tderrstr[e]; -} - -int -pthreaddbinit(void) -{ - int e; - struct ps_prochandle p; - - p.pid = 0; - if((e = td_ta_new(&p, &ta)) != TD_OK){ - werrstr("%s", terr(e)); - return -1; - } - return 0; -} - -Regs* -threadregs(uint tid) -{ - int e; - static UregRegs r; - static Ureg u; - td_thrhandle_t th; - prgregset_t regs; - - if(tid == 0) - return correg; - if(!ta) - pthreaddbinit(); - if((e = td_ta_map_id2thr(ta, tid, &th)) != TD_OK - || (e = td_thr_getgregs(&th, regs)) != TD_OK){ - werrstr("reading thread registers: %s", terr(e)); - return nil; - } - linux2ureg386((UregLinux386*)regs, &u); - r.r.rw = _uregrw; - r.ureg = (uchar*)&u; - return &r.r; -} - - -/* - * bottom-end functions for libthread_db to call - */ -enum -{ - PS_OK, - PS_ERR, - PS_BADPID, - PS_BADLWPID, - PS_BADADDR, - PS_NOSYM, - PS_NOFPREGS, -}; - -pid_t -ps_getpid(struct ps_prochandle *ph) -{ - return ph->pid; -} - -int -ps_pstop(const struct ps_prochandle *ph) -{ - return PS_ERR; -} - -int -ps_pcontinue(const struct ps_prochandle *ph) -{ - return PS_ERR; -} - -int -ps_lstop(const struct ps_prochandle *ph) -{ - return PS_ERR; -} - -int -ps_lcontinue(const struct ps_prochandle *ph) -{ - return PS_ERR; -} - -/* read/write data or text memory */ -int -ps_pdread(struct ps_prochandle *ph, psaddr_t addr, void *v, size_t sz) -{ - if(get1(cormap, (ulong)addr, v, sz) < 0) - return PS_ERR; - return PS_OK; -} - -int -ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr, void *v, size_t sz) -{ - if(put1(cormap, (ulong)addr, v, sz) < 0) - return PS_ERR; - return PS_OK; -} - -int -ps_ptread(struct ps_prochandle *ph, psaddr_t addr, void *v, size_t sz) -{ - return ps_pdread(ph, addr, v, sz); -} - -int -ps_ptwrite(struct ps_prochandle *ph, psaddr_t addr, void *v, size_t sz) -{ - return ps_pdwrite(ph, addr, v, sz); -} - -int -ps_lgetregs(struct ps_prochandle *ph, lwpid_t lwp, prgregset_t regs) -{ - int i; - - USED(ph); - if(corhdr == nil) - return sys_ps_lgetregs(ph, lwp, regs); - for(i=0; i<corhdr->nthread; i++){ - if(corhdr->thread[i].id == lwp){ - ureg2linux386(corhdr->thread[i].ureg, (UregLinux386*)regs); - return PS_OK; - } - } - return PS_ERR; -} - -int -ps_lsetregs(struct ps_prochandle *ph, lwpid_t lwp, prgregset_t regs) -{ - if(corhdr == nil) - return sys_ps_lsetregs(ph, lwp, regs); - return PS_ERR; -} - -int -ps_lgetfpregs(struct ps_prochandle *ph, lwpid_t lwp, prfpregset_t *fpregs) -{ - if(corhdr == nil) - return sys_ps_lgetfpregs(ph, lwp, fpregs); - /* BUG - Look in core dump. */ - return PS_ERR; -} - -int -ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lwp, prfpregset_t *fpregs) -{ - if(corhdr == nil) - return sys_ps_lsetfpregs(ph, lwp, fpregs); - return PS_ERR; -} - -/* Fetch the special per-thread address associated with the given LWP. - This call is only used on a few platforms (most use a normal register). - The meaning of the `int' parameter is machine-dependent. */ -int -ps_get_thread_area(struct ps_prochandle *ph, lwpid_t lwp, int xxx, psaddr_t *addr) -{ - return PS_ERR; -// return sys_ps_get_thread_area(ph, lwp, xxx, addr); -} - -int -ps_pglobal_lookup(struct ps_prochandle *ph, char *object_name, char *sym_name, psaddr_t *sym_addr) -{ - Fhdr *fp; - ulong addr; - - if((fp = findhdr(object_name)) == nil){ - print("libmach pthread: lookup %d %s %s => no such hdr\n", ph->pid, object_name, sym_name); - return PS_NOSYM; - } - if(elfsymlookup(fp->elf, sym_name, &addr) < 0){ - print("libmach pthread: lookup %d %s %s => name not found\n", ph->pid, object_name, sym_name); - return PS_NOSYM; - } - /* print("libmach pthread: lookup %d %s %s => 0x%lux\n", ph->pid, object_name, sym_name, addr); */ - *sym_addr = (void*)(addr+fp->base); - return PS_OK; -} - |