Skip to content

Commit

Permalink
debug stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Nov 11, 2023
1 parent 87d3511 commit b43f95e
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 11 deletions.
2 changes: 1 addition & 1 deletion source/common/cutscenes/screenjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Job_Init()
if (!done)
{
done = true;
GC::AddMarkerFunc([] { GC::Mark(cutscene.runner); });
GC::AddMarkerFunc([] { Printf("cutscene.runner = %p\n"); GC::Mark(cutscene.runner); });
}
cutscene.runnerclass = PClass::FindClass("ScreenJobRunner");
if (!cutscene.runnerclass) I_FatalError("ScreenJobRunner not defined");
Expand Down
11 changes: 10 additions & 1 deletion source/common/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(DMenuDescriptor, GetDescriptor, GetMenuDescriptor)

size_t DMenuDescriptor::PropagateMark()
{
for (auto item : mItems) GC::Mark(item);
for (auto item : mItems)
{
Printmark(item);
GC::Mark(item);
}
return 0;
}

Expand Down Expand Up @@ -186,9 +190,14 @@ void M_MarkMenus()
{
GC::Mark(pair->Value);
}

Printmark(CurrentMenu);
GC::Mark(CurrentMenu);
Printmark(menuDelegate);
GC::Mark(menuDelegate);
Printmark(transition.previous);
GC::Mark(transition.previous);
Printmark(transition.current);
GC::Mark(transition.current);
}

Expand Down
14 changes: 12 additions & 2 deletions source/common/objects/dobjgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ void SetThreshold()
size_t PropagateMark()
{
DObject *obj = Gray;
assert(!obj || allObjects.Find(obj) < allObjects.Size());
Printf("propagating %p\n", obj);
Printf("---> %s\n", obj->GetClass()->TypeName.GetChars());
assert(obj->IsGray());
obj->Gray2Black();
Gray = obj->GCNext;
Expand Down Expand Up @@ -327,7 +328,10 @@ void Mark(DObject **obj)
{
DObject *lobj = *obj;

assert(!lobj || allObjects.Find(lobj) < allObjects.Size());
if (!(!lobj || allObjects.Find(lobj) < allObjects.Size()))
{
fopen("a", "b");
}

//assert(lobj == nullptr || !(lobj->ObjectFlags & OF_Released));
if (lobj != nullptr && !(lobj->ObjectFlags & OF_Released))
Expand Down Expand Up @@ -357,6 +361,7 @@ void MarkArray(DObject **obj, size_t count)
{
for (size_t i = 0; i < count; ++i)
{
Printmark(obj[i]);
Mark(obj[i]);
}
}
Expand Down Expand Up @@ -463,16 +468,21 @@ static size_t SingleStep()
switch (State)
{
case GCS_Pause:
Printf("marking roots\n");
MarkRoot(); // Start a new collection
Printf("marked roots\n");
return 0;

case GCS_Propagate:
if (Gray != nullptr)
{
Printf("propagating\n");
return PropagateMark();
}
else
{ // no more gray objects
Printf("atomic\n");

Atomic(); // finish mark phase
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions source/common/objects/dobjgc.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,5 @@ namespace GC
GC::Mark(&obj.o);
}
}

#define Printmark(p) Printf("%s %d %p\n", __FILE__, __LINE__, p); Printf("---> %s\n", p ? p->GetClass()->TypeName.GetChars() : "");
1 change: 1 addition & 0 deletions source/common/scripting/interface/vmnatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static void MarkServices()
ZSMap<FName, DObject*>::Pair* pair;
while (it.NextPair(pair))
{
Printmark(pair->Value);
GC::Mark<DObject>(pair->Value);
}
}
Expand Down
4 changes: 4 additions & 0 deletions source/core/actorlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,13 @@ IMPLEMENT_CLASS(DCoreActor, false, false)

size_t DCoreActor::PropagateMark()
{
Printmark(prevStat);
GC::Mark(prevStat);
Printmark(nextStat);
GC::Mark(nextStat);
Printmark(prevSect);
GC::Mark(prevSect);
Printmark(nextSect);
GC::Mark(nextSect);
return Super::PropagateMark();
}
Expand Down
2 changes: 1 addition & 1 deletion source/core/gamecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ void CreateStatusBar()
StatusBar = static_cast<DStatusBarCore*>(stbarclass->CreateNew());
StatusBar->SetSize(0, 320, 200);
InitStatusBar();
GC::AddMarkerFunc([]() { GC::Mark(StatusBar); });
GC::AddMarkerFunc([]() { Printmark(StatusBar); GC::Mark(StatusBar); });
}


Expand Down
1 change: 1 addition & 0 deletions source/core/mainloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ IMPLEMENT_POINTERS_END

void MarkPlayers()
{
Printf("markplayers\n");
GC::MarkArray(PlayerArray, MAXPLAYERS);
}

Expand Down
10 changes: 9 additions & 1 deletion source/core/maploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,14 +867,22 @@ void MarkMap()
{
for (auto& stat : statList)
{
Printmark(stat.firstEntry);
GC::Mark(stat.firstEntry);
Printmark(stat.lastEntry);
GC::Mark(stat.lastEntry);
}
for (auto& sect: sector)
{
Printmark(sect.firstEntry);
GC::Mark(sect.firstEntry);
Printmark(sect.lastEntry);
GC::Mark(sect.lastEntry);
if (isDukeEngine()) GC::Mark(sect.hitagactor);
if (isDukeEngine())
{
Printmark(sect.hitagactor);
GC::Mark(sect.hitagactor);
}
else if (isBlood())
{
GC::Mark(sect.upperLink);
Expand Down
3 changes: 2 additions & 1 deletion source/core/shared_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ void CreateAltHUD()
AltHud = DoCreateAltHUD(NAME_AltHud);

assert(AltHud);
GC::AddMarkerFunc([]() { GC::Mark(AltHud); });
GC::AddMarkerFunc([]() { Printmark(AltHud);
GC::Mark(AltHud); });
}


Expand Down
4 changes: 4 additions & 0 deletions source/games/duke/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ size_t DDukeActor::PropagateMark()

static void markgcroots()
{
Printmark(camsprite);
GC::Mark(camsprite);
Printf("mark spriteq\n");
GC::MarkArray(spriteq, 1024);
Printmark(currentCommentarySprite);
GC::Mark(currentCommentarySprite);
Printmark(ud.cameraactor);
GC::Mark(ud.cameraactor);
}

Expand Down
5 changes: 1 addition & 4 deletions source/games/duke/src/gamevar.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ class GameVarValue

bool operator==(const GameVarValue& other) const { return index == other.index; }
bool operator!=(const GameVarValue& other) const { return index != other.index; }
void Mark()
{
if (isActor()) GC::Mark(ActorP);
}
void Mark();
};

enum
Expand Down
10 changes: 10 additions & 0 deletions source/games/duke/src/player_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1971,5 +1971,15 @@ void processinput_d(DDukePlayer* const p)
processweapon(p, actions);
}


void GameVarValue::Mark()
{
if (isActor())
{
Printmark(ActorP);
GC::Mark(ActorP);
}
}

END_DUKE_NS

0 comments on commit b43f95e

Please sign in to comment.