[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 17 15:02:10 PDT 2023


github-actions[bot] wrote:


<!--LLVM CODE FORMAT COMMENT: {clang-format}-->

:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff cf670d5e56d14afa7c3e005c13588fd7b5ee75ce 76493df4dcfc055ec0b4f7d745f3799b904f679d -- lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.cpp lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.h lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.cpp lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.h lldb/include/lldb/lldb-enumerations.h lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 8bcbae47b104..6db39d1eb3f6 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -81,7 +81,8 @@ bool InstrumentationRuntimeASan::NotifyBreakpointHit(
 
   ProcessSP process_sp = instance->GetProcessSP();
 
-  return ReportRetriever::NotifyBreakpointHit(process_sp, context, break_id, break_loc_id);
+  return ReportRetriever::NotifyBreakpointHit(process_sp, context, break_id,
+                                              break_loc_id);
 }
 
 void InstrumentationRuntimeASan::Activate() {
@@ -92,7 +93,8 @@ void InstrumentationRuntimeASan::Activate() {
   if (!process_sp)
     return;
 
-  Breakpoint *breakpoint = ReportRetriever::SetupBreakpoint(GetRuntimeModuleSP(), process_sp, ConstString("_ZN6__asanL7AsanDieEv"));
+  Breakpoint *breakpoint = ReportRetriever::SetupBreakpoint(
+      GetRuntimeModuleSP(), process_sp, ConstString("_ZN6__asanL7AsanDieEv"));
 
   if (!breakpoint)
     return;
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.cpp
index 6ab9f28010ae..04ee0ba8129a 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.cpp
@@ -1,4 +1,5 @@
-//===-- InstrumentationRuntimeLibsanitizers.cpp ------------------------------------===//
+//===-- InstrumentationRuntimeLibsanitizers.cpp
+//------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -22,13 +23,16 @@ using namespace lldb_private;
 LLDB_PLUGIN_DEFINE(InstrumentationRuntimeLibsanitizers)
 
 lldb::InstrumentationRuntimeSP
-InstrumentationRuntimeLibsanitizers::CreateInstance(const lldb::ProcessSP &process_sp) {
-  return InstrumentationRuntimeSP(new InstrumentationRuntimeLibsanitizers(process_sp));
+InstrumentationRuntimeLibsanitizers::CreateInstance(
+    const lldb::ProcessSP &process_sp) {
+  return InstrumentationRuntimeSP(
+      new InstrumentationRuntimeLibsanitizers(process_sp));
 }
 
 void InstrumentationRuntimeLibsanitizers::Initialize() {
   PluginManager::RegisterPlugin(
-      GetPluginNameStatic(), "AddressSanitizer instrumentation runtime plugin for Libsanitizers.",
+      GetPluginNameStatic(),
+      "AddressSanitizer instrumentation runtime plugin for Libsanitizers.",
       CreateInstance, GetTypeStatic);
 }
 
@@ -36,11 +40,14 @@ void InstrumentationRuntimeLibsanitizers::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb::InstrumentationRuntimeType InstrumentationRuntimeLibsanitizers::GetTypeStatic() {
+lldb::InstrumentationRuntimeType
+InstrumentationRuntimeLibsanitizers::GetTypeStatic() {
   return eInstrumentationRuntimeTypeLibsanitizersAsan;
 }
 
-InstrumentationRuntimeLibsanitizers::~InstrumentationRuntimeLibsanitizers() { Deactivate(); }
+InstrumentationRuntimeLibsanitizers::~InstrumentationRuntimeLibsanitizers() {
+  Deactivate();
+}
 
 const RegularExpression &
 InstrumentationRuntimeLibsanitizers::GetPatternForRuntimeLibrary() {
@@ -70,7 +77,8 @@ bool InstrumentationRuntimeLibsanitizers::NotifyBreakpointHit(
 
   ProcessSP process_sp = instance->GetProcessSP();
 
-  return ReportRetriever::NotifyBreakpointHit(process_sp, context, break_id, break_loc_id);
+  return ReportRetriever::NotifyBreakpointHit(process_sp, context, break_id,
+                                              break_loc_id);
 }
 
 void InstrumentationRuntimeLibsanitizers::Activate() {
@@ -81,15 +89,17 @@ void InstrumentationRuntimeLibsanitizers::Activate() {
   if (!process_sp)
     return;
 
-  Breakpoint *breakpoint = ReportRetriever::SetupBreakpoint(GetRuntimeModuleSP(), process_sp, ConstString("_Z22raise_sanitizers_error23sanitizer_error_context"));
+  Breakpoint *breakpoint = ReportRetriever::SetupBreakpoint(
+      GetRuntimeModuleSP(), process_sp,
+      ConstString("_Z22raise_sanitizers_error23sanitizer_error_context"));
 
   if (!breakpoint)
     return;
 
   bool sync = false;
 
-  breakpoint->SetCallback(InstrumentationRuntimeLibsanitizers::NotifyBreakpointHit, this,
-                          sync);
+  breakpoint->SetCallback(
+      InstrumentationRuntimeLibsanitizers::NotifyBreakpointHit, this, sync);
   breakpoint->SetBreakpointKind("address-sanitizer-report");
   SetBreakpointID(breakpoint->GetID());
 
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.h b/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.h
index 44eeb3669e9f..b4336a6fdfb4 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/Libsanitizers/InstrumentationRuntimeLibsanitizers.h
@@ -1,4 +1,5 @@
-//===-- InstrumentationRuntimeLibsanitizers.h ----------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeLibsanitizers.h ----------------------------*- C++
+//-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,10 +12,10 @@
 
 #include "../ReportRetriever.h"
 
-
 namespace lldb_private {
 
-class InstrumentationRuntimeLibsanitizers : public lldb_private::InstrumentationRuntime {
+class InstrumentationRuntimeLibsanitizers
+    : public lldb_private::InstrumentationRuntime {
 public:
   ~InstrumentationRuntimeLibsanitizers() override;
 
@@ -53,4 +54,4 @@ private:
 
 } // namespace lldb_private
 
-#endif //LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_ASAN_INSTRUMENTATIONRUNTIMELIBSANITIZERS_H
+#endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_ASAN_INSTRUMENTATIONRUNTIMELIBSANITIZERS_H
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.cpp
index 78b5abcaf829..f5f8dcbfbc52 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.cpp
@@ -55,7 +55,8 @@ t.description = __asan_get_report_description();
 t
 )";
 
-StructuredData::ObjectSP ReportRetriever::RetrieveReportData(const ProcessSP process_sp) {
+StructuredData::ObjectSP
+ReportRetriever::RetrieveReportData(const ProcessSP process_sp) {
   if (!process_sp)
     return StructuredData::ObjectSP();
 
@@ -101,7 +102,7 @@ StructuredData::ObjectSP ReportRetriever::RetrieveReportData(const ProcessSP pro
   addr_t pc =
       return_value_sp->GetValueForExpressionPath(".pc")->GetValueAsUnsigned(0);
   addr_t bp =
-  return_value_sp->GetValueForExpressionPath(".bp")->GetValueAsUnsigned(0);
+      return_value_sp->GetValueForExpressionPath(".bp")->GetValueAsUnsigned(0);
   addr_t sp =
       return_value_sp->GetValueForExpressionPath(".sp")->GetValueAsUnsigned(0);
   addr_t address = return_value_sp->GetValueForExpressionPath(".address")
@@ -180,9 +181,10 @@ ReportRetriever::FormatDescription(StructuredData::ObjectSP report) {
       .Default("AddressSanitizer detected: " + description);
 }
 
-bool ReportRetriever::NotifyBreakpointHit(
-    ProcessSP process_sp, StoppointCallbackContext *context,
-    user_id_t break_id, user_id_t break_loc_id) {
+bool ReportRetriever::NotifyBreakpointHit(ProcessSP process_sp,
+                                          StoppointCallbackContext *context,
+                                          user_id_t break_id,
+                                          user_id_t break_loc_id) {
 
   if (process_sp->GetModIDRef().IsLastResumeForUserExpression())
     return false;
@@ -213,9 +215,11 @@ bool ReportRetriever::NotifyBreakpointHit(
   return false; // Let target run
 }
 
-Breakpoint* ReportRetriever::SetupBreakpoint(ModuleSP module_sp, ProcessSP process_sp, ConstString symbol_name) {
-  const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
-      symbol_name, eSymbolTypeCode);
+Breakpoint *ReportRetriever::SetupBreakpoint(ModuleSP module_sp,
+                                             ProcessSP process_sp,
+                                             ConstString symbol_name) {
+  const Symbol *symbol =
+      module_sp->FindFirstSymbolWithNameAndType(symbol_name, eSymbolTypeCode);
 
   if (symbol == nullptr)
     return nullptr;
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.h b/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.h
index d66e548fb99e..2a5571a26c5a 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/ReportRetriever.h
@@ -14,18 +14,21 @@
 namespace lldb_private {
 
 class ReportRetriever {
-  private:
-  static StructuredData::ObjectSP RetrieveReportData(const lldb::ProcessSP process_sp);
+private:
+  static StructuredData::ObjectSP
+  RetrieveReportData(const lldb::ProcessSP process_sp);
 
   static std::string FormatDescription(StructuredData::ObjectSP report);
-  public:
 
+public:
   static bool NotifyBreakpointHit(lldb::ProcessSP process_sp,
-    StoppointCallbackContext *context, lldb::user_id_t break_id,
-    lldb::user_id_t break_loc_id);
+                                  StoppointCallbackContext *context,
+                                  lldb::user_id_t break_id,
+                                  lldb::user_id_t break_loc_id);
 
-  static Breakpoint *SetupBreakpoint(lldb::ModuleSP, lldb::ProcessSP, ConstString);
+  static Breakpoint *SetupBreakpoint(lldb::ModuleSP, lldb::ProcessSP,
+                                     ConstString);
 };
 } // namespace lldb_private
 
-#endif //LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_ASAN_REPORTRETRIEVER_H
+#endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_ASAN_REPORTRETRIEVER_H

``````````

</details>


https://github.com/llvm/llvm-project/pull/69388


More information about the lldb-commits mailing list