From owner-cvs-src@FreeBSD.ORG Mon Jan 28 23:09:36 2008 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37B8F16A524; Mon, 28 Jan 2008 23:09:36 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id BE62113C44B; Mon, 28 Jan 2008 23:09:35 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8s) with ESMTP id 230036742-1834499 for multiple; Mon, 28 Jan 2008 18:09:18 -0500 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m0SN8iU7087147; Mon, 28 Jan 2008 18:09:17 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: src-committers@freebsd.org Date: Mon, 28 Jan 2008 16:59:09 -0500 User-Agent: KMail/1.9.7 References: <200801282140.m0SLeAKC035073@repoman.freebsd.org> In-Reply-To: <200801282140.m0SLeAKC035073@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801281659.09265.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 28 Jan 2008 18:09:17 -0500 (EST) X-Virus-Scanned: ClamAV 0.91.2/5588/Mon Jan 28 16:24:15 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: cvs-src@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/gnu/usr.bin/gdb/kgdb kgdb.h kld.c trgt.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jan 2008 23:09:36 -0000 On Monday 28 January 2008 04:40:10 pm John Baldwin wrote: > jhb 2008-01-28 21:40:10 UTC > > FreeBSD src repository > > Modified files: > gnu/usr.bin/gdb/kgdb kgdb.h kld.c trgt.c > Log: > Add support for automatically loading symbols for kld's on startup: > - Add a new 'kgdb_auto_load_klds()' routine which is invoked during > startup that walks the list of linker files and tries to find a matching > kld on disk for each non-kernel kld. If a kld file is found, then it > is added as if the 'add-kld' command is invoked. One change from > 'add-kld' is that this method attempts to use the 'pathname' from the > linker_file structure first to try to load the file. If that fails > it then looks in the kernel directory followed by the directories in > the module path. > - Move the kld file suffix handling into a separate routine so that it > can be called standalone and to reduce duplicate code in find_kld_path(). > - Cache the offsets of members of 'struct linker_file' during startup > instead of computing them for each 'add-kld'. > - Use GDB's target_read_string() instead of direct KVM access. > - Add all resident sections from a kld by using bfd_map_over_sections() to > build the section list rather than just adding symbols for ".text", > ".data", ".bss", and ".rodata". > - Change the 'add-kld' command to do a y/n prompt before adding the > symbols when run interactively to match 'add-symbol-file'. Now 'add-kld' can be optional, you can always use it if the automatic magic picks a poor foo.ko (e.g. a stripped one w/o symbols). Example: > sudo ./kgdb -q -c /usr/crash/vmcore.10 /boot/kernel/kernel [GDB will not be able to debug user-mode threads: /usr/lib/libthread_db.so: Undefined symbol "ps_pglobal_lookup"] Loaded symbols for kld "crash.ko" from "/boot/modules/crash.ko" #0 doadump () at pcpu.h:195 195 pcpu.h: No such file or directory. in pcpu.h (kgdb) where #0 doadump () at pcpu.h:195 #1 0xc05d399c in boot (howto=260) at /usr/src/sys/kern/kern_shutdown.c:417 #2 0xc05d3c0a in panic (fmt=Variable "fmt" is not available. ) at /usr/src/sys/kern/kern_shutdown.c:571 #3 0xc08115d9 in dblfault_handler () at /usr/src/sys/i386/i386/trap.c:927 #4 0xc05c6220 in mtx_pool_setup_dynamic () #5 0xc065e125 in arc4rand (ptr=0xe61b0168, len=4, reseed=0) at /usr/src/sys/libkern/arc4random.c:142 #6 0xc065e171 in arc4random () at /usr/src/sys/libkern/arc4random.c:150 #7 0xc3d43402 in blow_stack () at crash.c:773 #8 0xc3d43410 in blow_stack () at crash.c:764 #9 0xc3d43410 in blow_stack () at crash.c:764 (Note that blow_stack() is in crash.ko and the stack trace worked right away.) It even works for the live kernel (scary): > sudo ./kgdb -q /boot/kernel/kernel /dev/mem [GDB will not be able to debug user-mode threads: /usr/lib/libthread_db.so: Undefined symbol "ps_pglobal_lookup"] Loaded symbols for kld "iwi_bss.ko" from "/boot/kernel/iwi_bss.ko" Loaded symbols for kld "logo_saver.ko" from "/boot/kernel/logo_saver.ko" #0 sched_switch (td=0xc08fdb90, newtd=Variable "newtd" is not available. ) at /usr/src/sys/kern/sched_ule.c:1905 1905 cpuid = PCPU_GET(cpuid); (kgdb) Now just need to axe that '[GDB will not be able blah blah blah]' message. Note that you can't see which kld's are loaded currently. At some point I will rewrite the kld support to actually hook into GDB's shared library support so that 'info sharedlibrary' will work. I'm slowly learning GDB internals, but that bit will probably take a while. -- John Baldwin