diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-08-31 09:41:25 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-08-31 09:41:25 +0000 |
commit | 04a4c0910b08fcd3961ad8cc74f99535efdee39a (patch) | |
tree | 65a472863f8ed47d0fa2c5ca03353e06d1e8b894 /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | d4df363b14fe91ac235c830f295551fd0f3e867b (diff) | |
download | llvm-04a4c0910b08fcd3961ad8cc74f99535efdee39a.zip llvm-04a4c0910b08fcd3961ad8cc74f99535efdee39a.tar.gz llvm-04a4c0910b08fcd3961ad8cc74f99535efdee39a.tar.bz2 |
[lldb] Unify target checking in CommandObject
Summary:
We currently have several CommandObjects that manually reimplement the checking for a selected target
or a target in the execution context (which is the selected target when they are invoked). This patch removes
all these checks and replaces them by setting the eCommandRequiresTarget flag that Pavel suggested. With
this flag we are doing the same check but without having to duplicate this code in all these CommandObjects.
I also added a `GetSelectedTarget()` variant of the `GetSelectedOrDummyTarget()` function to the
CommandObject that checks that the flag is set and then returns a reference to the target. I didn't rewrite
all the `target` variables from `Target *` to `Target &` in this patch as last time this change caused a lot of merge
conflicts in Swift and I would prefer having that in a separate NFC commit.
Reviewers: labath, clayborg
Reviewed By: labath, clayborg
Subscribers: clayborg, JDevlieghere, jingham, amccarth, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66863
llvm-svn: 370571
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index e934b7c..eb559cd 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -1290,7 +1290,7 @@ public: "Manage LLDB handling of OS signals for the " "current target process. Defaults to showing " "current policy.", - nullptr), + nullptr, eCommandRequiresTarget), m_options() { SetHelpLong("\nIf no signals are specified, update them all. If no update " "option is specified, list the current values."); @@ -1375,15 +1375,7 @@ public: protected: bool DoExecute(Args &signal_args, CommandReturnObject &result) override { - TargetSP target_sp = GetDebugger().GetSelectedTarget(); - - if (!target_sp) { - result.AppendError("No current target;" - " cannot handle signals until you have a valid target " - "and process.\n"); - result.SetStatus(eReturnStatusFailed); - return false; - } + Target *target_sp = &GetSelectedTarget(); ProcessSP process_sp = target_sp->GetProcessSP(); |