From owner-p4-projects@FreeBSD.ORG Sat Jun 12 07:39:57 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 006E816A4D1; Sat, 12 Jun 2004 07:39:56 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD72616A4CE for ; Sat, 12 Jun 2004 07:39:56 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0EE643D1F for ; Sat, 12 Jun 2004 07:39:56 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i5C7dnJ6099349 for ; Sat, 12 Jun 2004 07:39:49 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i5C7dn22099346 for perforce@freebsd.org; Sat, 12 Jun 2004 07:39:49 GMT (envelope-from marcel@freebsd.org) Date: Sat, 12 Jun 2004 07:39:49 GMT Message-Id: <200406120739.i5C7dn22099346@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 54708 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Jun 2004 07:39:57 -0000 http://perforce.freebsd.org/chv.cgi?CH=54708 Change 54708 by marcel@marcel_nfs on 2004/06/12 07:39:36 Implement the kernel thread support functions. We now have thread info in the debugger. Affected files ... .. //depot/projects/gdb/usr.bin/kgdb/kthr.c#3 edit Differences ... ==== //depot/projects/gdb/usr.bin/kgdb/kthr.c#3 (text+ko) ==== @@ -31,40 +31,87 @@ #include #include #include +#include #include #include #include +#include + +#include #include "kgdb.h" +static struct kthr *first; struct kthr *curkthr; struct kthr * kgdb_thr_first(void) { - return (NULL); + return (first); } struct kthr * kgdb_thr_init(void) { - return (NULL); + struct nlist nl[2]; + struct proc p; + struct thread td; + struct kthr *thr; + uintptr_t paddr, tdaddr; + + nl[0].n_name = (char *)(uintptr_t)"_allproc"; + nl[1].n_name = NULL; + if (kvm_nlist(kvm, nl) != 0) { + warnx(kvm_geterr(kvm)); + return (NULL); + } + kvm_read(kvm, nl[0].n_value, &paddr, sizeof(paddr)); + + while (paddr != 0) { + kvm_read(kvm, paddr, &p, sizeof(p)); + tdaddr = (uintptr_t)TAILQ_FIRST(&p.p_threads); + while (tdaddr != 0) { + kvm_read(kvm, tdaddr, &td, sizeof(td)); + if (td.td_last_frame != NULL) { + thr = malloc(sizeof(*thr)); + thr->next = first; + thr->kaddr = tdaddr; + thr->td_frame = td.td_last_frame; + thr->td_kstack = td.td_kstack; + thr->td_tid = td.td_tid; + first = thr; + } + tdaddr = (uintptr_t)TAILQ_NEXT(&td, td_plist); + } + paddr = (uintptr_t)LIST_NEXT(&p, p_list); + } + curkthr = first; + return (first); } struct kthr * -kgdb_thr_lookup(int tid __unused) +kgdb_thr_lookup(int tid) { - return (NULL); + struct kthr *thr; + + thr = first; + while (thr != NULL && thr->td_tid != tid) + thr = thr->next; + return (thr); } struct kthr * -kgdb_thr_next(struct kthr *thr __unused) +kgdb_thr_next(struct kthr *thr) { - return (NULL); + return (thr->next); } struct kthr * -kgdb_thr_select(struct kthr *thr __unused) +kgdb_thr_select(struct kthr *thr) { - return (NULL); + struct kthr *pcur; + + pcur = curkthr; + curkthr = thr; + return (pcur); }