PrintCallStack: "Fix" entry suppression

Backtraces may contain non-specific entries (n.b. FromListFilePath in
cmListFileContext). Our prior expectation is that these will ALWAYS
replaced by more specific entries. However, with the previous change to
allow users to create arbitrary stack entries, this is no longer the
case. Modify PrintCallStack to only skip printing these non-specific
entries if they were in fact preceded by a more specific entry.

This, and the functionality of the preceding commit, is intended to be
used for CPS dependency resolution. Because said resolution may fail at
a non-trivial depth, it is important to be able to provide the user with
the path of packages that led to the failure. However, because this
happens through parsing JSON, there is no listfile function to associate
with the stack entries, nor do we attempt to keep track of line numbers
from the JSON. As a result, these entries will never be more specific
than the name of the CPS file whose dependencies we are trying to
locate.
This commit is contained in:
Matthew Woehlke
2024-12-06 15:10:14 -05:00
committed by Brad King
parent a73955ae76
commit dcaa52c6c3
2 changed files with 12 additions and 7 deletions
+4 -4
View File
@@ -138,10 +138,10 @@ public:
static cmListFileContext FromListFilePath(std::string const& filePath)
{
// We are entering a file-level scope but have not yet reached
// any specific line or command invocation within it. This context
// is useful to print when it is at the top but otherwise can be
// skipped during call stack printing.
// We are entering a file-level scope but have not yet reached any specific
// line or command invocation within it. This context is useful to print
// when it is at the top, but otherwise can be skipped during call stack
// printing if preceded by a more specific entry.
cmListFileContext lfc;
lfc.FilePath = filePath;
return lfc;