i am debugging my kernel with bochs ( gdb-stub enabled).
sometimes, the kernel trapped into 'page_fault" and gdb's command [bt] didn't work any more.
so, i want to locate the function who caused this time page-fault.
i can get the illegal address within my kernel by reading CR2, i can get the instuction address at that time by reading eip.
but how can i locate the function(in source code) with gdb. is there exist a command like :
locate 0xc0304000
?
(assume i know instruction in 0xc0304000 caused this time page-error).
how to locate a function by a constant address value?(in gdb
Re: how to locate a function by a constant address value?(in
ok, i think this command should be :
info symbol 0xc0304000
info symbol 0xc0304000
Re: how to locate a function by a constant address value?(in
Use the option to produce a link map when linking your kernel. This will list all symbols and their addresses. You can then see which function a particular address belongs to.
-
- Member
- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: how to locate a function by a constant address value?(in
Hi,
You can also compile/link the kernel with the -g option, which adds as many debugging symbols as possible. Then, run objdump -d /your/kernel/file, which will show the address of each instruction in text sections. If this somehow doesn't happen in text sections, you can try to pass the -D option to objdump, which will disassemble all sections in the binary.
Also, you can try to redirect the output to another file, so you can inspect the instructions more closely, not to mention that the result will probably not fit in the terminal scroll-back.
Hope this helps.
Regards,
glauxosdever
You can also compile/link the kernel with the -g option, which adds as many debugging symbols as possible. Then, run objdump -d /your/kernel/file, which will show the address of each instruction in text sections. If this somehow doesn't happen in text sections, you can try to pass the -D option to objdump, which will disassemble all sections in the binary.
Also, you can try to redirect the output to another file, so you can inspect the instructions more closely, not to mention that the result will probably not fit in the terminal scroll-back.
Hope this helps.
Regards,
glauxosdever