Skip to content

Commit

Permalink
Added some debug informations
Browse files Browse the repository at this point in the history
  • Loading branch information
afxgroup committed Sep 22, 2023
1 parent 4d65396 commit 9c99f79
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions library/profile/gmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
30 changes: 19 additions & 11 deletions library/profile/profil.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "gmon.h"

#define COUNTER 1

static struct Interrupt CounterInt;
static struct PerformanceMonitorIFace *IPM;

Expand All @@ -36,28 +38,31 @@ 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)) {
//if (ProfileData->Buffer[sia] != 0xffff)
profileData->Buffer[sia]++;
}

IPM->CounterControl(1, profileData->CounterStart, PMCI_Transition);
IPM->CounterControl(COUNTER, profileData->CounterStart, PMCI_Transition);

return 1;
}
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 9c99f79

Please sign in to comment.