summaryrefslogtreecommitdiffstats
path: root/c/src/librdbg/src/servtgt.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2002-02-01 17:00:01 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2002-02-01 17:00:01 +0000
commit40cf43eab4e4121a92ec95bc1366cc5b3bad4e27 (patch)
tree5aef0f81416b68a9f035ac5d14ba9278f0787c1c /c/src/librdbg/src/servtgt.c
parent2001-02-01 Mike Siers <mikes@poliac.com> (diff)
downloadrtems-40cf43eab4e4121a92ec95bc1366cc5b3bad4e27.tar.bz2
* So many patches have been posted recently on the mailing list and
because we were unable to find correct solution to compile on various linux distros (due to rpcgen incompatibilities), and because the coding style of rdbg was rather inconsistant among various pieces of code, I decided to: 1) make some cleaning regarding global coding style (using indent + manual edits), 2) incorporate/review the paches send by various people (S. Holford, T. Strauman), 3) Fix the bug due to varying rpcgen code generation in remdeb_svc.c, 4) Remove some dead code, 5) Apply a patches enabling to call enterRdbg imediately after rdbg initialization is done, NB : the paches is huge but it is mainly due to coding styke chnages. Only few lines of codes have been really changed and they do not impact rdbg functionnality (AFAIKT). * include/rdbg/servrpc.h, include/rdbg/i386/rdbg_f.h, include/rdbg/m68k/rdbg_f.h, include/rdbg/powerpc/rdbg_f.h, src/_servtgt.c, src/awk.svc, src/excep.c, src/ptrace.c, src/rdbg.c, src/remdeb.x, src/servbkpt.c, src/servcon.c, src/servrpc.c, src/servtgt.c, src/servtsp.c, src/servutil.c, src/i386/excep_f.c, src/i386/rdbg_f.c, src/i386/any/Makefile.am, src/i386/any/remdeb.h, src/i386/any/remdeb_svc.c, src/i386/any/remdeb_xdr.c, src/m68k/excep_f.c, src/m68k/rdbg_f.c, src/m68k/any/Makefile.am, src/m68k/any/remdeb.h, src/m68k/any/remdeb_svc.c, src/m68k/any/remdeb_xdr.c, src/powerpc/excep_f.c, src/powerpc/rdbg_f.c, src/powerpc/new_exception_processing/Makefile.am, src/powerpc/new_exception_processing/remdeb.h, src/powerpc/new_exception_processing/remdeb_svc.c, src/powerpc/new_exception_processing/remdeb_xdr.c: Modified.
Diffstat (limited to 'c/src/librdbg/src/servtgt.c')
-rw-r--r--c/src/librdbg/src/servtgt.c708
1 files changed, 366 insertions, 342 deletions
diff --git a/c/src/librdbg/src/servtgt.c b/c/src/librdbg/src/servtgt.c
index de41abc1a6..4e96f14916 100644
--- a/c/src/librdbg/src/servtgt.c
+++ b/c/src/librdbg/src/servtgt.c
@@ -9,12 +9,11 @@
**************************************************************************
*/
-
#include <string.h>
#include <sys/errno.h>
-#include <rdbg/rdbg.h>
-#include <rdbg/servrpc.h>
-#include <sys/socket.h>
+#include <rdbg/rdbg.h>
+#include <rdbg/servrpc.h>
+#include <sys/socket.h>
#include <assert.h>
#ifdef DDEBUG
@@ -23,229 +22,234 @@
#define Ptrace TgtRealPtrace
#endif
-/* ----------------------------------------------------------------
- TgtBreakRestoreOrig - Restore original instruction at "addr"
- just before single-stepping it.
- ---------------------------------------------------------------- */
+/*
+ * TgtBreakRestoreOrig - Restore original instruction at "addr"
+ * just before single-stepping it.
+ */
-int TgtBreakRestoreOrig (int pid, void *addr, void *addr2)
- /* Process identifier */
- /* Breakpoint address */
- /* Original instruction or bkpt number */
+ int
+TgtBreakRestoreOrig (int pid, void *addr, void *addr2)
+ /*
+ * Process identifier
+ */
+ /*
+ * Breakpoint address
+ */
+ /*
+ * Original instruction or bkpt number
+ */
{
int ret;
int l;
-
- l = (long)Ptrace(RPT_PEEKTEXT, pid, addr, 0, NULL); /* assume ok */
- ret = ORG_BREAK (l, (UINT32) addr2); /* reconstruct old instr */
- ret = Ptrace(RPT_POKETEXT, pid, addr, ret, NULL); /* poke back old */
+
+ l = (long) Ptrace (RPT_PEEKTEXT, pid, addr, 0, NULL); /* assume ok */
+ ret = ORG_BREAK (l, (UINT32) addr2); /* reconstruct old instr */
+ ret = Ptrace (RPT_POKETEXT, pid, addr, ret, NULL); /* poke back old */
return ret;
}
-/* -----------------------------------------------------------------------
- TgtBreakCancelStep - Restore the breakpoint at "addr" if the single-step
- has failed at the ptrace level.
- ----------------------------------------------------------------------- */
+/*
+ *
+ * TgtBreakCancelStep - Restore the breakpoint at "addr" if the single-step
+ * has failed at the ptrace level.
+ */
#define BKPT0(plst) ((BASE_BREAK*)(plst)->break_list)
-void TgtBreakCancelStep (PID_LIST* plst)
+ void
+TgtBreakCancelStep (PID_LIST * plst)
{
assert (plst->break_list);
assert (BKPT0 (plst)->clr_step);
- if (plst->break_list && BKPT0 (plst)->clr_step) {
+ if (plst->break_list && BKPT0 (plst)->clr_step) {
int idx = BKPT0 (plst)->last_break;
int data;
data = Ptrace (RPT_PEEKTEXT, plst->pid,
- (char *)plst->break_list [idx].ee_loc, 0, NULL);
- assert (! IS_BREAK (data));
+ (char *) plst->break_list[idx].ee_loc, 0, NULL);
+ assert (!IS_BREAK (data));
Ptrace (RPT_POKETEXT, plst->pid,
- (char *)plst->break_list[idx].ee_loc,
- (int) SET_BREAK (data), NULL);
+ (char *) plst->break_list[idx].ee_loc,
+ (int) SET_BREAK (data), NULL);
}
}
-/* -----------------------------------------------------------------------
- TgtCreateNew - add a new process into the process management lists.
- ----------------------------------------------------------------------- */
+/*
+ * TgtCreateNew - add a new process into the process management lists.
+ */
- void
-TgtCreateNew(PID pid, int conn, INT32 child, char *name, Boolean spawn)
+ void
+TgtCreateNew (PID pid, int conn, INT32 child, char *name, Boolean spawn)
{
- int idx;
+ int idx;
for (idx = 0; idx < pid_list_cnt; idx++)
if (!pid_list[idx].pid)
- break; /* find empty */
+ break; /* find empty */
- if (idx >= pid_list_cnt)
- { /* no empties, add more */
- PID_LIST *tmp_pid_list = pid_list;
+ if (idx >= pid_list_cnt) { /* no empties, add more */
+ PID_LIST *tmp_pid_list = pid_list;
pid_list_cnt += PID_LIST_INC;
- pid_list = (PID_LIST*) Realloc(pid_list, /* get new or extend */
- pid_list_cnt * sizeof(PID_LIST));
- if (!pid_list)
- { /* out of memory */
+ pid_list = (PID_LIST *) Realloc (pid_list, /* get new or extend */
+ pid_list_cnt * sizeof (PID_LIST));
+ if (!pid_list) { /* out of memory */
pid_list_cnt -= PID_LIST_INC;
- if (pid_list_cnt)
- { /* realloc failed - malloc again */
- pid_list = tmp_pid_list;
- /* above relies on old pointer being valid after failed realloc */
+ if (pid_list_cnt) { /* realloc failed - malloc again */
+ pid_list = tmp_pid_list;
+ /*
+ * above relies on old pointer being valid after failed realloc
+ */
}
- return; /* failed */
+ return; /* failed */
}
- /* now clear newly added space */
- memset(pid_list+pid_list_cnt-PID_LIST_INC, 0,
- PID_LIST_INC * sizeof(PID_LIST));
+ /*
+ * now clear newly added space
+ */
+ memset (pid_list + pid_list_cnt - PID_LIST_INC, 0,
+ PID_LIST_INC * sizeof (PID_LIST));
idx = pid_list_cnt - PID_LIST_INC;
- }
- else /* clear entry we found */
- memset(&pid_list[idx], 0, sizeof(PID_LIST));
+ } else /* clear entry we found */
+ memset (&pid_list[idx], 0, sizeof (PID_LIST));
- /* now fill in empty entry */
+ /*
+ * now fill in empty entry
+ */
pid_list[idx].pid = pid;
- pid_list[idx].running = 1; /* we have not called wait yet */
- pid_list[idx].primary_conn = (UCHAR)conn; /* primary owner */
- if (conn != -1)
- { /* found caller */
+ pid_list[idx].running = 1; /* we have not called wait yet */
+ pid_list[idx].primary_conn = (UCHAR) conn; /* primary owner */
+ if (conn != -1) { /* found caller */
pid_list[idx].owners = 1;
- PIDMAP_SET (conn, idx); /* mask in */
+ PIDMAP_SET (conn, idx); /* mask in */
}
- pid_list[idx].thread = (UINT32)-1; /* no thread for now */
- pid_list[idx].last_start = LAST_START; /* handle MiX bug */
+ pid_list[idx].thread = (UINT32) - 1; /* no thread for now */
+ pid_list[idx].last_start = LAST_START; /* handle MiX bug */
- pid_list[idx].name = name ? (char *)StrDup(name) : (char *)NULL;
+ pid_list[idx].name = name ? (char *) StrDup (name) : (char *) NULL;
}
-/* -----------------------------------------------------------------------
- TgtNotifyWaitChange - send event to clients indicating child changed state.
- ----------------------------------------------------------------------- */
+/*
+ * TgtNotifyWaitChange - send event to clients indicating child changed state.
+ */
- void
-TgtNotifyWaitChange( PID pid, int status, Boolean exclude)
+ void
+TgtNotifyWaitChange (PID pid, int status, Boolean exclude)
{
- int conn, idx;
-
- idx = FindPidEntry (pid); /* locate the pid that changed */
- if (idx < 0)
- {
- DPRINTF(("TgtNotifyWaitChange: pid %d not in our list\n",
- (int) pid));
- return; /* not in our list */
+ int conn, idx;
+
+ idx = FindPidEntry (pid); /* locate the pid that changed */
+ if (idx < 0) {
+ DPRINTF (("TgtNotifyWaitChange: pid %d not in our list\n", (int) pid));
+ return; /* not in our list */
}
- pid_list[idx].running = 0; /* not running */
- pid_list[idx].state = status; /* save status of stop/term */
- if (!pid_list[idx].owners && !STS_SIGNALLED(status))
- TgtDelete(&pid_list[idx], -1, 0); /* terminated and no owners */
- else
- { /* normal cases */
- for (conn = 0; conn < conn_list_cnt; conn++)
- { /* now find all interested clients */
- if (!conn_list[conn].in_use /* free entry */
- || ! PIDMAP_TEST (conn, idx))
- continue; /* not using this pid */
+ pid_list[idx].running = 0; /* not running */
+ pid_list[idx].state = status; /* save status of stop/term */
+ if (!pid_list[idx].owners && !STS_SIGNALLED (status))
+ TgtDelete (&pid_list[idx], -1, 0); /* terminated and no owners */
+ else { /* normal cases */
+ for (conn = 0; conn < conn_list_cnt; conn++) { /* now find all interested clients */
+ if (!conn_list[conn].in_use /* free entry */
+ || !PIDMAP_TEST (conn, idx))
+ continue; /* not using this pid */
if (conn == exclude)
- continue; /* do not do this one */
- TspSendWaitChange(conn, BMSG_WAIT, 1, pid, 0, False);/* notify of change */
+ continue; /* do not do this one */
+ TspSendWaitChange (conn, BMSG_WAIT, 1, pid, 0, False); /* notify of change */
}
}
}
-/* -----------------------------------------------------------------------
- TgtNotifyAll - send a message to all clients interested in process.
- ----------------------------------------------------------------------- */
+/*
+ * TgtNotifyAll - send a message to all clients interested in process.
+ */
- void
- TgtNotifyAll( int pid_idx, BACK_MSG msg, UINT16 spec,
- UINT32 context, int exclude, Boolean force)
+ void
+TgtNotifyAll (int pid_idx, BACK_MSG msg, UINT16 spec,
+ UINT32 context, int exclude, Boolean force)
{
- int conn;
+ int conn;
- DPRINTF(("TgtNotifyAll: msg %d (%s) for pid_idx=%d (%d,%d)\n",
- msg, BmsgNames [msg], pid_idx, exclude, force));
+ DPRINTF (("TgtNotifyAll: msg %d (%s) for pid_idx=%d (%d,%d)\n",
+ msg, BmsgNames[msg], pid_idx, exclude, force));
for (conn = 0; conn < conn_list_cnt; conn++)
- if (conn_list[conn].in_use /* not free */
- && PIDMAP_TEST (conn, pid_idx))
- {
+ if (conn_list[conn].in_use /* not free */
+ && PIDMAP_TEST (conn, pid_idx)) {
if (conn != exclude)
- TspSendWaitChange(conn, msg, spec, pid_list[pid_idx].pid, context,
- force);
+ TspSendWaitChange (conn, msg, spec, pid_list[pid_idx].pid, context,
+ force);
}
}
-/* -----------------------------------------------------------------------
- TgtDelete - mark process as now uncontrolled.
-
- Notes:
- - this function removes a process from the process list.
- - the notify argument indicates a message to send if needed.
- ----------------------------------------------------------------------- */
+/*
+ * TgtDelete - mark process as now uncontrolled.
+ *
+ * Notes:
+ * - this function removes a process from the process list.
+ * - the notify argument indicates a message to send if needed.
+ */
-void TgtDelete(PID_LIST *plst, int conn_idx, BACK_MSG notify)
+ void
+TgtDelete (PID_LIST * plst, int conn_idx, BACK_MSG notify)
{
- int idx = plst - pid_list, cnt, conn;
+ int idx = plst - pid_list, cnt, conn;
- /* found */
+ /*
+ * found
+ */
cnt = pid_list[idx].owners;
- if (cnt)
- { /* some connections to break */
+ if (cnt) { /* some connections to break */
for (conn = 0; cnt && conn < conn_list_cnt; conn++)
- if (conn_list[conn].in_use /* not free */
- && PIDMAP_TEST (conn, idx))
- { /* found one that uses it */
- PIDMAP_CLEAR (conn, idx);
- if (notify && conn != conn_idx)
- TspSendWaitChange(conn, notify, 0, plst->pid, 0, True);
- if (!--cnt)
- break;
+ if (conn_list[conn].in_use /* not free */
+ && PIDMAP_TEST (conn, idx)) { /* found one that uses it */
+ PIDMAP_CLEAR (conn, idx);
+ if (notify && conn != conn_idx)
+ TspSendWaitChange (conn, notify, 0, plst->pid, 0, True);
+ if (!--cnt)
+ break;
}
}
if (pid_list[idx].name)
- Free(pid_list[idx].name); /* free string name back */
- /* Free breakpoint list */
- if (pid_list [idx].break_list != NULL) {
- Free (pid_list [idx].break_list);
+ Free (pid_list[idx].name); /* free string name back */
+ /*
+ * Free breakpoint list
+ */
+ if (pid_list[idx].break_list != NULL) {
+ Free (pid_list[idx].break_list);
}
- pid_list[idx].pid = 0; /* gone */
+ pid_list[idx].pid = 0; /* gone */
}
+/*
+ * TgtKillAndDelete - kill or detach process and remove entry.
+ */
-/* -----------------------------------------------------------------------
- TgtKillAndDelete - kill or detach process and remove entry.
- ----------------------------------------------------------------------- */
-
- int
-TgtKillAndDelete( PID_LIST *plst, struct svc_req *rqstp, Boolean term)
+ int
+TgtKillAndDelete (PID_LIST * plst, struct svc_req *rqstp, Boolean term)
{
- ptrace_in pin; /* used for ptrace call */
- ptrace_out *pout;
+ ptrace_in pin; /* used for ptrace call */
+ ptrace_out *pout;
- /* Remove breakpoints */
+ /*
+ * Remove breakpoints
+ */
if (plst->break_alloc > 0) {
pin.pid = plst->pid;
pin.addr.req = RPT_CLRBREAK;
- pin.data = 0; /* clear all */
+ pin.data = 0; /* clear all */
pin.flags = PTRFLG_NON_OWNER;
- pout = RPCGENSRVNAME(ptrace_2_svc) (&pin, rqstp);
+ pout = RPCGENSRVNAME (ptrace_2_svc) (&pin, rqstp);
if (pout->result < 0) {
- DPRINTF (("TgtKillAndDelete: RPT_CLRBREAK failed %d\n",
- getErrno()));
+ DPRINTF (("TgtKillAndDelete: RPT_CLRBREAK failed %d\n", getErrno ()));
return -1;
}
}
- if (term)
- { /* kill */
+ if (term) { /* kill */
pin.addr.ptrace_addr_data_in_u.address = 0;
- pin.data = -1; /* Don't want notification from slave */
+ pin.data = -1; /* Don't want notification from slave */
pin.addr.req = RPT_KILL;
- }
- else
- { /* detach */
+ } else { /* detach */
pin.addr.ptrace_addr_data_in_u.address = 1;
pin.data = 0;
pin.addr.req = RPT_DETACH;
@@ -254,26 +258,24 @@ TgtKillAndDelete( PID_LIST *plst, struct svc_req *rqstp, Boolean term)
pin.flags = PTRFLG_FREE | PTRFLG_NON_OWNER;
DPRINTF (("TgtKillAndDelete: ptrace_2_svc (%s (%d), %d)\n",
- PtraceName (pin.addr.req), pin.addr.req, pin.pid));
+ PtraceName (pin.addr.req), pin.addr.req, pin.pid));
- pout = RPCGENSRVNAME(ptrace_2_svc) (&pin, rqstp);/* start it */
+ pout = RPCGENSRVNAME (ptrace_2_svc) (&pin, rqstp); /* start it */
if (pout->errNo == ESRCH && plst->pid)
- TgtDelete(plst, -1, BMSG_KILLED); /* only entry remains */
+ TgtDelete (plst, -1, BMSG_KILLED); /* only entry remains */
return 0;
}
-/* -----------------------------------------------------------------------
- TgtDetachCon - detach a connection's ownership of a process.
- ----------------------------------------------------------------------- */
+/*
+ * TgtDetachCon - detach a connection's ownership of a process.
+ */
- void
-TgtDetachCon( int conn_idx, int pid_idx, Boolean delete)
+ void
+TgtDetachCon (int conn_idx, int pid_idx, Boolean delete)
{
- if ((unsigned) pid_idx >= pid_list_cnt
- || !pid_list[pid_idx].pid)
- return; /* not valid */
- if (PIDMAP_TEST (conn_idx, pid_idx))
- { /* if an owner, release control */
+ if ((unsigned) pid_idx >= pid_list_cnt || !pid_list[pid_idx].pid)
+ return; /* not valid */
+ if (PIDMAP_TEST (conn_idx, pid_idx)) { /* if an owner, release control */
PIDMAP_CLEAR (conn_idx, pid_idx);
if (pid_list[pid_idx].owners)
@@ -281,9 +283,8 @@ TgtDetachCon( int conn_idx, int pid_idx, Boolean delete)
if (pid_list[pid_idx].primary_conn == conn_idx)
pid_list[pid_idx].primary_conn = NO_PRIMARY;
if (delete
- && !pid_list[pid_idx].owners
- && PROC_TERMINATED (pid_list + pid_idx))
- TgtDelete(&pid_list[pid_idx], -1, 0); /* remove entry */
+ && !pid_list[pid_idx].owners && PROC_TERMINATED (pid_list + pid_idx))
+ TgtDelete (&pid_list[pid_idx], -1, 0); /* remove entry */
}
}
@@ -293,231 +294,254 @@ TgtDetachCon( int conn_idx, int pid_idx, Boolean delete)
----------------------------------------------------------------------- */
#ifdef DDEBUG
-static char* LastStartNames[] = {
+static char *LastStartNames[] = {
"NONE", "STEP", "CONT", "RANGE",
"STEPOFF", "KILLED", "DETACHED"
};
-char* GetLastStartName (int last_start)
+ char *
+GetLastStartName (int last_start)
{
- static char buf [32];
+ static char buf[32];
- strcpy (buf, LastStartNames [last_start & ~LAST_START]);
- if (last_start & LAST_START) {
- strcat (buf, "+START");
- }
- return buf;
+ strcpy (buf, LastStartNames[last_start & ~LAST_START]);
+ if (last_start & LAST_START) {
+ strcat (buf, "+START");
+ }
+ return buf;
}
#endif
-Boolean TgtHandleChildChange(PID pid, int* status, int *unexp,
- CPU_Exception_frame* ctx)
-{ /* return False if continue, else stop */
- int idx, sig;
- int bidx = 0;
- PID_LIST *plst;
- unsigned long PC;
- BASE_BREAK *base = NULL; /* break_list[0] is really BASE_BREAK */
- int hadStepEmul;
- int origHadStepEmul;
- int stopWanted;
+ Boolean
+TgtHandleChildChange (PID pid, int *status, int *unexp,
+ CPU_Exception_frame * ctx)
+{ /* return False if continue, else stop */
+ int idx, sig;
+ int bidx = 0;
+ PID_LIST *plst;
+ unsigned long PC;
+ BASE_BREAK *base = NULL; /* break_list[0] is really BASE_BREAK */
+ int hadStepEmul;
+ int origHadStepEmul;
+ int stopWanted;
DPRINTF (("TgtHandleChildChange: pid %d status %x cap\n",
- (int) pid, *status));
+ (int) pid, *status));
if (unexp)
- *unexp = 0; /* initialize to ok */
+ *unexp = 0; /* initialize to ok */
- /* first, find pid in question */
+ /*
+ * first, find pid in question
+ */
idx = FindPidEntry (pid);
- if (idx < 0)
- { /* cannot locate this process */
+ if (idx < 0) { /* cannot locate this process */
DPRINTF (("TgtHandleChildChange: unknown process (%s pid)\n",
- FindPidEntry (pid) >= 0 ? "stale" : "unknown"));
+ FindPidEntry (pid) >= 0 ? "stale" : "unknown"));
if (unexp)
- *unexp = 1; /* Unexpected change */
- return(False); /* unknown: ignore (used to stop and notify) */
+ *unexp = 1; /* Unexpected change */
+ return (False); /* unknown: ignore (used to stop and notify) */
}
- /* found */
- plst = &pid_list[idx]; /* pointer to entry */
- /* first we see if just stopped */
+ /*
+ * found
+ */
+ plst = &pid_list[idx]; /* pointer to entry */
+ /*
+ * first we see if just stopped
+ */
- /* copy ctxt */
- CtxToRegs(ctx, &(plst->regs));
+ /*
+ * copy ctxt
+ */
+ CtxToRegs (ctx, &(plst->regs));
stopWanted = plst->stop_wanted;
- plst->stop_wanted = 0; /* For the next time */
+ plst->stop_wanted = 0; /* For the next time */
hadStepEmul = BreakClear (plst, -1, -1) > 0;
- origHadStepEmul = hadStepEmul; /* hadStepEmul is cleared if real bkpt met */
+ origHadStepEmul = hadStepEmul; /* hadStepEmul is cleared if real bkpt met */
- if (STS_SIGNALLED (*status))
- { /* stopped, not terminated */
- sig = STS_GETSIG (*status); /* signal that stopped us */
+ if (STS_SIGNALLED (*status)) { /* stopped, not terminated */
+ sig = STS_GETSIG (*status); /* signal that stopped us */
- /* now, we read the registers and see what to do next */
- if (TgtPtrace(RPT_GETREGS, pid, (void *)&plst->regs, 0, NULL) < 0) {
- memset (&plst->regs, 0, sizeof plst->regs);
+ /*
+ * now, we read the registers and see what to do next
+ */
+ if (TgtPtrace (RPT_GETREGS, pid, (void *) &plst->regs, 0, NULL) < 0) {
+ memset (&plst->regs, 0, sizeof (plst->regs));
}
- /* Get current thread */
- plst->thread = TgtPtrace(RPT_GETTARGETTHREAD, pid, NULL, 0, NULL);
+ /*
+ * Get current thread
+ */
+ plst->thread = TgtPtrace (RPT_GETTARGETTHREAD, pid, NULL, 0, NULL);
- if (sig == SIGTRAP)
- { /* stopped from break/step */
+ if (sig == SIGTRAP) { /* stopped from break/step */
PC = plst->regs.REG_PC;
- /* Must check PC to see whether in situations where we had
- step emulation we are on a breakpoint or just
- have returned from an emulated single-step */
- if (BreakIdentify (plst, 0 /*no adjust*/, -1 /*no thread*/) > 0) {
- hadStepEmul = 0;
+ /*
+ * Must check PC to see whether in situations where we had
+ * step emulation we are on a breakpoint or just
+ * have returned from an emulated single-step
+ */
+ if (BreakIdentify (plst, 0 /*no adjust */ , -1 /*no thread */ ) > 0) {
+ hadStepEmul = 0;
}
- plst->is_step = hadStepEmul || IS_STEP(plst->regs)
- || plst->last_start == LAST_START;
+ plst->is_step = hadStepEmul || IS_STEP (plst->regs)
+ || plst->last_start == LAST_START;
DPRINTF (("TgtHandleChildChange: %s last_start %s\n", plst->is_step
- ? "step": "break", GetLastStartName (plst->last_start)));
+ ? "step" : "break", GetLastStartName (plst->last_start)));
if ((plst->is_step || origHadStepEmul || stopWanted)
- && (plst->last_start == LAST_STEP
- || plst->last_start == LAST_STEPOFF
- || plst->last_start == LAST_RANGE))
- {
- DPRINTF (("TgtHandleChildChange: restoring stepped-off bkpt\n"));
- BreakSteppedOff (plst);
+ && (plst->last_start == LAST_STEP
+ || plst->last_start == LAST_STEPOFF
+ || plst->last_start == LAST_RANGE)) {
+ DPRINTF (("TgtHandleChildChange: restoring stepped-off bkpt\n"));
+ BreakSteppedOff (plst);
}
- if (plst->last_start == LAST_STEPOFF && (plst->is_step||origHadStepEmul))
- { /* stepped off break and now need cont */
- DPRINTF (("TgtHandleChildChange: auto-resuming after step-off\n"));
- plst->last_start = LAST_CONT; /* convert to normal cont */
- if (!stopWanted) {
- if (TgtPtrace(RPT_CONT, pid, (char *)1, 0, NULL))
- return True; /* tell people */
- return(False); /* wait for change */
- }
- DPRINTF (("TgtHandleChildChange: stop_wanted %d in step-off\n",
- stopWanted));
- *status = STS_MAKESIG (stopWanted);
- return True; /* Stop and notify */
+ if (plst->last_start == LAST_STEPOFF && (plst->is_step || origHadStepEmul)) { /* stepped off break and now need cont */
+ DPRINTF (("TgtHandleChildChange: auto-resuming after step-off\n"));
+ plst->last_start = LAST_CONT; /* convert to normal cont */
+ if (!stopWanted) {
+ if (TgtPtrace (RPT_CONT, pid, (char *) 1, 0, NULL))
+ return True; /* tell people */
+ return (False); /* wait for change */
+ }
+ DPRINTF (("TgtHandleChildChange: stop_wanted %d in step-off\n",
+ stopWanted));
+ *status = STS_MAKESIG (stopWanted);
+ return True; /* Stop and notify */
}
- base = plst->break_list ? ((BASE_BREAK*)plst->break_list) :
- ((BASE_BREAK*)NULL);
- /* now see if step in range */
-
- if (plst->last_start == LAST_RANGE /* step in range */
- && (plst->is_step || origHadStepEmul) /* not a breakpoint */
- && PC >= base->range_start
- && PC <= base->range_end)
- { /* still in range, keep going */
- if (stopWanted) {
- DPRINTF (("TgtHandleChildChange: stop_wanted %d in step-range\n",
- stopWanted));
- } else {
- DPRINTF (("TgtHandleChildChange: Reservation at %x\n",
- plst->regs.REG_PC));
- }
+ base = plst->break_list ? ((BASE_BREAK *) plst->break_list) :
+ ((BASE_BREAK *) NULL);
+ /*
+ * now see if step in range
+ */
+
+ if (plst->last_start == LAST_RANGE /* step in range */
+ && (plst->is_step || origHadStepEmul) /* not a breakpoint */
+ &&PC >= base->range_start && PC <= base->range_end) { /* still in range, keep going */
+ if (stopWanted) {
+ DPRINTF (("TgtHandleChildChange: stop_wanted %d in step-range\n",
+ stopWanted));
+ } else {
+ DPRINTF (("TgtHandleChildChange: Reservation at %x\n",
+ plst->regs.REG_PC));
+ }
}
- if (!plst->is_step) /* was break */
- {
- bidx = BreakIdentify (plst, 1 /*adjust*/, plst->thread);
- if (bidx == 0) {
- DPRINTF (("TgtHandleChildChange: forwarding bkpt to kernel\n"));
- if (unexp) {
- *unexp = 1;
- }
- return False;
- }
- if (bidx < 0) { /* Unwanted breakpoint, must step it off */
- ptrace_in pin;
- ptrace_out* out;
- if (origHadStepEmul)
- {
- DPRINTF (("TgtHandleChildChange: bkpt %x becomes step\n",
- plst->regs.REG_PC));
- bidx = -bidx;
- plst->is_step = 1;
- base->clr_step = plst->break_list [bidx].type == BRKT_INSTR;
- base->last_break = bidx;
- return True;
- }
- if (stopWanted) {
- DPRINTF (("TgtHandleChildChange: stop_wanted %d at bkpt %x\n",
- stopWanted, plst->regs.REG_PC));
- /* The PC has already been adjusted by BreakIdentify */
- *status = STS_MAKESIG (stopWanted);
- return True;
- }
- /* All the handling is done in ptrace_2_svc() so call it */
- bidx = -bidx;
- DPRINTF (("TgtHandleChildChange: last %d (%s) restarting bkpt %d\n",
- plst->last_start, GetLastStartName (plst->last_start), bidx));
- base->clr_step = 1;
- base->last_break = bidx; /* remember which one */
- plst->running = 0; /* So that ptrace is accepted */
- pin.pid = plst->pid;
-
- if (plst->last_start == LAST_STEP) {
- pin.addr.req = RPT_SINGLESTEP;
- } else {
- pin.addr.req = RPT_CONT;
- }
- pin.addr.ptrace_addr_data_in_u.address = 1;
- pin.data = 0;
- pin.flags = PTRFLG_NON_OWNER;
- out = RPCGENSRVNAME(ptrace_2_svc) (&pin, NULL);
- if (out->result == 0) return False; /* Continue waiting */
- DPRINTF(("TgtHandleChildChange: failed to restart bkpt!\n"));
- /* If something went wrong, just stop on breakpoint */
- }
+ if (!plst->is_step) { /* was break */
+ bidx = BreakIdentify (plst, 1 /*adjust */ , plst->thread);
+ if (bidx == 0) {
+ DPRINTF (("TgtHandleChildChange: forwarding bkpt to kernel\n"));
+ if (unexp) {
+ *unexp = 1;
+ }
+ return False;
+ }
+ if (bidx < 0) { /* Unwanted breakpoint, must step it off */
+ ptrace_in pin;
+ ptrace_out *out;
+ if (origHadStepEmul) {
+ DPRINTF (("TgtHandleChildChange: bkpt %x becomes step\n",
+ plst->regs.REG_PC));
+ bidx = -bidx;
+ plst->is_step = 1;
+ base->clr_step = plst->break_list[bidx].type == BRKT_INSTR;
+ base->last_break = bidx;
+ return True;
+ }
+ if (stopWanted) {
+ DPRINTF (("TgtHandleChildChange: stop_wanted %d at bkpt %x\n",
+ stopWanted, plst->regs.REG_PC));
+ /*
+ * The PC has already been adjusted by BreakIdentify
+ */
+ *status = STS_MAKESIG (stopWanted);
+ return True;
+ }
+ /*
+ * All the handling is done in ptrace_2_svc() so call it
+ */
+ bidx = -bidx;
+ DPRINTF (("TgtHandleChildChange: last %d (%s) restarting bkpt %d\n",
+ plst->last_start, GetLastStartName (plst->last_start),
+ bidx));
+ base->clr_step = 1;
+ base->last_break = bidx; /* remember which one */
+ plst->running = 0; /* So that ptrace is accepted */
+ pin.pid = plst->pid;
+
+ if (plst->last_start == LAST_STEP) {
+ pin.addr.req = RPT_SINGLESTEP;
+ } else {
+ pin.addr.req = RPT_CONT;
+ }
+ pin.addr.ptrace_addr_data_in_u.address = 1;
+ pin.data = 0;
+ pin.flags = PTRFLG_NON_OWNER;
+ out = RPCGENSRVNAME (ptrace_2_svc) (&pin, NULL);
+ if (out->result == 0)
+ return False; /* Continue waiting */
+ DPRINTF (("TgtHandleChildChange: failed to restart bkpt!\n"));
+ /*
+ * If something went wrong, just stop on breakpoint
+ */
+ }
}
- } /* else sig != SIGTRAP */
-
- /* finally, fill in stop info in break point array base */
- if (bidx > 0)
- { /* store break info */
- /* will need to get off the break for SW breakpoints only */
- base->clr_step = plst->break_list [bidx].type == BRKT_INSTR;
- base->last_break = bidx; /* remember which one */
}
- else if (base)
- { /* clear break info */
- base->clr_step = False; /* not stopped on break */
+
+ /*
+ * else sig != SIGTRAP
+ */
+ /*
+ * finally, fill in stop info in break point array base
+ */
+ if (bidx > 0) { /* store break info */
+ /*
+ * will need to get off the break for SW breakpoints only
+ */
+ base->clr_step = plst->break_list[bidx].type == BRKT_INSTR;
+ base->last_break = bidx; /* remember which one */
+ } else if (base) { /* clear break info */
+ base->clr_step = False; /* not stopped on break */
base->last_break = 0;
}
- /* decision to notify owner based on last_start */
- } /* stopped */
- else /* terminated */
- {
- if (plst->last_start == LAST_START)
- { /* spawn failed */
- TgtNotifyAll(idx, BMSG_EXEC_FAIL, 0, 0, -1, True);
- plst->running = False; /* not running - dead */
- plst->state = *status; /* contains errno in high word */
- return(False);
+ /*
+ * decision to notify owner based on last_start
+ */
+ } /* stopped */
+ else { /* terminated */
+
+ if (plst->last_start == LAST_START) { /* spawn failed */
+ TgtNotifyAll (idx, BMSG_EXEC_FAIL, 0, 0, -1, True);
+ plst->running = False; /* not running - dead */
+ plst->state = *status; /* contains errno in high word */
+ return (False);
}
-
- else if ((UCHAR)(plst->last_start & ~LAST_START) < (UCHAR)LAST_KILLED)
+
+ else if ((UCHAR) (plst->last_start & ~LAST_START) < (UCHAR) LAST_KILLED)
plst->last_start = LAST_NONE; /* doesn't matter anymore */
else
- return(False); /* killed and detach already notified */
+ return (False); /* killed and detach already notified */
}
- return(True); /* stop and notify */
+ return (True); /* stop and notify */
}
#ifdef DDEBUG
-/* -----------------------------------------------------------------------
- TgtDbgPtrace - debug version of ptrace.
- ----------------------------------------------------------------------- */
+/*
+ * TgtDbgPtrace - debug version of ptrace.
+ */
-int TgtDbgPtrace(int request, PID pid, char *addr, int data, void *addr2)
+ int
+TgtDbgPtrace (int request, PID pid, char *addr, int data, void *addr2)
{
- int diag;
+ int diag;
DPRINTF (("TgtDbgPtrace: entered (%s (%d), %d, %x, %d, %x)\n",
- PtraceName (request), request, pid, (int) addr, data,
- (int) addr2));
+ PtraceName (request), request, pid, (int) addr, data,
+ (int) addr2));
if (request == RPT_WRITETEXT || request == RPT_WRITEDATA) {
int i;
@@ -525,7 +549,7 @@ int TgtDbgPtrace(int request, PID pid, char *addr, int data, void *addr2)
DPRINTF (("TgtDbgPtrace:"));
if (rdb_debug) {
for (i = 0; i < data && i < 16; ++i) {
- printf (" %02x", ((char*) addr2) [i] & 0xFF);
+ printf (" %02x", ((char *) addr2)[i] & 0xFF);
}
printf ("\n");
}
@@ -534,19 +558,19 @@ int TgtDbgPtrace(int request, PID pid, char *addr, int data, void *addr2)
diag = TgtRealPtrace (request, pid, addr, data, addr2);
DPRINTF (("TgtDbgPtrace: returned %d (%x) errno %d\n",
- diag, diag, getErrno()));
+ diag, diag, getErrno ()));
if (request == RPT_GETREGS || request == RPT_GETTHREADREGS
- || request == RPT_SETREGS || request == RPT_SETTHREADREGS)
- {
- /* Use DPRINTF() so as to have the id prefix */
+ || request == RPT_SETREGS || request == RPT_SETTHREADREGS) {
+ /*
+ * Use DPRINTF() so as to have the id prefix
+ */
DPRINTF (("TgtDbgPtrace: (%s) PC = %x, SP = %x, FP = %x\n",
- PtraceName (request),
- ((xdr_regs*)addr)->REG_PC,
- ((xdr_regs*)addr)->REG_SP,
- ((xdr_regs*)addr)->REG_FP));
+ PtraceName (request),
+ ((xdr_regs *) addr)->REG_PC,
+ ((xdr_regs *) addr)->REG_SP, ((xdr_regs *) addr)->REG_FP));
}
- return(diag);
+ return (diag);
}
-#endif /* DDEBUG */
+#endif /* DDEBUG */