teak-llvm/lldb/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style.  This kind of mass change has
*** two obvious implications:

Firstly, merging this particular commit into a downstream fork may be a huge
effort.  Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit.  The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):

    find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
    find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;

The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.

Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit.  There are alternatives available that will attempt
to look through this change and find the appropriate prior commit.  YMMV.

llvm-svn: 280751
2016-09-06 20:57:50 +00:00

88 lines
2.5 KiB
C++

//===-- ThreadWinMiniDump.cpp -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "ThreadWinMiniDump.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/windows/windows.h"
#include <DbgHelp.h>
#include "ProcessWinMiniDump.h"
#if defined(_WIN64)
#include "x64/RegisterContextWindowsMiniDump_x64.h"
#else
#include "x86/RegisterContextWindowsMiniDump_x86.h"
#endif
using namespace lldb;
using namespace lldb_private;
// This is a minimal implementation in order to get something running. It will
// be fleshed out as more mini-dump functionality is added.
class ThreadWinMiniDump::Data {
public:
Data() : m_context(nullptr) {}
const CONTEXT *m_context;
};
ThreadWinMiniDump::ThreadWinMiniDump(lldb_private::Process &process,
lldb::tid_t tid)
: Thread(process, tid), m_data(new Data) {}
ThreadWinMiniDump::~ThreadWinMiniDump() {}
void ThreadWinMiniDump::RefreshStateAfterStop() {}
lldb::RegisterContextSP ThreadWinMiniDump::GetRegisterContext() {
if (m_reg_context_sp.get() == NULL) {
m_reg_context_sp = CreateRegisterContextForFrame(NULL);
}
return m_reg_context_sp;
}
lldb::RegisterContextSP ThreadWinMiniDump::CreateRegisterContextForFrame(
lldb_private::StackFrame *frame) {
const uint32_t concrete_frame_idx =
(frame) ? frame->GetConcreteFrameIndex() : 0;
RegisterContextSP reg_ctx_sp;
ArchSpec arch = HostInfo::GetArchitecture();
switch (arch.GetMachine()) {
case llvm::Triple::x86:
#if defined(_WIN64)
// FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
#else
reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x86(
*this, concrete_frame_idx, m_data->m_context));
#endif
break;
case llvm::Triple::x86_64:
#if defined(_WIN64)
reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x64(
*this, concrete_frame_idx, m_data->m_context));
#else
// LLDB is 32-bit, but the target process is 64-bit. We probably can't debug
// this.
#endif
default:
break;
}
return reg_ctx_sp;
}
void ThreadWinMiniDump::ClearStackFrames() {}
void ThreadWinMiniDump::SetContext(const void *context) {
if (m_data) {
m_data->m_context = static_cast<const CONTEXT *>(context);
}
}
bool ThreadWinMiniDump::CalculateStopInfo() { return false; }