diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2024-07-31 09:57:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-31 09:57:10 -0700 |
commit | 8398ad9cb21736dc57ee4dd766bd0859ef9bd000 (patch) | |
tree | 928489616eb403b4328eb66656664c83ff9f1241 /lldb/source/Commands/CommandObjectBreakpoint.cpp | |
parent | faf3333510e0c2c3f319af40456e10c471e11ce8 (diff) | |
download | llvm-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/CommandObjectBreakpoint.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectBreakpoint.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 773f8ed..aad03af 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -539,7 +539,8 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy); + Target &target = + m_dummy_options.m_use_dummy ? GetDummyTarget() : GetTarget(); // The following are the various types of breakpoints that could be set: // 1). -f -l -p [-s -g] (setting breakpoint by source location) @@ -839,7 +840,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(m_dummy_opts.m_use_dummy); + Target &target = m_dummy_opts.m_use_dummy ? GetDummyTarget() : GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); @@ -903,7 +904,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(); + Target &target = GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); @@ -1010,7 +1011,7 @@ the second re-enables the first location."); protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(); + Target &target = GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); @@ -1148,7 +1149,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy); + Target &target = m_options.m_use_dummy ? GetDummyTarget() : GetTarget(); const BreakpointList &breakpoints = target.GetBreakpointList(m_options.m_internal); @@ -1267,7 +1268,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(); + Target &target = GetTarget(); // The following are the various types of breakpoints that could be // cleared: @@ -1416,7 +1417,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy); + Target &target = m_options.m_use_dummy ? GetDummyTarget() : GetTarget(); result.Clear(); std::unique_lock<std::recursive_mutex> lock; @@ -1676,7 +1677,7 @@ protected: return; } - Target &target = GetSelectedOrDummyTarget(false); + Target &target = GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); @@ -1764,7 +1765,7 @@ protected: } Target &target = - GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue()); + m_name_options.m_use_dummy ? GetDummyTarget() : GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); @@ -1838,7 +1839,7 @@ protected: } Target &target = - GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue()); + m_name_options.m_use_dummy ? GetDummyTarget() : GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); @@ -1897,7 +1898,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { Target &target = - GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue()); + m_name_options.m_use_dummy ? GetDummyTarget() : GetTarget(); std::vector<std::string> name_list; if (command.empty()) { @@ -2209,7 +2210,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(); + Target &target = GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); @@ -2319,7 +2320,7 @@ public: protected: void DoExecute(Args &command, CommandReturnObject &result) override { - Target &target = GetSelectedOrDummyTarget(); + Target &target = GetTarget(); std::unique_lock<std::recursive_mutex> lock; target.GetBreakpointList().GetListMutex(lock); |