diff options
author | Alistair Popple <alistair@popple.id.au> | 2016-11-28 10:10:25 +1100 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2016-11-28 10:18:35 +1100 |
commit | fcc3d4b737d664237e047c4de48639186edadbc6 (patch) | |
tree | 9ee19e7e45200cd0394d3ea97be9274f106eacdd /src | |
parent | adf7f8391b4e429668fdb9e8834de9a0570d533d (diff) | |
download | pdbg-fcc3d4b737d664237e047c4de48639186edadbc6.tar.gz pdbg-fcc3d4b737d664237e047c4de48639186edadbc6.zip |
src/main.c: Fix SPR encoding
The internal getreg/putreg functions encode the register to read by
assuming registers > R31 are special purpose registers (SPR). However
when reading/writing the SPR this offset was not removed and so the
incorrect SPR was read (or written). This is fixed by subtracting the
correct offset.
Also fixes a minor whitespace issue.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -641,26 +641,28 @@ static int putreg(struct target *thread, uint64_t reg, uint64_t *data) return 0; } - if (reg == REG_NIA) + if (reg == REG_NIA) if (ram_putnia(thread, *data)) PR_ERROR("Error reading register\n"); else printf("c%02d:t%d:nia = 0x%016llx\n", thread->next->index, thread->index, *data); - else if (reg == REG_MSR) + else if (reg == REG_MSR) if (ram_putmsr(thread, *data)) PR_ERROR("Error reading register\n"); else printf("c%02d:t%d:msr = 0x%016llx\n", thread->next->index, thread->index, *data); - else if (reg <= REG_R31) + else if (reg <= REG_R31) if (ram_putgpr(thread, reg, *data)) PR_ERROR("Error reading register\n"); else printf("c%02d:t%d:r%lld = 0x%016llx\n", thread->next->index, thread->index, reg, *data); - else + else { + reg -= 32; if (ram_putspr(thread, reg, *data)) PR_ERROR("Error reading register\n"); else printf("c%02d:t%d:spr%lld = 0x%016llx\n", thread->next->index, thread->index, reg, *data); + } return 0; } @@ -697,11 +699,13 @@ static int getreg(struct target *thread, uint64_t reg, uint64_t *data) PR_ERROR("Error reading register\n"); else printf("c%02d:t%d:r%lld = 0x%016llx\n", thread->next->index, thread->index, reg, *data); - else + else { + reg -= 32; if (ram_getspr(thread, reg, data)) PR_ERROR("Error reading register\n"); else printf("c%02d:t%d:spr%lld = 0x%016llx\n", thread->next->index, thread->index, reg, *data); + } return 0; } |