[haiku-development] Re: Haiku network booting and packagefs

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 02 Apr 2016 13:08:06 +0200

On 04/01/2016 08:36 AM, Adrien Destugues wrote:

A tedious, but working strategy to find the exact location of the
triple fault is to bisect the code by adding an infinite loop.

I wanted to try this, but the KDiskDeviceManager is run twice (first
for the boot archive, then for the root filesystem), so I will need
something a bit more complex than just an infinite loop (I guess I
can add a static variable to count how many times the function has
been executed already).

Yep, you'll definitely need some condition around the infinite loop in certain cases and sometimes possibly even static debug variables (though often some kernel state can be checked instead).

do we have a way to send the logs on UDP broadcast or some other
thing over the network?

Unfortunately not (yet). Having an alternative to serial debugging
would be very useful, though.

I tried to implement this in a form similar to
http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/debugger/bochs
(replacing the out to a fixed port with writing to an UDP socket, of
course). I added my module to the boot archive and added a symlink in
boot/, but as far as I can tell the module init was never called
before my reboot problem. Is there another place where I should plug
for this to work, or a way to force loading the module early? Do I
need to make my module depend on the network stack (since it uses
sockets) and how do I accomplish that? Is it safe to just try
creating a socket (and retry each time debug_puts is called, until it
succeeds)?

I think just trying to create a socket should work fine.

Debugger modules are initialized in debug_init_post_modules(). From what you wrote, your crash may already happen earlier.

Or any other way I could get the logs?

There's the debug syslog feature. It doesn't always work on all
computers. If it doesn't for you, you could try a different
(greater?) base address [1].

This works on my machine, but I'm not sure the very last logged
messages are always available after reboot. Sometimes the log was
ending earlier than what I saw with on-screen debug paging. I'm not
sure why this would happen.

That may be due to caching effects. I suspect a triple fault causes any cached and not written back writes to be discarded. We don't specify any particular caching policy/memory type for the debug syslog area [1], so it would be write-back and writes to it wouldn't go through to memory immediately. You could try adding (untested)

        physical_entry entry;
        if (get_memory_map(base, B_PAGE_ &entry, 1) == B_OK)
                vm_set_area_memory_type(area, entry.address, B_MTR_WT);

to change the memory type to write-through.

CU, Ingo

[1] http://cgit.haiku-os.org/haiku/tree/src/system/kernel/debug/debug.cpp?h=hrev50180#n1377

Other related posts: