1 //===-- ThreadPostMortemTrace.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 "ThreadPostMortemTrace.h"
10 
11 #include <memory>
12 #include <optional>
13 
14 #include "Plugins/Process/Utility/RegisterContextHistory.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Target/RegisterContext.h"
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 using namespace llvm;
21 
22 void ThreadPostMortemTrace::RefreshStateAfterStop() {}
23 
24 RegisterContextSP ThreadPostMortemTrace::GetRegisterContext() {
25   if (!m_reg_context_sp)
26     m_reg_context_sp = CreateRegisterContextForFrame(nullptr);
27 
28   return m_reg_context_sp;
29 }
30 
31 RegisterContextSP
32 ThreadPostMortemTrace::CreateRegisterContextForFrame(StackFrame *frame) {
33   // Eventually this will calculate the register context based on the current
34   // trace position.
35   return std::make_shared<RegisterContextHistory>(
36       *this, 0, GetProcess()->GetAddressByteSize(), LLDB_INVALID_ADDRESS);
37 }
38 
39 bool ThreadPostMortemTrace::CalculateStopInfo() { return false; }
40 
41 const std::optional<FileSpec> &ThreadPostMortemTrace::GetTraceFile() const {
42   return m_trace_file;
43 }
44