[Pdbg] [PATCH 2/9] libpdbg: Avoid direct access of class in pdbg_target
Amitay Isaacs
amitay at ozlabs.org
Mon Jun 22 10:44:54 AEST 2020
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/chip.c | 114 ++++++++++++++++++++++++-------------------------
1 file changed, 57 insertions(+), 57 deletions(-)
diff --git a/libpdbg/chip.c b/libpdbg/chip.c
index f9f184b..f0dd6bf 100644
--- a/libpdbg/chip.c
+++ b/libpdbg/chip.c
@@ -110,7 +110,7 @@ struct thread_state thread_status(struct pdbg_target *target)
{
struct thread *thread;
- assert(!strcmp(target->class, "thread"));
+ assert(pdbg_target_is_class(target, "thread"));
thread = target_to_thread(target);
return thread->status;
}
@@ -118,39 +118,39 @@ struct thread_state thread_status(struct pdbg_target *target)
/*
* Single step the thread count instructions.
*/
-int thread_step(struct pdbg_target *thread_target, int count)
+int thread_step(struct pdbg_target *target, int count)
{
struct thread *thread;
- assert(!strcmp(thread_target->class, "thread"));
- thread = target_to_thread(thread_target);
+ assert(pdbg_target_is_class(target, "thread"));
+ thread = target_to_thread(target);
return thread->step(thread, count);
}
-int thread_start(struct pdbg_target *thread_target)
+int thread_start(struct pdbg_target *target)
{
struct thread *thread;
- assert(!strcmp(thread_target->class, "thread"));
- thread = target_to_thread(thread_target);
+ assert(pdbg_target_is_class(target, "thread"));
+ thread = target_to_thread(target);
return thread->start(thread);
}
-int thread_stop(struct pdbg_target *thread_target)
+int thread_stop(struct pdbg_target *target)
{
struct thread *thread;
- assert(!strcmp(thread_target->class, "thread"));
- thread = target_to_thread(thread_target);
+ assert(pdbg_target_is_class(target, "thread"));
+ thread = target_to_thread(target);
return thread->stop(thread);
}
-int thread_sreset(struct pdbg_target *thread_target)
+int thread_sreset(struct pdbg_target *target)
{
struct thread *thread;
- assert(!strcmp(thread_target->class, "thread"));
- thread = target_to_thread(thread_target);
+ assert(pdbg_target_is_class(target, "thread"));
+ thread = target_to_thread(target);
return thread->sreset(thread);
}
@@ -526,29 +526,29 @@ int thread_putxer(struct pdbg_target *target, uint64_t value)
/*
* Read the given ring from the given chiplet. Result must be large enough to hold ring_len bits.
*/
-int getring(struct pdbg_target *chiplet_target, uint64_t ring_addr, uint64_t ring_len, uint32_t result[])
+int getring(struct pdbg_target *target, uint64_t ring_addr, uint64_t ring_len, uint32_t result[])
{
struct chiplet *chiplet;
- assert(!strcmp(chiplet_target->class, "chiplet"));
- chiplet = target_to_chiplet(chiplet_target);
+ assert(pdbg_target_is_class(target, "chiplet"));
+ chiplet = target_to_chiplet(target);
return chiplet->getring(chiplet, ring_addr, ring_len, result);
}
-int thread_getregs(struct pdbg_target *thread, struct thread_regs *regs)
+int thread_getregs(struct pdbg_target *target, struct thread_regs *regs)
{
+ struct thread *thread;
struct thread_regs _regs;
- struct thread *t;
uint64_t value = 0;
int i;
if (!regs)
regs = &_regs;
- assert(!strcmp(thread->class, "thread"));
- t = target_to_thread(thread);
+ assert(pdbg_target_is_class(target, "thread"));
+ thread = target_to_thread(target);
- CHECK_ERR(t->ram_setup(t));
+ CHECK_ERR(thread->ram_setup(thread));
/*
* It would be neat to do all the ramming up front, then go through
@@ -556,120 +556,120 @@ int thread_getregs(struct pdbg_target *thread, struct thread_regs *regs)
* can help to diagnose checkstop issues with ramming to print as
* we go. Once it's more robust and tested, maybe.
*/
- thread_getnia(thread, ®s->nia);
+ thread_getnia(target, ®s->nia);
printf("NIA : 0x%016" PRIx64 "\n", regs->nia);
- thread_getspr(thread, 28, ®s->cfar);
+ thread_getspr(target, 28, ®s->cfar);
printf("CFAR : 0x%016" PRIx64 "\n", regs->cfar);
- thread_getmsr(thread, ®s->msr);
+ thread_getmsr(target, ®s->msr);
printf("MSR : 0x%016" PRIx64 "\n", regs->msr);
- thread_getspr(thread, 8, ®s->lr);
+ thread_getspr(target, 8, ®s->lr);
printf("LR : 0x%016" PRIx64 "\n", regs->lr);
- thread_getspr(thread, 9, ®s->ctr);
+ thread_getspr(target, 9, ®s->ctr);
printf("CTR : 0x%016" PRIx64 "\n", regs->ctr);
- thread_getspr(thread, 815, ®s->tar);
+ thread_getspr(target, 815, ®s->tar);
printf("TAR : 0x%016" PRIx64 "\n", regs->tar);
- thread_getcr(thread, ®s->cr);
+ thread_getcr(target, ®s->cr);
printf("CR : 0x%08" PRIx32 "\n", regs->cr);
- thread_getxer(thread, ®s->xer);
+ thread_getxer(target, ®s->xer);
printf("XER : 0x%08" PRIx64 "\n", regs->xer);
printf("GPRS :\n");
for (i = 0; i < 32; i++) {
- thread_getgpr(thread, i, ®s->gprs[i]);
+ thread_getgpr(target, i, ®s->gprs[i]);
printf(" 0x%016" PRIx64 "", regs->gprs[i]);
if (i % 4 == 3)
printf("\n");
}
- thread_getspr(thread, 318, ®s->lpcr);
+ thread_getspr(target, 318, ®s->lpcr);
printf("LPCR : 0x%016" PRIx64 "\n", regs->lpcr);
- thread_getspr(thread, 464, ®s->ptcr);
+ thread_getspr(target, 464, ®s->ptcr);
printf("PTCR : 0x%016" PRIx64 "\n", regs->ptcr);
- thread_getspr(thread, 319, ®s->lpidr);
+ thread_getspr(target, 319, ®s->lpidr);
printf("LPIDR : 0x%016" PRIx64 "\n", regs->lpidr);
- thread_getspr(thread, 48, ®s->pidr);
+ thread_getspr(target, 48, ®s->pidr);
printf("PIDR : 0x%016" PRIx64 "\n", regs->pidr);
- thread_getspr(thread, 190, ®s->hfscr);
+ thread_getspr(target, 190, ®s->hfscr);
printf("HFSCR : 0x%016" PRIx64 "\n", regs->hfscr);
- thread_getspr(thread, 306, &value);
+ thread_getspr(target, 306, &value);
regs->hdsisr = value;
printf("HDSISR: 0x%08" PRIx32 "\n", regs->hdsisr);
- thread_getspr(thread, 307, ®s->hdar);
+ thread_getspr(target, 307, ®s->hdar);
printf("HDAR : 0x%016" PRIx64 "\n", regs->hdar);
- thread_getspr(thread, 339, &value);
+ thread_getspr(target, 339, &value);
regs->heir = value;
printf("HEIR : 0x%016" PRIx32 "\n", regs->heir);
- thread_getspr(thread, 1008, ®s->hid);
+ thread_getspr(target, 1008, ®s->hid);
printf("HID0 : 0x%016" PRIx64 "\n", regs->hid);
- thread_getspr(thread, 314, ®s->hsrr0);
+ thread_getspr(target, 314, ®s->hsrr0);
printf("HSRR0 : 0x%016" PRIx64 "\n", regs->hsrr0);
- thread_getspr(thread, 315, ®s->hsrr1);
+ thread_getspr(target, 315, ®s->hsrr1);
printf("HSRR1 : 0x%016" PRIx64 "\n", regs->hsrr1);
- thread_getspr(thread, 310, ®s->hdec);
+ thread_getspr(target, 310, ®s->hdec);
printf("HDEC : 0x%016" PRIx64 "\n", regs->hdec);
- thread_getspr(thread, 304, ®s->hsprg0);
+ thread_getspr(target, 304, ®s->hsprg0);
printf("HSPRG0: 0x%016" PRIx64 "\n", regs->hsprg0);
- thread_getspr(thread, 305, ®s->hsprg1);
+ thread_getspr(target, 305, ®s->hsprg1);
printf("HSPRG1: 0x%016" PRIx64 "\n", regs->hsprg1);
- thread_getspr(thread, 153, ®s->fscr);
+ thread_getspr(target, 153, ®s->fscr);
printf("FSCR : 0x%016" PRIx64 "\n", regs->fscr);
- thread_getspr(thread, 18, &value);
+ thread_getspr(target, 18, &value);
regs->dsisr = value;
printf("DSISR : 0x%08" PRIx32 "\n", regs->dsisr);
- thread_getspr(thread, 19, ®s->dar);
+ thread_getspr(target, 19, ®s->dar);
printf("DAR : 0x%016" PRIx64 "\n", regs->dar);
- thread_getspr(thread, 26, ®s->srr0);
+ thread_getspr(target, 26, ®s->srr0);
printf("SRR0 : 0x%016" PRIx64 "\n", regs->srr0);
- thread_getspr(thread, 27, ®s->srr1);
+ thread_getspr(target, 27, ®s->srr1);
printf("SRR1 : 0x%016" PRIx64 "\n", regs->srr1);
- thread_getspr(thread, 22, ®s->dec);
+ thread_getspr(target, 22, ®s->dec);
printf("DEC : 0x%016" PRIx64 "\n", regs->dec);
- thread_getspr(thread, 268, ®s->tb);
+ thread_getspr(target, 268, ®s->tb);
printf("TB : 0x%016" PRIx64 "\n", regs->tb);
- thread_getspr(thread, 272, ®s->sprg0);
+ thread_getspr(target, 272, ®s->sprg0);
printf("SPRG0 : 0x%016" PRIx64 "\n", regs->sprg0);
- thread_getspr(thread, 273, ®s->sprg1);
+ thread_getspr(target, 273, ®s->sprg1);
printf("SPRG1 : 0x%016" PRIx64 "\n", regs->sprg1);
- thread_getspr(thread, 274, ®s->sprg2);
+ thread_getspr(target, 274, ®s->sprg2);
printf("SPRG2 : 0x%016" PRIx64 "\n", regs->sprg2);
- thread_getspr(thread, 275, ®s->sprg3);
+ thread_getspr(target, 275, ®s->sprg3);
printf("SPRG3 : 0x%016" PRIx64 "\n", regs->sprg3);
- thread_getspr(thread, 896, ®s->ppr);
+ thread_getspr(target, 896, ®s->ppr);
printf("PPR : 0x%016" PRIx64 "\n", regs->ppr);
- CHECK_ERR(t->ram_destroy(t));
+ CHECK_ERR(thread->ram_destroy(thread));
return 0;
}
--
2.26.2
More information about the Pdbg
mailing list