aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectFrame.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2024-07-31 09:57:10 -0700
committerGitHub <noreply@github.com>2024-07-31 09:57:10 -0700
commit8398ad9cb21736dc57ee4dd766bd0859ef9bd000 (patch)
tree928489616eb403b4328eb66656664c83ff9f1241 /lldb/source/Commands/CommandObjectFrame.cpp
parentfaf3333510e0c2c3f319af40456e10c471e11ce8 (diff)
downloadllvm-8398ad9cb21736dc57ee4dd766bd0859ef9bd000.zip
llvm-8398ad9cb21736dc57ee4dd766bd0859ef9bd000.tar.gz
llvm-8398ad9cb21736dc57ee4dd766bd0859ef9bd000.tar.bz2
[lldb] Unify the way we get the Target in CommandObject (#101208)
Currently, CommandObjects are obtaining a target in a variety of ways. Often the command incorrectly operates on the selected target. As an example, when a breakpoint command is running, the current target is passed into the command but the target that hit the breakpoint is not the selected target. In other places we use the CommandObject's execution context, which is frozen during the execution of the command, and comes with its own limitations. Finally, we often want to fall back to the dummy target if no real target is available. Instead of having to guess how to get the target, this patch introduces one helper function in CommandObject to get the most relevant target. In order of priority, that's the target from the command object's execution context, from the interpreter's execution context, the selected target or the dummy target. rdar://110846511
Diffstat (limited to 'lldb/source/Commands/CommandObjectFrame.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 3f4178c..29e460f 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -687,7 +687,7 @@ protected:
m_cmd_name);
// Increment statistics.
- TargetStats &target_stats = GetSelectedOrDummyTarget().GetStatistics();
+ TargetStats &target_stats = GetTarget().GetStatistics();
if (result.Succeeded())
target_stats.GetFrameVariableStats().NotifySuccess();
else
@@ -874,13 +874,13 @@ void CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
RegularExpressionSP(new RegularExpression(m_options.m_module));
auto func =
RegularExpressionSP(new RegularExpression(m_options.m_symbols.front()));
- GetSelectedOrDummyTarget().GetFrameRecognizerManager().AddRecognizer(
+ GetTarget().GetFrameRecognizerManager().AddRecognizer(
recognizer_sp, module, func, m_options.m_first_instruction_only);
} else {
auto module = ConstString(m_options.m_module);
std::vector<ConstString> symbols(m_options.m_symbols.begin(),
m_options.m_symbols.end());
- GetSelectedOrDummyTarget().GetFrameRecognizerManager().AddRecognizer(
+ GetTarget().GetFrameRecognizerManager().AddRecognizer(
recognizer_sp, module, symbols, m_options.m_first_instruction_only);
}
#endif
@@ -898,9 +898,7 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
- GetSelectedOrDummyTarget()
- .GetFrameRecognizerManager()
- .RemoveAllRecognizers();
+ GetTarget().GetFrameRecognizerManager().RemoveAllRecognizers();
result.SetStatus(eReturnStatusSuccessFinishResult);
}
};
@@ -922,7 +920,7 @@ public:
if (request.GetCursorIndex() != 0)
return;
- GetSelectedOrDummyTarget().GetFrameRecognizerManager().ForEach(
+ GetTarget().GetFrameRecognizerManager().ForEach(
[&request](uint32_t rid, std::string rname, std::string module,
llvm::ArrayRef<lldb_private::ConstString> symbols,
bool regexp) {
@@ -953,9 +951,7 @@ protected:
return;
}
- GetSelectedOrDummyTarget()
- .GetFrameRecognizerManager()
- .RemoveAllRecognizers();
+ GetTarget().GetFrameRecognizerManager().RemoveAllRecognizers();
result.SetStatus(eReturnStatusSuccessFinishResult);
return;
}
@@ -973,9 +969,8 @@ protected:
return;
}
- if (!GetSelectedOrDummyTarget()
- .GetFrameRecognizerManager()
- .RemoveRecognizerWithID(recognizer_id)) {
+ if (!GetTarget().GetFrameRecognizerManager().RemoveRecognizerWithID(
+ recognizer_id)) {
result.AppendErrorWithFormat("'%s' is not a valid recognizer id.\n",
command.GetArgumentAtIndex(0));
return;
@@ -996,7 +991,7 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
bool any_printed = false;
- GetSelectedOrDummyTarget().GetFrameRecognizerManager().ForEach(
+ GetTarget().GetFrameRecognizerManager().ForEach(
[&result, &any_printed](
uint32_t recognizer_id, std::string name, std::string module,
llvm::ArrayRef<ConstString> symbols, bool regexp) {
@@ -1073,9 +1068,8 @@ protected:
return;
}
- auto recognizer = GetSelectedOrDummyTarget()
- .GetFrameRecognizerManager()
- .GetRecognizerForFrame(frame_sp);
+ auto recognizer =
+ GetTarget().GetFrameRecognizerManager().GetRecognizerForFrame(frame_sp);
Stream &output_stream = result.GetOutputStream();
output_stream.Printf("frame %d ", frame_index);