diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -949,9 +949,8 @@ uint32_t watch_type = m_option_watchpoint.watch_type; error.Clear(); - Watchpoint *wp = - target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error) - .get(); + WatchpointSP wp = + target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error); if (wp) { wp->SetWatchSpec(command.GetArgumentAtIndex(0)); wp->SetWatchVariable(true); @@ -1117,10 +1116,10 @@ CompilerType compiler_type(valobj_sp->GetCompilerType()); Status error; - Watchpoint *wp = - target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error) - .get(); + WatchpointSP wp = + target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error); if (wp) { + wp->SetWatchSpec(std::string(expr)); Stream &output_stream = result.GetOutputStream(); output_stream.Printf("Watchpoint created: "); wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull); diff --git a/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py b/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py --- a/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py +++ b/lldb/test/API/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py @@ -46,7 +46,7 @@ self.setTearDownCleanup() exe = self.getBuildArtifact("a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + target = self.dbg.CreateTarget(exe) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. lldbutil.run_break_set_by_file_and_line( @@ -81,6 +81,12 @@ self.expect("watchpoint list -v", substrs=['hit_count = 0']) + # Check the underlying SBWatchpoint. + watchpoint = target.GetWatchpointAtIndex(0) + self.assertEqual(watchpoint.GetWatchSize(), 1) + self.assertEqual(watchpoint.GetHitCount(), 0) + self.assertEqual(watchpoint.GetWatchSpec(), "g_char_ptr + 7") + self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type), but