ucontext_constants.h revision 4cad4cec53f206061f195aa9dcde7f504d69cd3f
1979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// Copyright (c) 2012, Google Inc.
2979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// All rights reserved.
3979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//
4979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// Redistribution and use in source and binary forms, with or without
5979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// modification, are permitted provided that the following conditions are
6979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// met:
7979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//
8979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//     * Redistributions of source code must retain the above copyright
9979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// notice, this list of conditions and the following disclaimer.
10979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//     * Redistributions in binary form must reproduce the above
11979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// copyright notice, this list of conditions and the following disclaimer
12979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// in the documentation and/or other materials provided with the
13979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// distribution.
14979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//     * Neither the name of Google Inc. nor the names of its
15979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// contributors may be used to endorse or promote products derived from
16979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// this software without specific prior written permission.
17979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//
18979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
30979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// This header can be included either from a C, C++ or Assembly file.
31979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// Its purpose is to contain constants that must match the offsets of
32979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// various fields in ucontext_t.
33979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//
34979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// They should match the definitions from
35979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// src/common/android/include/sys/ucontext.h
36979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org//
37979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// Used by src/common/android/breakpad_getcontext.S
38979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org// Tested by src/common/android/testing/breakpad_getcontext_unittest.cc
39979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
40979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#ifndef GOOGLEBREAKPAD_COMMON_ANDROID_UCONTEXT_CONSTANTS_H
41979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define GOOGLEBREAKPAD_COMMON_ANDROID_UCONTEXT_CONSTANTS_H
42979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
43979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#if defined(__arm__)
44979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
45979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_GREGS_OFFSET     32
46979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  UCONTEXT_SIGMASK_OFFSET   104
47979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
482eedc625759a8943d72711769a84fce05a23ecd0rmcilroy@chromium.org#elif defined(__aarch64__)
492eedc625759a8943d72711769a84fce05a23ecd0rmcilroy@chromium.org
50b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  UCONTEXT_SIGMASK_OFFSET     40
51b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org
524cad4cec53f206061f195aa9dcde7f504d69cd3frmcilroy@chromium.org#define  MCONTEXT_GREGS_OFFSET       184
534cad4cec53f206061f195aa9dcde7f504d69cd3frmcilroy@chromium.org#define  MCONTEXT_SP_OFFSET          432
544cad4cec53f206061f195aa9dcde7f504d69cd3frmcilroy@chromium.org#define  MCONTEXT_PC_OFFSET          440
554cad4cec53f206061f195aa9dcde7f504d69cd3frmcilroy@chromium.org#define  MCONTEXT_PSTATE_OFFSET      448
564cad4cec53f206061f195aa9dcde7f504d69cd3frmcilroy@chromium.org#define  MCONTEXT_EXTENSION_OFFSET   464
57b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org
58b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  FPSIMD_MAGIC                0x46508001
59b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org
60b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  FPSIMD_CONTEXT_MAGIC_OFFSET 0
61b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  FPSIMD_CONTEXT_SIZE_OFFSET  4
62b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  FPSIMD_CONTEXT_FPSR_OFFSET  8
63b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  FPSIMD_CONTEXT_FPCR_OFFSET  12
64b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  FPSIMD_CONTEXT_VREGS_OFFSET 16
65b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  FPSIMD_CONTEXT_SIZE         528
66b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org
67b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  REGISTER_SIZE               8
68b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org#define  SIMD_REGISTER_SIZE          16
69b8c5896ddca70d6926083bba0aebf860e5a3b291rmcilroy@chromium.org
70979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#elif defined(__i386__)
71979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
72979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_GREGS_OFFSET     20
73979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_GS_OFFSET        (MCONTEXT_GREGS_OFFSET + 0*4)
74979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_FS_OFFSET        (MCONTEXT_GREGS_OFFSET + 1*4)
75979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_ES_OFFSET        (MCONTEXT_GREGS_OFFSET + 2*4)
76979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_DS_OFFSET        (MCONTEXT_GREGS_OFFSET + 3*4)
77979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_EDI_OFFSET       (MCONTEXT_GREGS_OFFSET + 4*4)
78979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_ESI_OFFSET       (MCONTEXT_GREGS_OFFSET + 5*4)
79979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_EBP_OFFSET       (MCONTEXT_GREGS_OFFSET + 6*4)
80979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_ESP_OFFSET       (MCONTEXT_GREGS_OFFSET + 7*4)
81979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_EBX_OFFSET       (MCONTEXT_GREGS_OFFSET + 8*4)
82979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_EDX_OFFSET       (MCONTEXT_GREGS_OFFSET + 9*4)
83979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_ECX_OFFSET       (MCONTEXT_GREGS_OFFSET + 10*4)
84979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_EAX_OFFSET       (MCONTEXT_GREGS_OFFSET + 11*4)
85979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_TRAPNO_OFFSET    (MCONTEXT_GREGS_OFFSET + 12*4)
86979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_ERR_OFFSET       (MCONTEXT_GREGS_OFFSET + 13*4)
87979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_EIP_OFFSET       (MCONTEXT_GREGS_OFFSET + 14*4)
88979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_CS_OFFSET        (MCONTEXT_GREGS_OFFSET + 15*4)
89979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_EFL_OFFSET       (MCONTEXT_GREGS_OFFSET + 16*4)
90979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_UESP_OFFSET      (MCONTEXT_GREGS_OFFSET + 17*4)
91979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  MCONTEXT_SS_OFFSET        (MCONTEXT_GREGS_OFFSET + 18*4)
92979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
93979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  UCONTEXT_SIGMASK_OFFSET   108
94979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
95979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  UCONTEXT_FPREGS_OFFSET       96
96979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#define  UCONTEXT_FPREGS_MEM_OFFSET   116
97979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
98979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#elif defined(__mips__)
99979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
100faa2e5b56ea0148257e9610fe58e7305b407ba52gordana.cmiljanovic@imgtec.com#define  MCONTEXT_PC_OFFSET        32
101faa2e5b56ea0148257e9610fe58e7305b407ba52gordana.cmiljanovic@imgtec.com#define  MCONTEXT_GREGS_OFFSET     40
102faa2e5b56ea0148257e9610fe58e7305b407ba52gordana.cmiljanovic@imgtec.com#define  MCONTEXT_FPREGS_OFFSET    296
103faa2e5b56ea0148257e9610fe58e7305b407ba52gordana.cmiljanovic@imgtec.com#define  MCONTEXT_FPC_CSR          556
104faa2e5b56ea0148257e9610fe58e7305b407ba52gordana.cmiljanovic@imgtec.com#define  UCONTEXT_SIGMASK_OFFSET   616
105979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
106979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#else
107979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#error "This header has not been ported for your CPU"
108979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#endif
109979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org
110979d8f4dcba8a94b25772e2966125202fb664959digit@chromium.org#endif  // GOOGLEBREAKPAD_COMMON_ANDROID_UCONTEXT_CONSTANTS_H
111