[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 20 17:15:38 PST 2023


=?utf-8?q?José?= L. Junior <jljuniorpb at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/76112 at github.com>


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 912506b75d8a508353a701c230e73ca45a253161 648ec67f79e91ad4baaec40df3f07bf60fe5f8a7 -- lldb/include/lldb/Core/Address.h lldb/include/lldb/Symbol/Symbol.h lldb/include/lldb/Symbol/SymbolContext.h lldb/include/lldb/Utility/Stream.h lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/Address.cpp lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/SymbolContext.cpp lldb/source/Utility/Stream.cpp
``````````

</details>

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

``````````diff
diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index c5a47321c7..80c43bbe00 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -9,11 +9,11 @@
 #ifndef LLDB_CORE_ADDRESS_H
 #define LLDB_CORE_ADDRESS_H
 
+#include "lldb/Utility/Stream.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
 #include "lldb/lldb-types.h"
-#include "lldb/Utility/Stream.h"
 
 #include "llvm/ADT/StringRef.h"
 
@@ -257,7 +257,6 @@ public:
             DumpStyle fallback_style = DumpStyleInvalid,
             uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
             std::optional<Information> pattern_info = std::nullopt) const;
-            
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h
index 96ba7ba282..f5ba14be75 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -13,10 +13,10 @@
 #include "lldb/Core/Mangled.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Utility/Stream.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 #include "llvm/Support/JSON.h"
-#include "lldb/Utility/Stream.h"
 
 namespace lldb_private {
 
@@ -175,8 +175,9 @@ public:
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
-                      std::optional<Information> pattern_info = std::nullopt) const;
+  void
+  GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+                 std::optional<Information> pattern_info = std::nullopt) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h
index 529dc96308..74be06e742 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -154,11 +154,12 @@ public:
   ///
   /// \return
   ///     \b true if some text was dumped, \b false otherwise.
-  bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
-                       const Address &so_addr, bool show_fullpaths,
-                       bool show_module, bool show_inlined_frames,
-                       bool show_function_arguments, bool show_function_name,
-                       std::optional<Information> pattern_info = std::nullopt) const;
+  bool
+  DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
+                  const Address &so_addr, bool show_fullpaths, bool show_module,
+                  bool show_inlined_frames, bool show_function_arguments,
+                  bool show_function_name,
+                  std::optional<Information> pattern_info = std::nullopt) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -224,8 +225,9 @@ public:
   ///     The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
-                      std::optional<Information> pattern_info = std::nullopt) const;
+  void
+  GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+                 std::optional<Information> pattern_info = std::nullopt) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h
index 7aed0a8316..00c9d15b19 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -24,13 +24,13 @@
 namespace lldb_private {
 
 struct Information {
-    llvm::StringRef pattern;
-    llvm::StringRef prefix;
-    llvm::StringRef suffix;
-    
-    // Constructor
-    Information(llvm::StringRef p, llvm::StringRef pre, llvm::StringRef suf)
-        : pattern(p), prefix(pre), suffix(suf) {}
+  llvm::StringRef pattern;
+  llvm::StringRef prefix;
+  llvm::StringRef suffix;
+
+  // Constructor
+  Information(llvm::StringRef p, llvm::StringRef pre, llvm::StringRef suf)
+      : pattern(p), prefix(pre), suffix(suf) {}
 };
 
 /// \class Stream Stream.h "lldb/Utility/Stream.h"
@@ -270,8 +270,9 @@ public:
   ///     The ANSI color code to end colorization. This is
   ///     environment-dependent.
 
-  void PutCStringColorHighlighted(llvm::StringRef text,
-                                  std::optional<Information> pattern_info = std::nullopt);
+  void PutCStringColorHighlighted(
+      llvm::StringRef text,
+      std::optional<Information> pattern_info = std::nullopt);
 
   /// Output and End of Line character to the stream.
   size_t EOL();
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index ed2e3fee19..3d0c701021 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -53,9 +53,9 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
+#include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/Timer.h"
-#include "lldb/Utility/Stream.h"
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-enumerations.h"
 
@@ -1532,9 +1532,10 @@ static void DumpOsoFilesTable(Stream &strm,
   });
 }
 
