[Lldb-commits] [lldb] [lldb] enable wasm source debugging (PR #72634)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 17 02:30:42 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 915f6c3d6a4377e2672a95c656374d71df62e95a b9f6f4c03b6f72f44f9270a7de377deab3e0d8f6 -- lldb/source/Plugins/Process/wasm/ProcessWasm.cpp lldb/source/Plugins/Process/wasm/ProcessWasm.h lldb/source/Plugins/Process/wasm/ThreadWasm.cpp lldb/source/Plugins/Process/wasm/ThreadWasm.h lldb/source/Plugins/Process/wasm/UnwindWasm.cpp lldb/source/Plugins/Process/wasm/UnwindWasm.h lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp lldb/source/Plugins/Process/wasm/wasmRegisterContext.h lldb/source/Expression/DWARFExpression.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/source/Target/Platform.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 1693e390c2..8e8ea610b8 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -350,8 +350,7 @@ static offset_t GetOpcodeDataSize(const DataExtractor &data,
uint8_t wasm_op = data.GetU8(&offset);
if (wasm_op == 3) {
data.GetU32(&offset);
- }
- else {
+ } else {
data.GetULEB128(&offset);
}
return offset - data_offset;
@@ -2612,13 +2611,13 @@ bool DWARFExpression::Evaluate(
/* LLDB doesn't have an address space to represents WebAssembly Locals,
* GLobals and operand stacks.
- * We encode these elements into virtual registers:
+ * We encode these elements into virtual registers:
* | tag: 2 bits | index: 30 bits |
* where tag is:
* 0: Not a WebAssembly location
* 1: Local
* 2: Global
- * 3: Operand stack value
+ * 3: Operand stack value
*/
if (wasm_op == 3) {
index = opcodes.GetU32(&offset);
diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
index a2c6a33f83..698c8668e5 100644
--- a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
+++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
@@ -73,7 +73,7 @@ lldb::ProcessSP ProcessWasm::CreateInstance(lldb::TargetSP target_sp,
}
bool ProcessWasm::CanDebug(lldb::TargetSP target_sp,
- bool plugin_specified_by_name) {
+ bool plugin_specified_by_name) {
if (plugin_specified_by_name)
return true;
@@ -109,7 +109,7 @@ size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
}
size_t ProcessWasm::WasmReadMemory(uint32_t wasm_module_id, lldb::addr_t addr,
- void *buf, size_t buffer_size) {
+ void *buf, size_t buffer_size) {
char packet[64];
int packet_len =
::snprintf(packet, sizeof(packet), "qWasmMem:%d;%" PRIx64 ";%" PRIx64,
@@ -118,7 +118,8 @@ size_t ProcessWasm::WasmReadMemory(uint32_t wasm_module_id, lldb::addr_t addr,
assert(packet_len + 1 < (int)sizeof(packet));
UNUSED_IF_ASSERT_DISABLED(packet_len);
StringExtractorGDBRemote response;
- if (m_gdb_comm.SendPacketAndWaitForResponse(packet, response, GetInterruptTimeout()) ==
+ if (m_gdb_comm.SendPacketAndWaitForResponse(packet, response,
+ GetInterruptTimeout()) ==
GDBRemoteCommunication::PacketResult::Success) {
if (response.IsNormalResponse()) {
return response.GetHexBytes(llvm::MutableArrayRef<uint8_t>(
@@ -130,7 +131,7 @@ size_t ProcessWasm::WasmReadMemory(uint32_t wasm_module_id, lldb::addr_t addr,
}
size_t ProcessWasm::WasmReadData(uint32_t wasm_module_id, lldb::addr_t addr,
- void *buf, size_t buffer_size) {
+ void *buf, size_t buffer_size) {
char packet[64];
int packet_len =
::snprintf(packet, sizeof(packet), "qWasmData:%d;%" PRIx64 ";%" PRIx64,
@@ -139,7 +140,8 @@ size_t ProcessWasm::WasmReadData(uint32_t wasm_module_id, lldb::addr_t addr,
assert(packet_len + 1 < (int)sizeof(packet));
UNUSED_IF_ASSERT_DISABLED(packet_len);
StringExtractorGDBRemote response;
- if (m_gdb_comm.SendPacketAndWaitForResponse(packet, response, GetInterruptTimeout()) ==
+ if (m_gdb_comm.SendPacketAndWaitForResponse(packet, response,
+ GetInterruptTimeout()) ==
GDBRemoteCommunication::PacketResult::Success) {
if (response.IsNormalResponse()) {
return response.GetHexBytes(llvm::MutableArrayRef<uint8_t>(
diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.h b/lldb/source/Plugins/Process/wasm/ProcessWasm.h
index 4ef784ae9a..79338b175f 100644
--- a/lldb/source/Plugins/Process/wasm/ProcessWasm.h
+++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.h
@@ -26,11 +26,7 @@ namespace wasm {
//
// Struct wasm_addr_t provides this encoding using bitfields
//
-enum WasmAddressType {
- Memory = 0x00,
- Object = 0x01,
- Invalid = 0x03
-};
+enum WasmAddressType { Memory = 0x00, Object = 0x01, Invalid = 0x03 };
struct wasm_addr_t {
uint64_t offset : 32;
uint64_t module_id : 30;
@@ -93,11 +89,11 @@ public:
/// Read from the WebAssembly Memory space.
size_t WasmReadMemory(uint32_t wasm_module_id, lldb::addr_t addr, void *buf,
- size_t buffer_size);
+ size_t buffer_size);
/// Read from the WebAssembly Data space.
size_t WasmReadData(uint32_t wasm_module_id, lldb::addr_t addr, void *buf,
- size_t buffer_size);
+ size_t buffer_size);
/// Retrieve the current call stack from the WebAssembly remote process.
bool GetWasmCallStack(lldb::tid_t tid,
diff --git a/lldb/source/Plugins/Process/wasm/ThreadWasm.cpp b/lldb/source/Plugins/Process/wasm/ThreadWasm.cpp
index d9715dd23b..adcfba7400 100644
--- a/lldb/source/Plugins/Process/wasm/ThreadWasm.cpp
+++ b/lldb/source/Plugins/Process/wasm/ThreadWasm.cpp
@@ -49,7 +49,8 @@ ThreadWasm::CreateRegisterContextForFrame(StackFrame *frame) {
concrete_frame_idx = frame->GetConcreteFrameIndex();
if (concrete_frame_idx == 0) {
- reg_ctx_sp = std::make_shared<WasmRegisterContext>(*this, concrete_frame_idx, wasm_process->GetRegisterInfo());
+ reg_ctx_sp = std::make_shared<WasmRegisterContext>(
+ *this, concrete_frame_idx, wasm_process->GetRegisterInfo());
} else {
reg_ctx_sp = GetUnwinder().CreateRegisterContextForFrame(frame);
}
diff --git a/lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp b/lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp
index cb19f07ec2..ddcc2e8d03 100644
--- a/lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp
@@ -8,9 +8,9 @@
#include "wasmRegisterContext.h"
#include "Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h"
-#include "lldb/Utility/RegisterValue.h"
#include "ProcessWasm.h"
#include "ThreadWasm.h"
+#include "lldb/Utility/RegisterValue.h"
#include <memory>
using namespace lldb;
@@ -27,9 +27,8 @@ WasmRegisterContext::WasmRegisterContext(
WasmRegisterContext::~WasmRegisterContext() = default;
uint32_t WasmRegisterContext::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num)
-{
- return num;
+ lldb::RegisterKind kind, uint32_t num) {
+ return num;
}
size_t WasmRegisterContext::GetRegisterCount() { return 0; }
@@ -40,7 +39,8 @@ const RegisterInfo *WasmRegisterContext::GetRegisterInfoAtIndex(size_t reg) {
return m_reg_info_sp->GetRegisterInfoAtIndex(reg);
}
- WasmVirtualRegisterKinds kind = static_cast<WasmVirtualRegisterKinds>(tag - 1);
+ WasmVirtualRegisterKinds kind =
+ static_cast<WasmVirtualRegisterKinds>(tag - 1);
return new WasmVirtualRegisterInfo(kind, reg & 0x3fffffff);
}
@@ -61,7 +61,8 @@ bool WasmRegisterContext::ReadRegister(const RegisterInfo *reg_info,
if (!thread)
return false;
-// uint32_t frame_index = thread->GetSelectedFrameIndex(SelectMostRelevantFrame);
+ // uint32_t frame_index =
+ // thread->GetSelectedFrameIndex(SelectMostRelevantFrame);
uint32_t frame_index = m_concrete_frame_idx;
WasmVirtualRegisterInfo *wasm_reg_info =
static_cast<WasmVirtualRegisterInfo *>(
diff --git a/lldb/source/Plugins/Process/wasm/wasmRegisterContext.h b/lldb/source/Plugins/Process/wasm/wasmRegisterContext.h
index 61fb95cef6..16a89a2408 100644
--- a/lldb/source/Plugins/Process/wasm/wasmRegisterContext.h
+++ b/lldb/source/Plugins/Process/wasm/wasmRegisterContext.h
@@ -21,7 +21,7 @@ class WasmRegisterContext;
typedef std::shared_ptr<WasmRegisterContext> WasmRegisterContextSP;
enum WasmVirtualRegisterKinds {
- eLocal = 0, ///< wasm local
+ eLocal = 0, ///< wasm local
eGlobal, ///< wasm global
eOperandStack, ///< wasm operand stack
kNumWasmVirtualRegisterKinds
@@ -45,7 +45,7 @@ public:
~WasmRegisterContext() override;
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
+ uint32_t num) override;
void InvalidateAllRegisters() override;
``````````
</details>
https://github.com/llvm/llvm-project/pull/72634
More information about the lldb-commits
mailing list