tech-kern archive

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

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



        Hello Peter.  You're correct.  There's been no answer.  I'd be very
interested in the script.  If you don't mind sharing, I'd love to have it.
-thanks
-Brian
On Nov 18, 10:14pm, "Peter Reimers" wrote:
} Subject: AW: Gdb and lkm modules with NetBSD-5
} Hi,
} 
} Brian Buhrow wrotes:
} > Betreff: Gdb and lkm modules with NetBSD-5
} > Hello.=20
} > I'm trying to debug an lkm module under NetBSD-5.  I've built
} > netbsd with symbols in, and that works great for statically=20
} > linked modules.
} > However, I'd like to see the symbols of an lkm in the crash=20
} > 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 =
} coredump.
}   Right ?
}   Then maybe our solution could help (anyway it may be not the easiest =
} way): =20
}  =20
} 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 loaded.
} 
} 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 ;-)=20
} =20
} 
} best regards
} :peter:=20
} 
} 
} -------------------------------------------------------------------------=
} -------------------------=20
} TELES AG Informationstechnologien
} Ernst-Reuter-Platz 8
} 10587 Berlin
} Web:     www.teles.de <http://www.teles.de>
} -------------------------------------------------------------------------=
} -------------------------
} 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=20
} Handelsregister: Amtsgericht Berlin Charlottenburg, HRB 60781 =20
>-- End of excerpt from "Peter Reimers"




Home | Main Index | Thread Index | Old Index