summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2010-11-22 14:42:13 +0000
committerattilio <attilio@FreeBSD.org>2010-11-22 14:42:13 +0000
commit7718cbcbf47164ddaa66a748a050f670b3b37e1d (patch)
tree8831ac1227984e07e03c6ac1b5cf30bba847610f /sys/kern
parent225a98d4466b7d72ce67e249a3976b499437e798 (diff)
downloadFreeBSD-src-7718cbcbf47164ddaa66a748a050f670b3b37e1d.zip
FreeBSD-src-7718cbcbf47164ddaa66a748a050f670b3b37e1d.tar.gz
Add the ability for GDB to printout the thread name along with other
thread specific informations. In order to do that, and in order to avoid KBI breakage with existing infrastructure the following semantic is implemented: - For live programs, a new member to the PT_LWPINFO is added (pl_tdname) - For cores, a new ELF note is added (NT_THRMISC) that can be used for storing thread specific, miscellaneous, informations. Right now it is just popluated with a thread name. GDB, then, retrieves the correct informations from the corefile via the BFD interface, as it groks the ELF notes and create appropriate pseudo-sections. Sponsored by: Sandvine Incorporated Tested by: gianni Discussed with: dim, kan, kib MFC after: 2 weeks
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/imgact_elf.c10
-rw-r--r--sys/kern/sys_process.c3
2 files changed, 13 insertions, 0 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index e29ddfa..42f5573 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -1316,12 +1316,14 @@ typedef struct prpsinfo32 elf_prpsinfo_t;
typedef struct fpreg32 elf_prfpregset_t;
typedef struct fpreg32 elf_fpregset_t;
typedef struct reg32 elf_gregset_t;
+typedef struct thrmisc32 elf_thrmisc_t;
#else
typedef prstatus_t elf_prstatus_t;
typedef prpsinfo_t elf_prpsinfo_t;
typedef prfpregset_t elf_prfpregset_t;
typedef prfpregset_t elf_fpregset_t;
typedef gregset_t elf_gregset_t;
+typedef thrmisc_t elf_thrmisc_t;
#endif
static void
@@ -1331,10 +1333,12 @@ __elfN(puthdr)(struct thread *td, void *dst, size_t *off, int numsegs)
elf_prstatus_t status;
elf_prfpregset_t fpregset;
elf_prpsinfo_t psinfo;
+ elf_thrmisc_t thrmisc;
} *tempdata;
elf_prstatus_t *status;
elf_prfpregset_t *fpregset;
elf_prpsinfo_t *psinfo;
+ elf_thrmisc_t *thrmisc;
struct proc *p;
struct thread *thr;
size_t ehoff, noteoff, notesz, phoff;
@@ -1357,11 +1361,13 @@ __elfN(puthdr)(struct thread *td, void *dst, size_t *off, int numsegs)
status = &tempdata->status;
fpregset = &tempdata->fpregset;
psinfo = &tempdata->psinfo;
+ thrmisc = &tempdata->thrmisc;
} else {
tempdata = NULL;
status = NULL;
fpregset = NULL;
psinfo = NULL;
+ thrmisc = NULL;
}
if (dst != NULL) {
@@ -1401,11 +1407,15 @@ __elfN(puthdr)(struct thread *td, void *dst, size_t *off, int numsegs)
fill_regs(thr, &status->pr_reg);
fill_fpregs(thr, fpregset);
#endif
+ memset(&thrmisc->_pad, 0, sizeof (thrmisc->_pad));
+ strcpy(thrmisc->pr_tname, thr->td_name);
}
__elfN(putnote)(dst, off, "FreeBSD", NT_PRSTATUS, status,
sizeof *status);
__elfN(putnote)(dst, off, "FreeBSD", NT_FPREGSET, fpregset,
sizeof *fpregset);
+ __elfN(putnote)(dst, off, "FreeBSD", NT_THRMISC, thrmisc,
+ sizeof *thrmisc);
/*
* Allow for MD specific notes, as well as any MD
* specific preparations for writing MI notes.
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index af6b298..e5d9842 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -93,6 +93,7 @@ struct ptrace_lwpinfo32 {
sigset_t pl_sigmask; /* LWP signal mask */
sigset_t pl_siglist; /* LWP pending signal */
struct siginfo32 pl_siginfo; /* siginfo for signal */
+ char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */
};
#endif
@@ -520,6 +521,7 @@ ptrace_lwpinfo_to32(const struct ptrace_lwpinfo *pl,
pl32->pl_sigmask = pl->pl_sigmask;
pl32->pl_siglist = pl->pl_siglist;
siginfo_to_siginfo32(&pl->pl_siginfo, &pl32->pl_siginfo);
+ strcpy(pl32->pl_tdname, pl->pl_tdname);
}
#endif /* COMPAT_FREEBSD32 */
@@ -1164,6 +1166,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
pl->pl_flags |= PL_FLAG_EXEC;
pl->pl_sigmask = td2->td_sigmask;
pl->pl_siglist = td2->td_siglist;
+ strcpy(pl->pl_tdname, td2->td_name);
#ifdef COMPAT_FREEBSD32
if (wrap32)
ptrace_lwpinfo_to32(pl, pl32);
OpenPOWER on IntegriCloud