@@ -49,7 +49,7 @@ static const Stmt *getStmtForDiagnostics(const ExplodedNode *N)
4949}
5050
5151// Turn on/off the log here
52- #define DEBUG_LOG 0
52+ #define DEBUG_LOG 1
5353
5454class GCChecker
5555 : public Checker<
@@ -106,8 +106,14 @@ class GCChecker
106106 : (P == Moved) ? " Moved"
107107 : " Error" );
108108 llvm::dbgs () << " ," ;
109- if (S == Rooted)
110- llvm::dbgs () << " (" << RootDepth << " )" ;
109+ if (S == Rooted) {
110+ llvm::dbgs () << " Root(" ;
111+ if (Root) {
112+ Root->dump ();
113+ llvm::dbgs () << " ," ;
114+ }
115+ llvm::dbgs () << RootDepth << " )" ;
116+ }
111117 }
112118
113119 bool operator ==(const ValueState &VS) const {
@@ -1673,12 +1679,20 @@ bool GCChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
16731679 PoppedRoots.push_back (I.getKey ());
16741680 State = State->remove <GCRootMap>(I.getKey ());
16751681 State = State->remove <GCPinMap>(I.getKey ());
1682+ logWithDump (" - pop root" , I.getKey ());
16761683 }
16771684 }
1685+ log (" - Iterate value map" );
16781686 GCValueMapTy VMap = State->get <GCValueMap>();
16791687 for (const MemRegion *R : PoppedRoots) {
1688+ logWithDump (" -- check popped root" , R);
16801689 for (auto I = VMap.begin (), E = VMap.end (); I != E; ++I) {
1690+ logWithDump (" --- check value" , I.getKey ());
1691+ logWithDump (" --- check state" , I.getData ());
1692+ // FIXME: If this is a pop for TPin frame, we should remove TPin as well.
1693+ // For any region that is reachable from R, its pinning state should be reset.
16811694 if (I.getData ().isRootedBy (R)) {
1695+ logWithDump (" --- no longer rooted" , ValueState::getAllocated ());
16821696 State =
16831697 State->set <GCValueMap>(I.getKey (), ValueState::getAllocated ());
16841698 }
@@ -1707,11 +1721,17 @@ bool GCChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
17071721 return true ;
17081722 }
17091723 const MemRegion *Region = MRV->getRegion ();
1710- State = State->set <GCRootMap>(Region, RootState::getRoot (CurrentDepth));
1724+ RootState RS = RootState::getRoot (CurrentDepth);
1725+ State = State->set <GCRootMap>(Region, RS);
1726+ logWithDump (" - JL_GC_PUSH, Region" , Region);
1727+ logWithDump (" - JL_GC_PUSH, RS" , RS);
1728+ PinState PS = PinState::getNoPin (-1 );
17111729 if (tpin)
1712- State = State-> set <GCPinMap>(Region, PinState::getTransitivePin (CurrentDepth) );
1730+ PS = PinState::getTransitivePin (CurrentDepth);
17131731 else
1714- State = State->set <GCPinMap>(Region, PinState::getPin (CurrentDepth));
1732+ PS = PinState::getPin (CurrentDepth);
1733+ State = State->set <GCPinMap>(Region, PS);
1734+ logWithDump (" - JL_GC_PUSH, PS" , PS);
17151735 // Now for the value
17161736 SVal Value = State->getSVal (Region);
17171737 SymbolRef Sym = Value.getAsSymbol ();
@@ -1730,6 +1750,8 @@ bool GCChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
17301750 else
17311751 VS = ValueState::getPinned (VS);
17321752 State = State->set <GCValueMap>(Sym, VS);
1753+ logWithDump (" - JL_GC_PUSH, Sym" , Sym);
1754+ logWithDump (" - JL_GC_PUSH, VS" , VS);
17331755 }
17341756 CurrentDepth += 1 ;
17351757 State = State->set <GCDepth>(CurrentDepth);
0 commit comments