[trace][intel-pt] Fix a crash on unconsumed Expected's Error

Reproducible with build using libipt and -DLLVM_ENABLE_ASSERTIONS=ON:
(lldb) b main
(lldb) r
(lldb) process trace start
This commit is contained in:
Jan Kratochvil 2021-04-22 22:24:05 +02:00
parent 16ff1a7023
commit 18a8527642
1 changed files with 8 additions and 1 deletions

View File

@ -542,7 +542,14 @@ IntelPTManager::GetBinaryData(const TraceGetBinaryDataRequest &request) const {
void IntelPTManager::ClearProcessTracing() { m_process_trace = None; }
bool IntelPTManager::IsSupported() { return (bool)GetOSEventType(); }
bool IntelPTManager::IsSupported() {
Expected<uint32_t> intel_pt_type = GetOSEventType();
if (!intel_pt_type) {
llvm::consumeError(intel_pt_type.takeError());
return false;
}
return true;
}
bool IntelPTManager::IsProcessTracingEnabled() const {
return (bool)m_process_trace;