| 110 | } |
| 111 | |
| 112 | void 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 |
no test coverage detected
searching dependent graphs…