Remove dead code
* defs.h (tv_tv): Remove. * net.c (sys_xsetsockaddr): Remove commented out dead code. * process.c (setarg, sys_execv, sys_execve, struct_user_offsets): Likewise. * signal.c (sys_sigsuspend): Likewise. * strace.c (reaper, trace): Likewise. * stream.c (internal_stream_ioctl): Likewise. * syscall.c (trace_syscall): Likewise. * term.c (term_ioctl): Likewise. * util.c (tv_tv, umoven, uload, getpc, fixvfork, setbpt, clearbpt): Likewise.
This commit is contained in:
parent
257e15737d
commit
e5e6085806
1
defs.h
1
defs.h
@ -545,7 +545,6 @@ extern int rtc_ioctl(struct tcb *, long, long);
|
||||
extern int scsi_ioctl(struct tcb *, long, long);
|
||||
#endif
|
||||
|
||||
extern void tv_tv(struct timeval *, int, int);
|
||||
extern int tv_nz(struct timeval *);
|
||||
extern int tv_cmp(struct timeval *, struct timeval *);
|
||||
extern double tv_float(struct timeval *);
|
||||
|
13
net.c
13
net.c
@ -2045,17 +2045,6 @@ struct tcb *tcp;
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
int
|
||||
sys_xsetsockaddr(tcp)
|
||||
struct tcb *tcp;
|
||||
{
|
||||
return netlib_call (tcp, sys_setsockaddr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
sys_xgetsockopt(tcp)
|
||||
struct tcb *tcp;
|
||||
@ -2077,4 +2066,4 @@ struct tcb *tcp;
|
||||
return netlib_call (tcp, sys_shutdown);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* UNIXWARE */
|
||||
|
155
process.c
155
process.c
@ -88,9 +88,9 @@
|
||||
#endif /* LINUX && SPARC64 */
|
||||
|
||||
#ifdef HAVE_LINUX_FUTEX_H
|
||||
#include <linux/futex.h>
|
||||
# include <linux/futex.h>
|
||||
#endif
|
||||
#if defined LINUX
|
||||
#ifdef LINUX
|
||||
# ifndef FUTEX_WAIT
|
||||
# define FUTEX_WAIT 0
|
||||
# endif
|
||||
@ -103,7 +103,7 @@
|
||||
# ifndef FUTEX_REQUEUE
|
||||
# define FUTEX_REQUEUE 3
|
||||
# endif
|
||||
#endif
|
||||
#endif /* LINUX */
|
||||
|
||||
#ifdef LINUX
|
||||
#include <sched.h>
|
||||
@ -120,15 +120,8 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PRCTL
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
# include <sys/prctl.h>
|
||||
|
||||
#ifndef WCOREDUMP
|
||||
#define WCOREDUMP(status) ((status) & 0200)
|
||||
#endif
|
||||
|
||||
/* WTA: this was `&& !defined(LINUXSPARC)', this seems unneeded though? */
|
||||
#if defined(HAVE_PRCTL)
|
||||
static const struct xlat prctl_options[] = {
|
||||
#ifdef PR_MAXPROCS
|
||||
{ PR_MAXPROCS, "PR_MAXPROCS" },
|
||||
@ -365,7 +358,6 @@ struct tcb *tcp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_PRCTL */
|
||||
|
||||
#if defined(FREEBSD) || defined(SUNOS4) || defined(SVR4)
|
||||
@ -672,7 +664,7 @@ sys_unshare(struct tcb *tcp)
|
||||
printflags(clone_flags, tcp->u_arg[0], "CLONE_???");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* LINUX */
|
||||
|
||||
int
|
||||
sys_fork(tcp)
|
||||
@ -686,7 +678,7 @@ struct tcb *tcp;
|
||||
int
|
||||
change_syscall(struct tcb *tcp, int new)
|
||||
{
|
||||
#if defined(LINUX)
|
||||
#ifdef LINUX
|
||||
#if defined(I386)
|
||||
/* Attempt to make vfork into fork, which we can follow. */
|
||||
if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(ORIG_EAX * 4), new) < 0)
|
||||
@ -789,113 +781,6 @@ change_syscall(struct tcb *tcp, int new)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
setarg(tcp, argnum)
|
||||
struct tcb *tcp;
|
||||
int argnum;
|
||||
{
|
||||
#if defined(AVR32)
|
||||
{
|
||||
errno = 0;
|
||||
if (argnum == 0)
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid,
|
||||
(char *)(REG_R12_ORIG),
|
||||
tcp->u_arg[argnum]);
|
||||
else if (argnum < 4)
|
||||
/* r11 .. r9 */
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid,
|
||||
(char *)(REG_R12 - 4 * argnum),
|
||||
tcp->u_arg[argnum]);
|
||||
else if (argnum < 5)
|
||||
/* r5 */
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid,
|
||||
(char *)(REG_R5),
|
||||
tcp->u_arg[argnum]);
|
||||
else if (argnum < 6)
|
||||
/* r3 */
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid,
|
||||
(char *)(REG_R3),
|
||||
tcp->u_arg[argnum]);
|
||||
else
|
||||
return -E2BIG;
|
||||
if (errno)
|
||||
return -1;
|
||||
}
|
||||
#elif defined(IA64)
|
||||
{
|
||||
unsigned long *bsp, *ap;
|
||||
|
||||
if (upeek(tcp, PT_AR_BSP, (long *) &bsp) , 0)
|
||||
return -1;
|
||||
|
||||
ap = ia64_rse_skip_regs(bsp, argnum);
|
||||
errno = 0;
|
||||
ptrace(PTRACE_POKEDATA, tcp->pid, (char *) ap, tcp->u_arg[argnum]);
|
||||
if (errno)
|
||||
return -1;
|
||||
|
||||
}
|
||||
#elif defined(I386)
|
||||
{
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*argnum), tcp->u_arg[argnum]);
|
||||
if (errno)
|
||||
return -1;
|
||||
}
|
||||
#elif defined(X86_64)
|
||||
{
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(8*(long)argnum), tcp->u_arg[argnum]);
|
||||
if (errno)
|
||||
return -1;
|
||||
}
|
||||
#elif defined(POWERPC)
|
||||
#ifndef PT_ORIG_R3
|
||||
#define PT_ORIG_R3 34
|
||||
#endif
|
||||
{
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid,
|
||||
(char*)((argnum==0 ? PT_ORIG_R3 : argnum+PT_R3)*sizeof(unsigned long)),
|
||||
tcp->u_arg[argnum]);
|
||||
if (errno)
|
||||
return -1;
|
||||
}
|
||||
#elif defined(MIPS)
|
||||
{
|
||||
errno = 0;
|
||||
if (argnum < 4)
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid,
|
||||
(char*)(REG_A0 + argnum), tcp->u_arg[argnum]);
|
||||
else {
|
||||
unsigned long *sp;
|
||||
|
||||
if (upeek(tcp, REG_SP, (long *) &sp) , 0)
|
||||
return -1;
|
||||
|
||||
ptrace(PTRACE_POKEDATA, tcp->pid,
|
||||
(char*)(sp + argnum - 4), tcp->u_arg[argnum]);
|
||||
}
|
||||
if (errno)
|
||||
return -1;
|
||||
}
|
||||
#elif defined(S390) || defined(S390X)
|
||||
{
|
||||
if(argnum <= 5)
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid,
|
||||
(char *) (argnum==0 ? PT_ORIGGPR2 :
|
||||
PT_GPR2 + argnum*sizeof(long)),
|
||||
tcp->u_arg[argnum]);
|
||||
else
|
||||
return -E2BIG;
|
||||
if (errno)
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
# warning Sorry, setargs not implemented for this architecture.
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
int
|
||||
internal_fork(struct tcb *tcp)
|
||||
@ -1725,7 +1610,7 @@ struct tcb *tcp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* UNIXWARE */
|
||||
|
||||
|
||||
static void
|
||||
@ -1777,17 +1662,12 @@ long addr;
|
||||
|
||||
#if defined(SPARC) || defined(SPARC64) || defined(SUNOS4)
|
||||
int
|
||||
sys_execv(tcp)
|
||||
struct tcb *tcp;
|
||||
sys_execv(struct tcb *tcp)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
printpath(tcp, tcp->u_arg[0]);
|
||||
if (!verbose(tcp))
|
||||
tprintf(", %#lx", tcp->u_arg[1]);
|
||||
#if 0
|
||||
else if (abbrev(tcp))
|
||||
printargc(", [/* %d arg%s */]", tcp, tcp->u_arg[1]);
|
||||
#endif
|
||||
else {
|
||||
tprintf(", [");
|
||||
printargv(tcp, tcp->u_arg[1]);
|
||||
@ -1799,17 +1679,12 @@ struct tcb *tcp;
|
||||
#endif /* SPARC || SPARC64 || SUNOS4 */
|
||||
|
||||
int
|
||||
sys_execve(tcp)
|
||||
struct tcb *tcp;
|
||||
sys_execve(struct tcb *tcp)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
printpath(tcp, tcp->u_arg[0]);
|
||||
if (!verbose(tcp))
|
||||
tprintf(", %#lx", tcp->u_arg[1]);
|
||||
#if 0
|
||||
else if (abbrev(tcp))
|
||||
printargc(", [/* %d arg%s */]", tcp, tcp->u_arg[1]);
|
||||
#endif
|
||||
else {
|
||||
tprintf(", [");
|
||||
printargv(tcp, tcp->u_arg[1]);
|
||||
@ -1907,8 +1782,12 @@ static const struct xlat wait4_options[] = {
|
||||
# define WCOREFLAG WCOREFLG
|
||||
#endif
|
||||
#ifndef WCOREFLAG
|
||||
#define WCOREFLAG 0x80
|
||||
# define WCOREFLAG 0x80
|
||||
#endif
|
||||
#ifndef WCOREDUMP
|
||||
# define WCOREDUMP(status) ((status) & 0200)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef W_STOPCODE
|
||||
#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
|
||||
@ -2735,12 +2614,6 @@ const struct xlat struct_user_offsets[] = {
|
||||
{ 8*RDX, "8*RDX" },
|
||||
{ 8*RSI, "8*RSI" },
|
||||
{ 8*RDI, "8*RDI" },
|
||||
# if 0
|
||||
{ DS, "DS" },
|
||||
{ ES, "ES" },
|
||||
{ FS, "FS" },
|
||||
{ GS, "GS" },
|
||||
# endif
|
||||
{ 8*ORIG_RAX, "8*ORIG_RAX" },
|
||||
{ 8*RIP, "8*RIP" },
|
||||
{ 8*CS, "8*CS" },
|
||||
|
8
signal.c
8
signal.c
@ -1513,17 +1513,11 @@ struct tcb *tcp;
|
||||
}
|
||||
|
||||
int
|
||||
sys_sigsuspend(tcp)
|
||||
struct tcb *tcp;
|
||||
sys_sigsuspend(struct tcb *tcp)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
sigset_t sigm;
|
||||
long_to_sigset(tcp->u_arg[2], &sigm);
|
||||
#if 0
|
||||
/* first two are not really arguments, but print them anyway */
|
||||
/* nevermind, they are an anachronism now, too bad... */
|
||||
tprintf("%d, %#x, ", tcp->u_arg[0], tcp->u_arg[1]);
|
||||
#endif
|
||||
printsigmask(&sigm, 0);
|
||||
}
|
||||
return 0;
|
||||
|
17
strace.c
17
strace.c
@ -1655,21 +1655,12 @@ int sig;
|
||||
|
||||
#ifdef USE_PROCFS
|
||||
|
||||
static void
|
||||
reaper(sig)
|
||||
int sig;
|
||||
static void reaper(int sig)
|
||||
{
|
||||
int pid;
|
||||
int status;
|
||||
|
||||
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
|
||||
#if 0
|
||||
struct tcb *tcp;
|
||||
|
||||
tcp = pid2tcb(pid);
|
||||
if (tcp)
|
||||
droptcb(tcp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -2322,12 +2313,6 @@ trace()
|
||||
* version of SunOS sometimes reports
|
||||
* ECHILD before sending us SIGCHILD.
|
||||
*/
|
||||
#if 0
|
||||
if (nprocs == 0)
|
||||
return 0;
|
||||
fprintf(stderr, "strace: proc miscount\n");
|
||||
exit(1);
|
||||
#endif
|
||||
return 0;
|
||||
default:
|
||||
errno = wait_errno;
|
||||
|
11
stream.c
11
stream.c
@ -1033,10 +1033,7 @@ int len;
|
||||
#endif /* TI_BIND */
|
||||
|
||||
|
||||
static int
|
||||
internal_stream_ioctl(tcp, arg)
|
||||
struct tcb *tcp;
|
||||
int arg;
|
||||
static int internal_stream_ioctl(struct tcb *tcp, int arg)
|
||||
{
|
||||
struct strioctl si;
|
||||
struct ioctlent *iop;
|
||||
@ -1151,9 +1148,6 @@ int arg;
|
||||
case SI_GETUDATA:
|
||||
if (entering(tcp))
|
||||
break;
|
||||
#if 0
|
||||
tprintf("struct si_udata ");
|
||||
#endif
|
||||
if (umove(tcp, (int) si.ic_dp, &udata) < 0)
|
||||
tprintf("{...}");
|
||||
else {
|
||||
@ -1164,9 +1158,6 @@ int arg;
|
||||
tprintf("servtype=%d, so_state=%d, ",
|
||||
udata.servtype, udata.so_state);
|
||||
tprintf("so_options=%d", udata.so_options);
|
||||
#if 0
|
||||
tprintf(", tsdusize=%d", udata.tsdusize);
|
||||
#endif
|
||||
tprintf("}");
|
||||
}
|
||||
break;
|
||||
|
@ -2555,12 +2555,6 @@ trace_syscall(struct tcb *tcp)
|
||||
decode_subcall(tcp, SYS_semsys_subcall,
|
||||
SYS_semsys_nsubcalls, shift_style);
|
||||
break;
|
||||
#if 0 /* broken */
|
||||
case SYS_utssys:
|
||||
decode_subcall(tcp, SYS_utssys_subcall,
|
||||
SYS_utssys_nsubcalls, shift_style);
|
||||
break;
|
||||
#endif
|
||||
case SYS_sysfs:
|
||||
decode_subcall(tcp, SYS_sysfs_subcall,
|
||||
SYS_sysfs_nsubcalls, shift_style);
|
||||
|
13
term.c
13
term.c
@ -178,10 +178,7 @@ static const struct xlat modem_flags[] = {
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
term_ioctl(tcp, code, arg)
|
||||
struct tcb *tcp;
|
||||
long code, arg;
|
||||
int term_ioctl(struct tcb *tcp, long code, long arg)
|
||||
{
|
||||
struct termios tios;
|
||||
#ifndef FREEBSD
|
||||
@ -417,14 +414,6 @@ long code, arg;
|
||||
printnum_int(tcp, arg, "%d");
|
||||
return 1;
|
||||
|
||||
#if 0
|
||||
/* ioctls with an indirect parameter displayed in hex */
|
||||
|
||||
tprintf(", ");
|
||||
printnum(tcp, arg, "%#x");
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
/* ioctls with an indirect parameter displayed as a char */
|
||||
|
||||
#ifdef TIOCSTI
|
||||
|
558
util.c
558
util.c
@ -93,18 +93,6 @@
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void
|
||||
tv_tv(tv, a, b)
|
||||
struct timeval *tv;
|
||||
int a;
|
||||
int b;
|
||||
{
|
||||
tv->tv_sec = a;
|
||||
tv->tv_usec = b;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
tv_nz(a)
|
||||
struct timeval *a;
|
||||
@ -817,39 +805,6 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
|
||||
|
||||
#ifdef SUNOS4
|
||||
int pid = tcp->pid;
|
||||
#if 0
|
||||
int n, m;
|
||||
union {
|
||||
long val;
|
||||
char x[sizeof(long)];
|
||||
} u;
|
||||
|
||||
if (addr & (sizeof(long) - 1)) {
|
||||
/* addr not a multiple of sizeof(long) */
|
||||
n = addr - (addr & -sizeof(long)); /* residue */
|
||||
addr &= -sizeof(long); /* residue */
|
||||
errno = 0;
|
||||
u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
|
||||
if (errno) {
|
||||
if (errno != ESRCH)
|
||||
perror("umoven");
|
||||
return -1;
|
||||
}
|
||||
memcpy(laddr, &u.x[n], m = MIN(sizeof(long) - n, len));
|
||||
addr += sizeof(long), laddr += m, len -= m;
|
||||
}
|
||||
while (len) {
|
||||
errno = 0;
|
||||
u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
|
||||
if (errno) {
|
||||
if (errno != ESRCH)
|
||||
perror("umoven");
|
||||
return -1;
|
||||
}
|
||||
memcpy(laddr, u.x, m = MIN(sizeof(long), len));
|
||||
addr += sizeof(long), laddr += m, len -= m;
|
||||
}
|
||||
#else /* !oldway */
|
||||
int n;
|
||||
|
||||
while (len) {
|
||||
@ -867,7 +822,6 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
|
||||
addr += n;
|
||||
laddr += n;
|
||||
}
|
||||
#endif /* !oldway */
|
||||
#endif /* SUNOS4 */
|
||||
|
||||
#ifdef USE_PROCFS
|
||||
@ -992,21 +946,6 @@ long addr;
|
||||
int len;
|
||||
char *laddr;
|
||||
{
|
||||
# if 0
|
||||
int n;
|
||||
|
||||
while (len) {
|
||||
n = MIN(len, PAGSIZ);
|
||||
n = MIN(n, ((addr + PAGSIZ) & PAGMASK) - addr);
|
||||
if (ptrace(cmd, pid, (char *)addr, n, laddr) < 0) {
|
||||
perror("uload: ptrace(PTRACE_WRITE, ...)");
|
||||
return -1;
|
||||
}
|
||||
len -= n;
|
||||
addr += n;
|
||||
laddr += n;
|
||||
}
|
||||
# else
|
||||
int peek, poke;
|
||||
int n, m;
|
||||
union {
|
||||
@ -1049,7 +988,6 @@ char *laddr;
|
||||
}
|
||||
addr += sizeof(long), laddr += m, len -= m;
|
||||
}
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1123,95 +1061,6 @@ long *res;
|
||||
|
||||
#endif /* !USE_PROCFS */
|
||||
|
||||
#if 0
|
||||
long
|
||||
getpc(struct tcb *tcp)
|
||||
{
|
||||
|
||||
#ifdef LINUX
|
||||
long pc;
|
||||
# if defined(I386)
|
||||
if (upeek(tcp, 4*EIP, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(X86_64)
|
||||
if (upeek(tcp, 8*RIP, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(IA64)
|
||||
if (upeek(tcp, PT_B0, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(ARM)
|
||||
if (upeek(tcp, 4*15, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(AVR32)
|
||||
if (upeek(tcp, REG_PC, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(BFIN)
|
||||
if (upeek(tcp, REG_PC, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(POWERPC)
|
||||
if (upeek(tcp, sizeof(unsigned long)*PT_NIP, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(M68K)
|
||||
if (upeek(tcp, 4*PT_PC, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(ALPHA)
|
||||
if (upeek(tcp, REG_PC, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(MIPS)
|
||||
if (upeek(tcp, REG_EPC, &pc) < 0)
|
||||
return -1;
|
||||
# elif defined(SPARC) || defined(SPARC64)
|
||||
struct pt_regs regs;
|
||||
if (ptrace(PTRACE_GETREGS,tcp->pid,(char *)®s,0) < 0)
|
||||
return -1;
|
||||
# if defined(SPARC64)
|
||||
pc = regs.tpc;
|
||||
# else
|
||||
pc = regs.pc;
|
||||
# endif
|
||||
# elif defined(S390) || defined(S390X)
|
||||
if(upeek(tcp,PT_PSWADDR,&pc) < 0)
|
||||
return -1;
|
||||
# elif defined(HPPA)
|
||||
if(upeek(tcp,PT_IAOQ0,&pc) < 0)
|
||||
return -1;
|
||||
# elif defined(SH)
|
||||
if (upeek(tcp, 4*REG_PC ,&pc) < 0)
|
||||
return -1;
|
||||
# elif defined(SH64)
|
||||
if (upeek(tcp, REG_PC ,&pc) < 0)
|
||||
return -1;
|
||||
# endif
|
||||
return pc;
|
||||
#endif /* LINUX */
|
||||
|
||||
#ifdef SUNOS4
|
||||
/*
|
||||
* Return current program counter for `pid'
|
||||
* Assumes PC is never 0xffffffff
|
||||
*/
|
||||
struct regs regs;
|
||||
|
||||
if (ptrace(PTRACE_GETREGS, tcp->pid, (char *) ®s, 0) < 0) {
|
||||
perror("getpc: ptrace(PTRACE_GETREGS, ...)");
|
||||
return -1;
|
||||
}
|
||||
return regs.r_pc;
|
||||
#endif /* SUNOS4 */
|
||||
|
||||
#ifdef SVR4
|
||||
/* XXX */
|
||||
return 0;
|
||||
#endif /* SVR4 */
|
||||
|
||||
#ifdef FREEBSD
|
||||
struct reg regs;
|
||||
pread(tcp->pfd_reg, ®s, sizeof(regs), 0);
|
||||
return regs.r_eip;
|
||||
#endif /* FREEBSD */
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
void
|
||||
printcall(struct tcb *tcp)
|
||||
{
|
||||
@ -1397,7 +1246,7 @@ printcall(struct tcb *tcp)
|
||||
*/
|
||||
#ifndef USE_PROCFS
|
||||
|
||||
# if defined LINUX
|
||||
#ifdef LINUX
|
||||
|
||||
# include "syscall.h"
|
||||
|
||||
@ -1721,206 +1570,6 @@ int
|
||||
setbpt(tcp)
|
||||
struct tcb *tcp;
|
||||
{
|
||||
# ifdef LINUX
|
||||
DEAD CODE HERE? WE ARE IN 'else !defined LINUX'
|
||||
# if defined (SPARC) || defined (SPARC64)
|
||||
/* We simply use the SunOS breakpoint code. */
|
||||
|
||||
struct regs regs;
|
||||
unsigned long inst;
|
||||
# define LOOPA 0x30800000 /* ba,a 0 */
|
||||
|
||||
if (tcp->flags & TCB_BPTSET) {
|
||||
fprintf(stderr, "PANIC: TCB already set in pid %u\n", tcp->pid);
|
||||
return -1;
|
||||
}
|
||||
if (ptrace(PTRACE_GETREGS, tcp->pid, (char *)®s, 0) < 0) {
|
||||
perror("setbpt: ptrace(PTRACE_GETREGS, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->baddr = regs.r_o7 + 8;
|
||||
errno = 0;
|
||||
tcp->inst[0] = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)tcp->baddr, 0);
|
||||
if(errno) {
|
||||
perror("setbpt: ptrace(PTRACE_PEEKTEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX - BRUTAL MODE ON
|
||||
* We cannot set a real BPT in the child, since it will not be
|
||||
* traced at the moment it will reach the trap and would probably
|
||||
* die with a core dump.
|
||||
* Thus, we are force our way in by taking out two instructions
|
||||
* and insert an eternal loop instead, in expectance of the SIGSTOP
|
||||
* generated by our PTRACE_ATTACH.
|
||||
* Of cause, if we evaporate ourselves in the middle of all this...
|
||||
*/
|
||||
errno = 0;
|
||||
inst = LOOPA;
|
||||
# if defined (SPARC64)
|
||||
inst <<= 32;
|
||||
inst |= (tcp->inst[0] & 0xffffffffUL);
|
||||
# endif
|
||||
ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, inst);
|
||||
if(errno) {
|
||||
perror("setbpt: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->flags |= TCB_BPTSET;
|
||||
|
||||
# else /* !SPARC && !SPARC64 */
|
||||
# ifdef IA64
|
||||
if (ia32) {
|
||||
# define LOOP 0x0000feeb
|
||||
if (tcp->flags & TCB_BPTSET) {
|
||||
fprintf(stderr, "PANIC: bpt already set in pid %u\n",
|
||||
tcp->pid);
|
||||
return -1;
|
||||
}
|
||||
if (upeek(tcp, PT_CR_IIP, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
if (debug)
|
||||
fprintf(stderr, "[%d] setting bpt at %lx\n",
|
||||
tcp->pid, tcp->baddr);
|
||||
tcp->inst[0] = ptrace(PTRACE_PEEKTEXT, tcp->pid,
|
||||
(char *) tcp->baddr, 0);
|
||||
if (errno) {
|
||||
perror("setbpt: ptrace(PTRACE_PEEKTEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, LOOP);
|
||||
if (errno) {
|
||||
perror("setbpt: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->flags |= TCB_BPTSET;
|
||||
} else {
|
||||
/*
|
||||
* Our strategy here is to replace the bundle that
|
||||
* contained the clone() syscall with a bundle of the
|
||||
* form:
|
||||
*
|
||||
* { 1: br 1b; br 1b; br 1b }
|
||||
*
|
||||
* This ensures that the newly forked child will loop
|
||||
* endlessly until we've got a chance to attach to it.
|
||||
*/
|
||||
# define LOOP0 0x0000100000000017
|
||||
# define LOOP1 0x4000000000200000
|
||||
unsigned long addr, ipsr;
|
||||
pid_t pid;
|
||||
|
||||
pid = tcp->pid;
|
||||
if (upeek(tcp, PT_CR_IPSR, &ipsr) < 0)
|
||||
return -1;
|
||||
if (upeek(tcp, PT_CR_IIP, &addr) < 0)
|
||||
return -1;
|
||||
/* store "ri" in low two bits */
|
||||
tcp->baddr = addr | ((ipsr >> 41) & 0x3);
|
||||
|
||||
errno = 0;
|
||||
tcp->inst[0] = ptrace(PTRACE_PEEKTEXT, pid, (char *) addr + 0,
|
||||
0);
|
||||
tcp->inst[1] = ptrace(PTRACE_PEEKTEXT, pid, (char *) addr + 8,
|
||||
0);
|
||||
if (errno) {
|
||||
perror("setbpt: ptrace(PTRACE_PEEKTEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
ptrace(PTRACE_POKETEXT, pid, (char *) addr + 0, LOOP0);
|
||||
ptrace(PTRACE_POKETEXT, pid, (char *) addr + 8, LOOP1);
|
||||
if (errno) {
|
||||
perror("setbpt: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->flags |= TCB_BPTSET;
|
||||
}
|
||||
# else /* !IA64 */
|
||||
|
||||
# if defined (I386) || defined(X86_64)
|
||||
# define LOOP 0x0000feeb
|
||||
# elif defined (M68K)
|
||||
# define LOOP 0x60fe0000
|
||||
# elif defined (ALPHA)
|
||||
# define LOOP 0xc3ffffff
|
||||
# elif defined (POWERPC)
|
||||
# define LOOP 0x48000000
|
||||
# elif defined(ARM)
|
||||
# define LOOP 0xEAFFFFFE
|
||||
# elif defined(MIPS)
|
||||
# define LOOP 0x1000ffff
|
||||
# elif defined(S390)
|
||||
# define LOOP 0xa7f40000 /* BRC 15,0 */
|
||||
# elif defined(S390X)
|
||||
# define LOOP 0xa7f4000000000000UL /* BRC 15,0 */
|
||||
# elif defined(HPPA)
|
||||
# define LOOP 0xe81f1ff7 /* b,l,n <loc>,r0 */
|
||||
# elif defined(SH)
|
||||
# ifdef __LITTLE_ENDIAN__
|
||||
# define LOOP 0x0000affe
|
||||
# else
|
||||
# define LOOP 0xfeaf0000
|
||||
# endif
|
||||
# else
|
||||
# error unknown architecture
|
||||
# endif
|
||||
|
||||
if (tcp->flags & TCB_BPTSET) {
|
||||
fprintf(stderr, "PANIC: bpt already set in pid %u\n", tcp->pid);
|
||||
return -1;
|
||||
}
|
||||
# if defined (I386)
|
||||
if (upeek(tcp, 4*EIP, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
# elif defined (X86_64)
|
||||
if (upeek(tcp, 8*RIP, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
# elif defined (M68K)
|
||||
if (upeek(tcp, 4*PT_PC, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
# elif defined (ALPHA)
|
||||
return -1;
|
||||
# elif defined (ARM)
|
||||
return -1;
|
||||
# elif defined (MIPS)
|
||||
return -1; /* FIXME: I do not know what i do - Flo */
|
||||
# elif defined (POWERPC)
|
||||
if (upeek(tcp, sizeof(unsigned long)*PT_NIP, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
# elif defined(S390) || defined(S390X)
|
||||
if (upeek(tcp,PT_PSWADDR, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
# elif defined(HPPA)
|
||||
if (upeek(tcp, PT_IAOQ0, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
tcp->baddr &= ~0x03;
|
||||
# elif defined(SH)
|
||||
if (upeek(tcp, 4*REG_PC, &tcp->baddr) < 0)
|
||||
return -1;
|
||||
# else
|
||||
# error unknown architecture
|
||||
# endif
|
||||
if (debug)
|
||||
fprintf(stderr, "[%d] setting bpt at %lx\n", tcp->pid, tcp->baddr);
|
||||
tcp->inst[0] = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *) tcp->baddr, 0);
|
||||
if (errno) {
|
||||
perror("setbpt: ptrace(PTRACE_PEEKTEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, LOOP);
|
||||
if (errno) {
|
||||
perror("setbpt: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->flags |= TCB_BPTSET;
|
||||
|
||||
# endif /* !IA64 */
|
||||
# endif /* !SPARC && !SPARC64 */
|
||||
# endif /* LINUX */
|
||||
|
||||
# ifdef SUNOS4
|
||||
# ifdef SPARC /* This code is slightly sparc specific */
|
||||
|
||||
@ -1977,204 +1626,6 @@ int
|
||||
clearbpt(tcp)
|
||||
struct tcb *tcp;
|
||||
{
|
||||
|
||||
# ifdef LINUX
|
||||
DEAD CODE HERE? WE ARE IN 'else !defined LINUX'
|
||||
# if defined(I386) || defined(X86_64)
|
||||
long eip;
|
||||
# elif defined(POWERPC)
|
||||
long pc;
|
||||
# elif defined(M68K)
|
||||
long pc;
|
||||
# elif defined(ALPHA)
|
||||
long pc;
|
||||
# elif defined(HPPA)
|
||||
long iaoq;
|
||||
# elif defined(SH)
|
||||
long pc;
|
||||
# endif /* architecture */
|
||||
|
||||
# if defined (SPARC) || defined (SPARC64)
|
||||
/* Again, we borrow the SunOS breakpoint code. */
|
||||
if (!(tcp->flags & TCB_BPTSET)) {
|
||||
fprintf(stderr, "PANIC: TCB not set in pid %u\n", tcp->pid);
|
||||
return -1;
|
||||
}
|
||||
errno = 0;
|
||||
ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, tcp->inst[0]);
|
||||
if(errno) {
|
||||
perror("clearbtp: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->flags &= ~TCB_BPTSET;
|
||||
# elif defined(IA64)
|
||||
if (ia32) {
|
||||
unsigned long addr;
|
||||
|
||||
if (debug)
|
||||
fprintf(stderr, "[%d] clearing bpt\n", tcp->pid);
|
||||
if (!(tcp->flags & TCB_BPTSET)) {
|
||||
fprintf(stderr, "PANIC: TCB not set in pid %u\n", tcp->pid);
|
||||
return -1;
|
||||
}
|
||||
errno = 0;
|
||||
ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, tcp->inst[0]);
|
||||
if (errno) {
|
||||
perror("clearbtp: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->flags &= ~TCB_BPTSET;
|
||||
|
||||
if (upeek(tcp, PT_CR_IIP, &addr) < 0)
|
||||
return -1;
|
||||
if (addr != tcp->baddr) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr,
|
||||
"NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
addr, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
unsigned long addr, ipsr;
|
||||
pid_t pid;
|
||||
|
||||
pid = tcp->pid;
|
||||
|
||||
if (upeek(tcp, PT_CR_IPSR, &ipsr) < 0)
|
||||
return -1;
|
||||
if (upeek(tcp, PT_CR_IIP, &addr) < 0)
|
||||
return -1;
|
||||
|
||||
/* restore original bundle: */
|
||||
errno = 0;
|
||||
ptrace(PTRACE_POKETEXT, pid, (char *) addr + 0, tcp->inst[0]);
|
||||
ptrace(PTRACE_POKETEXT, pid, (char *) addr + 8, tcp->inst[1]);
|
||||
if (errno) {
|
||||
perror("clearbpt: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* restore original "ri" in ipsr: */
|
||||
ipsr = (ipsr & ~(0x3ul << 41)) | ((tcp->baddr & 0x3) << 41);
|
||||
errno = 0;
|
||||
ptrace(PTRACE_POKEUSER, pid, (char *) PT_CR_IPSR, ipsr);
|
||||
if (errno) {
|
||||
perror("clrbpt: ptrace(PTRACE_POKEUSER, ...)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tcp->flags &= ~TCB_BPTSET;
|
||||
|
||||
if (addr != (tcp->baddr & ~0x3)) {
|
||||
/* the breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr, "NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
addr, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
# else /* !IA64 && !SPARC && !SPARC64 */
|
||||
|
||||
if (debug)
|
||||
fprintf(stderr, "[%d] clearing bpt\n", tcp->pid);
|
||||
if (!(tcp->flags & TCB_BPTSET)) {
|
||||
fprintf(stderr, "PANIC: TCB not set in pid %u\n", tcp->pid);
|
||||
return -1;
|
||||
}
|
||||
errno = 0;
|
||||
ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, tcp->inst[0]);
|
||||
if (errno) {
|
||||
perror("clearbtp: ptrace(PTRACE_POKETEXT, ...)");
|
||||
return -1;
|
||||
}
|
||||
tcp->flags &= ~TCB_BPTSET;
|
||||
|
||||
# ifdef I386
|
||||
if (upeek(tcp, 4*EIP, &eip) < 0)
|
||||
return -1;
|
||||
if (eip != tcp->baddr) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr,
|
||||
"NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
eip, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
# elif defined(X86_64)
|
||||
if (upeek(tcp, 8*RIP, &eip) < 0)
|
||||
return -1;
|
||||
if (eip != tcp->baddr) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr,
|
||||
"NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
eip, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
# elif defined(POWERPC)
|
||||
if (upeek(tcp, sizeof(unsigned long)*PT_NIP, &pc) < 0)
|
||||
return -1;
|
||||
if (pc != tcp->baddr) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr, "NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
pc, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
# elif defined(M68K)
|
||||
if (upeek(tcp, 4*PT_PC, &pc) < 0)
|
||||
return -1;
|
||||
if (pc != tcp->baddr) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr, "NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
pc, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
# elif defined(ALPHA)
|
||||
if (upeek(tcp, REG_PC, &pc) < 0)
|
||||
return -1;
|
||||
if (pc != tcp->baddr) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr, "NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
pc, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
# elif defined(HPPA)
|
||||
if (upeek(tcp, PT_IAOQ0, &iaoq) < 0)
|
||||
return -1;
|
||||
iaoq &= ~0x03;
|
||||
if (iaoq != tcp->baddr && iaoq != tcp->baddr + 4) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr, "NOTE: PC not at bpt (iaoq %#lx baddr %#lx)\n",
|
||||
iaoq, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
iaoq = tcp->baddr | 3;
|
||||
/* We should be pointing at a 'ldi -1000,r1' in glibc, so it is
|
||||
* safe to set both IAOQ0 and IAOQ1 to that so the PSW N bit
|
||||
* has no significant effect.
|
||||
*/
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid, (void *)PT_IAOQ0, iaoq);
|
||||
ptrace(PTRACE_POKEUSER, tcp->pid, (void *)PT_IAOQ1, iaoq);
|
||||
# elif defined(SH)
|
||||
if (upeek(tcp, 4*REG_PC, &pc) < 0)
|
||||
return -1;
|
||||
if (pc != tcp->baddr) {
|
||||
/* The breakpoint has not been reached yet. */
|
||||
if (debug)
|
||||
fprintf(stderr, "NOTE: PC not at bpt (pc %#lx baddr %#lx)\n",
|
||||
pc, tcp->baddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif /* arch */
|
||||
# endif /* !SPARC && !SPARC64 && !IA64 */
|
||||
# endif /* LINUX */
|
||||
|
||||
# ifdef SUNOS4
|
||||
# ifdef SPARC
|
||||
|
||||
@ -2293,13 +1744,6 @@ struct tcb *tcp;
|
||||
(int)ld.ld_symb_size, strtab) < 0)
|
||||
goto err;
|
||||
|
||||
# if 0
|
||||
for (cp = strtab; cp < strtab + ld.ld_symb_size; ) {
|
||||
fprintf(stderr, "[symbol: %s]\n", cp);
|
||||
cp += strlen(cp)+1;
|
||||
}
|
||||
return 0;
|
||||
# endif
|
||||
for (cp = strtab; cp < strtab + ld.ld_symb_size; ) {
|
||||
if (strcmp(cp, "_vfork") == 0) {
|
||||
if (debug)
|
||||
|
Loading…
x
Reference in New Issue
Block a user