summaryrefslogtreecommitdiffstats
path: root/src/mem.c
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-05-03 16:27:02 +1000
committerAlistair Popple <alistair@popple.id.au>2018-05-18 11:19:21 +1000
commitd795d979a1bc47882bb62f3714577eaf6102c784 (patch)
tree3d8964a6c10f8a63844038de320a4b6f364def41 /src/mem.c
parent18de4ba00b600e40fd49aaaea8d0bf118b8a90e5 (diff)
downloadpdbg-d795d979a1bc47882bb62f3714577eaf6102c784.tar.gz
pdbg-d795d979a1bc47882bb62f3714577eaf6102c784.zip
pdbg: add basic kernel stack trace to 'regs' command
NIA : 0xc000000000984604 CFAR : 0xc00000000098461c MSR : 0x9000000000009033 LR : 0xc0000000009846e4 CTR : 0xc000000000984560 TAR : 0x0000000000000000 CR : 0x24004424 XER : 0x00000000 GPRS : 0xc0000000009845a8 0xc000000006e07d90 0xc000000001306000 0x0000000000000000 0x0000000000000001 0x0000000000000000 0x0000000000000009 0x0000000000000808 0x0000000000000000 0x00000565ba95ebcd 0xc000000006e04000 0x822ca467ef411b43 0xc000000000984560 0xc000000ffffe0200 0xc000000006e07f90 0x0000000000000000 0x0000000000000000 0xc000000000029d8c 0xc000000000043630 0xc000000000fa5410 0x0000000000000800 0xc0000000013481f4 0x0000000000000026 0x0000000000000000 0x0000000000000001 0x0000000000000000 0x0000000000000000 0x0000000000000000 0xc000000001266ba0 0xc000000ff57a1d58 0x0000000000000000 0x00000565ba95f7b5 LPCR : 0x0040400001d2f012 PTCR : 0x0040400001d2f012 LPIDR : 0x0000000000000000 PIDR : 0x0000000000080081 HFSCR : 0x000000000000059f HDSISR: 0x00000000 HDAR : 0x0000000000000000 HSRR0 : 0xc000000000984618 HSRR1 : 0x9000000000009033 HDEC : 0xfffffaa5941c2f0a HSPRG0: 0xc000000ffffe0200 HSPRG1: 0xc000000ffffe0200 FSCR : 0x0000000000000184 DSISR : 0x00000000 DAR : 0x0000000000000000 SRR0 : 0xc000000000984608 SRR1 : 0x9000000000009033 DEC : 0xfffffffee1c2b8cf TB : 0x00000566dd7f0784 SPRG0 : 0x0000000000000000 SPRG1 : 0x0000000000000000 SPRG2 : 0x0000000000000000 SPRG3 : 0x0000000000000000 PPR : 0x0004000000000000 STACK: 0xc000000006e07dd0 0xc00000000098170c 0xc000000006e07e40 0xc00000000013e60c 0xc000000006e07e60 0xc00000000013e920 0xc000000006e07ed0 0xc00000000013eeb8 0xc000000006e07f00 0xc000000000045bc4 0xc000000006e07f90 0xc00000000000af70 Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Diffstat (limited to 'src/mem.c')
-rw-r--r--src/mem.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mem.c b/src/mem.c
index ba0cf39..ff22500 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -87,6 +87,57 @@ static int putmem(uint64_t addr, int ci)
return rc;
}
+static bool is_real_address(struct thread_regs *regs, uint64_t addr)
+{
+ return true;
+ if ((addr & 0xf000000000000000ULL) == 0xc000000000000000ULL)
+ return true;
+ return false;
+}
+
+static int load8(struct pdbg_target *target, uint64_t addr, uint64_t *value)
+{
+ if (adu_getmem(target, addr, (uint8_t *)value, 8, false)) {
+ PR_ERROR("Unable to read memory address=%016" PRIx64 ".\n", addr);
+ return 0;
+ }
+
+ return 1;
+}
+
+int dump_stack(struct thread_regs *regs)
+{
+ struct pdbg_target *target;
+ uint64_t sp = regs->gprs[1];
+ uint64_t pc;
+
+ pdbg_for_each_class_target("adu", target) {
+ if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
+ continue;
+ break;
+ }
+
+ printf("STACK:\n");
+ if (!target)
+ PR_ERROR("Unable to read memory (no ADU found)\n");
+
+ if (sp && is_real_address(regs, sp)) {
+ if (!load8(target, sp, &sp))
+ return 1;
+ while (sp && is_real_address(regs, sp)) {
+ if (!load8(target, sp + 16, &pc))
+ return 1;
+
+ printf(" 0x%016" PRIx64 " 0x%16" PRIx64 "\n", sp, pc);
+
+ if (!load8(target, sp, &sp))
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int handle_mem(int optind, int argc, char *argv[])
{
uint64_t addr;
OpenPOWER on IntegriCloud