tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

AW: Gdb and lkm modules with NetBSD-5


Brian Buhrow wrotes:
> Betreff: Gdb and lkm modules with NetBSD-5
> Hello. 
> I'm trying to debug an lkm module under NetBSD-5.  I've built
> netbsd with symbols in, and that works great for statically 
> linked modules.
> However, I'd like to see the symbols of an lkm in the crash 
> dump.  Is there a command to gdb that I can give which will
> load the symbols of the loaded modules as well as the
> netbsd.gdb file itself?

o there was no answer so far - so we assume there is no such gdb command/script 

o we understand that the problem appears if LKM(s) (loaded by modload) crash
  the kernel and should then debugged later with gdb on a netbsd.N.core 
  Right ?
  Then maybe our solution could help (anyway it may be not the easiest way):  
o we run into the same problem with netbsd 3.0 and now 5.0
  We discovered that the problem is not to add the symbols/files (e.g. <lkm>.o)
  to the gdb, but to do the 'relocation' to the adress where the LKMs was 

o So we solved this by a sh-script (using gdb and ld internally)

  The script needs:
  - the netbsd.N.core file
  - the netbsd.N      file    (or the netbsd.gdb)
  - the LKM           file(s) (the .o files)

  Then its
  a) read the lkm-name and data/code adresses of all loaded LKMs out of the 
.core file (by a gdb-script)
     (instead you could use the output of modstat from the system - before it 
has core-dumped)
  b) link (ld -R) the netbsd.N against all LKMs found (using <lkm-name>.o and 
data/code adresses from a)
     The result is one! new file with the symbols of the kernel and symbols of 
all loaded LKMs ... relocated!.
  c) starts the gdb on the netbsd.N.core file and use the new file (created by 
b) for the symbols.

  At the end, we see LKM symbols within stack-dump and could print global 
data-structures of LKMs.

  It works at least (tested)
  - for netbsd 3.0, 3.1 and 5.0
  - for i386 (and i386 Xen/PAE)
  - for modload/modstat LKMs (we are not sure if/how the new in-kernel-linking 
stuff works)

o If you are interested ... we could send you this sh-script to play with (not 
well documented)
  If not ... sorry for the noise.

o If you allready found an easier way .... we are also intrested in ;-) 

best regards

TELES AG Informationstechnologien
Ernst-Reuter-Platz 8
10587 Berlin
Web: <>
Vorstand: Prof. Dr.-Ing. Sigram Schindler (Vorsitz), Richard Fahringer, Frank 
Paetsch, Olaf Schulz
Aufsichtsrat: Prof. Dr. Walter L. Rust (Vorsitz), Prof. Dr. Radu 
Popescu-Zeletin, Prof. Dr. Ralph N. Schindler 
Handelsregister: Amtsgericht Berlin Charlottenburg, HRB 60781  

Home | Main Index | Thread Index | Old Index