aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectWatchpoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpoint.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 314c751..126982d 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -39,10 +39,10 @@ static void AddWatchpointDescription(Stream &s, Watchpoint &wp,
s.EOL();
}
-static bool CheckTargetForWatchpointOperations(Target *target,
+static bool CheckTargetForWatchpointOperations(Target &target,
CommandReturnObject &result) {
bool process_is_valid =
- target->GetProcessSP() && target->GetProcessSP()->IsAlive();
+ target.GetProcessSP() && target.GetProcessSP()->IsAlive();
if (!process_is_valid) {
result.AppendError("There's no process or it is not alive.");
return false;
@@ -67,12 +67,10 @@ static int32_t WithRSAIndex(llvm::StringRef Arg) {
// Return true if wp_ids is successfully populated with the watch ids. False
// otherwise.
bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
- Target *target, Args &args, std::vector<uint32_t> &wp_ids) {
+ Target &target, Args &args, std::vector<uint32_t> &wp_ids) {
// Pre-condition: args.GetArgumentCount() > 0.
if (args.GetArgumentCount() == 0) {
- if (target == nullptr)
- return false;
- WatchpointSP watch_sp = target->GetLastCreatedWatchpoint();
+ WatchpointSP watch_sp = target.GetLastCreatedWatchpoint();
if (watch_sp) {
wp_ids.push_back(watch_sp->GetID());
return true;
@@ -203,22 +201,24 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = &GetTarget();
+ Target &target = GetTarget();
- if (target->GetProcessSP() && target->GetProcessSP()->IsAlive()) {
- std::optional<uint32_t> num_supported_hardware_watchpoints =
- target->GetProcessSP()->GetWatchpointSlotCount();
+ if (ProcessSP process_sp = target.GetProcessSP()) {
+ if (process_sp->IsAlive()) {
+ std::optional<uint32_t> num_supported_hardware_watchpoints =
+ process_sp->GetWatchpointSlotCount();
- if (num_supported_hardware_watchpoints)
- result.AppendMessageWithFormat(
- "Number of supported hardware watchpoints: %u\n",
- *num_supported_hardware_watchpoints);
+ if (num_supported_hardware_watchpoints)
+ result.AppendMessageWithFormat(
+ "Number of supported hardware watchpoints: %u\n",
+ *num_supported_hardware_watchpoints);
+ }
}
- const WatchpointList &watchpoints = target->GetWatchpointList();
+ const WatchpointList &watchpoints = target.GetWatchpointList();
std::unique_lock<std::recursive_mutex> lock;
- target->GetWatchpointList().GetListMutex(lock);
+ target.GetWatchpointList().GetListMutex(lock);
size_t num_watchpoints = watchpoints.GetSize();
@@ -286,14 +286,14 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = &GetTarget();
+ Target &target = GetTarget();
if (!CheckTargetForWatchpointOperations(target, result))
return;
std::unique_lock<std::recursive_mutex> lock;
- target->GetWatchpointList().GetListMutex(lock);
+ target.GetWatchpointList().GetListMutex(lock);
- const WatchpointList &watchpoints = target->GetWatchpointList();
+ const WatchpointList &watchpoints = target.GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -304,7 +304,7 @@ protected:
if (command.GetArgumentCount() == 0) {
// No watchpoint selected; enable all currently set watchpoints.
- target->EnableAllWatchpoints();
+ target.EnableAllWatchpoints();
result.AppendMessageWithFormat("All watchpoints enabled. (%" PRIu64
" watchpoints)\n",
(uint64_t)num_watchpoints);
@@ -321,7 +321,7 @@ protected:
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
- if (target->EnableWatchpointByID(wp_ids[i]))
+ if (target.EnableWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints enabled.\n", count);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -355,14 +355,14 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = &GetTarget();
+ Target &target = GetTarget();
if (!CheckTargetForWatchpointOperations(target, result))
return;
std::unique_lock<std::recursive_mutex> lock;
- target->GetWatchpointList().GetListMutex(lock);
+ target.GetWatchpointList().GetListMutex(lock);
- const WatchpointList &watchpoints = target->GetWatchpointList();
+ const WatchpointList &watchpoints = target.GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0) {
@@ -372,7 +372,7 @@ protected:
if (command.GetArgumentCount() == 0) {
// No watchpoint selected; disable all currently set watchpoints.
- if (target->DisableAllWatchpoints()) {
+ if (target.DisableAllWatchpoints()) {
result.AppendMessageWithFormat("All watchpoints disabled. (%" PRIu64
" watchpoints)\n",
(uint64_t)num_watchpoints);
@@ -392,7 +392,7 @@ protected:
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
- if (target->DisableWatchpointByID(wp_ids[i]))
+ if (target.DisableWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints disabled.\n", count);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -464,14 +464,14 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = &GetTarget();
+ Target &target = GetTarget();
if (!CheckTargetForWatchpointOperations(target, result))
return;
std::unique_lock<std::recursive_mutex> lock;
- target->GetWatchpointList().GetListMutex(lock);
+ target.GetWatchpointList().GetListMutex(lock);
- const WatchpointList &watchpoints = target->GetWatchpointList();
+ const WatchpointList &watchpoints = target.GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -487,7 +487,7 @@ protected:
true)) {
result.AppendMessage("Operation cancelled...");
} else {
- target->RemoveAllWatchpoints();
+ target.RemoveAllWatchpoints();
result.AppendMessageWithFormat("All watchpoints removed. (%" PRIu64
" watchpoints)\n",
(uint64_t)num_watchpoints);
@@ -507,7 +507,7 @@ protected:
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
- if (target->RemoveWatchpointByID(wp_ids[i]))
+ if (target.RemoveWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints deleted.\n", count);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -584,14 +584,14 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = &GetTarget();
+ Target &target = GetTarget();
if (!CheckTargetForWatchpointOperations(target, result))
return;
std::unique_lock<std::recursive_mutex> lock;
- target->GetWatchpointList().GetListMutex(lock);
+ target.GetWatchpointList().GetListMutex(lock);
- const WatchpointList &watchpoints = target->GetWatchpointList();
+ const WatchpointList &watchpoints = target.GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -601,7 +601,7 @@ protected:
}
if (command.GetArgumentCount() == 0) {
- target->IgnoreAllWatchpoints(m_options.m_ignore_count);
+ target.IgnoreAllWatchpoints(m_options.m_ignore_count);
result.AppendMessageWithFormat("All watchpoints ignored. (%" PRIu64
" watchpoints)\n",
(uint64_t)num_watchpoints);
@@ -618,7 +618,7 @@ protected:
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
- if (target->IgnoreWatchpointByID(wp_ids[i], m_options.m_ignore_count))
+ if (target.IgnoreWatchpointByID(wp_ids[i], m_options.m_ignore_count))
++count;
result.AppendMessageWithFormat("%d watchpoints ignored.\n", count);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -703,14 +703,14 @@ public:
protected:
void DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = &GetTarget();
+ Target &target = GetTarget();
if (!CheckTargetForWatchpointOperations(target, result))
return;
std::unique_lock<std::recursive_mutex> lock;
- target->GetWatchpointList().GetListMutex(lock);
+ target.GetWatchpointList().GetListMutex(lock);
- const WatchpointList &watchpoints = target->GetWatchpointList();
+ const WatchpointList &watchpoints = target.GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@@ -720,7 +720,7 @@ protected:
}
if (command.GetArgumentCount() == 0) {
- WatchpointSP watch_sp = target->GetLastCreatedWatchpoint();
+ WatchpointSP watch_sp = target.GetLastCreatedWatchpoint();
watch_sp->SetCondition(m_options.m_condition.c_str());
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
@@ -804,7 +804,7 @@ protected:
}
void DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = &GetTarget();
+ Target &target = GetTarget();
StackFrame *frame = m_exe_ctx.GetFramePtr();
// If no argument is present, issue an error message. There's no way to
@@ -852,8 +852,8 @@ protected:
Status error(Variable::GetValuesForVariableExpressionPath(
command.GetArgumentAtIndex(0),
- m_exe_ctx.GetBestExecutionContextScope(), GetVariableCallback, target,
- variable_list, valobj_list));
+ m_exe_ctx.GetBestExecutionContextScope(), GetVariableCallback,
+ &target, variable_list, valobj_list));
if (valobj_list.GetSize())
valobj_sp = valobj_list.GetValueObjectAtIndex(0);
@@ -904,7 +904,7 @@ protected:
error.Clear();
WatchpointSP watch_sp =
- target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
+ target.CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
if (!watch_sp) {
result.AppendErrorWithFormat(
"Watchpoint creation failed (addr=0x%" PRIx64 ", size=%" PRIu64
@@ -991,7 +991,7 @@ protected:
m_option_group.NotifyOptionParsingStarting(
&exe_ctx); // This is a raw command, so notify the option group
- Target *target = &GetTarget();
+ Target &target = GetTarget();
StackFrame *frame = m_exe_ctx.GetFramePtr();
OptionsWithRaw args(raw_command);
@@ -1034,7 +1034,7 @@ protected:
options.SetLanguage(m_option_watchpoint.language_type);
ExpressionResults expr_result =
- target->EvaluateExpression(expr, frame, valobj_sp, options);
+ target.EvaluateExpression(expr, frame, valobj_sp, options);
if (expr_result != eExpressionCompleted) {
result.AppendError("expression evaluation of address to watch failed");
result.AppendErrorWithFormat("expression evaluated: \n%s", expr.data());
@@ -1054,7 +1054,7 @@ protected:
if (m_option_watchpoint.watch_size.GetCurrentValue() != 0)
size = m_option_watchpoint.watch_size.GetCurrentValue();
else
- size = target->GetArchitecture().GetAddressByteSize();
+ size = target.GetArchitecture().GetAddressByteSize();
// Now it's time to create the watchpoint.
uint32_t watch_type;
@@ -1095,7 +1095,7 @@ protected:
Status error;
WatchpointSP watch_sp =
- target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
+ target.CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
if (watch_sp) {
watch_sp->SetWatchSpec(std::string(expr));
Stream &output_stream = result.GetOutputStream();