================
@@ -584,9 +586,13 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
size_t ptr_size = m_process->GetAddressByteSize();
std::vector<lldb::addr_t> pcs;
for (size_t idx = 0; idx < count; idx++) {
- Status error;
- addr_t pc = m_process->ReadPointerFromMemory(
- frames_addr + (ignore + idx) * ptr_size, error);
+ addr_t pc = LLDB_INVALID_ADDRESS;
+ if (llvm::Expected<lldb::addr_t> pc_or_err =
+ m_process->ReadPointerFromMemory(frames_addr +
+ (ignore + idx) * ptr_size))
+ pc = *pc_or_err;
+ else
+ llvm::consumeError(pc_or_err.takeError());
----------------
felipepiovezan wrote:
I noticed that throughout the PR you've adopted the `_or_err` convention, but
IMO this is needlessly verbose (like all of our `_sp`, `m_`, `_up`, `g_`
suffixes...).
The scope of the variables in this PR is much shorter than the other
suffix-adopting variables, and it leads to you defining multiple variables for
the same idea. For example, here all of this could be just:
```
llvm::Expected<lldb::addr_t> pc =
m_process->ReadPointerFromMemory(frames_addr +
(ignore + idx) * ptr_size))
if (pc)
pcs.push_back(*pc);
else {
llvm::consumeError(pc_or_err.takeError());
pcs.push_back(LLDB_INVALID_ADDRESS);
}
```
It becomes more explicit what is happening in the fail case (i.e. we still push
an error value into the array)
https://github.com/llvm/llvm-project/pull/216389
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits