Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Aug 2010 13:10:37 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Alexander Fiveg <pebu3op@googlemail.com>
Cc:        freebsd-hackers@freebsd.org, doc@freebsd.org
Subject:   Re: Debugging Loadable Modules Using GDB
Message-ID:  <201008301310.38148.jhb@freebsd.org>
In-Reply-To: <20100830161250.GA3135@debmaster-laptop>
References:  <20100827201140.GA2812@debmaster-laptop> <201008300816.11278.jhb@freebsd.org> <20100830161250.GA3135@debmaster-laptop>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, August 30, 2010 12:12:50 pm Alexander Fiveg wrote:
> On Mon, Aug 30, 2010 at 08:16:11AM -0400, John Baldwin wrote:
>  > On Friday, August 27, 2010 4:11:41 pm Alexander Fiveg wrote:
> > > Hi,
> > > from "FreeBSD Developers' Handbook, 10.7 Debugging Loadable Modules U=
sing
> > > GDB":
> > > "...
> > > (kgdb) add-symbol-file /sys/modules/linux/linux.ko 0xc0ae22d0
> > > ...
> > > "
> > > Actually I couldn't debug my modules using .ko-file. Moreover, I've f=
ind out=20
> > that .ko files do not contain sections with debugging info. With .kld-f=
ile=20
> > debugging works out. Do I something incorrectly or the info in the Deve=
lopers=20
> > Book is outdated?
> >=20
> > With newer versions of kgdb you shouldn't need to manually invoke 'add-=
symbol-
> > file'.  Kernel modules are treated as shared libraries and should=20
> > automatically be loaded.  Try using 'info sharedlibrary' to see the lis=
t of=20
> > kernel modules and if symbols for them are loaded already.
> Yes, the .ko files are loaded automatically. The problem is that they do
> not contain debugging info. I have always to load the .kld file in order =
to=20
> debug a module:
>=20
> (kgdb) f 9
> #9  0xc4dc558b in rm_8254_delayed_interrupt_per_packet () from
> /boot/kernel/if_ringmap.ko
> (kgdb) info locals
> No symbol table info available.
>=20
> (kgdb) add-symbol-file /home/alexandre/p4/ringmap/current/sys/modules/rin=
gmap/if_ringmap.kld 0xc4dafc70
> add symbol table from file "/home/alexandre/p4/ringmap/current/sys/module=
s/ringmap/if_ringmap.kld"
> at
> 	.text_addr =3D 0xc4dafc70
> (y or n) y
> Reading symbols from /home/alexandre/p4/ringmap/current/sys/modules/ringm=
ap/if_ringmap.kld...done.
>=20
> (kgdb) f 9=20
> #9  0xc4dc558b in rm_8254_delayed_interrupt_per_packet ()
>     at /home/alexandre/p4/ringmap/current/sys/modules/ringmap/../../dev/e=
1000/ringmap_8254.c:142
> 142	co->ring->slot[slot_num].ts =3D co->ring->last_ts;
>=20
> (kgdb) info locals
> co =3D (struct capt_object *) 0xc4d68380
> adapter =3D (struct adapter *) 0xc4e77000
> __func__ =3D "E\000\000=EF=BF=BD\034@\000\000\211\203=EF=BF=BDE\000\000\0=
17\206B\022\000\000\2039\000\213A\004\017\205=EF=BF=BD\f\000\000\001=EF=BF=
=BD=EF=BF=BD1=EF=BF=BD"
>=20
>=20
> Is there any way to get the all symbols and needed debug info without
> loading the .kld file ?

How are you compiling the kld?  If you are building it by hand, use
'make DEBUG_FLAGS=3D-g' when you build and install the kld.  That should bu=
ild
with debug symbols enabled and install the ko.symbols file which kgdb will
find and use.

=2D-=20
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008301310.38148.jhb>