-static void DumpAddress(ExecutionContextScope *exe_scope,
-                        const Address &so_addr, bool verbose, bool all_ranges,
-                        Stream &strm, std::optional<Information> pattern_info = std::nullopt) {
+static void
+DumpAddress(ExecutionContextScope *exe_scope, const Address &so_addr,
+            bool verbose, bool all_ranges, Stream &strm,
+            std::optional<Information> pattern_info = std::nullopt) {
   strm.IndentMore();
   strm.Indent("    Address: ");
   so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress);
@@ -1612,9 +1613,9 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter,
 
   if (num_matches > 0) {
     llvm::StringRef ansi_prefix =
-          interpreter.GetDebugger().GetRegexMatchAnsiPrefix();
-      llvm::StringRef ansi_suffix =
-          interpreter.GetDebugger().GetRegexMatchAnsiSuffix();
+        interpreter.GetDebugger().GetRegexMatchAnsiPrefix();
+    llvm::StringRef ansi_suffix =
+        interpreter.GetDebugger().GetRegexMatchAnsiSuffix();
     Information info(name, ansi_prefix, ansi_suffix);
     strm.Indent();
     strm.Printf("%u symbols match %s'%s' in ", num_matches,
@@ -1629,7 +1630,8 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter,
           DumpAddress(
               interpreter.GetExecutionContext().GetBestExecutionContextScope(),
               symbol->GetAddressRef(), verbose, all_ranges, strm,
-              use_color && name_is_regex ? std::optional<Information>{info} : std::nullopt);
+              use_color && name_is_regex ? std::optional<Information>{info}
+                                         : std::nullopt);
           strm.EOL();
         } else {
           strm.IndentMore();
@@ -1653,11 +1655,11 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter,
   return num_matches;
 }
 
-static void DumpSymbolContextList(ExecutionContextScope *exe_scope,
-                                  Stream &strm,
-                                  const SymbolContextList &sc_list,
-                                  bool verbose, bool all_ranges, 
-                                  std::optional<Information> pattern_info = std::nullopt) {
+static void
+DumpSymbolContextList(ExecutionContextScope *exe_scope, Stream &strm,
+                      const SymbolContextList &sc_list, bool verbose,
+                      bool all_ranges,
+                      std::optional<Information> pattern_info = std::nullopt) {
   strm.IndentMore();
   bool first_module = true;
   for (const SymbolContext &sc : sc_list) {
@@ -1693,9 +1695,9 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter,
     num_matches = sc_list.GetSize();
     if (num_matches) {
       llvm::StringRef ansi_prefix =
-            interpreter.GetDebugger().GetRegexMatchAnsiPrefix();
-        llvm::StringRef ansi_suffix =
-            interpreter.GetDebugger().GetRegexMatchAnsiSuffix();
+          interpreter.GetDebugger().GetRegexMatchAnsiPrefix();
+      llvm::StringRef ansi_suffix =
+          interpreter.GetDebugger().GetRegexMatchAnsiSuffix();
       Information info(name, ansi_prefix, ansi_suffix);
       strm.Indent();
       strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches,
@@ -1705,7 +1707,8 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter,
       DumpSymbolContextList(
           interpreter.GetExecutionContext().GetBestExecutionContextScope(),
           strm, sc_list, verbose, all_ranges,
-          use_color && name_is_regex ? std::optional<Information>{info} : std::nullopt);
+          use_color && name_is_regex ? std::optional<Information>{info}
+                                     : std::nullopt);
     }
     return num_matches;
   }
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index fe6ec00ad2..81f3e6c090 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -407,7 +407,8 @@ bool Address::GetDescription(Stream &s, Target &target,
 
 bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
                    DumpStyle fallback_style, uint32_t addr_size,
-                   bool all_ranges, std::optional<Information> pattern_info) const {
+                   bool all_ranges,
+                   std::optional<Information> pattern_info) const {
   // If the section was nullptr, only load address is going to work unless we
   // are trying to deref a pointer
   SectionSP section_sp(GetSection());
diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 60763f878b..67223b5c2b 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -227,7 +227,8 @@ bool Symbol::IsTrampoline() const { return m_type == eSymbolTypeTrampoline; }
 bool Symbol::IsIndirect() const { return m_type == eSymbolTypeResolver; }
 
 void Symbol::GetDescription(Stream *s, lldb::DescriptionLevel level,
-                            Target *target, std::optional<Information> pattern_info) const {
+                            Target *target,
+                            std::optional<Information> pattern_info) const {
   s->Printf("id = {0x%8.8x}", m_uid);
 
   if (m_addr_range.GetBaseAddress().GetSection()) {
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index 10dc266c00..4659cf90f4 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -24,8 +24,8 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
-#include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-enumerations.h"
 
 using namespace lldb;
@@ -69,12 +69,11 @@ void SymbolContext::Clear(bool clear_target) {
   variable = nullptr;
 }
 
-bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
-                                    const Address &addr, bool show_fullpaths,
-                                    bool show_module, bool show_inlined_frames,
-                                    bool show_function_arguments,
-                                    bool show_function_name,
-                                    std::optional<Information> pattern_info) const {
+bool SymbolContext::DumpStopContext(
+    Stream *s, ExecutionContextScope *exe_scope, const Address &addr,
+    bool show_fullpaths, bool show_module, bool show_inlined_frames,
+    bool show_function_arguments, bool show_function_name,
+    std::optional<Information> pattern_info) const {
   bool dumped_something = false;
   if (show_module && module_sp) {
     if (show_fullpaths)
@@ -201,9 +200,9 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
   return dumped_something;
 }
 
-void SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level,
-                                   Target *target,
-                                   std::optional<Information> pattern_info) const {
+void SymbolContext::GetDescription(
+    Stream *s, lldb::DescriptionLevel level, Target *target,
+    std::optional<Information> pattern_info) const {
   if (module_sp) {
     s->Indent("     Module: file = \"");
     module_sp->GetFileSpec().Dump(s->AsRawOstream());
diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp
index 9a670ea9b5..f9a8d84c87 100644
--- a/lldb/source/Utility/Stream.cpp
+++ b/lldb/source/Utility/Stream.cpp
@@ -72,8 +72,8 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
-void Stream::PutCStringColorHighlighted(llvm::StringRef text,
-                                        std::optional<Information> pattern_info) {
+void Stream::PutCStringColorHighlighted(
+    llvm::StringRef text, std::optional<Information> pattern_info) {
   // Only apply color formatting when a pattern is present and both prefix and
   // suffix are specified. In the absence of these conditions, output the text
   // without color formatting.
@@ -86,7 +86,8 @@ void Stream::PutCStringColorHighlighted(llvm::StringRef text,
   llvm::SmallVector<llvm::StringRef, 1> matches;
   llvm::StringRef remaining = text;
   std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes(
-      pattern_info.value().prefix.str() + "%.*s" + pattern_info.value().suffix.str());
+      pattern_info.value().prefix.str() + "%.*s" +
+      pattern_info.value().suffix.str());
   while (reg_pattern.match(remaining, &matches)) {
     llvm::StringRef match = matches[0];
     size_t match_start_pos = match.data() - remaining.data();

``````````

</details>


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


More information about the lldb-commits mailing list