1 //===-- ThreadElfCore.h -----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ThreadElfCore_h_
11 #define liblldb_ThreadElfCore_h_
13 #include "Plugins/Process/elf-core/RegisterUtilities.h"
14 #include "lldb/Target/Thread.h"
15 #include "lldb/Utility/DataExtractor.h"
16 #include "llvm/ADT/DenseMap.h"
19 struct compat_timeval {
20 alignas(8) uint64_t tv_sec;
21 alignas(8) uint64_t tv_usec;
24 // PRSTATUS structure's size differs based on architecture.
25 // This is the layout in the x86-64 arch.
26 // In the i386 case we parse it manually and fill it again
27 // in the same structure
28 // The gp registers are also a part of this struct, but they are handled
35 struct ELFLinuxPrStatus {
42 alignas(8) uint64_t pr_sigpend;
43 alignas(8) uint64_t pr_sighold;
50 compat_timeval pr_utime;
51 compat_timeval pr_stime;
52 compat_timeval pr_cutime;
53 compat_timeval pr_cstime;
57 lldb_private::Status Parse(const lldb_private::DataExtractor &data,
58 const lldb_private::ArchSpec &arch);
60 // Return the bytesize of the structure
61 // 64 bit - just sizeof
62 // 32 bit - hardcoded because we are reusing the struct, but some of the
63 // members are smaller -
64 // so the layout is not the same
65 static size_t GetSize(const lldb_private::ArchSpec &arch);
68 static_assert(sizeof(ELFLinuxPrStatus) == 112,
69 "sizeof ELFLinuxPrStatus is not correct!");
71 struct ELFLinuxSigInfo {
78 lldb_private::Status Parse(const lldb_private::DataExtractor &data,
79 const lldb_private::ArchSpec &arch);
81 // Return the bytesize of the structure
82 // 64 bit - just sizeof
83 // 32 bit - hardcoded because we are reusing the struct, but some of the
84 // members are smaller -
85 // so the layout is not the same
86 static size_t GetSize(const lldb_private::ArchSpec &arch);
89 static_assert(sizeof(ELFLinuxSigInfo) == 12,
90 "sizeof ELFLinuxSigInfo is not correct!");
92 // PRPSINFO structure's size differs based on architecture.
93 // This is the layout in the x86-64 arch case.
94 // In the i386 case we parse it manually and fill it again
95 // in the same structure
96 struct ELFLinuxPrPsInfo {
101 alignas(8) uint64_t pr_flag;
113 lldb_private::Status Parse(const lldb_private::DataExtractor &data,
114 const lldb_private::ArchSpec &arch);
116 // Return the bytesize of the structure
117 // 64 bit - just sizeof
118 // 32 bit - hardcoded because we are reusing the struct, but some of the
119 // members are smaller -
120 // so the layout is not the same
121 static size_t GetSize(const lldb_private::ArchSpec &arch);
124 static_assert(sizeof(ELFLinuxPrPsInfo) == 136,
125 "sizeof ELFLinuxPrPsInfo is not correct!");
128 lldb_private::DataExtractor gpregset;
129 std::vector<lldb_private::CoreNote> notes;
132 int prstatus_sig = 0;
136 class ThreadElfCore : public lldb_private::Thread {
138 ThreadElfCore(lldb_private::Process &process, const ThreadData &td);
140 ~ThreadElfCore() override;
142 void RefreshStateAfterStop() override;
144 lldb::RegisterContextSP GetRegisterContext() override;
146 lldb::RegisterContextSP
147 CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
149 void ClearStackFrames() override;
151 static bool ThreadIDIsValid(lldb::tid_t thread) { return thread != 0; }
153 const char *GetName() override {
154 if (m_thread_name.empty())
156 return m_thread_name.c_str();
159 void SetName(const char *name) override {
161 m_thread_name.assign(name);
163 m_thread_name.clear();
167 //------------------------------------------------------------------
169 //------------------------------------------------------------------
170 std::string m_thread_name;
171 lldb::RegisterContextSP m_thread_reg_ctx_sp;
175 lldb_private::DataExtractor m_gpregset_data;
176 std::vector<lldb_private::CoreNote> m_notes;
178 bool CalculateStopInfo() override;
181 #endif // liblldb_ThreadElfCore_h_