summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-08-31 09:41:25 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-08-31 09:41:25 +0000
commit04a4c0910b08fcd3961ad8cc74f99535efdee39a (patch)
tree65a472863f8ed47d0fa2c5ca03353e06d1e8b894 /lldb/source/Commands/CommandObjectBreakpointCommand.cpp
parentd4df363b14fe91ac235c830f295551fd0f3e867b (diff)
downloadbcm5719-llvm-04a4c0910b08fcd3961ad8cc74f99535efdee39a.tar.gz
bcm5719-llvm-04a4c0910b08fcd3961ad8cc74f99535efdee39a.zip
[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/CommandObjectBreakpointCommand.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 5988b1c5302..11fdb85e844 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -589,10 +589,10 @@ private:
class CommandObjectBreakpointCommandList : public CommandObjectParsed {
public:
CommandObjectBreakpointCommandList(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "list", "List the script or set of "
- "commands to be executed when "
- "the breakpoint is hit.",
- nullptr) {
+ : CommandObjectParsed(interpreter, "list",
+ "List the script or set of commands to be "
+ "executed when the breakpoint is hit.",
+ nullptr, eCommandRequiresTarget) {
CommandArgumentEntry arg;
CommandArgumentData bp_id_arg;
@@ -612,14 +612,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = GetDebugger().GetSelectedTarget().get();
-
- if (target == nullptr) {
- result.AppendError("There is not a current executable; there are no "
- "breakpoints for which to list commands");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ Target *target = &GetSelectedTarget();
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
OpenPOWER on IntegriCloud