[Lldb-commits] [lldb] 18a8527 - [trace][intel-pt] Fix a crash on unconsumed Expected's Error

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 22 13:27:16 PDT 2021


Author: Jan Kratochvil
Date: 2021-04-22T22:27:08+02:00
New Revision: 18a85276426b9604a9ceca8c528b694964dd8d7c

URL: https://github.com/llvm/llvm-project/commit/18a85276426b9604a9ceca8c528b694964dd8d7c
DIFF: https://github.com/llvm/llvm-project/commit/18a85276426b9604a9ceca8c528b694964dd8d7c.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Plugins/Process/Linux/IntelPTManager.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/Linux/IntelPTManager.cpp b/lldb/source/Plugins/Process/Linux/IntelPTManager.cpp
index 14b08a6aa93c0..00aed576eb1d5 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTManager.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTManager.cpp
@@ -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;


        


More information about the lldb-commits mailing list