Lines Matching refs:pid
89 static int write_memory(pid_t pid, CORE_ADDR memaddr, in write_memory() argument
93 snprintf(procname, sizeof(procname), "/proc/%d/as", pid); in write_memory()
127 static Bool attach(pid_t pid) in attach() argument
130 snprintf(procname, sizeof(procname), "/proc/%d/ctl", pid); in attach()
132 DEBUG(1, "Attaching to pid %d.\n", pid); in attach()
141 DEBUG(1, "Setting run-on-last-close-flag (PR_RLC) to pid %d.\n", pid); in attach()
154 DEBUG(1, "Stopping process %d.\n", pid); in attach()
165 DEBUG(1, "Process %d stopped.\n", pid); in attach()
168 snprintf(procname, sizeof(procname), "/proc/%d/status", pid); in attach()
184 DEBUG(2, "Process %d has run-on-last-close flag set. Good.\n", pid); in attach()
186 ERROR(0, "Process %d does not have run-on-last-close flag set!\n", pid); in attach()
192 DEBUG(3, "Process %d seems to be stopped. Good.\n", pid); in attach()
194 ERROR(0, "Process %d is not stopped!\n", pid); in attach()
203 static void detach(pid_t pid) in detach() argument
210 DEBUG(1, "Detached from pid %d.\n", pid); in detach()
214 static Bool get_regs(pid_t pid, prgregset_t *regs) in get_regs() argument
217 snprintf(procname, sizeof(procname), "/proc/%d/lwp/1/lwpstatus", pid); in get_regs()
219 DEBUG(1, "Getting registers from the first thread of process %d.\n", pid); in get_regs()
236 DEBUG(3, "Registers of thread %d from process %d: ", status.pr_lwpid, pid); in get_regs()
252 static Bool setup_stack_frame(pid_t pid, prgregset_t *regs) in setup_stack_frame() argument
254 DEBUG(1, "Setting up new stack frame of process %d.\n", pid); in setup_stack_frame()
281 DEBUG(1, "Pushing check argument to process %d memory.\n", pid); in setup_stack_frame()
283 int error = write_memory(pid, sp, &check, regsize); in setup_stack_frame()
286 pid); in setup_stack_frame()
287 detach(pid); in setup_stack_frame()
293 pid); in setup_stack_frame()
296 error = write_memory(pid, sp, &bad_return, regsize); in setup_stack_frame()
299 "memory.\n", pid); in setup_stack_frame()
300 detach(pid); in setup_stack_frame()
337 pid); in setup_stack_frame()
338 int error = write_memory(pid, sp, &bad_return, in setup_stack_frame()
342 "memory.\n", pid); in setup_stack_frame()
343 detach(pid); in setup_stack_frame()
358 DEBUG(1, "New stack frame set up for process %d.\n", pid); in setup_stack_frame()
371 static Bool invoke_agent(pid_t pid, prgregset_t *regs, id_t *agent_lwpid) in invoke_agent() argument
375 DEBUG(1, "Creating an agent thread within process %d.\n", pid); in invoke_agent()
388 DEBUG(1, "Obtaining agent thread lwpid for process %d.\n", pid); in invoke_agent()
392 "/proc/%d/lwp/agent/lwpstatus", pid); in invoke_agent()
414 "/proc/%d/lwp/agent/lwpctl", pid); in invoke_agent()
424 DEBUG(1, "Resuming the agent thread for process %d.\n", pid); in invoke_agent()
440 *agent_lwpid, pid); in invoke_agent()
447 static Bool wait_for_agent_exit(pid_t pid, id_t agent_lwpid) in wait_for_agent_exit() argument
450 snprintf(procname, sizeof(procname), "/proc/%d/lwp/agent/lwpctl", pid); in wait_for_agent_exit()
475 agent_lwpid, pid); in wait_for_agent_exit()
487 Bool invoker_invoke_gdbserver(pid_t pid) in invoker_invoke_gdbserver() argument
489 if (attach(pid) != True) { in invoker_invoke_gdbserver()
494 if (get_regs(pid, ®s) != True) { in invoker_invoke_gdbserver()
495 detach(pid); in invoker_invoke_gdbserver()
499 if (setup_stack_frame(pid, ®s) != True) { in invoker_invoke_gdbserver()
500 detach(pid); in invoker_invoke_gdbserver()
505 if (invoke_agent(pid, ®s, &agent_lwpid) != True) { in invoker_invoke_gdbserver()
506 detach(pid); in invoker_invoke_gdbserver()
510 if (wait_for_agent_exit(pid, agent_lwpid) != True) { in invoker_invoke_gdbserver()
511 detach(pid); in invoker_invoke_gdbserver()
515 detach(pid); in invoker_invoke_gdbserver()