1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | class CrashInfo; |
6 | |
7 | #if defined(__arm__) |
8 | #define user_regs_struct user_regs |
9 | #define user_fpregs_struct user_fpregs |
10 | |
11 | #if defined(__VFP_FP__) && !defined(__SOFTFP__) |
12 | struct user_vfpregs_struct |
13 | { |
14 | unsigned long long fpregs[32]; |
15 | unsigned long fpscr; |
16 | } __attribute__((__packed__)); |
17 | #endif |
18 | |
19 | #endif |
20 | |
21 | class ThreadInfo |
22 | { |
23 | private: |
24 | pid_t m_tid; // thread id |
25 | pid_t m_ppid; // parent process |
26 | pid_t m_tgid; // thread group |
27 | struct user_regs_struct m_gpRegisters; // general purpose registers |
28 | struct user_fpregs_struct m_fpRegisters; // floating point registers |
29 | #if defined(__i386__) |
30 | struct user_fpxregs_struct m_fpxRegisters; // x86 floating point registers |
31 | #elif defined(__arm__) && defined(__VFP_FP__) && !defined(__SOFTFP__) |
32 | struct user_vfpregs_struct m_vfpRegisters; // ARM VFP/NEON registers |
33 | #endif |
34 | |
35 | public: |
36 | ThreadInfo(pid_t tid); |
37 | ~ThreadInfo(); |
38 | bool Initialize(ICLRDataTarget* pDataTarget); |
39 | void ResumeThread(); |
40 | bool UnwindThread(CrashInfo& crashInfo, IXCLRDataProcess* pClrDataProcess); |
41 | void GetThreadStack(CrashInfo& crashInfo); |
42 | void GetThreadContext(uint32_t flags, CONTEXT* context) const; |
43 | |
44 | inline pid_t Tid() const { return m_tid; } |
45 | inline pid_t Ppid() const { return m_ppid; } |
46 | inline pid_t Tgid() const { return m_tgid; } |
47 | |
48 | inline const user_regs_struct* GPRegisters() const { return &m_gpRegisters; } |
49 | inline const user_fpregs_struct* FPRegisters() const { return &m_fpRegisters; } |
50 | #if defined(__i386__) |
51 | inline const user_fpxregs_struct* FPXRegisters() const { return &m_fpxRegisters; } |
52 | #elif defined(__arm__) && defined(__VFP_FP__) && !defined(__SOFTFP__) |
53 | inline const user_vfpregs_struct* VFPRegisters() const { return &m_vfpRegisters; } |
54 | #endif |
55 | |
56 | private: |
57 | void UnwindNativeFrames(CrashInfo& crashInfo, CONTEXT* pContext); |
58 | bool GetRegistersWithPTrace(); |
59 | bool GetRegistersWithDataTarget(ICLRDataTarget* dataTarget); |
60 | }; |
61 | |