tech-kern archive

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

Re: AW: AW: Gdb and lkm modules with NetBSD-5



        Hello Peter.  It's been several months, but I wanted to write and tell
you that I got your script working, and it worked great.  The only problem
I had was that it looked for MISC06 in the output of objdump, but my
objdump was emitting MISC02.  I don't know why it was different, but once I
changed it, it linked everything together, started gdb and I was off to the
races!
        Again, thank you very much for your help.  With this script, I was
able to track down a problem that's been plaguing us for over a year and a
half.

-Thanks
-Brian
On Nov 19,  6:25pm, "Peter Reimers" wrote:
} Subject: AW: AW: Gdb and lkm modules with NetBSD-5
} This is a multi-part message in MIME format.
} 
} ------_=_NextPart_001_01CA693D.5BB2BEA6
} Content-Type: text/plain;
}       charset="iso-8859-1"
} Content-Transfer-Encoding: quoted-printable
} 
} Hi,
} 
} Brian Buhrow wrotes:
} > Hello Peter.  You're correct.  There's been no answer. =20
} > I'd be very interested in the script.=20
} > If you don't mind sharing, I'd love to have it.
} 
} o script is attached (igdbdump.sh).
} 
} o you must only specifiy=20
}   - the kernel             (by -N) e.g. -N /kernel.gdb
}   - the core-file          (by -M) e.g. -M /var/crash/netbsd.0.core
}   - the path to the LKM(s) (by -L) e.g  -L /usr/lkm
} 
}   All files (kernel and LKM(s)) should be compiled with -g
}  =20
}   See igdbdump -h or -hh for all options.
} 
} o have fun ;-)
} 
} o if something goes wrong, try or send us the output of a run with -v
}   (-v shows some debug-information/steps, maybe this helps)
} 
} o btw: we use the same kind of script to profile LKMs (by kgmon/gprof).
}        but this needs some little changes within the kernel/LKM code =
} too.
} 
} best regards
} :peter:
} 
} > -thanks
} > -Brian
} > On Nov 18, 10:14pm, "Peter Reimers" wrote:
} > } Subject: AW: Gdb and lkm modules with NetBSD-5
} > } Hi,
} > }=20
} > } Brian Buhrow wrotes:
} > } > Betreff: Gdb and lkm modules with NetBSD-5
} > } > Hello.=3D20
} > } > I'm trying to debug an lkm module under NetBSD-5.  I've built
} > } > netbsd with symbols in, and that works great for statically=3D20
} > } > linked modules.
} > } > However, I'd like to see the symbols of an lkm in the crash=3D20
} > } > 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?
} > }=20
} > } o there was no answer so far - so we assume there is no such gdb =3D
} > } command/script ?
} > }=20
} > } o we understand that the problem appears if LKM(s) (loaded=20
} > by modload) =3D
} > } crash
} > }   the kernel and should then debugged later with gdb on a=20
} > netbsd.N.core =3D
} > } coredump.
} > }   Right ?
} > }   Then maybe our solution could help (anyway it may be not=20
} > the easiest =3D
} > } way): =3D20
} > }  =3D20
} > } 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=20
} > symbols/files (e.g. =3D
} > } <lkm>.o)
} > }   to the gdb, but to do the 'relocation' to the adress=20
} > where the LKMs =3D
} > } was loaded.
} > }=20
} > } o So we solved this by a sh-script (using gdb and ld internally)
} > }=20
} > }   The script needs:
} > }   - the netbsd.N.core file
} > }   - the netbsd.N      file    (or the netbsd.gdb)
} > }   - the LKM           file(s) (the .o files)
} > }=20
} > }   Then its
} > }   a) read the lkm-name and data/code adresses of all loaded=20
} > LKMs out of =3D
} > } the .core file (by a gdb-script)
} > }      (instead you could use the output of modstat from the=20
} > system - =3D
} > } before it has core-dumped)
} > }   b) link (ld -R) the netbsd.N against all LKMs found (using =3D
} > } <lkm-name>.o and data/code adresses from a)
} > }      The result is one! new file with the symbols of the=20
} > kernel and =3D
} > } symbols of all loaded LKMs ... relocated!.
} > }   c) starts the gdb on the netbsd.N.core file and use the new file =
} =3D
} > } (created by b) for the symbols.
} > }=20
} > }   At the end, we see LKM symbols within stack-dump and could print =
} =3D
} > } global data-structures of LKMs.
} > }=20
} > }   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 =3D
} > } in-kernel-linking stuff works)
} > }=20
} > } o If you are interested ... we could send you this=20
} > sh-script to play =3D
} > } with (not well documented)
} > }   If not ... sorry for the noise.
} > }=20
} > } o If you allready found an easier way .... we are also=20
} > intrested in ;-)=3D20
} > } =3D20
} > }=20
} > } best regards
} > } :peter:=3D20
} > }=20
} > }=20


Home | Main Index | Thread Index | Old Index