coredump: Support threads
Change-Id: Id75ade6c87b15abcff5d772d90f77950376a32c1 Refs: #1219
This commit is contained in:
@ -18,8 +18,6 @@ void arch_fill_prstatus(struct elf_prstatus64 *prstatus, struct thread *thread,
|
||||
short int pr_cursig;
|
||||
a8_uint64_t pr_sigpend;
|
||||
a8_uint64_t pr_sighold;
|
||||
pid_t pr_pid;
|
||||
pid_t pr_ppid;
|
||||
pid_t pr_pgrp;
|
||||
pid_t pr_sid;
|
||||
struct prstatus64_timeval pr_utime;
|
||||
@ -28,6 +26,11 @@ void arch_fill_prstatus(struct elf_prstatus64 *prstatus, struct thread *thread,
|
||||
struct prstatus64_timeval pr_cstime;
|
||||
*/
|
||||
|
||||
prstatus->pr_pid = thread->tid;
|
||||
if (thread->proc->parent) {
|
||||
prstatus->pr_ppid = thread->proc->parent->pid;
|
||||
}
|
||||
|
||||
prstatus->pr_reg[0] = _r15;
|
||||
prstatus->pr_reg[1] = _r14;
|
||||
prstatus->pr_reg[2] = _r13;
|
||||
|
||||
@ -573,7 +573,7 @@ long ptrace_write_regset(struct thread *thread, long type, struct iovec *iov)
|
||||
return rc;
|
||||
}
|
||||
|
||||
extern void coredump(struct thread *thread, void *regs);
|
||||
extern int coredump(struct thread *thread, void *regs, int sig);
|
||||
|
||||
void ptrace_report_signal(struct thread *thread, int sig)
|
||||
{
|
||||
@ -741,6 +741,7 @@ do_signal(unsigned long rc, void *regs0, struct thread *thread, struct sig_pendi
|
||||
struct mcs_rwlock_node_irqsave lock;
|
||||
struct mcs_rwlock_node_irqsave mcs_rw_node;
|
||||
int restart = 0;
|
||||
int ret;
|
||||
|
||||
for(w = pending->sigmask.__val[0], sig = 0; w; sig++, w >>= 1);
|
||||
dkprintf("do_signal(): tid=%d, pid=%d, sig=%d\n", thread->tid, proc->pid, sig);
|
||||
@ -1006,9 +1007,31 @@ do_signal(unsigned long rc, void *regs0, struct thread *thread, struct sig_pendi
|
||||
case SIGXCPU:
|
||||
case SIGXFSZ:
|
||||
core:
|
||||
dkprintf("do_signal,default,core,sig=%d\n", sig);
|
||||
coredump(thread, regs);
|
||||
coredumped = 0x80;
|
||||
thread->coredump_regs =
|
||||
kmalloc(sizeof(struct x86_user_context),
|
||||
IHK_MC_AP_NOWAIT);
|
||||
if (!thread->coredump_regs) {
|
||||
kprintf("%s: Out of memory\n", __func__);
|
||||
goto skip;
|
||||
}
|
||||
memcpy(thread->coredump_regs, regs,
|
||||
sizeof(struct x86_user_context));
|
||||
|
||||
ret = coredump(thread, regs, sig);
|
||||
switch (ret) {
|
||||
case -EBUSY:
|
||||
kprintf("%s: INFO: coredump not performed, try ulimit -c <non-zero>\n",
|
||||
__func__);
|
||||
break;
|
||||
case 0:
|
||||
coredumped = 0x80;
|
||||
break;
|
||||
default:
|
||||
kprintf("%s: ERROR: coredump failed (%d)\n",
|
||||
__func__, ret);
|
||||
break;
|
||||
}
|
||||
skip:
|
||||
terminate(0, sig | coredumped);
|
||||
break;
|
||||
case SIGCHLD:
|
||||
@ -1609,7 +1632,7 @@ set_signal(int sig, void *regs0, siginfo_t *info)
|
||||
}
|
||||
|
||||
if ((__sigmask(sig) & thread->sigmask.__val[0])) {
|
||||
coredump(thread, regs0);
|
||||
coredump(thread, regs0, sig);
|
||||
terminate(0, sig | 0x80);
|
||||
}
|
||||
do_kill(thread, thread->proc->pid, thread->tid, sig, info, 0);
|
||||
@ -1763,10 +1786,20 @@ out:
|
||||
|
||||
SYSCALL_DECLARE(clone)
|
||||
{
|
||||
return do_fork((int)ihk_mc_syscall_arg0(ctx), ihk_mc_syscall_arg1(ctx),
|
||||
struct process *proc = cpu_local_var(current)->proc;
|
||||
struct mcs_rwlock_node_irqsave lock_dump;
|
||||
unsigned long ret;
|
||||
|
||||
/* mutex coredump */
|
||||
mcs_rwlock_reader_lock(&proc->coredump_lock, &lock_dump);
|
||||
|
||||
ret = do_fork((int)ihk_mc_syscall_arg0(ctx), ihk_mc_syscall_arg1(ctx),
|
||||
ihk_mc_syscall_arg2(ctx), ihk_mc_syscall_arg3(ctx),
|
||||
ihk_mc_syscall_arg4(ctx), ihk_mc_syscall_pc(ctx),
|
||||
ihk_mc_syscall_sp(ctx));
|
||||
|
||||
mcs_rwlock_reader_unlock(&proc->coredump_lock, &lock_dump);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(fork)
|
||||
|
||||
Reference in New Issue
Block a user