[Lldb-commits] [lldb] 6564ca1 - [trace] Fix errors when handling command arguments
Walter Erquinigo via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 28 17:54:41 PDT 2022
Author: Walter Erquinigo
Date: 2022-06-28T17:54:30-07:00
New Revision: 6564ca188a122c79c36ad7e4b3d362fb22fbd0b5
URL: https://github.com/llvm/llvm-project/commit/6564ca188a122c79c36ad7e4b3d362fb22fbd0b5
DIFF: https://github.com/llvm/llvm-project/commit/6564ca188a122c79c36ad7e4b3d362fb22fbd0b5.diff
LOG: [trace] Fix errors when handling command arguments
https://reviews.llvm.org/D128453 recently added some safety checks for
command arguments. Unfortunately, some few commands started failing due
to that, and this diff fixes it. But fortunately, the fix is trivial, which is
simply declaring the argument that these commands will receive.
Differential Revision: https://reviews.llvm.org/D128775
Added:
Modified:
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/CommandObjectThreadUtil.cpp
lldb/source/Commands/CommandObjectThreadUtil.h
Removed:
################################################################################
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 65512a051ab4..7dd89e601af8 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -2219,7 +2219,10 @@ class CommandObjectTraceDumpInstructions : public CommandObjectParsed {
nullptr,
eCommandRequiresProcess | eCommandRequiresThread |
eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
- eCommandProcessMustBePaused | eCommandProcessMustBeTraced) {}
+ eCommandProcessMustBePaused | eCommandProcessMustBeTraced) {
+ CommandArgumentData thread_arg{eArgTypeThreadIndex, eArgRepeatOptional};
+ m_arguments.push_back({thread_arg});
+ }
~CommandObjectTraceDumpInstructions() override = default;
diff --git a/lldb/source/Commands/CommandObjectThreadUtil.cpp b/lldb/source/Commands/CommandObjectThreadUtil.cpp
index cac1bef3e9df..504d5fa0118d 100644
--- a/lldb/source/Commands/CommandObjectThreadUtil.cpp
+++ b/lldb/source/Commands/CommandObjectThreadUtil.cpp
@@ -25,6 +25,15 @@ CommandObjectIterateOverThreads::CommandObjectIterateOverThreads(
m_arguments.push_back({thread_arg});
}
+CommandObjectMultipleThreads::CommandObjectMultipleThreads(
+ CommandInterpreter &interpreter, const char *name, const char *help,
+ const char *syntax, uint32_t flags)
+ : CommandObjectParsed(interpreter, name, help, syntax, flags) {
+ // These commands all take thread ID's as arguments.
+ CommandArgumentData thread_arg{eArgTypeThreadIndex, eArgRepeatStar};
+ m_arguments.push_back({thread_arg});
+}
+
bool CommandObjectIterateOverThreads::DoExecute(Args &command,
CommandReturnObject &result) {
result.SetStatus(m_success_return);
diff --git a/lldb/source/Commands/CommandObjectThreadUtil.h b/lldb/source/Commands/CommandObjectThreadUtil.h
index 289ffdfc1894..c8f51eabc043 100644
--- a/lldb/source/Commands/CommandObjectThreadUtil.h
+++ b/lldb/source/Commands/CommandObjectThreadUtil.h
@@ -80,7 +80,9 @@ class CommandObjectIterateOverThreads : public CommandObjectParsed {
/// an action on multiple threads at once instead of iterating over each thread.
class CommandObjectMultipleThreads : public CommandObjectParsed {
public:
- using CommandObjectParsed::CommandObjectParsed;
+ CommandObjectMultipleThreads(CommandInterpreter &interpreter,
+ const char *name, const char *help,
+ const char *syntax, uint32_t flags);
bool DoExecute(Args &command, CommandReturnObject &result) override;
More information about the lldb-commits
mailing list