diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2025-07-09 13:19:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-09 13:19:02 -0700 |
commit | d193a586c0b41192b031ce6a858bec0f855560ad (patch) | |
tree | 1233d5e36e22f35a3b143cc450140e0ef03e552c /lldb/source/Commands/CommandObjectBreakpoint.cpp | |
parent | 0d2b47ae4a01fd97fe479806a45a535ad347eb63 (diff) | |
download | llvm-d193a586c0b41192b031ce6a858bec0f855560ad.zip llvm-d193a586c0b41192b031ce6a858bec0f855560ad.tar.gz llvm-d193a586c0b41192b031ce6a858bec0f855560ad.tar.bz2 |
[lldb] Change breakpoint interfaces for error handling (#146972)
This RP changes some Breakpoint-related interfaces to return errors. On
its own these improvements are small, but they encourage better error
handling going forward. There are a bunch of other candidates, but these
were the functions that I touched while working on #146602.
Diffstat (limited to 'lldb/source/Commands/CommandObjectBreakpoint.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectBreakpoint.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 4631c97..2440a7e 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -28,6 +28,7 @@ #include "lldb/Target/ThreadSpec.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/StreamString.h" +#include "llvm/Support/FormatAdapters.h" #include <memory> #include <optional> @@ -956,7 +957,10 @@ protected: BreakpointLocation *location = breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get(); if (location) { - location->SetEnabled(true); + if (llvm::Error error = location->SetEnabled(true)) + result.AppendErrorWithFormatv( + "failed to enable breakpoint location: {0}", + llvm::fmt_consume(std::move(error))); ++loc_count; } } else { @@ -1062,7 +1066,10 @@ protected: BreakpointLocation *location = breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get(); if (location) { - location->SetEnabled(false); + if (llvm::Error error = location->SetEnabled(false)) + result.AppendErrorWithFormatv( + "failed to disable breakpoint location: {0}", + llvm::fmt_consume(std::move(error))); ++loc_count; } } else { @@ -1508,7 +1515,10 @@ protected: // It makes no sense to try to delete individual locations, so we // disable them instead. if (location) { - location->SetEnabled(false); + if (llvm::Error error = location->SetEnabled(false)) + result.AppendErrorWithFormatv( + "failed to disable breakpoint location: {0}", + llvm::fmt_consume(std::move(error))); ++disable_count; } } else { |