[Lldb-commits] [lldb] 85446d4 - [lldb] Use AppendMessageWithFormatv instead of AppendMessageWithFormat (#185634)

via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 30 01:36:06 PDT 2026


Author: David Spickett
Date: 2026-03-30T09:36:01+01:00
New Revision: 85446d41458319709333355745b8c8574c52d05f

URL: https://github.com/llvm/llvm-project/commit/85446d41458319709333355745b8c8574c52d05f
DIFF: https://github.com/llvm/llvm-project/commit/85446d41458319709333355745b8c8574c52d05f.diff

LOG: [lldb] Use AppendMessageWithFormatv instead of AppendMessageWithFormat (#185634)

Part 4. This converts all the remaining simple uses (the ones that ended
with a newline).

What remains in tree are the outliers that expect multiple ending
newlines, or are building a message in pieces.

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectPlugin.cpp
    lldb/source/Commands/CommandObjectProcess.cpp
    lldb/source/Commands/CommandObjectThread.cpp
    lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp
index 093ebde5f5f2c..c0ea20d0e9b22 100644
--- a/lldb/source/Commands/CommandObjectPlugin.cpp
+++ b/lldb/source/Commands/CommandObjectPlugin.cpp
@@ -96,9 +96,9 @@ int SetEnableOnMatchingPlugins(const llvm::StringRef &pattern,
             continue;
           }
 
-          result.AppendMessageWithFormat(
-              "  %s %-30s %s\n", enabled ? "[+]" : "[-]", plugin.name.data(),
-              plugin.description.data());
+          result.AppendMessageWithFormatv("  {0} {1, -30} {2}",
+                                          enabled ? "[+]" : "[-]", plugin.name,
+                                          plugin.description);
         }
       });
 }
