[Lldb-commits] [PATCH] D121062: [lldb] Add a setting to change the progress color

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Mar 5 16:08:49 PST 2022


JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, labath.
Herald added a project: All.
JDevlieghere requested review of this revision.
Herald added a project: LLDB.

Add a setting to change how progress is shown in a color enabled terminal. This follows the existing `-prefix`, `-suffix` pattern that's used elsewhere in lldb.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121062

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp


Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -436,6 +436,16 @@
   return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
 }
 
+llvm::StringRef Debugger::GetShowProgressPrefix() const {
+  const uint32_t idx = ePropertyShowProgressPrefix;
+  return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
+llvm::StringRef Debugger::GetShowProgressSuffix() const {
+  const uint32_t idx = ePropertyShowProgressSuffix;
+  return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
 uint32_t Debugger::GetStopSourceLineCount(bool before) const {
   const uint32_t idx =
       before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter;
@@ -1769,6 +1779,12 @@
     return;
   }
 
+  const bool use_color = GetUseColor();
+  llvm::StringRef prefix = GetShowProgressPrefix();
+  if (!prefix.empty())
+    output.Printf("%s",
+                  ansi::FormatAnsiTerminalCodes(prefix, use_color).c_str());
+
   // Print over previous line, if any.
   output.Printf("\r");
 
@@ -1781,6 +1797,11 @@
     output.Printf("%s...", message.c_str());
   }
 
+  llvm::StringRef suffix = GetShowProgressSuffix();
+  if (!suffix.empty())
+    output.Printf("%s",
+                  ansi::FormatAnsiTerminalCodes(suffix, use_color).c_str());
+
   // Clear until the end of the line.
   output.Printf("\x1B[K");
 
Index: lldb/source/Core/CoreProperties.td
===================================================================
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -135,6 +135,14 @@
     Global,
     DefaultTrue,
     Desc<"Whether to show progress or not.">;
+  def ShowProgressPrefix: Property<"show-progress-prefix", "String">,
+    Global,
+    DefaultStringValue<"${ansi.faint}">,
+    Desc<"When displaying progress a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the column to be marked.">;
+  def ShowProgressSuffix: Property<"show-progress-suffix", "String">,
+    Global,
+    DefaultStringValue<"${ansi.normal}">,
+    Desc<"When displaying progress a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the line to be marked.">;
   def UseSourceCache: Property<"use-source-cache", "Boolean">,
     Global,
     DefaultTrue,
Index: lldb/include/lldb/Core/Debugger.h
===================================================================
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -345,6 +345,10 @@
 
   llvm::StringRef GetStopShowColumnAnsiSuffix() const;
 
+  llvm::StringRef GetShowProgressPrefix() const;
+
+  llvm::StringRef GetShowProgressSuffix() const;
+
   uint32_t GetStopSourceLineCount(bool before) const;
 
   StopDisassemblyType GetStopDisassemblyDisplay() const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121062.413261.patch
Type: text/x-patch
Size: 2937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220306/b2a337d9/attachment.bin>


More information about the lldb-commits mailing list