[Lldb-commits] [lldb] 6f2ebc4 - [lldb] Change SymbolContext::GetAddressRangeFromHereToEndLine to return Expected (NFC) (#110718)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 8 10:04:57 PDT 2024
Author: AbdAlRahman Gad
Date: 2024-10-08T10:04:52-07:00
New Revision: 6f2ebc435f1cd8f121d227a52c76b6477cec8c91
URL: https://github.com/llvm/llvm-project/commit/6f2ebc435f1cd8f121d227a52c76b6477cec8c91
DIFF: https://github.com/llvm/llvm-project/commit/6f2ebc435f1cd8f121d227a52c76b6477cec8c91.diff
LOG: [lldb] Change SymbolContext::GetAddressRangeFromHereToEndLine to return Expected (NFC) (#110718)
Signed-off-by: AbdAlRahman Gad <abdobngad at gmail.com>
Co-authored-by: Adrian Prantl <adrian.prantl at gmail.com>
Added:
Modified:
lldb/include/lldb/Symbol/SymbolContext.h
lldb/source/API/SBThread.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Symbol/SymbolContext.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h
index 0bc707070f8504..f65f57b0d11034 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -201,8 +201,8 @@ class SymbolContext {
bool GetAddressRange(uint32_t scope, uint32_t range_idx,
bool use_inline_block_range, AddressRange &range) const;
- bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range,
- Status &error);
+ llvm::Error GetAddressRangeFromHereToEndLine(uint32_t end_line,
+ AddressRange &range);
/// Find the best global data symbol visible from this context.
///
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 7508eed5d6fdbd..a99456e06d0329 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -605,8 +605,11 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line,
if (end_line == LLDB_INVALID_LINE_NUMBER)
range = sc.line_entry.range;
else {
- if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
+ llvm::Error err = sc.GetAddressRangeFromHereToEndLine(end_line, range);
+ if (err) {
+ error = Status::FromErrorString(llvm::toString(std::move(err)).c_str());
return;
+ }
}
const LazyBool step_out_avoids_code_without_debug_info =
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index bc1f5c39e702c6..2e2b0edeec0fc1 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -489,11 +489,11 @@ class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
AddressRange range;
SymbolContext sc = frame->GetSymbolContext(eSymbolContextEverything);
if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER) {
- Status error;
- if (!sc.GetAddressRangeFromHereToEndLine(m_options.m_end_line, range,
- error)) {
- result.AppendErrorWithFormat("invalid end-line option: %s.",
- error.AsCString());
+ llvm::Error err =
+ sc.GetAddressRangeFromHereToEndLine(m_options.m_end_line, range);
+ if (err) {
+ result.AppendErrorWithFormatv("invalid end-line option: {0}.",
+ llvm::toString(std::move(err)));
return;
}
} else if (m_options.m_end_line_is_block_end) {
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index a1020a5aae4e79..de083e81206e2a 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -706,20 +706,18 @@ LineEntry SymbolContext::GetFunctionStartLineEntry() const {
return LineEntry();
}
-bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
- AddressRange &range,
- Status &error) {
+llvm::Error
+SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
+ AddressRange &range) {
if (!line_entry.IsValid()) {
- error = Status::FromErrorString("Symbol context has no line table.");
- return false;
+ return llvm::createStringError("Symbol context has no line table.");
}
range = line_entry.range;
if (line_entry.line > end_line) {
- error = Status::FromErrorStringWithFormat(
+ return llvm::createStringError(
"end line option %d must be after the current line: %d", end_line,
line_entry.line);
- return false;
}
uint32_t line_index = 0;
@@ -740,35 +738,32 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
if (!found) {
// Can't find the index of the SymbolContext's line entry in the
// SymbolContext's CompUnit.
- error = Status::FromErrorString(
+ return llvm::createStringError(
"Can't find the current line entry in the CompUnit - can't process "
"the end-line option");
- return false;
}
line_index = comp_unit->FindLineEntry(line_index, end_line, nullptr, false,
&end_entry);
if (line_index == UINT32_MAX) {
- error = Status::FromErrorStringWithFormat(
+ return llvm::createStringError(
"could not find a line table entry corresponding "
"to end line number %d",
end_line);
- return false;
}
Block *func_block = GetFunctionBlock();
if (func_block && func_block->GetRangeIndexContainingAddress(
end_entry.range.GetBaseAddress()) == UINT32_MAX) {
- error = Status::FromErrorStringWithFormat(
+ return llvm::createStringError(
"end line number %d is not contained within the current function.",
end_line);
- return false;
}
lldb::addr_t range_size = end_entry.range.GetBaseAddress().GetFileAddress() -
range.GetBaseAddress().GetFileAddress();
range.SetByteSize(range_size);
- return true;
+ return llvm::Error::success();
}
const Symbol *SymbolContext::FindBestGlobalDataSymbol(ConstString name,
More information about the lldb-commits
mailing list