kthr.c (173681) | kthr.c (175452) |
---|---|
1/* 2 * Copyright (c) 2004 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2004 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/kthr.c 173681 2007-11-16 22:17:37Z jhb $"); | 28__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/kthr.c 175452 2008-01-18 18:57:27Z emaste $"); |
29 30#include <sys/param.h> 31#include <sys/proc.h> 32#include <sys/types.h> 33#include <sys/signal.h> 34#include <err.h> 35#include <inttypes.h> 36#include <kvm.h> 37#include <stdio.h> 38#include <stdlib.h> | 29 30#include <sys/param.h> 31#include <sys/proc.h> 32#include <sys/types.h> 33#include <sys/signal.h> 34#include <err.h> 35#include <inttypes.h> 36#include <kvm.h> 37#include <stdio.h> 38#include <stdlib.h> |
39#include <string.h> |
|
39 40#include <defs.h> 41#include <frame-unwind.h> 42 43#include "kgdb.h" 44#include <machine/pcb.h> 45 46static uintptr_t dumppcb; --- 152 unchanged lines hidden (view full) --- 199 pcur = curkthr; 200 curkthr = kt; 201 return (pcur); 202} 203 204char * 205kgdb_thr_extra_thread_info(int tid) 206{ | 40 41#include <defs.h> 42#include <frame-unwind.h> 43 44#include "kgdb.h" 45#include <machine/pcb.h> 46 47static uintptr_t dumppcb; --- 152 unchanged lines hidden (view full) --- 200 pcur = curkthr; 201 curkthr = kt; 202 return (pcur); 203} 204 205char * 206kgdb_thr_extra_thread_info(int tid) 207{ |
208 char comm[MAXCOMLEN + 1]; 209 char td_name[MAXCOMLEN + 1]; |
|
207 struct kthr *kt; 208 struct proc *p; | 210 struct kthr *kt; 211 struct proc *p; |
209 static char comm[MAXCOMLEN + 1]; | 212 struct thread *t; 213 static char info[MAXCOMLEN + 1 + MAXCOMLEN + 1]; |
210 211 kt = kgdb_thr_lookup_tid(tid); 212 if (kt == NULL) 213 return (NULL); 214 p = (struct proc *)kt->paddr; | 214 215 kt = kgdb_thr_lookup_tid(tid); 216 if (kt == NULL) 217 return (NULL); 218 p = (struct proc *)kt->paddr; |
219 t = (struct thread *)kt->kaddr; |
|
215 if (kvm_read(kvm, (uintptr_t)&p->p_comm[0], &comm, sizeof(comm)) != 216 sizeof(comm)) 217 return (NULL); | 220 if (kvm_read(kvm, (uintptr_t)&p->p_comm[0], &comm, sizeof(comm)) != 221 sizeof(comm)) 222 return (NULL); |
218 219 return (comm); | 223 if (kvm_read(kvm, (uintptr_t)&t->td_name[0], &td_name, 224 sizeof(td_name)) == sizeof(td_name) && 225 strcmp(comm, td_name) != 0) 226 snprintf(info, sizeof(info), "%s/%s", comm, td_name); 227 else 228 strlcpy(info, comm, sizeof(info)); 229 return (info); |
220} | 230} |