blob: 95ba682e18bba691d1cd46769cb89f5f1ff545b5 [file] [log] [blame]
Christopher Ferris2a25c4a2017-07-07 16:35:48 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _LIBUNWINDSTACK_UCONTEXT_H
30#define _LIBUNWINDSTACK_UCONTEXT_H
31
32#include <stdint.h>
33
34//-------------------------------------------------------------------
35// ARM ucontext structures
36//-------------------------------------------------------------------
37struct arm_stack_t {
38 uint32_t ss_sp; // void __user*
39 int32_t ss_flags; // int
40 uint32_t ss_size; // size_t
41};
42
43struct arm_mcontext_t {
44 uint32_t trap_no; // unsigned long
45 uint32_t error_code; // unsigned long
46 uint32_t oldmask; // unsigned long
47 uint32_t regs[ARM_REG_LAST]; // unsigned long
48 uint32_t cpsr; // unsigned long
49 uint32_t fault_address; // unsigned long
50};
51
52struct arm_ucontext_t {
53 uint32_t uc_flags; // unsigned long
54 uint32_t uc_link; // struct ucontext*
55 arm_stack_t uc_stack;
56 arm_mcontext_t uc_mcontext;
57 // Nothing else is used, so don't define it.
58};
59//-------------------------------------------------------------------
60
61//-------------------------------------------------------------------
62// ARM64 ucontext structures
63//-------------------------------------------------------------------
64struct arm64_stack_t {
65 uint64_t ss_sp; // void __user*
66 int32_t ss_flags; // int
67 uint64_t ss_size; // size_t
68};
69
70struct arm64_sigset_t {
71 uint64_t sig; // unsigned long
72};
73
74struct arm64_mcontext_t {
75 uint64_t fault_address; // __u64
76 uint64_t regs[ARM64_REG_LAST]; // __u64
77 uint64_t pstate; // __u64
78 // Nothing else is used, so don't define it.
79};
80
81struct arm64_ucontext_t {
82 uint64_t uc_flags; // unsigned long
83 uint64_t uc_link; // struct ucontext*
84 arm64_stack_t uc_stack;
85 arm64_sigset_t uc_sigmask;
86 // The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM64.
87 char __padding[128 - sizeof(arm64_sigset_t)];
88 // The full structure requires 16 byte alignment, but our partial structure
89 // doesn't, so force the alignment.
90 arm64_mcontext_t uc_mcontext __attribute__((aligned(16)));
91};
92//-------------------------------------------------------------------
93
94//-------------------------------------------------------------------
95// X86 ucontext structures
96//-------------------------------------------------------------------
97struct x86_stack_t {
98 uint32_t ss_sp; // void __user*
99 int32_t ss_flags; // int
100 uint32_t ss_size; // size_t
101};
102
103struct x86_mcontext_t {
104 uint32_t gs;
105 uint32_t fs;
106 uint32_t es;
107 uint32_t ds;
108 uint32_t edi;
109 uint32_t esi;
110 uint32_t ebp;
111 uint32_t esp;
112 uint32_t ebx;
113 uint32_t edx;
114 uint32_t ecx;
115 uint32_t eax;
116 uint32_t trapno;
117 uint32_t err;
118 uint32_t eip;
119 uint32_t cs;
120 uint32_t efl;
121 uint32_t uesp;
122 uint32_t ss;
123 // Only care about the registers, skip everything else.
124};
125
126struct x86_ucontext_t {
127 uint32_t uc_flags; // unsigned long
128 uint32_t uc_link; // struct ucontext*
129 x86_stack_t uc_stack;
130 x86_mcontext_t uc_mcontext;
131 // Nothing else is used, so don't define it.
132};
133//-------------------------------------------------------------------
134
135//-------------------------------------------------------------------
136// X86_64 ucontext structures
137//-------------------------------------------------------------------
138struct x86_64_stack_t {
139 uint64_t ss_sp; // void __user*
140 int32_t ss_flags; // int
141 uint64_t ss_size; // size_t
142};
143
144struct x86_64_mcontext_t {
145 uint64_t r8;
146 uint64_t r9;
147 uint64_t r10;
148 uint64_t r11;
149 uint64_t r12;
150 uint64_t r13;
151 uint64_t r14;
152 uint64_t r15;
153 uint64_t rdi;
154 uint64_t rsi;
155 uint64_t rbp;
156 uint64_t rbx;
157 uint64_t rdx;
158 uint64_t rax;
159 uint64_t rcx;
160 uint64_t rsp;
161 uint64_t rip;
162 uint64_t efl;
163 uint64_t csgsfs;
164 uint64_t err;
165 uint64_t trapno;
166 uint64_t oldmask;
167 uint64_t cr2;
168 // Only care about the registers, skip everything else.
169};
170
171typedef struct x86_64_ucontext {
172 uint64_t uc_flags; // unsigned long
173 uint64_t uc_link; // struct ucontext*
174 x86_64_stack_t uc_stack;
175 x86_64_mcontext_t uc_mcontext;
176 // Nothing else is used, so don't define it.
177} x86_64_ucontext_t;
178//-------------------------------------------------------------------
179
180#endif // _LIBUNWINDSTACK_UCONTEXT_H