[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 14 13:58:47 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 447af1ce99c066169c5ea85a23963e8d3d93124a dd4dd79853566049874f49d1290217f5abde23fd -- lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 8699479cad..50d1b563f4 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -8,8 +8,8 @@
#include "MinidumpFileBuilder.h"
-#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
#include "Plugins/Process/minidump/RegisterContextMinidump_ARM64.h"
+#include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
@@ -354,10 +354,8 @@ void read_register_u128(RegisterContext *reg_ctx, llvm::StringRef reg_name,
lldb_private::RegisterValue reg_value;
if (reg_ctx->ReadRegister(reg_info, reg_value)) {
Status error;
- uint32_t bytes_copied =
- reg_value.GetAsMemoryData(*reg_info, dst, 16,
- lldb::ByteOrder::eByteOrderLittle,
- error);
+ uint32_t bytes_copied = reg_value.GetAsMemoryData(
+ *reg_info, dst, 16, lldb::ByteOrder::eByteOrderLittle, error);
if (bytes_copied == 16)
return;
}
@@ -409,7 +407,7 @@ GetThreadContext_ARM64(RegisterContext *reg_ctx) {
minidump::RegisterContextMinidump_ARM64::Flags::Integer |
minidump::RegisterContextMinidump_ARM64::Flags::FloatingPoint);
char reg_name[16];
- for (uint32_t i=0; i<31; ++i) {
+ for (uint32_t i = 0; i < 31; ++i) {
snprintf(reg_name, sizeof(reg_name), "x%u", i);
thread_context.x[i] = read_register_u64(reg_ctx, reg_name);
}
@@ -420,9 +418,9 @@ GetThreadContext_ARM64(RegisterContext *reg_ctx) {
thread_context.cpsr = read_register_u32(reg_ctx, "cpsr");
thread_context.fpsr = read_register_u32(reg_ctx, "fpsr");
thread_context.fpcr = read_register_u32(reg_ctx, "fpcr");
- for (uint32_t i=0; i<32; ++i) {
+ for (uint32_t i = 0; i < 32; ++i) {
snprintf(reg_name, sizeof(reg_name), "v%u", i);
- read_register_u128(reg_ctx, reg_name, &thread_context.v[i*16]);
+ read_register_u128(reg_ctx, reg_name, &thread_context.v[i * 16]);
}
return thread_context;
}
@@ -433,39 +431,37 @@ class ArchThreadContexts {
lldb_private::minidump::MinidumpContext_x86_64 x86_64;
lldb_private::minidump::RegisterContextMinidump_ARM64::Context arm64;
};
+
public:
ArchThreadContexts(llvm::Triple::ArchType arch) : m_arch(arch) {}
bool prepareRegisterContext(RegisterContext *reg_ctx) {
switch (m_arch) {
- case llvm::Triple::ArchType::x86_64:
- x86_64 = GetThreadContext_x86_64(reg_ctx);
- return true;
- case llvm::Triple::ArchType::aarch64:
- arm64 = GetThreadContext_ARM64(reg_ctx);
- return true;
- default:
- break;
+ case llvm::Triple::ArchType::x86_64:
+ x86_64 = GetThreadContext_x86_64(reg_ctx);
+ return true;
+ case llvm::Triple::ArchType::aarch64:
+ arm64 = GetThreadContext_ARM64(reg_ctx);
+ return true;
+ default:
+ break;
}
return false;
}
- const void *data() const {
- return &x86_64;
- }
+ const void *data() const { return &x86_64; }
size_t size() const {
switch (m_arch) {
- case llvm::Triple::ArchType::x86_64:
- return sizeof(x86_64);
- case llvm::Triple::ArchType::aarch64:
- return sizeof(arm64);
- default:
- break;
+ case llvm::Triple::ArchType::x86_64:
+ return sizeof(x86_64);
+ case llvm::Triple::ArchType::aarch64:
+ return sizeof(arm64);
+ default:
+ break;
}
return 0;
}
-
};
// Function returns start and size of the memory region that contains
@@ -525,7 +521,8 @@ Status MinidumpFileBuilder::AddThreadList(const lldb::ProcessSP &process_sp) {
const ArchSpec &arch = target.GetArchitecture();
ArchThreadContexts thread_context(arch.GetMachine());
if (!thread_context.prepareRegisterContext(reg_ctx)) {
- error.SetErrorStringWithFormat("architecture %s not supported.",
+ error.SetErrorStringWithFormat(
+ "architecture %s not supported.",
arch.GetTriple().getArchName().str().c_str());
return error;
}
@@ -571,7 +568,6 @@ Status MinidumpFileBuilder::AddThreadList(const lldb::ProcessSP &process_sp) {
helper_data.AppendData(thread_context.data(), thread_context.size());
-
llvm::minidump::Thread t;
t.ThreadId = static_cast<llvm::support::ulittle32_t>(thread_sp->GetID());
t.SuspendCount = static_cast<llvm::support::ulittle32_t>(
@@ -598,12 +594,12 @@ void MinidumpFileBuilder::AddExceptions(const lldb::ProcessSP &process_sp) {
bool add_exception = false;
if (stop_info_sp) {
switch (stop_info_sp->GetStopReason()) {
- case eStopReasonSignal:
- case eStopReasonException:
- add_exception = true;
- break;
- default:
- break;
+ case eStopReasonSignal:
+ case eStopReasonException:
+ add_exception = true;
+ break;
+ default:
+ break;
}
}
if (add_exception) {
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
index f50c0ff49c..58cf8d62fb 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
@@ -73,6 +73,7 @@ public:
FloatingPoint = ARM64_Flag | 0x00000004,
LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ FloatingPoint)
};
+
protected:
Context m_regs;
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/72315
More information about the lldb-commits
mailing list