diff options
author | attilio <attilio@FreeBSD.org> | 2010-11-22 14:42:13 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2010-11-22 14:42:13 +0000 |
commit | 7718cbcbf47164ddaa66a748a050f670b3b37e1d (patch) | |
tree | 8831ac1227984e07e03c6ac1b5cf30bba847610f /usr.bin/gcore | |
parent | 225a98d4466b7d72ce67e249a3976b499437e798 (diff) | |
download | FreeBSD-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 'usr.bin/gcore')
-rw-r--r-- | usr.bin/gcore/elfcore.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index 5d655c3..9da22d7 100644 --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -284,10 +284,12 @@ elf_getstatus(pid_t pid, prpsinfo_t *psinfo) static void elf_puthdr(pid_t pid, vm_map_entry_t map, void *dst, size_t *off, int numsegs) { + struct ptrace_lwpinfo lwpinfo; struct { prstatus_t status; prfpregset_t fpregset; prpsinfo_t psinfo; + thrmisc_t thrmisc; } *tempdata; size_t ehoff; size_t phoff; @@ -300,6 +302,7 @@ elf_puthdr(pid_t pid, vm_map_entry_t map, void *dst, size_t *off, int numsegs) prstatus_t *status; prfpregset_t *fpregset; prpsinfo_t *psinfo; + thrmisc_t *thrmisc; ehoff = *off; *off += sizeof(Elf_Ehdr); @@ -315,11 +318,13 @@ elf_puthdr(pid_t pid, vm_map_entry_t map, 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; } errno = 0; @@ -356,11 +361,17 @@ elf_puthdr(pid_t pid, vm_map_entry_t map, void *dst, size_t *off, int numsegs) ptrace(PT_GETREGS, tids[i], (void *)&status->pr_reg, 0); ptrace(PT_GETFPREGS, tids[i], (void *)fpregset, 0); + ptrace(PT_LWPINFO, tids[i], (void *)&lwpinfo, + sizeof(lwpinfo)); + memset(&thrmisc->_pad, 0, sizeof(thrmisc->_pad)); + strcpy(thrmisc->pr_tname, lwpinfo.pl_tdname); } elf_putnote(dst, off, "FreeBSD", NT_PRSTATUS, status, sizeof *status); elf_putnote(dst, off, "FreeBSD", NT_FPREGSET, fpregset, sizeof *fpregset); + elf_putnote(dst, off, "FreeBSD", NT_THRMISC, thrmisc, + sizeof *thrmisc); } notesz = *off - noteoff; |