Remove closed D63 debug scaffolding (libultra.c + game-file probes)

D63 is a closed finding. Strips the dead TEMP D63 probe code:
- port/src/libultra.c: watchdog thread, activity ring, gun-barrel slot
  watchers, and their call sites in osSendMesg/osRecvMesg/osSpTaskStartGo.
- #ifdef PORT probe blocks in blood_animation.c, dyn.c, front.c, rsp.c,
  title.c (all env-gated / no side effects).

port/fast3d/gfx_pc.cpp still carries a D63 branch trail -- left for a
later pass. Build links clean; no behaviour change.
@
This commit is contained in:
James Dansereau committed 2026-08-29 22:13:14 -04:00
1 parent bb14baf3bf
commit ef1ec52366
6 files changed
-232

No files matched your search

-166
View File
@@ -258,7 +258,6 @@ void portKernelInit(void)
{
memset(g_pt, 0, sizeof(g_pt));
g_pqCount = 0;
d63WatchdogStart(); /* TEMP D63 */
/* Anchor the heartbeat clock so the first check doesn't compare against
* epoch 0 (the host QPC has a large absolute offset). */
g_lastFrameUs = sysGetMicroseconds();
@@ -487,135 +486,11 @@ static void d62log(const char *op, OSMesgQueue *mq, OSMesg msg)
}
}
/* TEMP D63: watch the gun-barrel sub-DL slot (V1+0x12EC38) for clobbering.
* Hooked in osSendMesg/osRecvMesg so both game threads are sampled often. */
void d63SlotLog(const char *tag)
{
if (!getenv("GE_D63")) return;
u32 cur = *(const u32 *)0x7012EC38;
sysLogPrintf(LOG_NOTE, "D63 slot %s: word@0x7012ec38=%08x", tag, cur);
}
/* TEMP D63: log only when the slot value changes (first 8 per tag). */
void d63SlotCheck(const char *tag)
{
if (!getenv("GE_D63")) return;
static const char *s_tags[16];
static u32 s_vals[16];
static int s_n = 0, s_count = 0;
u32 cur = *(const u32 *)0x7012EC38;
int i;
for (i = 0; i < s_n; i++) {
if (s_tags[i] == tag) {
if (cur != s_vals[i] && s_count < 64) {
sysLogPrintf(LOG_NOTE, "D63 check %s: %08x -> %08x", tag, s_vals[i], cur);
s_vals[i] = cur;
++s_count;
}
return;
}
}
if (s_n < 16) { s_tags[s_n] = tag; s_vals[s_n] = cur; ++s_n; }
}
/* TEMP D63: timestamped cross-thread activity ring + watchdog thread. */
typedef struct { uint64_t t; unsigned long tid; const char *tag; } D63Act;
#define D63_ACT_N 2048
static D63Act s_d63act[D63_ACT_N];
static volatile long s_d63actIdx = 0;
static int s_d63on = -1;
int d63On(void) { if (s_d63on < 0) s_d63on = getenv("GE_D63") != 0; return s_d63on; }
unsigned long d63Tid(void)
{
#if defined(PLATFORM_WINDOWS)
return GetCurrentThreadId();
#else
return (unsigned long)pthread_self();
#endif
}
void d63Act(const char *tag)
{
if (!d63On()) return;
long i = s_d63actIdx++;
s_d63act[i & (D63_ACT_N - 1)] = (D63Act){ sysGetMicroseconds(), d63Tid(), tag };
}
static void d63DumpActivity(uint64_t now)
{
long newest = s_d63actIdx - 1;
int k;
for (k = 47; k >= 0; --k) {
long i = newest - k;
if (i < 0) break;
const D63Act *e = &s_d63act[i & (D63_ACT_N - 1)];
sysLogPrintf(LOG_NOTE, "D63 act t=%llu d=%lld tid=%lu %s",
(unsigned long long)e->t,
(long long)(e->t >= now ? (long long)(e->t - now) : -(long long)(now - e->t)),
e->tid, e->tag);
}
}
static void d63WatchdogThread(void *arg)
{
const u32 *slot = (const u32 *)0x7012EC38;
u32 last = *slot;
int changes = 0;
for (;;) {
u32 cur = *slot;
if (cur != last) {
uint64_t now = sysGetMicroseconds();
if (changes < 8) {
sysLogPrintf(LOG_NOTE, "D63 WATCHDOG t=%llu word@0x7012ec38 %08x -> %08x",
(unsigned long long)now, last, cur);
d63DumpActivity(now);
}
++changes;
last = cur;
}
#if defined(PLATFORM_WINDOWS)
Sleep(0); /* yield to same-priority threads */
#else
sched_yield();
#endif
}
}
void d63WatchdogStart(void)
{
if (!d63On()) return;
static pthread_t th;
pthread_create(&th, NULL,
(void *(*)(void *))d63WatchdogThread, NULL);
pthread_detach(th);
sysLogPrintf(LOG_NOTE, "D63 watchdog started");
}
static void d63WatchGunbarrelSlot(void)
{
if (!d63On()) return;
static u32 s_last = 0;
static int s_init = 0;
static int s_changes = 0;
const u32 *slot = (const u32 *)0x7012EC38;
u32 cur = *slot;
if (!s_init) { s_init = 1; s_last = cur; return; }
if (cur != s_last && s_changes < 64) {
sysLogPrintf(LOG_NOTE, "D63 clobber-watch: word@0x7012ec38 %08x -> %08x tid=%lu changes=%d",
s_last, cur, d63Tid(), s_changes);
s_last = cur;
++s_changes;
}
}
s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag)
{
PortQueue *pq = portQueueGet(mq);
d62log("SEND", mq, msg); /* TEMP D62 */
d63Act("send"); /* TEMP D63 */
d63WatchGunbarrelSlot(); /* TEMP D63 */
/* TEMP D51: watch sends to the 32-slot queues (sched cmdQ + client Qs) */
if (getenv("GE_D51") && mq->msgCount == 32 && !(g_viRetraceMQ && mq == g_viRetraceMQ)) {
void *ra = __builtin_return_address(0);
@@ -655,8 +530,6 @@ s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flag)
{
PortQueue *pq = portQueueGet(mq);
d62log("RECV", mq, 0); /* TEMP D62 */
d63Act("recv"); /* TEMP D63 */
d63WatchGunbarrelSlot(); /* TEMP D63 */
pthread_mutex_lock(&pq->lock);
while (mq->validCount == 0) {
if (flag != OS_MESG_BLOCK) {
@@ -1107,51 +980,12 @@ void osSpTaskLoad(OSTask *t) { (void)t; /* nothing to load on the host */ }
void osSpTaskStartGo(OSTask *t)
{
d63Act(t->t.type == M_AUDTASK ? "audtask" : "spgo"); /* TEMP D63 */
if (t->t.type == M_AUDTASK) {
/* Phase 3: execute the audio ucode against t->t.data_ptr (an Acmd
* list). For now the task simply completes; libaudio's amMain still
* runs its per-frame bookkeeping. */
} else {
/* Graphics task: run the software RSP on the display list. */
/* TEMP D63: log every gfx task's DL pointer (env GE_D63=1) */
if (getenv("GE_D63")) {
unsigned long tid = 0;
#if defined(PLATFORM_WINDOWS)
tid = GetCurrentThreadId();
#else
tid = (unsigned long)pthread_self();
#endif
sysLogPrintf(LOG_NOTE, "D63 gfx task data_ptr=%p data_size=%d tid=%lu slot=%08x",
(void *)t->t.data_ptr, (int)t->t.data_size, tid,
*(const u32 *)0x7012EC38);
}
#if defined(PORT)
/* TEMP D63: find when the fatal G_DL value first appears in the master DL */
{
static int s_d63seen = 0;
if (getenv("GE_D63") && !s_d63seen) {
const uint32_t *p = (const uint32_t *)t->t.data_ptr;
size_t nwords = t->t.data_size / 4;
static int s_d63scancount = 0;
if ((s_d63scancount++ % 100) == 0)
sysLogPrintf(LOG_NOTE, "D63 scan running: ptr=%p nwords=%zu", (void *)p, nwords);
for (size_t i = 1; i + 1 < nwords; i += 2) {
if (p[i] == 0x0012EC38u) {
s_d63seen = 1;
sysLogPrintf(LOG_NOTE, "D63 fatal-value first seen: frame=%d off=0x%zx words:",
g_framesRendered + 1, i * 4);
for (int k = -3; k <= 3; ++k) {
long j = (long)i + 2 * k;
if (j >= 0 && j + 1 < (long)nwords)
sysLogPrintf(LOG_NOTE, "D63 [%d] %08x %08x", k, p[j], p[j+1]);
}
break;
}
}
}
}
#endif
uint64_t t0 = sysGetMicroseconds();
videoStartFrame();
gfx_run((Gfx *)t->t.data_ptr);
-19
View File
@@ -246,9 +246,6 @@ s32 die_blood_image_routine(s32 arg0) {
}
}
#ifdef PORT
extern void d63SlotCheck(const char *tag); /* TEMP D63 */
#endif
g_CurrentPlayer->bloodImgIdx = (1 - g_CurrentPlayer->bloodImgIdx);
g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx] = dynAllocate(BLOOD_IMG_WIDTH * BLOOD_IMG_HEIGHT);
temp_v0_2 = dynAllocate(BLOOD_IMG_WIDTH * BLOOD_IMG_HEIGHT);
@@ -257,28 +254,12 @@ s32 die_blood_image_routine(s32 arg0) {
osSyncPrintf("D63 blood: buf=%p temp=%p\n",
(void *)g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx],
(void *)temp_v0_2);
d63SlotCheck("blood-a-alloc");
#endif
g_CurrentPlayer->bloodImgNxt = decrypt_bleeding_animation_data(g_CurrentPlayer->bloodImgCur, BLOOD_IMG_WIDTH, BLOOD_IMG_HEIGHT, temp_v0_2, &sp37);
#ifdef PORT
d63SlotCheck("blood-b-decrypt");
#endif
bloodImgTranspose(temp_v0_2, BLOOD_IMG_WIDTH, BLOOD_IMG_HEIGHT, g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx]);
#ifdef PORT
d63SlotCheck("blood-c-transpose");
#endif
sub_GAME_7F01D02C(g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx], BLOOD_IMG_WIDTH, g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx]);
#ifdef PORT
d63SlotCheck("blood-d-d02c");
#endif
sub_GAME_7F01CEEC(g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx], BLOOD_IMG_WIDTH, g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx]);
#ifdef PORT
d63SlotCheck("blood-e-ceec");
#endif
sub_GAME_7F01CC94(g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx], BLOOD_IMG_WIDTH * BLOOD_IMG_HEIGHT, g_CurrentPlayer->bloodImgBufPtrArray[g_CurrentPlayer->bloodImgIdx]);
#ifdef PORT
d63SlotCheck("blood-f-cc94");
#endif
return (g_CurrentPlayer->bloodImgNxt >= &die_blood_image_end);
}
-4
View File
@@ -138,10 +138,6 @@ Light *dynAllocateLights(s32 count)
}
void *dynAllocate(s32 size) {
#ifdef PORT
extern void d63Act(const char *tag); /* TEMP D63 */
d63Act("dyn");
#endif
void *ptr = g_GfxMemPos;
size = ALIGN16_a(size);
g_GfxMemPos += size;
-10
View File
@@ -1876,20 +1876,10 @@ Gfx * constructor_menu02_rareware(Gfx * DL) {
void init_menu03_gunbarrel(void) {
#ifdef PORT
d63MenuProbe("gunbarrel");
extern void d63SlotLog(const char *tag); /* TEMP D63 */
#endif
initializeGunBarrelIntro(ptr_logo_and_walletbond_DL, 0x78000);
#ifdef PORT
d63SlotLog("gb:after-init");
#endif
musicTrack1Play(M_INTRO);
#ifdef PORT
d63SlotLog("gb:after-music");
#endif
maybe_is_in_menu = TRUE;
#ifdef PORT
d63SlotLog("gb:end");
#endif
}
/*
-2
View File
@@ -230,8 +230,6 @@ void rspGfxTaskStart(Gfx *firstGdl, Gfx *gdl, s32 arg2, OSMesg rspReplyMsg)
OSTask *task;
#ifdef PORT
extern void d63Act(const char *tag); /* TEMP D63 */
d63Act("rspstart");
/* TEMP D63: log task submission (main thread) with tid */
if (getenv("GE_D63")) {
unsigned long tid = 0;
-31
View File
@@ -602,12 +602,8 @@ void clearChrGunModelInstances(void)
/*
* Address: 0x7F009254
*/
#ifdef PORT
extern void d63SlotCheck(const char *tag); /* TEMP D63 */
#endif
Gfx *renderGunbarrelEyeIntroSequence (Gfx *gdl) {
#ifdef PORT
d63SlotCheck("gb-render-entry");
if (getenv("GE_D63")) {
static int n = 0;
if ((++n % 200) == 1)
@@ -647,19 +643,10 @@ Gfx *renderGunbarrelEyeIntroSequence (Gfx *gdl) {
gdl = clear_framebuffer_black(gdl++);
#endif
gdl = insert_sniper_sight_eye_intro(gdl++);
#ifdef PORT
d63SlotCheck("gb1-after-sight");
#endif
gdl = insert_sight_backdrop_eye_intro(gdl++);
#ifdef PORT
d63SlotCheck("gb1-after-backdrop");
#endif
if (g_TitleX < 600.0f) {
gdl = insert_bond_eye_intro(gdl);
#ifdef PORT
d63SlotCheck("gb1-after-bond");
#endif
}
g_TitleX -= XDEC3;
if (g_TitleX <= -80.0f) {
@@ -675,13 +662,7 @@ Gfx *renderGunbarrelEyeIntroSequence (Gfx *gdl) {
intro_eye_counter--;
if (intro_eye_counter < 0) {
gunbarrel_mode++;
#ifdef PORT
d63SlotCheck("gb2-before-blood0");
#endif
die_blood_image_routine(0);
#ifdef PORT
d63SlotCheck("gb2-after-blood0");
#endif
intro_state_blood_animation = 0;
intro_eye_counter = 1;
}
@@ -690,25 +671,13 @@ Gfx *renderGunbarrelEyeIntroSequence (Gfx *gdl) {
case 3:
intro_eye_counter--;
if (intro_eye_counter == 0) {
#ifdef PORT
d63SlotCheck("gb3-before-blood1");
#endif
intro_state_blood_animation = die_blood_image_routine(1);
#ifdef PORT
d63SlotCheck("gb3-after-blood1");
#endif
intro_eye_counter = 2;
}
gdl = insert_sniper_sight_eye_intro(gdl);
gdl = insert_sight_backdrop_eye_intro(gdl);
gdl = insert_bond_eye_intro(gdl);
#ifdef PORT
d63SlotCheck("gb3-before-bloodDL");
#endif
gdl = gunbarrelBloodOverlayDL(gdl);
#ifdef PORT
d63SlotCheck("gb3-after-bloodDL");
#endif
if (intro_state_blood_animation != 0) {
gunbarrel_mode++;
word_CODE_bss_80069584 = 0;