summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-05-29 20:37:59 (GMT)
committerBrad King <brad.king@kitware.com>2015-07-06 15:22:42 (GMT)
commitd2475bb5c4488a0ef6015f13ee46ddc7a2e4455b (patch)
treed590a226216dde3fad489be3170f240b40f459ee /Source/cmListFileCache.cxx
parent238aac23514ecdae0d4edb71033e443f30e94158 (diff)
downloadCMake-d2475bb5c4488a0ef6015f13ee46ddc7a2e4455b.zip
CMake-d2475bb5c4488a0ef6015f13ee46ddc7a2e4455b.tar.gz
CMake-d2475bb5c4488a0ef6015f13ee46ddc7a2e4455b.tar.bz2
cmListFileBacktrace: Implement in terms of cmState::Snapshot.
Avoid copying many strings into each backtrace object.
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r--Source/cmListFileCache.cxx38
1 files changed, 24 insertions, 14 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 9141d88..1097dc2 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -398,40 +398,50 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
}
}
-void cmListFileBacktrace::Append(cmListFileContext const& context)
-{
- this->push_back(context);
-}
-
void cmListFileBacktrace::PrintTitle(std::ostream& out)
{
- if (this->empty())
+ if (!this->Snapshot.IsValid())
{
return;
}
-
cmOutputConverter converter(this->Snapshot);
- cmListFileContext lfc = this->front();
+ cmListFileContext lfc =
+ cmListFileContext::FromCommandContext(
+ this->Context, this->Snapshot.GetExecutionListFile());
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
out << (lfc.Line ? " at " : " in ") << lfc;
}
void cmListFileBacktrace::PrintCallStack(std::ostream& out)
{
- if (size() <= 1)
+ if (!this->Snapshot.IsValid())
+ {
+ return;
+ }
+ cmState::Snapshot parent = this->Snapshot.GetCallStackParent();
+ if (!parent.IsValid() || parent.GetExecutionListFile().empty())
{
return;
}
cmOutputConverter converter(this->Snapshot);
- const_iterator i = this->begin() + 1;
+ std::string commandName = this->Snapshot.GetEntryPointCommand();
+ long commandLine = this->Snapshot.GetEntryPointLine();
+
out << "Call Stack (most recent call first):\n";
- while(i != this->end())
+ while(parent.IsValid())
{
- cmListFileContext lfc = *i;
- lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
+ cmListFileContext lfc;
+ lfc.Name = commandName;
+ lfc.Line = commandLine;
+
+ lfc.FilePath = converter.Convert(parent.GetExecutionListFile(),
+ cmOutputConverter::HOME);
out << " " << lfc << "\n";
- ++i;
+
+ commandName = parent.GetEntryPointCommand();
+ commandLine = parent.GetEntryPointLine();
+ parent = parent.GetCallStackParent();
}
}