[haiku-development] Re: UEFI: gRuntimeLoader function pointers wrong

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 10 Dec 2016 11:51:42 +0100

On 12/10/2016 07:57 AM, Jessica Hamilton wrote:

On 10 December 2016 at 12:18, Ingo Weinhold <ingo_weinhold@xxxxxx> wrote:
As Fredrik already pointed out, the different load addresses are due to
ASLR. It may or may not be useful to disable it to get reproducible results.

For debugging early userland crashes I'd recommend panic()ing in
vm_page_fault() (turn dprintf() into panic() [1]). This way you have at
least the kernel debugging facilities at your disposal to inspect the
crashed team.
[1] 
http://cgit.haiku-os.org/haiku/tree/src/system/kernel/vm/vm.cpp?id=19d8d9fa3983e6687caeab8fe1193861a5202ab6#n4283

I had added a call to kernel_debugger in the function that attempts to
start the userland debugger, but this works too :)

Sure, same thing really. :-)

Having access to the kernel debugger is one thing, knowing what to
look for is another...

I usually start with a disassembly of the crashing instruction and the previous ones (mostly up to the beginning of the function) and try to reconstruct where the bad address came from (tracing back the register/memory assignments) and match it against the source code. Having an objdump of the concerned executable/library at hand for reference ("objdump -D --demangle <file>" -- you can additionally intermix source code with '-S') helps a lot.

From there on it depends on what you find. If it is some value that should be different, you'll need to track down, at which place that value is written and continue debugging there. While not particularly comfortable to use, the kernel debugger has support for kernel breakpoints and watchpoints. You can also set them programmatically (arch_{set,clear}_kernel_{break,watch}point()).

I haven't tried that yet, but in theory it should also be possible to write
a core dump [2] at that point. You'll need Haiku's Debugger to analyze it --
the format is only marginally compatible with Linux/BSD core dumps.
[2] 
http://cgit.haiku-os.org/haiku/tree/headers/private/kernel/core_dump.h?id=19d8d9fa3983e6687caeab8fe1193861a5202ab6#n14

This doesn't seem to be available from the kernel debugger...

No, I meant you'd have to call core_dump_write_core_file() from vm_page_fault() (or install_team_debugger()).

CU, Ingo


Other related posts: