summaryrefslogtreecommitdiff
path: root/src/libmach_amd64/linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmach_amd64/linux.c')
-rw-r--r--src/libmach_amd64/linux.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/libmach_amd64/linux.c b/src/libmach_amd64/linux.c
index 3f66d2f1b..ee4c8a217 100644
--- a/src/libmach_amd64/linux.c
+++ b/src/libmach_amd64/linux.c
@@ -49,8 +49,8 @@ struct user_regs_struct {
unsigned long rip,cs,eflags;
unsigned long rsp,ss;
unsigned long fs_base, gs_base;
- unsigned long ds,es,fs,gs;
-};
+ unsigned long ds,es,fs,gs;
+};
static int
isstopped(int pid)
@@ -160,7 +160,7 @@ detachproc(Map *m)
free(m);
}
-/* /proc/pid/stat contains
+/* /proc/pid/stat contains
pid
command in parens
0. state
@@ -289,41 +289,25 @@ ctlproc(int pid, char *msg)
if(strcmp(msg, "startstop") == 0){
if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
return -1;
- goto waitstop;
+ return waitstop(pid);
}
if(strcmp(msg, "sysstop") == 0){
if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
return -1;
- goto waitstop;
+ return waitstop(pid);
}
if(strcmp(msg, "stop") == 0){
if(kill(pid, SIGSTOP) < 0)
return -1;
- goto waitstop;
+ return waitstop(pid);
}
if(strcmp(msg, "step") == 0){
if(ptrace(PTRACE_SINGLESTEP, pid, 0, 0) < 0)
return -1;
- goto waitstop;
- }
- if(strcmp(msg, "waitstop") == 0){
- waitstop:
- if(isstopped(pid))
- return 0;
- for(;;){
- p = waitpid(pid, &status, WUNTRACED|__WALL);
- if(p <= 0){
- if(errno == ECHILD){
- if(isstopped(pid))
- return 0;
- }
- return -1;
- }
-/*fprint(2, "got pid %d status %x\n", pid, status); */
- if(WIFEXITED(status) || WIFSTOPPED(status))
- return 0;
- }
+ return waitstop(pid);
}
+ if(strcmp(msg, "waitstop") == 0)
+ return waitstop(pid);
if(strcmp(msg, "start") == 0)
return ptrace(PTRACE_CONT, pid, 0, 0);
werrstr("unknown control message '%s'", msg);