@@ -226,8 +226,17 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
current->thread.segv_regs = container_of(regs, struct pt_regs, regs);
catcher = current->thread.fault_catcher;
- if (catcher && current->thread.is_running_test)
+ if (catcher && current->thread.is_running_test) {
+ /*
+ * TODO(b/77223210): Right now we don't have a way to store a
+ * copy of the stack, or a copy of information from the stack,
+ * so we need to print it now; otherwise, the stack will be
+ * destroyed by segv_run_catcher which works by popping off
+ * stack frames.
+ */
+ show_stack(NULL, NULL);
segv_run_catcher(catcher, (void *) address);
+ }
else if (!is_user && (address >= start_vm) && (address < end_vm)) {
flush_tlb_kernel_vm();
goto out;
@@ -210,12 +210,17 @@ static void test_handle_test_crash(struct test *test,
struct test_module *module,
struct test_case *test_case)
{
- test_err(test, "%s crashed", test_case->name);
/*
- * TODO(brendanhiggins@google.com): This prints the stack trace up
- * through this frame, not up to the frame that caused the crash.
+ * TODO(brendanhiggins@google.com): Right now we don't have a way to
+ * store a copy of the stack, or a copy of information from the stack,
+ * so we need to print it in the "trap" handler; otherwise, the stack
+ * will be destroyed when it returns to us by popping off the
+ * appropriate stack frames (see longjmp).
+ *
+ * Ideally we would print the stack trace here, but we do not have the
+ * ability to do so with meaningful information at this time.
*/
- show_stack(NULL, NULL);
+ test_err(test, "%s crashed", test_case->name);
test_case_internal_cleanup(test);
}
Sacrificed the control of printing stack trace within the crash handler in the test runner for getting a better stack trace; this is still not ideal, but much better than before. Signed-off-by: Brendan Higgins <brendanhiggins@google.com> --- arch/um/kernel/trap.c | 11 ++++++++++- kunit/test.c | 13 +++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-)