Now we're developping the feature of makedumpfile producing vmcore in
kdump-compressed format from sadump-related formats. The vmcores
generated from the sadump-related formats have register set collected
by sadump as ELF note, meaning that the registers could be the values
collected during execution in kernel text or user space; of course,
they could also be broken just as register set collected by kdump for
non-panic tasks.

Currently, on sadump-related formats, bt command displays register set
at top level, but doesn't on kdump-compressed format. This patch
changes the logic on kdump-compressed format so that bt displays the
register set in the same way as on sadump-related formats. If they are
not useful--that is, they don't belong to neither kernel text nor user
space--, the current logic remains.

Example:

[Before]

crash> bt
PID: 0      TASK: ffffffff80314b60  CPU: 0   COMMAND: "swapper"

 #0 [ffffffff8045bf88] mwait_idle at ffffffff80056ca4
 #1 [ffffffff8045bf90] cpu_idle at ffffffff80048fc5

[After]

crash> bt
PID: 0      TASK: ffffffff80314b60  CPU: 0   COMMAND: "swapper"
    [exception RIP: mwait_idle_with_hints+102]
    RIP: ffffffff8006b9bf  RSP: ffffffff8045bf88  RFLAGS: 00000246
    RAX: 0000000000000000  RBX: ffffffff80056c98  RCX: 0000000000000000
    RDX: 0000000000000000  RSI: 0000000000000000  RDI: 0000000000000000
    RBP: 000000000008fc00   R8: ffffffff8045a000   R9: ffff81047e4f6340
    R10: 0000000000000002  R11: 0000000000000246  R12: 0000000000000018
    R13: 0000000000000018  R14: 0000000000000018  R15: 0000000076c18a58
    CS: 0010  SS: 0018
 #0 [ffffffff8045bf88] mwait_idle at ffffffff80056ca4
 #1 [ffffffff8045bf90] cpu_idle at ffffffff80048fc5

Signed-off-by: HATAYAMA Daisuke <[email protected]>
---

 netdump.c |   17 +++++++++++++++++
 x86.c     |    2 ++
 x86_64.c  |    6 +++++-
 3 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/netdump.c b/netdump.c
index f8da284..1c141d5 100644
--- a/netdump.c
+++ b/netdump.c
@@ -2297,6 +2297,22 @@ get_netdump_regs_x86_64(struct bt_info *bt, ulong *ripp, 
ulong *rspp)
                        netdump_print("ELF prstatus rsp: %lx rip: %lx\n",
                                rsp, rip);
 
+               if (is_kernel_text(rip) &&
+                   (((rsp >= GET_STACKBASE(bt->task)) &&
+                     (rsp < GET_STACKTOP(bt->task))) ||
+                    in_alternate_stack(bt->tc->processor, rsp))) {
+                       *ripp = rip;
+                       *rspp = rsp;
+                       bt->flags |= BT_KERNEL_SPACE;
+                       return;
+               }
+
+               if (!is_kernel_text(rip) &&
+                   in_user_stack(bt->tc->task, rsp)) {
+                       bt->flags |= BT_USER_SPACE;
+                       return;
+               }
+
                *rspp = rsp;
                *ripp = rip;
 
@@ -2508,6 +2524,7 @@ next_sysrq:
                    (((sp >= GET_STACKBASE(bt->task)) &&
                      (sp < GET_STACKTOP(bt->task))) ||
                    in_alternate_stack(bt->tc->processor, sp))) {
+                       bt->flags |= BT_KERNEL_SPACE;
                        *eip = ip;
                        *esp = sp;
                        return;
diff --git a/x86.c b/x86.c
index b69adb2..df91110 100755
--- a/x86.c
+++ b/x86.c
@@ -699,6 +699,8 @@ db_stack_trace_cmd(addr, have_addr, count, modif, task, 
flags)
        } else if ((bt->flags & BT_KERNEL_SPACE)) {
                if (KVMDUMP_DUMPFILE())
                        kvmdump_display_regs(bt->tc->processor, fp);
+               else if (ELF_NOTES_VALID() && DISKDUMP_DUMPFILE())
+                       diskdump_display_regs(bt->tc->processor, fp);
                else if (SADUMP_DUMPFILE())
                        sadump_display_regs(bt->tc->processor, fp);
        }
diff --git a/x86_64.c b/x86_64.c
index 7a7de3c..2379f44 100755
--- a/x86_64.c
+++ b/x86_64.c
@@ -2880,7 +2880,9 @@ x86_64_low_budget_back_trace_cmd(struct bt_info *bt_in)
                        sadump_display_regs(bt->tc->processor, ofp);
                return;
        } else if ((bt->flags & BT_KERNEL_SPACE) &&
-                  (KVMDUMP_DUMPFILE() || SADUMP_DUMPFILE())) {
+                  (KVMDUMP_DUMPFILE() ||
+                   (ELF_NOTES_VALID() && DISKDUMP_DUMPFILE()) ||
+                   SADUMP_DUMPFILE())) {
                fprintf(ofp, "    [exception RIP: ");
                if ((sp = value_search(bt->instptr, &offset))) {
                        fprintf(ofp, "%s", sp->name);
@@ -2892,6 +2894,8 @@ x86_64_low_budget_back_trace_cmd(struct bt_info *bt_in)
                fprintf(ofp, "]\n");
                if (KVMDUMP_DUMPFILE())
                        kvmdump_display_regs(bt->tc->processor, ofp);
+               else if (ELF_NOTES_VALID() && DISKDUMP_DUMPFILE())
+                       diskdump_display_regs(bt->tc->processor, ofp);
                else if (SADUMP_DUMPFILE())
                        sadump_display_regs(bt->tc->processor, ofp);
         } else if (bt->flags & BT_START) {
--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to