@@ -253,9 +253,9 @@ List only the plugin 'foo' matching a fully qualified name exactly
                        const std::vector<RegisteredPluginInfo> &plugins) {
             result.AppendMessage(plugin_namespace.name);
             for (auto &plugin : plugins) {
-              result.AppendMessageWithFormat(
-                  "  %s %-30s %s\n", plugin.enabled ? "[+]" : "[-]",
-                  plugin.name.data(), plugin.description.data());
+              result.AppendMessageWithFormatv("  {0} {1, -30} {2}",
+                                              plugin.enabled ? "[+]" : "[-]",
+                                              plugin.name, plugin.description);
             }
           });
       if (num_matching == 0) {

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index b0adbf8156bed..a4dfc23b0fea2 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1057,8 +1057,8 @@ class CommandObjectProcessLoad : public CommandObjectParsed {
       }
 
       if (image_token != LLDB_INVALID_IMAGE_TOKEN) {
-        result.AppendMessageWithFormat(
-            "Loading \"%s\"...ok\nImage %u loaded.\n", image_path.str().c_str(),
+        result.AppendMessageWithFormatv(
+            "Loading \"{0}\"...ok\nImage {1} loaded.", image_path.str().c_str(),
             image_token);
         result.SetStatus(eReturnStatusSuccessFinishResult);
       } else {
@@ -1362,7 +1362,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed {
                   SaveCoreStyle::eSaveCoreDirtyOnly ||
               core_dump_options.GetStyle() ==
                   SaveCoreStyle::eSaveCoreStackOnly) {
-            result.AppendMessageWithFormat(
+            result.AppendMessage(
                 "\nModified-memory or stack-memory only corefile "
                 "created.  This corefile may \n"
                 "not show library/framework/app binaries "
@@ -1370,7 +1370,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed {
                 "those binaries have "
                 "been updated/modified. Copies are not included\n"
                 "in this corefile.  Use --style full to include all "
-                "process memory.\n");
+                "process memory.");
           }
           result.SetStatus(eReturnStatusSuccessFinishResult);
         } else {

diff  --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index ab01dc59fc6af..47c30524856c3 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -718,8 +718,7 @@ class CommandObjectThreadContinue : public CommandObjectParsed {
               thread->SetResumeState(eStateSuspended);
             }
           }
-          result.AppendMessageWithFormat("in process %" PRIu64 "\n",
-                                         process->GetID());
+          result.AppendMessageWithFormatv("in process {0}", process->GetID());
         }
       } else {
         // These two lines appear at the beginning of both blocks in this
@@ -737,9 +736,9 @@ class CommandObjectThreadContinue : public CommandObjectParsed {
         for (uint32_t idx = 0; idx < num_threads; ++idx) {
           Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get();
           if (thread == current_thread) {
-            result.AppendMessageWithFormat("Resuming thread 0x%4.4" PRIx64
-                                           " in process %" PRIu64 "\n",
-                                           thread->GetID(), process->GetID());
+            result.AppendMessageWithFormatv(
+                "Resuming thread {0:x4} in process {1}", thread->GetID(),
+                process->GetID());
             const bool override_suspend = true;
             thread->SetResumeState(eStateRunning, override_suspend);
           } else {
@@ -757,8 +756,8 @@ class CommandObjectThreadContinue : public CommandObjectParsed {
 
       // We should not be holding the thread list lock when we do this.
       if (error.Success()) {
-        result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
-                                       process->GetID());
+        result.AppendMessageWithFormatv("Process {0} resuming",
+                                        process->GetID());
         if (synchronous_execution) {
           // If any state changed events had anything to say, add that to the
           // result
@@ -1062,8 +1061,8 @@ class CommandObjectThreadUntil : public CommandObjectParsed {
         error = process->Resume();
 
       if (error.Success()) {
-        result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
-                                       process->GetID());
+        result.AppendMessageWithFormatv("Process {0} resuming",
+                                        process->GetID());
         if (synchronous_execution) {
           // If any state changed events had anything to say, add that to the
           // result

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index d616becbf09d8..eeb1ae0ff3eb8 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1641,9 +1641,9 @@ void CommandInterpreter::GetHelp(CommandReturnObject &result,
 
   if (!m_alias_dict.empty() &&
       ((cmd_types & eCommandTypesAliases) == eCommandTypesAliases)) {
-    result.AppendMessageWithFormat(
+    result.AppendMessageWithFormatv(
         "Current command abbreviations "
-        "(type '%shelp command alias' for more info):\n",
+        "(type '{0}help command alias' for more info):",
         GetCommandPrefix());
     result.AppendMessage("");
     max_len = FindLongestCommandWord(m_alias_dict);
@@ -1680,8 +1680,8 @@ void CommandInterpreter::GetHelp(CommandReturnObject &result,
     result.AppendMessage("");
   }
 
-  result.AppendMessageWithFormat(
-      "For more information on any command, type '%shelp <command-name>'.\n",
+  result.AppendMessageWithFormatv(
+      "For more information on any command, type '{0}help <command-name>'.",
       GetCommandPrefix());
 }
 
@@ -2830,8 +2830,8 @@ void CommandInterpreter::HandleCommands(
 
     if (options.GetEchoCommands()) {
       // TODO: Add Stream support.
-      result.AppendMessageWithFormat("%s %s\n",
-                                     m_debugger.GetPrompt().str().c_str(), cmd);
+      result.AppendMessageWithFormatv(
+          "{0} {1}", m_debugger.GetPrompt().str().c_str(), cmd);
     }
 
     CommandReturnObject tmp_result(m_debugger.GetUseColor());
@@ -2892,9 +2892,9 @@ void CommandInterpreter::HandleCommands(
               ": '%s' continued the target.\n",
               (uint64_t)idx + 1, cmd);
         else
-          result.AppendMessageWithFormat("Command #%" PRIu64
-                                         " '%s' continued the target.\n",
-                                         (uint64_t)idx + 1, cmd);
+          result.AppendMessageWithFormatv(
+              "Command #{0} '{1}' continued the target.", (uint64_t)idx + 1,
+              cmd);
 
         result.SetStatus(tmp_result.GetStatus());
         m_debugger.SetAsyncExecution(old_async_execution);
@@ -2912,8 +2912,8 @@ void CommandInterpreter::HandleCommands(
             ": '%s' stopped with a signal or exception.\n",
             (uint64_t)idx + 1, cmd);
       else
-        result.AppendMessageWithFormat(
-            "Command #%" PRIu64 " '%s' stopped with a signal or exception.\n",
+        result.AppendMessageWithFormatv(
+            "Command #{0} '{1}' stopped with a signal or exception.",
             (uint64_t)idx + 1, cmd);
 
       result.SetStatus(tmp_result.GetStatus());
@@ -3552,8 +3552,8 @@ bool CommandInterpreter::SaveTranscript(
                      "Bytes written do not match transcript size.");
 
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
-  result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
-                                 output_file->c_str());
+  result.AppendMessageWithFormatv("Session's transcripts saved to {0}",
+                                  output_file->c_str());
   if (!GetSaveTranscript())
     result.AppendError(
         "Note: the setting interpreter.save-transcript is set to false, so the "


        


More information about the lldb-commits mailing list