tech-kern archive

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

Re: Regarding the debugging through Qemu on Preken




23-Jan-2020 1:34:23 am maya%NetBSD.org@localhost:

> On Wed, Jan 22, 2020 at 02:41:46PM +0530, Neeraj Pal wrote:
>
> > Hi there,
> >
> > First of all thanks to Maxime Villard and the team for the different
> > approach on KASLR implementation, "prekern".
> >
> > Out of curiosity, I am learning about the internals of the prekern by
> > reading the source code and also trying to attach the debugger as well to
> > read the code with the flow.
> > I have tried some setups but none of them is working to put a break point
> > on the functions mentioned in prekern.c file, like init_prekern(), etc.
> >
> > My setup includes
> > Debugger machine : NetBSD-9.RC1 amd64
> > Debuggee machine : NetBSD-9.RC1 amd64
> >
> > I have compiled the code on debugger machine and copied the netbsd_kaslr
> > and prekern binary (prekern from /usr/mdec/prekern) to the taget debuggee
> > machine.
> > Then, invoked the target debuggee machine using qemu-system-x86_64 with -S
> > and -s options and attached the gdb from debugger machine to debuggee
> > machine using :1234 port.
> >
> > I am able to see the code files and able to put the breakpoints on other
> > functions/syscalls but not able to put breakpoint on init_prekern(). It
> > seems that the init_prekern() is not in the debug symbols, not sure why?.
> >
>
>
> I think it might be in the bootloader, not the actual kernel.
>
Yes, you are right. Thanks for the help.

Actually, I was loading the real kernel image into the gdb instead of prekern image and I forgot that Maxime Villard has already mentioned in his blog (https://m00nbsd.net/542a5cfd448aaf7db7adcadce74123d2.html) that prekern is an intermediary kernel which jumps into the real kernel.

So, I have tried again with loading the prekern binary into the gdb and then in the second machine, executed "pkboot netbsd_kaslr" from the bootloader prompt and it works. Debugger hits the functions inside the prekern source code.

Thanks,
Neeraj




Home | Main Index | Thread Index | Old Index