mib created this revision.
mib added a reviewer: teemperor.
mib added a project: LLDB.
Herald added a subscriber: lldb-commits.
This patch improves the error reporting for SBBreakpoint::AddName by
changing its return type form a boolean to a SBError.
This way, if the breakpoint naming failed in the backend, the client
(i.e. Xcode), will be able to report the reason of that failure to the
user.
rdar://64765461
Signed-off-by: Med Ismail Bennani <[email protected]>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82879
Files:
lldb/include/lldb/API/SBBreakpoint.h
lldb/source/API/SBBreakpoint.cpp
lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py
Index: lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py
===================================================================
--- lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py
@@ -100,7 +100,7 @@
# 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.")
+ 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")
@@ -143,7 +143,7 @@
"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))
+ 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));
@@ -165,7 +165,7 @@
# 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.")
+ 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)
@@ -244,7 +244,7 @@
# 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")
+ 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:
@@ -318,7 +318,7 @@
unprotected_id = unprotected_bkpt.GetID()
success = protected_bkpt.AddName(self.bp_name_string)
- self.assertTrue(success, "Couldn't add this name to the breakpoint")
+ 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")
Index: lldb/source/API/SBBreakpoint.cpp
===================================================================
--- lldb/source/API/SBBreakpoint.cpp
+++ lldb/source/API/SBBreakpoint.cpp
@@ -649,22 +649,23 @@
return LLDB_RECORD_RESULT(sb_error);
}
-bool SBBreakpoint::AddName(const char *new_name) {
- LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name);
+SBError SBBreakpoint::AddName(const char *new_name) {
+ LLDB_RECORD_METHOD(SBError, SBBreakpoint, AddName, (const char *), new_name);
BreakpointSP bkpt_sp = GetSP();
+ SBError status;
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> 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) {
@@ -1014,7 +1015,7 @@
(const char *, SBStructuredData &));
LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
(const char *));
- LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddName, (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 &));
Index: lldb/include/lldb/API/SBBreakpoint.h
===================================================================
--- lldb/include/lldb/API/SBBreakpoint.h
+++ lldb/include/lldb/API/SBBreakpoint.h
@@ -103,7 +103,7 @@
SBError SetScriptCallbackBody(const char *script_body_text);
- bool AddName(const char *new_name);
+ SBError AddName(const char *new_name);
void RemoveName(const char *name_to_remove);
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits