Skip to content

Commit 1242826

Browse files
authored
Merge pull request #6504 from apple/🍒/navy/2a7642977876+147b60964064
🍒/navy/2a7642977876+147b60964064
2 parents a469ca2 + 4716970 commit 1242826

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

lldb/source/Commands/CommandObjectWatchpoint.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
using namespace lldb;
3030
using namespace lldb_private;
3131

32-
static void AddWatchpointDescription(Stream *s, Watchpoint *wp,
32+
static void AddWatchpointDescription(Stream &s, Watchpoint &wp,
3333
lldb::DescriptionLevel level) {
34-
s->IndentMore();
35-
wp->GetDescription(s, level);
36-
s->IndentLess();
37-
s->EOL();
34+
s.IndentMore();
35+
wp.GetDescription(&s, level);
36+
s.IndentLess();
37+
s.EOL();
3838
}
3939

4040
static bool CheckTargetForWatchpointOperations(Target *target,
@@ -237,8 +237,8 @@ class CommandObjectWatchpointList : public CommandObjectParsed {
237237
// No watchpoint selected; show info about all currently set watchpoints.
238238
result.AppendMessage("Current watchpoints:");
239239
for (size_t i = 0; i < num_watchpoints; ++i) {
240-
Watchpoint *wp = watchpoints.GetByIndex(i).get();
241-
AddWatchpointDescription(&output_stream, wp, m_options.m_level);
240+
WatchpointSP watch_sp = watchpoints.GetByIndex(i);
241+
AddWatchpointDescription(output_stream, *watch_sp, m_options.m_level);
242242
}
243243
result.SetStatus(eReturnStatusSuccessFinishNoResult);
244244
} else {
@@ -252,9 +252,9 @@ class CommandObjectWatchpointList : public CommandObjectParsed {
252252

253253
const size_t size = wp_ids.size();
254254
for (size_t i = 0; i < size; ++i) {
255-
Watchpoint *wp = watchpoints.FindByID(wp_ids[i]).get();
256-
if (wp)
257-
AddWatchpointDescription(&output_stream, wp, m_options.m_level);
255+
WatchpointSP watch_sp = watchpoints.FindByID(wp_ids[i]);
256+
if (watch_sp)
257+
AddWatchpointDescription(output_stream, *watch_sp, m_options.m_level);
258258
result.SetStatus(eReturnStatusSuccessFinishNoResult);
259259
}
260260
}
@@ -758,8 +758,8 @@ class CommandObjectWatchpointModify : public CommandObjectParsed {
758758
}
759759

760760
if (command.GetArgumentCount() == 0) {
761-
WatchpointSP wp_sp = target->GetLastCreatedWatchpoint();
762-
wp_sp->SetCondition(m_options.m_condition.c_str());
761+
WatchpointSP watch_sp = target->GetLastCreatedWatchpoint();
762+
watch_sp->SetCondition(m_options.m_condition.c_str());
763763
result.SetStatus(eReturnStatusSuccessFinishNoResult);
764764
} else {
765765
// Particular watchpoints selected; set condition on them.
@@ -773,9 +773,9 @@ class CommandObjectWatchpointModify : public CommandObjectParsed {
773773
int count = 0;
774774
const size_t size = wp_ids.size();
775775
for (size_t i = 0; i < size; ++i) {
776-
WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]);
777-
if (wp_sp) {
778-
wp_sp->SetCondition(m_options.m_condition.c_str());
776+
WatchpointSP watch_sp = watchpoints.FindByID(wp_ids[i]);
777+
if (watch_sp) {
778+
watch_sp->SetCondition(m_options.m_condition.c_str());
779779
++count;
780780
}
781781
}
@@ -949,20 +949,19 @@ corresponding to the byte size of the data type.");
949949
uint32_t watch_type = m_option_watchpoint.watch_type;
950950

951951
error.Clear();
952-
Watchpoint *wp =
953-
target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
954-
.get();
955-
if (wp) {
956-
wp->SetWatchSpec(command.GetArgumentAtIndex(0));
957-
wp->SetWatchVariable(true);
952+
WatchpointSP watch_sp =
953+
target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
954+
if (watch_sp) {
955+
watch_sp->SetWatchSpec(command.GetArgumentAtIndex(0));
956+
watch_sp->SetWatchVariable(true);
958957
if (var_sp && var_sp->GetDeclaration().GetFile()) {
959958
StreamString ss;
960959
// True to show fullpath for declaration file.
961960
var_sp->GetDeclaration().DumpStopContext(&ss, true);
962-
wp->SetDeclInfo(std::string(ss.GetString()));
961+
watch_sp->SetDeclInfo(std::string(ss.GetString()));
963962
}
964963
output_stream.Printf("Watchpoint created: ");
965-
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
964+
watch_sp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
966965
output_stream.EOL();
967966
result.SetStatus(eReturnStatusSuccessFinishResult);
968967
} else {
@@ -1117,13 +1116,13 @@ class CommandObjectWatchpointSetExpression : public CommandObjectRaw {
11171116
CompilerType compiler_type(valobj_sp->GetCompilerType());
11181117

11191118
Status error;
1120-
Watchpoint *wp =
1121-
target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
1122-
.get();
1123-
if (wp) {
1119+
WatchpointSP watch_sp =
1120+
target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);
1121+
if (watch_sp) {
1122+
watch_sp->SetWatchSpec(std::string(expr));
11241123
Stream &output_stream = result.GetOutputStream();
11251124
output_stream.Printf("Watchpoint created: ");
1126-
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
1125+
watch_sp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
11271126
output_stream.EOL();
11281127
result.SetStatus(eReturnStatusSuccessFinishResult);
11291128
} else {

lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_watchlocation_using_watchpoint_set(self):
4646
self.setTearDownCleanup()
4747

4848
exe = self.getBuildArtifact("a.out")
49-
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
49+
target = self.dbg.CreateTarget(exe)
5050

5151
# Add a breakpoint to set a watchpoint when stopped on the breakpoint.
5252
lldbutil.run_break_set_by_file_and_line(
@@ -81,6 +81,12 @@ def test_watchlocation_using_watchpoint_set(self):
8181
self.expect("watchpoint list -v",
8282
substrs=['hit_count = 0'])
8383

84+
# Check the underlying SBWatchpoint.
85+
watchpoint = target.GetWatchpointAtIndex(0)
86+
self.assertEqual(watchpoint.GetWatchSize(), 1)
87+
self.assertEqual(watchpoint.GetHitCount(), 0)
88+
self.assertEqual(watchpoint.GetWatchSpec(), "g_char_ptr + 7")
89+
8490
self.runCmd("process continue")
8591

8692
# We should be stopped again due to the watchpoint (write type), but

0 commit comments

Comments
 (0)