From 9c99f79f7d95748e7c4328d6086866113eadc03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrea=20Palmat=C3=A8?= Date: Fri, 22 Sep 2023 08:52:03 +0200 Subject: [PATCH] Added some debug informations --- library/profile/gmon.c | 4 ++-- library/profile/profil.c | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/library/profile/gmon.c b/library/profile/gmon.c index ae6b4ac7..b39e9ae6 100644 --- a/library/profile/gmon.c +++ b/library/profile/gmon.c @@ -361,8 +361,8 @@ void mongetpcs(uint32 *lowpc, uint32 *highpc) { uint32 base = (uint32) GetSectionTags(elfHandle, GST_SectionIndex, i, TAG_DONE); *lowpc = base; *highpc = base + shdr->sh_size; - dprintf("LOWPC = %x\n", lowpc); - dprintf("HIGHPC = %x\n", highpc); + dprintf("LOWPC = %x\n", *lowpc); + dprintf("HIGHPC = %x\n", *highpc); break; } } diff --git a/library/profile/profil.c b/library/profile/profil.c index 21b01519..12e30e13 100644 --- a/library/profile/profil.c +++ b/library/profile/profil.c @@ -10,6 +10,8 @@ #include "gmon.h" +#define COUNTER 1 + static struct Interrupt CounterInt; static struct PerformanceMonitorIFace *IPM; @@ -36,20 +38,23 @@ GetCounterStart(void) { TAG_DONE); /* Timebase ticks at 1/4 of FSB */ - bit0time = (double) 8.0 / (double) fsb; - count = (uint32)((double) 0.01 / bit0time); + bit0time = 8.0 / (double) fsb; + count = (uint32) (0.01 / bit0time); + dprintf("bit0time = %f - fsb = %lld - count = %ld - %x\n", bit0time, fsb, count, 0x80000000 - count); + return 0x80000000 - count; } uint32 CounterIntFn(struct ExceptionContext *ctx, struct ExecBase *ExecBase, struct IntData *profileData) { - APTR sampledAddress = profileData->IPM->GetSampledAddress(); - uint32 sia = (uint32) sampledAddress; - /* Silence compiler */ (void) ExecBase; (void) ctx; + APTR sampledAddress = profileData->IPM->GetSampledAddress(); + uint32 sia = (uint32) sampledAddress; + dprintf("CounterIntFn\n"); + sia = ((sia - profileData->Offset) * profileData->Scale) >> 16; if (sia <= (profileData->BufferSize >> 1)) { @@ -57,7 +62,7 @@ CounterIntFn(struct ExceptionContext *ctx, struct ExecBase *ExecBase, struct Int profileData->Buffer[sia]++; } - IPM->CounterControl(1, profileData->CounterStart, PMCI_Transition); + IPM->CounterControl(COUNTER, profileData->CounterStart, PMCI_Transition); return 1; } @@ -80,7 +85,7 @@ profil(unsigned short *buffer, size_t bufSize, size_t offset, unsigned int scale PMECT_Disable, PMEC_MasterInterrupt, TAG_DONE); - IPM->SetInterruptVector(1, 0); + IPM->SetInterruptVector(COUNTER, 0); IPM->Unmark(0); IPM->Release(); @@ -97,7 +102,7 @@ profil(unsigned short *buffer, size_t bufSize, size_t offset, unsigned int scale } Stack = SuperState(); - +printf("offset = %x\n", offset); /* Init IntData */ ProfileData.IPM = IPM; ProfileData.Buffer = buffer; @@ -113,10 +118,13 @@ profil(unsigned short *buffer, size_t bufSize, size_t offset, unsigned int scale /* Prepare Performance Monitor */ IPM->MonitorControlTags( - PMMCT_FreezeCounters, PMMC_Unmarked, - PMMCT_RTCBitSelect, PMMC_BIT0, + PMMCT_FreezeCounters, PMMC_Unmarked, + PMMCT_RTCBitSelect, PMMC_BIT0, TAG_DONE); - IPM->CounterControl(1, ProfileData.CounterStart, PMCI_Transition); + + if (!IPM->CounterControl(COUNTER, ProfileData.CounterStart, PMCI_Transition)) { + printf("Cannot set CounterControl\n"); + } IPM->EventControlTags( PMECT_Enable, 1,