@@ -49,7 +49,7 @@ static const Stmt *getStmtForDiagnostics(const ExplodedNode *N)
49
49
}
50
50
51
51
// Turn on/off the log here
52
- #define DEBUG_LOG 0
52
+ #define DEBUG_LOG 1
53
53
54
54
class GCChecker
55
55
: public Checker<
@@ -106,8 +106,14 @@ class GCChecker
106
106
: (P == Moved) ? " Moved"
107
107
: " Error" );
108
108
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
+ }
111
117
}
112
118
113
119
bool operator ==(const ValueState &VS) const {
@@ -1673,12 +1679,20 @@ bool GCChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
1673
1679
PoppedRoots.push_back (I.getKey ());
1674
1680
State = State->remove <GCRootMap>(I.getKey ());
1675
1681
State = State->remove <GCPinMap>(I.getKey ());
1682
+ logWithDump (" - pop root" , I.getKey ());
1676
1683
}
1677
1684
}
1685
+ log (" - Iterate value map" );
1678
1686
GCValueMapTy VMap = State->get <GCValueMap>();
1679
1687
for (const MemRegion *R : PoppedRoots) {
1688
+ logWithDump (" -- check popped root" , R);
1680
1689
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.
1681
1694
if (I.getData ().isRootedBy (R)) {
1695
+ logWithDump (" --- no longer rooted" , ValueState::getAllocated ());
1682
1696
State =
1683
1697
State->set <GCValueMap>(I.getKey (), ValueState::getAllocated ());
1684
1698
}
@@ -1707,11 +1721,17 @@ bool GCChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
1707
1721
return true ;
1708
1722
}
1709
1723
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 );
1711
1729
if (tpin)
1712
- State = State-> set <GCPinMap>(Region, PinState::getTransitivePin (CurrentDepth) );
1730
+ PS = PinState::getTransitivePin (CurrentDepth);
1713
1731
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);
1715
1735
// Now for the value
1716
1736
SVal Value = State->getSVal (Region);
1717
1737
SymbolRef Sym = Value.getAsSymbol ();
@@ -1730,6 +1750,8 @@ bool GCChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
1730
1750
else
1731
1751
VS = ValueState::getPinned (VS);
1732
1752
State = State->set <GCValueMap>(Sym, VS);
1753
+ logWithDump (" - JL_GC_PUSH, Sym" , Sym);
1754
+ logWithDump (" - JL_GC_PUSH, VS" , VS);
1733
1755
}
1734
1756
CurrentDepth += 1 ;
1735
1757
State = State->set <GCDepth>(CurrentDepth);
0 commit comments