]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / source / Plugins / Process / Windows / MiniDump / ThreadWinMiniDump.cpp
1 //===-- ThreadWinMiniDump.cpp -----------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "ThreadWinMiniDump.h"
11
12 #include "lldb/Host/HostInfo.h"
13 #include "lldb/Host/windows/windows.h"
14 #include <DbgHelp.h>
15
16 #include "ProcessWinMiniDump.h"
17 #if defined(_WIN64)
18 #include "x64/RegisterContextWindowsMiniDump_x64.h"
19 #else
20 #include "x86/RegisterContextWindowsMiniDump_x86.h"
21 #endif
22
23 using namespace lldb;
24 using namespace lldb_private;
25
26 // This is a minimal implementation in order to get something running.  It will
27 // be fleshed out as more mini-dump functionality is added.
28
29 class ThreadWinMiniDump::Data {
30   public:
31     Data() : m_context(nullptr) {}
32     const CONTEXT *m_context;
33 };
34
35 ThreadWinMiniDump::ThreadWinMiniDump(lldb_private::Process &process, lldb::tid_t tid) :
36     Thread(process, tid),
37     m_data(new Data)
38 {
39 }
40
41 ThreadWinMiniDump::~ThreadWinMiniDump()
42 {
43 }
44
45 void
46 ThreadWinMiniDump::RefreshStateAfterStop()
47 {
48 }
49
50 lldb::RegisterContextSP
51 ThreadWinMiniDump::GetRegisterContext()
52 {
53     if (m_reg_context_sp.get() == NULL) {
54         m_reg_context_sp = CreateRegisterContextForFrame (NULL);
55     }
56     return m_reg_context_sp;
57 }
58
59 lldb::RegisterContextSP
60 ThreadWinMiniDump::CreateRegisterContextForFrame(lldb_private::StackFrame *frame)
61 {
62     const uint32_t concrete_frame_idx = (frame) ? frame->GetConcreteFrameIndex() : 0;
63     RegisterContextSP reg_ctx_sp;
64     ArchSpec arch = HostInfo::GetArchitecture();
65     switch (arch.GetMachine())
66     {
67         case llvm::Triple::x86:
68 #if defined(_WIN64)
69             // FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
70 #else
71             reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x86(*this, concrete_frame_idx, m_data->m_context));
72 #endif
73             break;
74         case llvm::Triple::x86_64:
75 #if defined(_WIN64)
76             reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x64(*this, concrete_frame_idx, m_data->m_context));
77 #else
78             // LLDB is 32-bit, but the target process is 64-bit.  We probably can't debug this.
79 #endif
80         default:
81             break;
82     }
83     return reg_ctx_sp;
84 }
85
86 void
87 ThreadWinMiniDump::ClearStackFrames()
88 {
89 }
90
91 void
92 ThreadWinMiniDump::SetContext(const void *context)
93 {
94     if (m_data)
95     {
96         m_data->m_context = static_cast<const CONTEXT *>(context);
97     }
98 }
99
100 bool
101 ThreadWinMiniDump::CalculateStopInfo()
102 {
103     return false;
104 }