diff --git a/lldb/bindings/interface/SBBreakpoint.i b/lldb/bindings/interface/SBBreakpoint.i --- a/lldb/bindings/interface/SBBreakpoint.i +++ b/lldb/bindings/interface/SBBreakpoint.i @@ -206,6 +206,9 @@ bool AddName (const char *new_name); + SBError + AddNameWithError (const char *new_name); + void RemoveName (const char *name_to_remove); diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h --- a/lldb/include/lldb/API/SBBreakpoint.h +++ b/lldb/include/lldb/API/SBBreakpoint.h @@ -105,6 +105,8 @@ bool AddName(const char *new_name); + SBError AddNameWithError(const char *new_name); + void RemoveName(const char *name_to_remove); bool MatchesName(const char *name); diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -652,19 +652,28 @@ bool SBBreakpoint::AddName(const char *new_name) { LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name); + SBError status = AddNameWithError(new_name); + return status.Success(); +} + +SBError SBBreakpoint::AddNameWithError(const char *new_name) { + LLDB_RECORD_METHOD(SBError, SBBreakpoint, AddNameWithError, (const char *), + new_name); + BreakpointSP bkpt_sp = GetSP(); + SBError status; if (bkpt_sp) { std::lock_guard guard( bkpt_sp->GetTarget().GetAPIMutex()); - Status error; // Think I'm just going to swallow the error here, it's - // probably more annoying to have to provide it. + Status error; bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error); - if (error.Fail()) - return false; + status.SetError(error); + } else { + status.SetErrorString("invalid breakpoint"); } - return true; + return status; } void SBBreakpoint::RemoveName(const char *name_to_remove) { @@ -1015,6 +1024,8 @@ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody, (const char *)); LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddNameWithError, + (const char *)); LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *)); LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *)); LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &)); diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py b/lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py --- a/lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py @@ -99,8 +99,8 @@ other_bkpt_name = "_AnotherBreakpoint" # Add a name and make sure we match it: - success = bkpt.AddName(bkpt_name) - self.assertTrue(success, "We couldn't add a legal name to a breakpoint.") + success = bkpt.AddNameWithError(bkpt_name) + self.assertTrue(success.Success(), "We couldn't add a legal name to a breakpoint.") matches = bkpt.MatchesName(bkpt_name) self.assertTrue(matches, "We didn't match the name we just set") @@ -113,7 +113,7 @@ self.check_name_in_target(bkpt_name) # Add another name, make sure that works too: - bkpt.AddName(other_bkpt_name) + bkpt.AddNameWithError(other_bkpt_name) matches = bkpt.MatchesName(bkpt_name) self.assertTrue(matches, "Adding a name means we didn't match the name we just set") @@ -142,8 +142,8 @@ "CantHave-ADash", "Cant Have Spaces"] for bad_name in bad_names: - success = bkpt.AddName(bad_name) - self.assertTrue(not success,"We allowed an illegal name: %s"%(bad_name)) + success = bkpt.AddNameWithError(bad_name) + self.assertTrue(success.Fail(),"We allowed an illegal name: %s"%(bad_name)) bp_name = lldb.SBBreakpointName(self.target, bad_name) self.assertFalse(bp_name.IsValid(), "We made a breakpoint name with an illegal name: %s"%(bad_name)); @@ -164,8 +164,8 @@ other_bkpt_name= "_AnotherBreakpoint" # Add a name and make sure we match it: - success = bkpt.AddName(bkpt_name) - self.assertTrue(success, "We couldn't add a legal name to a breakpoint.") + success = bkpt.AddNameWithError(bkpt_name) + self.assertTrue(success.Success(), "We couldn't add a legal name to a breakpoint.") bkpts = lldb.SBBreakpointList(self.target) self.target.FindBreakpointsByName(bkpt_name, bkpts) @@ -243,8 +243,8 @@ # Now add this name to a breakpoint, and make sure it gets configured properly bkpt = self.target.BreakpointCreateByLocation(self.main_file_spec, 10) - success = bkpt.AddName(self.bp_name_string) - self.assertTrue(success, "Couldn't add this name to the breakpoint") + success = bkpt.AddNameWithError(self.bp_name_string) + self.assertTrue(success.Success(), "Couldn't add this name to the breakpoint") self.check_option_values(bkpt) # Now make a name from this breakpoint, and make sure the new name is properly configured: @@ -317,8 +317,8 @@ unprotected_bkpt = self.target.BreakpointCreateByLocation(self.main_file_spec, 10) unprotected_id = unprotected_bkpt.GetID() - success = protected_bkpt.AddName(self.bp_name_string) - self.assertTrue(success, "Couldn't add this name to the breakpoint") + success = protected_bkpt.AddNameWithError(self.bp_name_string) + self.assertTrue(success.Success(), "Couldn't add this name to the breakpoint") self.target.DisableAllBreakpoints() self.assertEqual(protected_bkpt.IsEnabled(), True, "Didnt' keep breakpoint from being disabled")