summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2004-07-21 04:49:48 +0000
committermarcel <marcel@FreeBSD.org>2004-07-21 04:49:48 +0000
commit0afdd77e87f742c3e90ad01e2ba251fb15b086f8 (patch)
tree8bb8c899f61b15dd7d1cdb0376018b2ee69e8603 /sys
parenta1da1e9157198d9a90d15cc90ee5e98f6bdd83ea (diff)
downloadFreeBSD-src-0afdd77e87f742c3e90ad01e2ba251fb15b086f8.zip
FreeBSD-src-0afdd77e87f742c3e90ad01e2ba251fb15b086f8.tar.gz
Add kdb_thr_from_pid(), which given a PID returns the first thread
in the process. This is useful when working from or with a process.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_kdb.c16
-rw-r--r--sys/sys/kdb.h3
2 files changed, 17 insertions, 2 deletions
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c
index 0fc015e..e2ea277 100644
--- a/sys/kern/subr_kdb.c
+++ b/sys/kern/subr_kdb.c
@@ -316,7 +316,21 @@ kdb_thr_first(void)
}
struct thread *
-kdb_thr_lookup(pid_t tid)
+kdb_thr_from_pid(pid_t pid)
+{
+ struct proc *p;
+
+ p = LIST_FIRST(&allproc);
+ while (p != NULL) {
+ if (p->p_sflag & PS_INMEM && p->p_pid == pid)
+ return (FIRST_THREAD_IN_PROC(p));
+ p = LIST_NEXT(p, p_list);
+ }
+ return (NULL);
+}
+
+struct thread *
+kdb_thr_lookup(lwpid_t tid)
{
struct thread *thr;
diff --git a/sys/sys/kdb.h b/sys/sys/kdb.h
index 6a1b8f7..55a88f4 100644
--- a/sys/sys/kdb.h
+++ b/sys/sys/kdb.h
@@ -71,7 +71,8 @@ void * kdb_jmpbuf(jmp_buf);
void kdb_reenter(void);
struct pcb *kdb_thr_ctx(struct thread *);
struct thread *kdb_thr_first(void);
-struct thread *kdb_thr_lookup(pid_t);
+struct thread *kdb_thr_from_pid(pid_t);
+struct thread *kdb_thr_lookup(lwpid_t);
struct thread *kdb_thr_next(struct thread *);
int kdb_thr_select(struct thread *);
int kdb_trap(int, int, struct trapframe *);
OpenPOWER on IntegriCloud