From owner-freebsd-current Fri Mar 7 20:25:18 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7C74537B401 for ; Fri, 7 Mar 2003 20:25:15 -0800 (PST) Received: from mail.gmx.net (mail.gmx.net [213.165.65.60]) by mx1.FreeBSD.org (Postfix) with SMTP id 28C3E43FAF for ; Fri, 7 Mar 2003 20:25:14 -0800 (PST) (envelope-from JunSu@gmx.net) Received: (qmail 18212 invoked by uid 0); 8 Mar 2003 04:25:06 -0000 Received: from unknown (HELO 211.161.222.21) (211.161.222.21) by mail.gmx.net (mp007-rz3) with SMTP; 8 Mar 2003 04:25:06 -0000 From: Jun Su To: freebsd-current@freebsd.org Subject: GDB kernel debug new command Date: Sat, 8 Mar 2003 12:24:53 +0800 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303081224.53273.JunSu@gmx.net> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi All, To help myself more easily check the kernel dump, I added two new command. One is ps, the other is kldstat. I know we can print the kernel data manually to get the same information. I still think this is useful. This can help the newbies to get the information without many knowledge about the kernel. This also can help the experienced user to get the data more quickly. Here is the new file. Just put it in /usr/src/gnu/usr.bin/binutils/gdb. And add the file to Makefile. Please give me some comments if this is garbage. :) Jun Su --/usr/src/gnu/usr.bin/binutils/gdb/fbsd-kgdbpack.c-- #include "fbsd-kgdb.h" #include "defs.h" #include "command.h" #include "symtab.h" #define _KERNEL #include #include #undef _KERNEL #include static void kgdbpack_kldstat_cmd(char* arg, int from_tty) { CORE_ADDR allfile_addr; CORE_ADDR startfile; struct minimal_symbol *sym; char buf[sizeof(struct linker_file)]; char namebuf[256]; sym = lookup_minimal_symbol("linker_files",NULL,NULL); if (!sym) error ("can not find the linker_files symbosl.\n"); allfile_addr = SYMBOL_VALUE_ADDRESS(sym); namebuf[255]=0; struct linker_file *lf = (struct linker_file *)buf; target_read_memory(allfile_addr, &startfile, sizeof(startfile)); printf("Id\tRefs\tAddress \tSize\tName\n"); while(startfile) { target_read_memory(startfile, buf, sizeof(struct linker_file)); target_read_memory((int)lf->filename, namebuf, 254); printf ("%d\t%d\t0x%8X\t%x\t%s\n", lf->id, lf->refs, lf->address, lf->size, namebuf); startfile = (CORE_ADDR)lf->link.tqe_next; } return; } static void kgdbpack_ps_cmd(char* argv, int from_tty) { CORE_ADDR allproc_addr; CORE_ADDR procstart; struct minimal_symbol *sym; sym = lookup_minimal_symbol("allproc",NULL,NULL); if (!sym) error ("No symbol allproc found."); allproc_addr = SYMBOL_VALUE_ADDRESS(sym); target_read_memory(allproc_addr, &procstart, sizeof(int)); char buf[sizeof(struct proc)]; struct proc *p = (struct proc*)buf; printf("ADDRESS\tPID\tSTAT\tCOMMAND\n"); while (procstart) { target_read_memory(procstart, buf, sizeof(struct proc)); printf("%08x\t%d\t0\t%s\n", procstart, p->p_pid, p->p_comm); procstart = p->p_list.le_next; } } void _initialize_kgdbpack() { add_com ("kldstat", class_obscure, kgdbpack_kldstat_cmd, "KLDSTAT cmd clone"); add_com ("ps", class_obscure, kgdbpack_ps_cmd, "PS cmd clone"); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message