[Crash-utility] [PATCH v7 10/15] Stop stack unwinding at non-kernel address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The stack unwinding is for kernel addresses only. If non-kernel address
encountered, it is usually a user space address, or non-address value
like a function call parameter. So stopping stack unwinding at non-kernel
address will decrease the invalid unwind results.

Before:
crash> gdb bt
 #0  0xffffffff816a8f65 in context_switch ...
 #1  __schedule () ...
 #2  0xffffffff816a94e9 in schedule ...
 #3  0xffffffff816a86fd in schedule_hrtimeout_range_clock ...
 #4  0xffffffff816a8733 in schedule_hrtimeout_range ...
 #5  0xffffffff8124bb7e in ep_poll ...
 #6  0xffffffff8124d00d in SYSC_epoll_wait ...
 #7  SyS_epoll_wait ...
 #8  <signal handler called>
 #9  0x00007f0449407923 in ?? ()
 #10 0xffff880100000001 in ?? ()
 #11 0xffff880169b3c010 in ?? ()
 #12 0x0000000000000040 in irq_stack_union ()
 #13 0xffff880169b3c058 in ?? ()
 #14 0xffff880169b3c048 in ?? ()
 #15 0xffff880169b3c050 in ?? ()
 #16 0x0000000000000000 in ?? ()

After:
crash> gdb bt
 #0  0xffffffff816a8f65 in context_switch ...
 #1  __schedule () ...
 #2  0xffffffff816a94e9 in schedule () ...
 #3  0xffffffff816a86fd in schedule_hrtimeout_range_clock ...
 #4  0xffffffff816a8733 in schedule_hrtimeout_range ...
 #5  0xffffffff8124bb7e in ep_poll ...
 #6  0xffffffff8124d00d in SYSC_epoll_wait ...
 #7  SyS_epoll_wait ...
 #8  <signal handler called>
Backtrace stopped due to non-kernel addr: 0x7f0449407923

Cc: Sourabh Jain <sourabhjain@xxxxxxxxxxxxx>
Cc: Hari Bathini <hbathini@xxxxxxxxxxxxx>
Cc: Mahesh J Salgaonkar <mahesh@xxxxxxxxxxxxx>
Cc: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
Cc: Lianbo Jiang <lijiang@xxxxxxxxxx>
Cc: HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@xxxxxxx>
Cc: Tao Liu <ltao@xxxxxxxxxx>
Cc: Alexey Makhalov <alexey.makhalov@xxxxxxxxxxxx>
Cc: Aditya Gupta <adityag@xxxxxxxxxxxxx>
Signed-off-by: Tao Liu <ltao@xxxxxxxxxx>
---
 defs.h          |  1 +
 gdb-10.2.patch  | 32 ++++++++++++++++++++++++++++++++
 gdb_interface.c |  6 ++++++
 3 files changed, 39 insertions(+)

diff --git a/defs.h b/defs.h
index 0d16721..adf45a1 100644
--- a/defs.h
+++ b/defs.h
@@ -7934,6 +7934,7 @@ extern unsigned char *gdb_prettyprint_arrays;
 extern unsigned int *gdb_repeat_count_threshold;
 extern unsigned char *gdb_stop_print_at_null;
 extern unsigned int *gdb_output_radix;
+int is_kvaddr(ulong);
 
 /*
  *  gdb/top.c
diff --git a/gdb-10.2.patch b/gdb-10.2.patch
index 0bed96a..7f66e5c 100644
--- a/gdb-10.2.patch
+++ b/gdb-10.2.patch
@@ -16171,3 +16171,35 @@ exit 0
  }
  
  /*
+--- gdb-10.2/gdb/stack.c.orig
++++ gdb-10.2/gdb/stack.c
+@@ -1990,6 +1990,11 @@
+ /* Print briefly all stack frames or just the innermost COUNT_EXP
+    frames.  */
+ 
++#ifdef CRASH_MERGE
++extern "C" int is_kvaddr(ulong);
++extern "C" int gdb_CRASHDEBUG(ulong);
++#endif
++
+ static void
+ backtrace_command_1 (const frame_print_options &fp_opts,
+ 		     const backtrace_cmd_options &bt_opts,
+@@ -2082,6 +2086,17 @@
+ 	     hand, perhaps the code does or could be fixed to make sure
+ 	     the frame->prev field gets set to NULL in that case).  */
+ 
++#ifdef CRASH_MERGE
++	  CORE_ADDR pc = 0;
++	  get_frame_pc_if_available (fi, &pc);
++	  if (!is_kvaddr(pc)) {
++	    if (gdb_CRASHDEBUG(1)) {
++	      printf_filtered (_("Backtrace stopped: due to non-kernel addr: 0x%lx\n"),pc);
++	    }
++	    fi = NULL;
++	    break;
++	  }
++#endif
+ 	  print_frame_info (fp_opts, fi, 1, LOCATION, 1, 0);
+ 	  if ((flags & PRINT_LOCALS) != 0)
+ 	    {
diff --git a/gdb_interface.c b/gdb_interface.c
index ab4ebd3..315711e 100644
--- a/gdb_interface.c
+++ b/gdb_interface.c
@@ -947,6 +947,12 @@ gdb_lookup_module_symbol(ulong addr, ulong *offset)
 	}
 }
 
+int
+is_kvaddr(ulong addr)
+{
+	return IS_KVADDR(addr);
+}
+
 /*
  *  Used by gdb_interface() to catch gdb-related errors, if desired.
  */
-- 
2.40.1
--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux