LLDB mainline
ThreadMinidump.cpp
Go to the documentation of this file.
1//===-- ThreadMinidump.cpp ------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "ThreadMinidump.h"
10
11#include "ProcessMinidump.h"
12
17
22
25#include "lldb/Target/Target.h"
26#include "lldb/Target/Unwind.h"
28#include "lldb/Utility/Log.h"
29
30#include <memory>
31
32using namespace lldb;
33using namespace lldb_private;
34using namespace minidump;
35
36ThreadMinidump::ThreadMinidump(Process &process, const minidump::Thread &td,
37 llvm::ArrayRef<uint8_t> gpregset_data)
38 : Thread(process, td.ThreadId), m_thread_reg_ctx_sp(),
39 m_gpregset_data(gpregset_data) {}
40
42
44
46 if (!m_reg_context_sp) {
48 }
49 return m_reg_context_sp;
50}
51
54 RegisterContextSP reg_ctx_sp;
55 uint32_t concrete_frame_idx = 0;
56
57 if (frame)
58 concrete_frame_idx = frame->GetConcreteFrameIndex();
59
60 if (concrete_frame_idx == 0) {
63
64 ProcessMinidump *process =
65 static_cast<ProcessMinidump *>(GetProcess().get());
66 ArchSpec arch = process->GetArchitecture();
67 RegisterInfoInterface *reg_interface = nullptr;
68
69 // TODO write other register contexts and add them here
70 switch (arch.GetMachine()) {
71 case llvm::Triple::x86: {
72 reg_interface = new RegisterContextLinux_i386(arch);
75 DataExtractor gpregset(buf, lldb::eByteOrderLittle, 4);
76 m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_x86_64>(
77 *this, reg_interface, gpregset,
78 llvm::ArrayRef<lldb_private::CoreNote>());
79 break;
80 }
81 case llvm::Triple::x86_64: {
82 reg_interface = new RegisterContextLinux_x86_64(arch);
85 DataExtractor gpregset(buf, lldb::eByteOrderLittle, 8);
86 m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_x86_64>(
87 *this, reg_interface, gpregset,
88 llvm::ArrayRef<lldb_private::CoreNote>());
89 break;
90 }
91 case llvm::Triple::aarch64: {
95 std::make_shared<RegisterContextMinidump_ARM64>(*this, data);
96 break;
97 }
98 case llvm::Triple::arm: {
101 const bool apple = arch.GetTriple().getVendor() == llvm::Triple::Apple;
103 std::make_shared<RegisterContextMinidump_ARM>(*this, data, apple);
104 break;
105 }
106 default:
107 break;
108 }
109
110 reg_ctx_sp = m_thread_reg_ctx_sp;
111 } else if (m_unwinder_up) {
112 reg_ctx_sp = m_unwinder_up->CreateRegisterContextForFrame(frame);
113 }
114
115 return reg_ctx_sp;
116}
117
118bool ThreadMinidump::CalculateStopInfo() { return false; }
An architecture specification class.
Definition: ArchSpec.h:31
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:450
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:683
An data extractor class.
Definition: DataExtractor.h:48
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
RegisterInfo interface to patch RegisterInfo structure for archs.
This base class provides an interface to stack frames.
Definition: StackFrame.h:43
uint32_t GetConcreteFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList, not counting inlined frame...
Definition: StackFrame.h:434
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
Definition: Thread.h:1343
lldb::ProcessSP GetProcess() const
Definition: Thread.h:157
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
Definition: Thread.h:1319
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) override
ThreadMinidump(Process &process, const minidump::Thread &td, llvm::ArrayRef< uint8_t > gpregset_data)
lldb::RegisterContextSP GetRegisterContext() override
bool CalculateStopInfo() override
Ask the thread subclass to set its stop info.
llvm::ArrayRef< uint8_t > m_gpregset_data
lldb::RegisterContextSP m_thread_reg_ctx_sp
lldb::DataBufferSP ConvertMinidumpContext_x86_32(llvm::ArrayRef< uint8_t > source_data, RegisterInfoInterface *target_reg_interface)
lldb::DataBufferSP ConvertMinidumpContext_x86_64(llvm::ArrayRef< uint8_t > source_data, RegisterInfoInterface *target_reg_interface)
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
@ eByteOrderLittle
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:334
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
Definition: lldb-forward.h:392