Skip to content

Commit

Permalink
Log executed scripts in debug builds
Browse files Browse the repository at this point in the history
  • Loading branch information
benstone committed Jan 8, 2025
1 parent d03fb2a commit 661aa24
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
30 changes: 30 additions & 0 deletions kauai/src/screxe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ bool SCEB::FAttachScript(PSCPT pscpt, long *prglw, long clw)
long lw;
DVER dver;

#ifdef DEBUG
if (pscpt != pvNil)
{
STN stnTrace;
if (pscpt->_stnSrcChunk.Cch() > 0)
{
stnTrace.FFormatSz(PszLit("Executing: %f:%d: %s\n"), pscpt->Ctg(), pscpt->Cno(), &pscpt->_stnSrcChunk);
}
else
{
stnTrace.FFormatSz(PszLit("Executing: %f:%d\n"), pscpt->Ctg(), pscpt->Cno());
}
OutputDebugStringA(stnTrace.Psz());
}
#endif // DEBUG

Free();
_lwReturn = 0;
_fError = fFalse;
Expand Down Expand Up @@ -1381,6 +1397,20 @@ PSCPT SCPT::PscptRead(PCFL pcfl, CTG ctg, CNO cno)
return pvNil;
}

#ifdef DEBUG
{
// Store source information in the script object
FLO flo;
AssertDo(blck.FGetFlo(&flo), "Cannot get file location for script chunk");
flo.pfil->GetFni(&pscpt->_fniSrc);

if (!pcfl->FGetName(ctg, cno, &pscpt->_stnSrcChunk))
{
pscpt->_stnSrcChunk = "";
}
}
#endif // DEBUG

if (kboOther == bo)
SwapBytesRglw(pgllw->QvGet(0), pgllw->IvMac());
pscpt->_pgllw = pgllw;
Expand Down
6 changes: 6 additions & 0 deletions kauai/src/screxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class SCPT : public SCPT_PAR
friend class SCEB;
friend class SCCB;

#ifdef DEBUG
FNI _fniSrc; // Source file
STN _stnSrcChunk = ""; // Source chunk name

#endif // DEBUG

public:
static bool FReadScript(PCRF pcrf, CTG ctg, CNO cno, PBLCK pblck, PBACO *ppbaco, long *pcb);
static PSCPT PscptRead(PCFL pcfl, CTG ctg, CNO cno);
Expand Down

0 comments on commit 661aa24

Please sign in to comment.