[Tizen] Add a library to retrieve memory regions for a coredump
[platform/upstream/coreclr.git] / src / debug / createdump / threadinfo.h
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 #endif
11
12 #if defined(__aarch64__)
13 #define user_fpregs_struct user_fpsimd_struct
14 #endif
15
16 #if defined(__arm__) && defined(__VFP_FP__) && !defined(__SOFTFP__)
17 struct user_vfpregs_struct
18 {
19   unsigned long long  fpregs[32];
20   unsigned long       fpscr;
21 } __attribute__((__packed__));
22 #endif
23
24 class ThreadInfo 
25 {
26 private:
27     pid_t m_tid;                                // thread id
28     pid_t m_ppid;                               // parent process
29     pid_t m_tgid;                               // thread group
30     struct user_regs_struct m_gpRegisters;      // general purpose registers
31     struct user_fpregs_struct m_fpRegisters;    // floating point registers
32 #if defined(__i386__)
33     struct user_fpxregs_struct m_fpxRegisters;  // x86 floating point registers
34 #elif defined(__arm__) && defined(__VFP_FP__) && !defined(__SOFTFP__)
35     struct user_vfpregs_struct m_vfpRegisters;  // ARM VFP/NEON registers
36 #endif
37
38 public:
39     ThreadInfo(pid_t tid);
40     ~ThreadInfo();
41     bool Initialize(ICLRDataTarget* pDataTarget);
42     void ResumeThread();
43     bool UnwindThread(CrashInfo& crashInfo, IXCLRDataProcess* pClrDataProcess);
44     void GetThreadStack(CrashInfo& crashInfo);
45     void GetThreadContext(uint32_t flags, CONTEXT* context) const;
46     void SetRegisters(elf_prstatus *prstatus);
47
48     inline pid_t Tid() const { return m_tid; }
49     inline pid_t Ppid() const { return m_ppid; }
50     inline pid_t Tgid() const { return m_tgid; }
51
52     inline const user_regs_struct* GPRegisters() const { return &m_gpRegisters; }
53     inline const user_fpregs_struct* FPRegisters() const { return &m_fpRegisters; }
54 #if defined(__i386__)
55     inline const user_fpxregs_struct* FPXRegisters() const { return &m_fpxRegisters; }
56 #elif defined(__arm__) && defined(__VFP_FP__) && !defined(__SOFTFP__)
57     inline const user_vfpregs_struct* VFPRegisters() const { return &m_vfpRegisters; }
58 #endif
59
60 private:
61     void UnwindNativeFrames(CrashInfo& crashInfo, CONTEXT* pContext);
62     bool GetRegistersWithPTrace();
63     bool GetRegistersWithDataTarget(ICLRDataTarget* dataTarget);
64 };