https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/176464
>From 6d9cd136ed8ee6fd5bf70d783dd433bc7522a19f Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere <[email protected]> Date: Fri, 16 Jan 2026 11:39:57 -0800 Subject: [PATCH 1/2] [lldb] Fix llvm_unreachable for invalid Wasm address We had an llvm_unreachable following a switch on the WasmAddress's type. However, the type is encoded in a larger 64 bit address, and therefore it's possible to create an invalid value that doesn't map back on one of the enum types. We could try to diagnose that in the wrapper, or treat all invalid types the same. I took the latter approach because it makes it easier to show the invalid type after the fact in an error message. rdar://168314695 --- lldb/source/Plugins/Process/wasm/ProcessWasm.cpp | 14 +++++++++----- lldb/source/Plugins/Process/wasm/ProcessWasm.h | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp index 62bcf442d097a..87a9d26368d76 100644 --- a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp +++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp @@ -93,12 +93,16 @@ size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, case WasmAddressType::Memory: case WasmAddressType::Object: return ProcessGDBRemote::ReadMemory(vm_addr, buf, size, error); - case WasmAddressType::Invalid: - error.FromErrorStringWithFormat( - "Wasm read failed for invalid address 0x%" PRIx64, vm_addr); - return 0; + default: + break; } - llvm_unreachable("Fully covered switch above"); + + error.FromErrorStringWithFormatv( + "Wasm read failed for invalid address {0:x} (type = {1:x}, module = " + "{2:x}, offset = {3:x})", + vm_addr, wasm_addr.GetType(), wasm_addr.GetModuleID(), + wasm_addr.GetOffset()); + return 0; } llvm::Expected<std::vector<lldb::addr_t>> diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.h b/lldb/source/Plugins/Process/wasm/ProcessWasm.h index 22effe7340ed7..4bd728dff24dc 100644 --- a/lldb/source/Plugins/Process/wasm/ProcessWasm.h +++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.h @@ -35,7 +35,9 @@ struct wasm_addr_t { wasm_addr_t(WasmAddressType type, uint32_t module_id, uint32_t offset) : offset(offset), module_id(module_id), type(type) {} - WasmAddressType GetType() { return static_cast<WasmAddressType>(type); } + WasmAddressType GetType() const { return static_cast<WasmAddressType>(type); } + uint32_t GetModuleID() const { return module_id; } + uint32_t GetOffset() const { return offset; } operator lldb::addr_t() { return *(uint64_t *)this; } }; >From d17be8bacf40c32c8a5700075fb65e168a0fbc92 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere <[email protected]> Date: Fri, 16 Jan 2026 13:58:41 -0800 Subject: [PATCH 2/2] Keep missing-case-in-switch --- lldb/source/Plugins/Process/wasm/ProcessWasm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp index 87a9d26368d76..421338b0e1cae 100644 --- a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp +++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp @@ -93,7 +93,7 @@ size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, case WasmAddressType::Memory: case WasmAddressType::Object: return ProcessGDBRemote::ReadMemory(vm_addr, buf, size, error); - default: + case WasmAddressType::Invalid: break; } _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
