[Lldb-commits] [lldb] [lldb] Use AppendMessageWithFormatv instead of AppendMessageWithFormat (PR #185634)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 10 05:20:07 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: David Spickett (DavidSpickett)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/185634.diff
4 Files Affected:
- (modified) lldb/source/Commands/CommandObjectPlugin.cpp (+6-6)
- (modified) lldb/source/Commands/CommandObjectProcess.cpp (+4-4)
- (modified) lldb/source/Commands/CommandObjectThread.cpp (+8-6)
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+13-13)
``````````diff
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 e870b86bc0a33..8b2bcc82113c2 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
@@ -740,6 +739,9 @@ class CommandObjectThreadContinue : public CommandObjectParsed {
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 +759,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
@@ -1063,8 +1065,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 9aed946492632..0fef580e23b60 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1640,9 +1640,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);
@@ -1679,8 +1679,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());
}
@@ -2829,8 +2829,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());
@@ -2891,9 +2891,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);
@@ -2911,8 +2911,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());
@@ -3551,8 +3551,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 "
``````````
</details>
https://github.com/llvm/llvm-project/pull/185634
More information about the lldb-commits
mailing list