MCPcopy Create free account
hub / github.com/Kitware/CMake / PrintCallStack

Function PrintCallStack

Source/cmMessenger.cxx:112–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void PrintCallStack(std::ostream& out, cmListFileBacktrace bt,
113 cm::optional<std::string> const& topSource)
114{
115 // The call stack exists only if we have at least two calls on top
116 // of the bottom.
117 if (bt.Empty()) {
118 return;
119 }
120 std::string lastFilePath = bt.Top().FilePath;
121 bt = bt.Pop();
122 if (bt.Empty()) {
123 return;
124 }
125
126 bool first = true;
127 for (; !bt.Empty(); bt = bt.Pop()) {
128 cmListFileContext lfc = bt.Top();
129 if (lfc.Name.empty() &&
130 lfc.Line != cmListFileContext::DeferPlaceholderLine &&
131 lfc.FilePath == lastFilePath) {
132 // An entry with no function name is frequently preceded (in the stack)
133 // by a more specific entry. When this happens (as verified by the
134 // preceding entry referencing the same file path), skip the less
135 // specific entry, as we have already printed the more specific one.
136 continue;
137 }
138 if (first) {
139 first = false;
140 out << "Call Stack (most recent call first):\n";
141 }
142 lastFilePath = lfc.FilePath;
143 if (topSource) {
144 lfc.FilePath = cmSystemTools::RelativeIfUnder(*topSource, lfc.FilePath);
145 }
146 out << " " << lfc << '\n';
147 }
148}
149
150} // anonymous namespace
151

Callers 1

DisplayMessageMethod · 0.85

Calls 4

RelativeIfUnderFunction · 0.85
EmptyMethod · 0.80
PopMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…