1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 03:09:51 +03:00
aports/community/qt6-qtwebengine/qt6-6.9.0.loongarch64-crashpad.diff

862 lines
38 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context.h 2000-01-01 00:00:00.000000000 +0800
@@ -687,6 +687,56 @@ struct MinidumpContextRISCV64 {
uint32_t fcsr;
};
+//! \brief LOONG64-specifc flags for MinidumpContextLOONG64::context_flags.
+//! Based on minidump_cpu_loong64.h from breakpad
+enum MinidumpContextLOONG64Flags : uint32_t {
+ //! \brief Identifies the context structure as LOONG64.
+ kMinidumpContextLOONG64 = 0x00800000,
+
+ //! \brief Indicates the validity of integer registers.
+ //!
+ //! Registers `0`-`31`, `csr_era` are valid.
+ kMinidumpContextLOONG64Integer = kMinidumpContextLOONG64 | 0x00000002,
+
+ //! \brief Indicates the validity of floating point registers.
+ //!
+ //! Floating point registers `0`-`31`, `fcsr` and `fcc` are valid
+ kMinidumpContextLOONG64FloatingPoint = kMinidumpContextLOONG64 | 0x00000004,
+
+ //! \brief Indicates the validity of all registers.
+ kMinidumpContextLOONG64All = kMinidumpContextLOONG64Integer |
+ kMinidumpContextLOONG64FloatingPoint,
+};
+
+//! \brief A LOONG64 CPU context (register state) carried in a minidump file.
+struct MinidumpContextLOONG64 {
+ uint64_t context_flags;
+
+ //! \brief General purpose registers.
+ uint64_t regs[32];
+
+ //! \brief csr_era registers.
+ uint64_t csr_era;
+
+ //! \brief FPU registers.
+ union {
+ struct {
+ float _fp_fregs;
+ uint32_t _fp_pad;
+ } fregs[32];
+ double dregs[32];
+ } fpregs;
+
+ //! \brief Floating-point status and control register.
+ uint64_t fcc;
+
+ //! \brief Floating-point control and status register.
+ uint32_t fcsr;
+
+ //! \brief padding
+ uint32_t _pad;
+};
+
} // namespace crashpad
#endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc 2000-01-01 00:00:00.000000000 +0800
@@ -110,6 +110,13 @@ MinidumpContextWriter::CreateFromSnapsho
break;
}
+ case kCPUArchitectureLOONG64: {
+ context = std::make_unique<MinidumpContextLOONG64Writer>();
+ reinterpret_cast<MinidumpContextLOONG64Writer*>(context.get())
+ ->InitializeFromSnapshot(context_snapshot->loong64);
+ break;
+ }
+
default: {
LOG(ERROR) << "unknown context architecture "
<< context_snapshot->architecture;
@@ -605,5 +612,44 @@ size_t MinidumpContextRISCV64Writer::Con
DCHECK_GE(state(), kStateFrozen);
return sizeof(context_);
}
+
+MinidumpContextLOONG64Writer::MinidumpContextLOONG64Writer()
+ : MinidumpContextWriter(), context_() {
+ context_.context_flags = kMinidumpContextLOONG64;
+}
+
+MinidumpContextLOONG64Writer::~MinidumpContextLOONG64Writer() = default;
+
+void MinidumpContextLOONG64Writer::InitializeFromSnapshot(
+ const CPUContextLOONG64* context_snapshot) {
+ DCHECK_EQ(state(), kStateMutable);
+ DCHECK_EQ(context_.context_flags, kMinidumpContextLOONG64);
+
+ context_.context_flags = kMinidumpContextLOONG64All;
+
+ static_assert(sizeof(context_.regs) == sizeof(context_snapshot->regs),
+ "GPRs size mismatch");
+ memcpy(context_.regs, context_snapshot->regs, sizeof(context_.regs));
+ context_.csr_era = context_snapshot->csr_era;
+
+ static_assert(sizeof(context_.fpregs) == sizeof(context_snapshot->fpregs),
+ "FPRs size mismatch");
+ memcpy(context_.fpregs.dregs,
+ context_snapshot->fpregs.dregs,
+ sizeof(context_.fpregs.dregs));
+ context_.fcsr = context_snapshot->fcsr;
+ context_.fcc = context_snapshot->fcc;
+}
+
+bool MinidumpContextLOONG64Writer::WriteObject(
+ FileWriterInterface* file_writer) {
+ DCHECK_EQ(state(), kStateWritable);
+ return file_writer->Write(&context_, sizeof(context_));
+}
+
+size_t MinidumpContextLOONG64Writer::ContextSize() const {
+ DCHECK_GE(state(), kStateFrozen);
+ return sizeof(context_);
+}
} // namespace crashpad
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_context_writer.h 2000-01-01 00:00:00.000000000 +0800
@@ -413,6 +413,44 @@ class MinidumpContextRISCV64Writer final
MinidumpContextRISCV64 context_;
};
+//! \brief The writer for a MinidumpContextLOONG64 structure in a minidump file.
+class MinidumpContextLOONG64Writer final : public MinidumpContextWriter {
+ public:
+ MinidumpContextLOONG64Writer();
+ ~MinidumpContextLOONG64Writer() override;
+
+ //! \brief Initializes the MinidumpContextLOONG64 based on \a context_snapshot.
+ //!
+ //! \param[in] context_snapshot The context snapshot to use as source data.
+ //!
+ //! \note Valid in #kStateMutable. No mutation of context() may be done before
+ //! calling this method, and it is not normally necessary to alter
+ //! context() after calling this method.
+ void InitializeFromSnapshot(const CPUContextLOONG64* context_snapshot);
+
+ //! \brief Returns a pointer to the context structure that this object will
+ //! write.
+ //!
+ //! \attention This returns a non-`const` pointer to this objects private
+ //! data so that a caller can populate the context structure directly.
+ //! This is done because providing setter interfaces to each field in the
+ //! context structure would be unwieldy and cumbersome. Care must be taken
+ //! to populate the context structure correctly. The context structure
+ //! must only be modified while this object is in the #kStateMutable
+ //! state.
+ MinidumpContextLOONG64* context() { return &context_; }
+
+ protected:
+ // MinidumpWritable:
+ bool WriteObject(FileWriterInterface* file_writer) override;
+
+ // MinidumpContextWriter:
+ size_t ContextSize() const override;
+
+ private:
+ MinidumpContextLOONG64 context_;
+};
+
} // namespace crashpad
#endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_extensions.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_extensions.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_extensions.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_extensions.h 2000-01-01 00:00:00.000000000 +0800
@@ -213,6 +213,9 @@ enum MinidumpCPUArchitecture : uint16_t
//! \brief Used by Breakpad for 64-bit RISC-V.
kMinidumpCPUArchitectureRISCV64Breakpad = 0x8006,
+ //! \brief Used by Breakpad for 64-bit LoongArch.
+ kMinidumpCPUArchitectureLOONG64Breakpad = 0x8007,
+
//! \brief Unknown CPU architecture.
kMinidumpCPUArchitectureUnknown = PROCESSOR_ARCHITECTURE_UNKNOWN,
};
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc 2000-01-01 00:00:00.000000000 +0800
@@ -177,6 +177,8 @@ std::string MinidumpMiscInfoDebugBuildSt
static constexpr char kCPU[] = "mips64";
#elif defined(ARCH_CPU_RISCV64)
static constexpr char kCPU[] = "riscv64";
+#elif defined(ARCH_CPU_LOONGARCH64)
+ static constexpr char kCPU[] = "loong64";
#else
#error define kCPU for this CPU
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_system_info_writer.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_system_info_writer.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_system_info_writer.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/minidump/minidump_system_info_writer.cc 2000-01-01 00:00:00.000000000 +0800
@@ -135,6 +135,9 @@ void MinidumpSystemInfoWriter::Initializ
case kCPUArchitectureRISCV64:
cpu_architecture = kMinidumpCPUArchitectureRISCV64Breakpad;
break;
+ case kCPUArchitectureLOONG64:
+ cpu_architecture = kMinidumpCPUArchitectureLOONG64Breakpad;
+ break;
default:
NOTREACHED();
}
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/capture_memory.cc 2000-01-01 00:00:00.000000000 +0800
@@ -123,6 +123,11 @@ void CaptureMemory::PointedToByContext(c
for (size_t i = 0; i < std::size(context.riscv64->regs); ++i) {
MaybeCaptureMemoryAround(delegate, context.riscv64->regs[i]);
}
+#elif defined(ARCH_CPU_LOONGARCH64)
+ MaybeCaptureMemoryAround(delegate, context.loong64->csr_era);
+ for (size_t i = 0; i < std::size(context.loong64->regs); ++i) {
+ MaybeCaptureMemoryAround(delegate, context.loong64->regs[i]);
+ }
#else
#error Port.
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_architecture.h 2000-01-01 00:00:00.000000000 +0800
@@ -47,6 +47,9 @@ enum CPUArchitecture {
//! \brief 64-bit RISC-V.
kCPUArchitectureRISCV64,
+
+ //! \brief 64-bit LOONGARCH.
+ kCPUArchitectureLOONG64,
};
} // namespace crashpad
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.cc 2000-01-01 00:00:00.000000000 +0800
@@ -173,6 +173,8 @@ uint64_t CPUContext::InstructionPointer(
return arm64->pc;
case kCPUArchitectureRISCV64:
return riscv64->pc;
+ case kCPUArchitectureLOONG64:
+ return loong64->csr_era;
default:
NOTREACHED();
}
@@ -190,6 +192,8 @@ uint64_t CPUContext::StackPointer() cons
return arm64->sp;
case kCPUArchitectureRISCV64:
return riscv64->regs[1];
+ case kCPUArchitectureLOONG64:
+ return loong64->regs[3];
default:
NOTREACHED();
}
@@ -227,6 +231,7 @@ bool CPUContext::Is64Bit() const {
case kCPUArchitectureARM64:
case kCPUArchitectureMIPS64EL:
case kCPUArchitectureRISCV64:
+ case kCPUArchitectureLOONG64:
return true;
case kCPUArchitectureX86:
case kCPUArchitectureARM:
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/cpu_context.h 2000-01-01 00:00:00.000000000 +0800
@@ -371,6 +371,22 @@ struct CPUContextRISCV64 {
uint32_t fcsr;
};
+//! \brief A context structure carrying LOONG64 CPU state.
+struct CPUContextLOONG64 {
+ uint64_t regs[32];
+ uint64_t csr_era;
+
+ union {
+ double dregs[32];
+ struct {
+ float _fp_fregs;
+ uint32_t _fp_pad;
+ } fregs[32];
+ } fpregs;
+ uint64_t fcc;
+ uint32_t fcsr;
+};
+
//! \brief A context structure capable of carrying the context of any supported
//! CPU architecture.
struct CPUContext {
@@ -412,6 +428,7 @@ struct CPUContext {
CPUContextMIPS* mipsel;
CPUContextMIPS64* mips64;
CPUContextRISCV64* riscv64;
+ CPUContextLOONG64* loong64;
};
};
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -281,6 +281,40 @@ void InitializeCPUContextRISCV64(const T
context->fcsr = float_context.fcsr;
}
+#elif defined(ARCH_CPU_LOONGARCH64)
+
+void InitializeCPUContextLOONG64_NoFloatingPoint(
+ const ThreadContext::t64_t& thread_context,
+ CPUContextLOONG64* context) {
+ static_assert(sizeof(context->regs) == sizeof(thread_context.regs),
+ "gpr context size mismtach");
+ memcpy(context->regs, thread_context.regs, sizeof(context->regs));
+ context->csr_era = thread_context.csr_era;
+
+ memset(&context->fpregs, 0, sizeof(context->fpregs));
+ context->fcc = 0;
+ context->fcsr = 0;
+}
+
+void InitializeCPUContextLOONG64_OnlyFPU(
+ const FloatContext::f64_t& float_context,
+ CPUContextLOONG64* context) {
+ static_assert(sizeof(context->fpregs) == sizeof(float_context.fpregs),
+ "fpu context size mismatch");
+ memcpy(&context->fpregs, &float_context.fpregs, sizeof(context->fpregs));
+ context->fcc = float_context.fcc;
+ context->fcsr = float_context.fcsr;
+}
+
+void InitializeCPUContextLOONG64(
+ const ThreadContext::t64_t& thread_context,
+ const FloatContext::f64_t& float_context,
+ CPUContextLOONG64* context) {
+ InitializeCPUContextLOONG64_NoFloatingPoint(thread_context, context);
+
+ InitializeCPUContextLOONG64_OnlyFPU(float_context, context);
+}
+
#endif // ARCH_CPU_X86_FAMILY
} // namespace internal
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h 2000-01-01 00:00:00.000000000 +0800
@@ -188,6 +188,45 @@ void InitializeCPUContextRISCV64(const T
#endif // ARCH_CPU_RISCV64 || DOXYGEN
+#if defined(ARCH_CPU_LOONGARCH64) || DOXYGEN
+
+//! \brief Initializes GPR state in a CPUContextLOONG64 from a native context
+//! structure on Linux.
+//!
+//! Floating point state is initialized to zero.
+//!
+//! \param[in] thread_context The native thread context.
+//! \param[out] context The CPUContextLOONG64 structure to initialize.
+void InitializeCPUContextLOONG64_NoFloatingPoint(
+ const ThreadContext::t64_t& thread_context,
+ CPUContextLOONG64* context);
+//! \brief Initializes FPU state in a CPUContextLOONG64 from a native fpu
+//! signal context structure on Linux.
+//!
+//! General purpose registers are not initialized.
+//!
+//! \param[in] float_context The native fpu context.
+//! \param[out] context The CPUContextLOONG64 structure to initialize.
+void InitializeCPUContextLOONG64_OnlyFPU(
+ const FloatContext::f64_t& float_context,
+ CPUContextLOONG64* context);
+//! \brief Initializes a CPUContextLOONG64 structure from native context
+//! structures on Linux.
+//!
+//! This function has template specializations for LOONG64 architecture
+//! contexts, using ContextTraits32 or ContextTraits64 as template parameter,
+//! respectively.
+//!
+//! \param[in] thread_context The native thread context.
+//! \param[in] float_context The native float context.
+//! \param[out] context The CPUContextLOONG64 structure to initialize.
+void InitializeCPUContextLOONG64(
+ const ThreadContext::t64_t& thread_context,
+ const FloatContext::f64_t& float_context,
+ CPUContextLOONG64* context);
+
+#endif // ARCH_CPU_LOONGARCH64 || DOXYGEN
+
} // namespace internal
} // namespace crashpad
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -15,6 +15,7 @@
#include "snapshot/linux/exception_snapshot_linux.h"
#include <signal.h>
+#include <cstring>
#include "base/logging.h"
#include "snapshot/linux/capture_memory_delegate_linux.h"
@@ -367,6 +368,77 @@ bool ExceptionSnapshotLinux::ReadContext
return internal::ReadContext(reader, context_address, context_.riscv64);
}
+#elif defined(ARCH_CPU_LOONGARCH64)
+
+static bool ReadContext(ProcessReaderLinux* reader,
+ LinuxVMAddress context_address,
+ typename ContextTraits64::CPUContext* dest_context) {
+ const ProcessMemory* memory = reader->Memory();
+ LinuxVMAddress gregs_address = context_address +
+ offsetof(UContext<ContextTraits64>, mcontext);
+ ThreadContext::t64_t thread_context;
+ ContextTraits64::MContext mcontext;
+ if (!memory->Read(gregs_address, sizeof(mcontext), &mcontext)) {
+ LOG(ERROR) << "Couldn't read gregs";
+ return false;
+ }
+ static_assert(sizeof(thread_context.regs) == sizeof(mcontext.gregs),
+ "gpr context size mismtach");
+ memcpy(thread_context.regs, mcontext.gregs, sizeof(mcontext.gregs));
+ thread_context.csr_era = mcontext.pc;
+ thread_context.orig_a0 = 0;
+ thread_context.csr_badv = 0;
+ InitializeCPUContextLOONG64_NoFloatingPoint(thread_context, dest_context);
+ LinuxVMAddress reserved_address =
+ context_address + offsetof(UContext<ContextTraits64>, mcontext.extcontext);
+ if ((reserved_address & 15) != 0) {
+ LOG(ERROR) << "invalid alignment 0x" << std::hex << reserved_address;
+ return false;
+ }
+ constexpr VMSize kMaxContextSpace = 4096;
+ ProcessMemoryRange range;
+ if (!range.Initialize(memory, true, reserved_address, kMaxContextSpace)) {
+ return false;
+ }
+ do {
+ struct sctx_info head;
+ if (!range.Read(reserved_address, sizeof(head), &head)) {
+ LOG(ERROR) << "missing context terminator";
+ return false;
+ }
+ reserved_address += sizeof(head);
+ switch (head.magic) {
+ case FPU_CTX_MAGIC:
+ if (head.size != sizeof(struct fpu_context) + sizeof(head)) {
+ LOG(ERROR) << "unexpected fpu context size " << head.size;
+ return false;
+ }
+ FloatContext::f64_t fpucontext;
+ if (!range.Read(reserved_address, sizeof(fpucontext), &fpucontext)) {
+ LOG(ERROR) << "Couldn't read fpu " << head.size;
+ return false;
+ }
+ InitializeCPUContextLOONG64_OnlyFPU(fpucontext, dest_context);
+ return true;
+ case 0:
+ return true;
+ default:
+ LOG(ERROR) << "invalid magic number 0x" << std::hex << head.magic;
+ return false;
+ }
+ } while (true);
+}
+
+template <>
+bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
+ ProcessReaderLinux* reader,
+ LinuxVMAddress context_address) {
+ context_.architecture = kCPUArchitectureLOONG64;
+ context_.loong64 = &context_union_.loong64;
+
+ return internal::ReadContext(reader, context_address, context_.loong64);
+}
+
#endif // ARCH_CPU_X86_FAMILY
bool ExceptionSnapshotLinux::Initialize(
@@ -397,7 +469,7 @@ bool ExceptionSnapshotLinux::Initialize(
return false;
}
} else {
-#if !defined(ARCH_CPU_RISCV64)
+#if !defined(ARCH_CPU_RISCV64) && !defined(ARCH_CPU_LOONGARCH64)
if (!ReadContext<ContextTraits32>(process_reader, context_address) ||
!ReadSiginfo<Traits32>(process_reader, siginfo_address)) {
return false;
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h 2000-01-01 00:00:00.000000000 +0800
@@ -91,6 +91,8 @@ class ExceptionSnapshotLinux final : pub
CPUContextMIPS64 mips64;
#elif defined(ARCH_CPU_RISCV64)
CPUContextRISCV64 riscv64;
+#elif defined(ARCH_CPU_LOONGARCH64)
+ CPUContextLOONG64 loong64;
#endif
} context_union_;
CPUContext context_;
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -129,6 +129,8 @@ void ProcessReaderLinux::Thread::Initial
: thread_info.thread_context.t32.regs[29];
#elif defined(ARCH_CPU_RISCV64)
stack_pointer = thread_info.thread_context.t64.regs[1];
+#elif defined(ARCH_CPU_LOONGARCH64)
+ stack_pointer = thread_info.thread_context.t64.regs[3];
#else
#error Port.
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/signal_context.h 2000-01-01 00:00:00.000000000 +0800
@@ -456,6 +456,46 @@ static_assert(offsetof(UContext<ContextT
offsetof(ucontext_t, uc_mcontext.__fpregs),
"context offset mismatch");
+#elif defined(ARCH_CPU_LOONGARCH64)
+
+// See asm/sigcontext.h
+struct MContext64 {
+ uint64_t pc;
+ uint64_t gregs[32];
+ uint32_t flags;
+ uint32_t padding;
+ uint64_t extcontext[0] __attribute__((__aligned__(16)));
+};
+
+struct ContextTraits64 : public Traits64 {
+ using MContext = MContext64;
+ using SignalThreadContext = ThreadContext::t64_t;
+ using SignalFloatContext = FloatContext::f64_t;
+ using CPUContext = CPUContextLOONG64;
+};
+
+// See asm/ucontext.h
+template <typename Traits>
+struct UContext {
+ typename Traits::ULong flags;
+ typename Traits::Address link;
+ SignalStack<Traits> stack;
+ Sigset<Traits> sigmask;
+ char alignment_padding_[8];
+ char padding[128 - sizeof(Sigset<Traits>)];
+ MContext64 mcontext;
+};
+
+static_assert(offsetof(UContext<ContextTraits64>, mcontext) ==
+ offsetof(ucontext_t, uc_mcontext),
+ "context offset mismatch");
+static_assert(offsetof(UContext<ContextTraits64>, mcontext.gregs) ==
+ offsetof(ucontext_t, uc_mcontext.__gregs),
+ "context offset mismatch");
+static_assert(offsetof(UContext<ContextTraits64>, mcontext.extcontext) ==
+ offsetof(ucontext_t, uc_mcontext.__extcontext),
+ "context offset mismatch");
+
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -208,6 +208,8 @@ CPUArchitecture SystemSnapshotLinux::Get
: kCPUArchitectureMIPSEL;
#elif defined(ARCH_CPU_RISCV64)
return kCPUArchitectureRISCV64;
+#elif defined(ARCH_CPU_LOONGARCH64)
+ return kCPUArchitectureLOONG64;
#else
#error port to your architecture
#endif
@@ -226,6 +228,9 @@ uint32_t SystemSnapshotLinux::CPURevisio
#elif defined(ARCH_CPU_RISCV64)
// Not implemented
return 0;
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ // Not implemented
+ return 0;
#else
#error port to your architecture
#endif
@@ -249,6 +254,9 @@ std::string SystemSnapshotLinux::CPUVend
#elif defined(ARCH_CPU_RISCV64)
// Not implemented
return std::string();
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ // Not implemented
+ return std::string();
#else
#error port to your architecture
#endif
@@ -380,6 +388,9 @@ bool SystemSnapshotLinux::NXEnabled() co
#elif defined(ARCH_CPU_RISCV64)
// Not implemented
return false;
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ // Not implemented
+ return false;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc 2000-01-01 00:00:00.000000000 +0800
@@ -196,6 +196,13 @@ bool ThreadSnapshotLinux::Initialize(
InitializeCPUContextRISCV64(thread.thread_info.thread_context.t64,
thread.thread_info.float_context.f64,
context_.riscv64);
+#elif defined(ARCH_CPU_LOONGARCH64)
+ context_.architecture = kCPUArchitectureLOONG64;
+ context_.loong64 = &context_union_.loong64;
+ InitializeCPUContextLOONG64<ContextTraits64>(
+ thread.thread_info.thread_context.t64,
+ thread.thread_info.float_context.f64,
+ context_.loong64);
#else
#error Port.
#endif
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h 2000-01-01 00:00:00.000000000 +0800
@@ -76,6 +76,8 @@ class ThreadSnapshotLinux final : public
CPUContextMIPS64 mips64;
#elif defined(ARCH_CPU_RISCV64)
CPUContextRISCV64 riscv64;
+#elif defined(ARCH_CPU_LOONGARCH64)
+ CPUContextLOONG64 loong64;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/minidump_context_converter.cc 2000-01-01 00:00:00.000000000 +0800
@@ -293,6 +293,30 @@ bool MinidumpContextConverter::Initializ
memcpy(&context_.riscv64->fpregs, &src->fpregs, sizeof(src->fpregs));
context_.riscv64->fcsr = src->fcsr;
+ } else if (context_.architecture ==
+ CPUArchitecture::kCPUArchitectureLOONG64) {
+ context_memory_.resize(sizeof(CPUContextLOONG64));
+ context_.loong64 =
+ reinterpret_cast<CPUContextLOONG64*>(context_memory_.data());
+ const MinidumpContextLOONG64* src =
+ reinterpret_cast<const MinidumpContextLOONG64*>(minidump_context.data());
+ if (minidump_context.size() < sizeof(MinidumpContextLOONG64)) {
+ return false;
+ }
+
+ if (!(src->context_flags & kMinidumpContextLOONG64)) {
+ return false;
+ }
+
+ for (size_t i = 0; i < std::size(src->regs); i++) {
+ context_.loong64->regs[i] = src->regs[i];
+ }
+
+ context_.loong64->csr_era = src->csr_era;
+ context_.loong64->fcsr = src->fcsr;
+ context_.loong64->fcc = src->fcc;
+
+ memcpy(&context_.loong64->fpregs, &src->fpregs, sizeof(src->fpregs));
} else {
// Architecture is listed as "unknown".
DLOG(ERROR) << "Unknown architecture";
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/system_snapshot_minidump.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/system_snapshot_minidump.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/system_snapshot_minidump.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/minidump/system_snapshot_minidump.cc 2000-01-01 00:00:00.000000000 +0800
@@ -70,6 +70,8 @@ CPUArchitecture SystemSnapshotMinidump::
// No word on how MIPS64 is signalled
case kMinidumpCPUArchitectureRISCV64Breakpad:
return kCPUArchitectureRISCV64;
+ case kMinidumpCPUArchitectureLOONG64Breakpad:
+ return kCPUArchitectureLOONG64;
default:
return CPUArchitecture::kCPUArchitectureUnknown;
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc 2000-01-01 00:00:00.000000000 +0800
@@ -430,6 +430,37 @@ bool GetThreadArea64(pid_t tid,
return true;
}
+#elif defined(ARCH_CPU_LOONGARCH64)
+
+bool GetFloatingPointRegisters64(pid_t tid,
+ FloatContext* context,
+ bool can_log) {
+ iovec iov;
+ iov.iov_base = context;
+ iov.iov_len = sizeof(*context);
+ if (ptrace(
+ PTRACE_GETREGSET, tid, reinterpret_cast<void*>(NT_PRFPREG), &iov) !=
+ 0) {
+ PLOG_IF(ERROR, can_log) << "ptrace";
+ return false;
+ }
+ if (iov.iov_len != sizeof(context->f64)) {
+ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len
+ << " != " << sizeof(context->f64);
+ return false;
+ }
+ return true;
+}
+
+bool GetThreadArea64(pid_t tid,
+ const ThreadContext& context,
+ LinuxVMAddress* address,
+ bool can_log) {
+ // Thread pointer register
+ *address = context.t64.regs[2];
+ return true;
+}
+
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -534,7 +565,7 @@ bool Ptracer::GetThreadInfo(pid_t tid, T
can_log_);
}
-#if !defined(ARCH_CPU_RISCV64)
+#if !defined(ARCH_CPU_RISCV64) && !defined(ARCH_CPU_LOONGARCH64)
return GetGeneralPurposeRegisters32(tid, &info->thread_context, can_log_) &&
GetFloatingPointRegisters32(tid, &info->float_context, can_log_) &&
GetThreadArea32(tid,
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h 2000-01-01 00:00:00.000000000 +0800
@@ -87,6 +87,8 @@ union ThreadContext {
uint32_t padding1_;
#elif defined(ARCH_CPU_RISCV64)
// 32 bit RISC-V not supported
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ // 32 bit LoongArch not supported
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -144,13 +146,20 @@ union ThreadContext {
// Reflects user_regs_struct in asm/ptrace.h.
uint64_t pc;
uint64_t regs[31];
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ // Reflects user_regs_struct in sys/user.h.
+ uint64_t regs[32];
+ uint64_t orig_a0;
+ uint64_t csr_era;
+ uint64_t csr_badv;
+ uint64_t reserved[10];
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
} t64;
#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) || \
- defined(ARCH_CPU_RISCV64)
+ defined(ARCH_CPU_RISCV64) || defined(ARCH_CPU_LOONGARCH64)
using NativeThreadContext = user_regs_struct;
#elif defined(ARCH_CPU_ARMEL)
using NativeThreadContext = user_regs;
@@ -233,6 +242,8 @@ union FloatContext {
uint32_t fpu_id;
#elif defined(ARCH_CPU_RISCV64)
// 32 bit RISC-V not supported
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ // 32 bit LoongArch not supported
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -271,6 +282,11 @@ union FloatContext {
// Reflects __riscv_d_ext_state in asm/ptrace.h
uint64_t fpregs[32];
uint64_t fcsr;
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ // Reflects user_fp_struct in sys/user.h
+ uint64_t fpregs[32];
+ uint64_t fcc;
+ uint32_t fcsr;
#else
#error Port.
#endif // ARCH_CPU_X86_FAMILY
@@ -302,6 +318,8 @@ union FloatContext {
// No appropriate floating point context native type for available MIPS.
#elif defined(ARCH_CPU_RISCV64)
static_assert(sizeof(f64) == sizeof(__riscv_d_ext_state), "Size mismatch");
+#elif defined(ARCH_CPU_LOONGARCH_FAMILY)
+ static_assert(sizeof(f64) == sizeof(user_fp_struct), "Size mismatch");
#else
#error Port.
#endif // ARCH_CPU_X86
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/misc/capture_context_linux.S b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/misc/capture_context_linux.S
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/misc/capture_context_linux.S 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/misc/capture_context_linux.S 2000-01-01 00:00:00.000000000 +0800
@@ -338,6 +338,51 @@ CAPTURECONTEXT_SYMBOL2:
// TODO(https://crashpad.chromium.org/bug/300): save floating-point registers.
+#elif defined(__loongarch_lp64)
+
+#define MCONTEXT_GREG_SIZE 8
+#define MCONTEXT_PC_OFFSET 176
+#define MCONTEXT_GREGS_OFFSET 184
+
+#define STORE_GPR(X) st.d $r##X, $a0, MCONTEXT_GREGS_OFFSET + X * MCONTEXT_GREG_SIZE
+#define STORE_PC st.d $ra, $a0, MCONTEXT_PC_OFFSET
+
+ STORE_PC
+ STORE_GPR(0)
+ STORE_GPR(1)
+ STORE_GPR(2)
+ STORE_GPR(3)
+ STORE_GPR(4)
+ STORE_GPR(5)
+ STORE_GPR(6)
+ STORE_GPR(7)
+ STORE_GPR(8)
+ STORE_GPR(9)
+ STORE_GPR(10)
+ STORE_GPR(11)
+ STORE_GPR(12)
+ STORE_GPR(13)
+ STORE_GPR(14)
+ STORE_GPR(15)
+ STORE_GPR(16)
+ STORE_GPR(17)
+ STORE_GPR(18)
+ STORE_GPR(19)
+ STORE_GPR(20)
+ STORE_GPR(21)
+ STORE_GPR(22)
+ STORE_GPR(23)
+ STORE_GPR(24)
+ STORE_GPR(25)
+ STORE_GPR(26)
+ STORE_GPR(27)
+ STORE_GPR(28)
+ STORE_GPR(29)
+ STORE_GPR(30)
+ STORE_GPR(31)
+
+ jirl $zero, $ra, 0
+
ret
#elif defined(__mips__)
.set noat
diff '--color=auto' -p -X ../chromium-loongarch64/qt6-webengine/exclude -N -u -r a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc 2000-01-01 00:00:00.000000000 +0800
+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc 2000-01-01 00:00:00.000000000 +0800
@@ -239,6 +239,8 @@ std::string UserAgent() {
#endif
#elif defined (ARCH_CPU_RISCV64)
static constexpr char arch[] = "riscv64";
+#elif defined(ARCH_CPU_LOONGARCH64)
+ static constexpr char arch[] = "loong64";
#else
#error Port
#endif