Date: Sat, 8 Mar 2003 12:24:53 +0800 From: Jun Su <JunSu@gmx.net> To: freebsd-current@freebsd.org Subject: GDB kernel debug new command Message-ID: <200303081224.53273.JunSu@gmx.net>
next in thread | raw e-mail | index | archive | help
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 <sys/queue.h> #include <sys/linker.h> #undef _KERNEL #include <sys/proc.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303081224.53273.JunSu>