Page MenuHomeFreeBSD

i386: stop guessing the address of the trap frame in ddb backtrace.
ClosedPublic

Authored by kib on Nov 11 2019, 10:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 27, 1:00 AM
Unknown Object (File)
Sat, Apr 27, 1:00 AM
Unknown Object (File)
Sat, Apr 27, 1:00 AM
Unknown Object (File)
Sat, Apr 27, 1:00 AM
Unknown Object (File)
Fri, Apr 26, 11:02 PM
Unknown Object (File)
Thu, Apr 25, 12:02 AM
Unknown Object (File)
Feb 7 2024, 7:23 PM
Unknown Object (File)
Dec 20 2023, 6:20 AM
Subscribers

Details

Summary

Save the address of the trap frame in %ebp on kernel entry. This automatically provides it in struct i386_frame.f_frame to unwinder.

While there, more accurately handle the terminating frames,

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Looks good to me in general.

sys/i386/i386/db_trace.c
383 ↗(On Diff #64212)

This comment is a little bit hard to read.
Maybe start with "This can be the case for" or something like that.

384 ↗(On Diff #64212)

After the change, "--- trap" won't be printed in this case, but probably that's okay?

412 ↗(On Diff #64212)

The new long condition is a little bit harder to parse than the previous code.
Maybe keep the switch statement but modify the if statement, so that the userland condition falls through to SYSCALL case.

switch (frame_type) {
case TRAP:
case INTERRUPT:
        if ((tf->tf_eflags & PSL_VM) == 0 &&
            (tf->tf_cs & SEL_RPL_MASK) == 0)
                break;
        /* FALLTHROUGH */
case SYSCALL:
        ebp = 0;
        eip = 0;
        break;
}
This revision is now accepted and ready to land.Nov 12 2019, 12:10 PM
kib marked 2 inline comments as done.Nov 12 2019, 3:29 PM
kib added inline comments.
sys/i386/i386/db_trace.c
384 ↗(On Diff #64212)

But that is the part of the improvement IMO. The kthread does not have trap frame on top of the stack.

I can add a frame type for fork_trampoline() just to print e.g. 'kthread start', but could as well leave it as is. It is really the last frame.

kib marked an inline comment as done.

Handle avg' suggestions.

Improve comment.
Restore switch(), but use TRAPF_USERMODE().
Print something after last frame of kthread.

This revision now requires review to proceed.Nov 12 2019, 3:30 PM

Looks great!

sys/i386/i386/db_trace.c
384 ↗(On Diff #64212)

Yes, I agree, that's okay.

This revision is now accepted and ready to land.Nov 12 2019, 3:46 PM