From owner-freebsd-hackers Tue Oct 8 6:37:54 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 798E137B401 for ; Tue, 8 Oct 2002 06:37:53 -0700 (PDT) Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id CFF5843E4A for ; Tue, 8 Oct 2002 06:37:52 -0700 (PDT) (envelope-from gallatin@cs.duke.edu) Received: from grasshopper.cs.duke.edu (grasshopper.cs.duke.edu [152.3.145.30]) by duke.cs.duke.edu (8.9.3/8.9.3) with ESMTP id JAA29916; Tue, 8 Oct 2002 09:37:52 -0400 (EDT) Received: (from gallatin@localhost) by grasshopper.cs.duke.edu (8.11.6/8.9.1) id g98DbMK52337; Tue, 8 Oct 2002 09:37:22 -0400 (EDT) (envelope-from gallatin@cs.duke.edu) From: Andrew Gallatin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15778.57234.386016.42431@grasshopper.cs.duke.edu> Date: Tue, 8 Oct 2002 09:37:22 -0400 (EDT) To: Ian Dowse Cc: hackers@freebsd.org Subject: Re: gdb support for kernel modules In-Reply-To: <20021007234145.GC1408@hades.hell.gr> References: <200210071709.aa25499@salmon.maths.tcd.ie> <20021007234145.GC1408@hades.hell.gr> X-Mailer: VM 6.75 under 21.1 (patch 12) "Channel Islands" XEmacs Lucid Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Giorgos Keramidas writes: > On 2002-10-07 17:09, Ian Dowse wrote: > > > > This is something I have been meaning to investigate for a while: [...] > > Anyway, below is a proof-of-concept patch that does the basics, but > > among other things, its logic for locating the kernel module files > > needs a lot of work - currently it just assumes /boot/kernel/, > > > diff -N solib-fbsd-kld.c > > --- /dev/null 1 Jan 1970 00:00:00 -0000 > > +++ solib-fbsd-kld.c 7 Oct 2002 10:39:48 -0000 > > > + snprintf (new->so_name, SO_NAME_MAX_PATH_SIZE, "/boot/kernel/%s", > > + new->so_original_name); > > I'm not really sure this would work for remote gdb sessions, but locally > it's probably more correct to use sysctl and grab the value of > kern.module_path or kern.bootfile instead of hardwiring `/boot/kernel/%s'. gdbmods does an ugly thing which is incredibly useful. It assumes that the modules you want to debug are sitting in your kernel build pool. So what it does is extract the build directory from the kernel (using strings), and runs a find rooted there for the module in question. But its a shell script, so it can get away with stuff like that ;) Perhaps we could embed the build directory somewhere the elf headers of each kernel module (including the kernel) so that kgdb could find the corresponding build file with symbols. Then your (very cool) solib-fbsd-kld.c could easily find the kernel and modules which match the kernel you're debugging.. Drew To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message