Home | History | Annotate | Download | only in android
      1 // Copyright (c) 2012, Google Inc.
      2 // All rights reserved.
      3 //
      4 // Redistribution and use in source and binary forms, with or without
      5 // modification, are permitted provided that the following conditions are
      6 // met:
      7 //
      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
     11 // copyright notice, this list of conditions and the following disclaimer
     12 // in the documentation and/or other materials provided with the
     13 // distribution.
     14 //     * Neither the name of Google Inc. nor the names of its
     15 // contributors may be used to endorse or promote products derived from
     16 // this software without specific prior written permission.
     17 //
     18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 
     30 // This header can be included either from a C, C++ or Assembly file.
     31 // Its purpose is to contain constants that must match the offsets of
     32 // various fields in ucontext_t.
     33 //
     34 // They should match the definitions from
     35 // src/common/android/include/sys/ucontext.h
     36 //
     37 // Used by src/common/android/breakpad_getcontext.S
     38 // Tested by src/common/android/testing/breakpad_getcontext_unittest.cc
     39 
     40 #ifndef GOOGLEBREAKPAD_COMMON_ANDROID_UCONTEXT_CONSTANTS_H
     41 #define GOOGLEBREAKPAD_COMMON_ANDROID_UCONTEXT_CONSTANTS_H
     42 
     43 #if defined(__arm__)
     44 
     45 #define  MCONTEXT_GREGS_OFFSET     32
     46 #define  UCONTEXT_SIGMASK_OFFSET   104
     47 
     48 #elif defined(__aarch64__)
     49 
     50 #define  UCONTEXT_SIGMASK_OFFSET     40
     51 
     52 #define  MCONTEXT_GREGS_OFFSET       184
     53 #define  MCONTEXT_SP_OFFSET          432
     54 #define  MCONTEXT_PC_OFFSET          440
     55 #define  MCONTEXT_PSTATE_OFFSET      448
     56 #define  MCONTEXT_EXTENSION_OFFSET   464
     57 
     58 #define  FPSIMD_MAGIC                0x46508001
     59 
     60 #define  FPSIMD_CONTEXT_MAGIC_OFFSET 0
     61 #define  FPSIMD_CONTEXT_SIZE_OFFSET  4
     62 #define  FPSIMD_CONTEXT_FPSR_OFFSET  8
     63 #define  FPSIMD_CONTEXT_FPCR_OFFSET  12
     64 #define  FPSIMD_CONTEXT_VREGS_OFFSET 16
     65 #define  FPSIMD_CONTEXT_SIZE         528
     66 
     67 #define  REGISTER_SIZE               8
     68 #define  SIMD_REGISTER_SIZE          16
     69 
     70 #elif defined(__i386__)
     71 
     72 #define  MCONTEXT_GREGS_OFFSET     20
     73 #define  MCONTEXT_GS_OFFSET        (MCONTEXT_GREGS_OFFSET + 0*4)
     74 #define  MCONTEXT_FS_OFFSET        (MCONTEXT_GREGS_OFFSET + 1*4)
     75 #define  MCONTEXT_ES_OFFSET        (MCONTEXT_GREGS_OFFSET + 2*4)
     76 #define  MCONTEXT_DS_OFFSET        (MCONTEXT_GREGS_OFFSET + 3*4)
     77 #define  MCONTEXT_EDI_OFFSET       (MCONTEXT_GREGS_OFFSET + 4*4)
     78 #define  MCONTEXT_ESI_OFFSET       (MCONTEXT_GREGS_OFFSET + 5*4)
     79 #define  MCONTEXT_EBP_OFFSET       (MCONTEXT_GREGS_OFFSET + 6*4)
     80 #define  MCONTEXT_ESP_OFFSET       (MCONTEXT_GREGS_OFFSET + 7*4)
     81 #define  MCONTEXT_EBX_OFFSET       (MCONTEXT_GREGS_OFFSET + 8*4)
     82 #define  MCONTEXT_EDX_OFFSET       (MCONTEXT_GREGS_OFFSET + 9*4)
     83 #define  MCONTEXT_ECX_OFFSET       (MCONTEXT_GREGS_OFFSET + 10*4)
     84 #define  MCONTEXT_EAX_OFFSET       (MCONTEXT_GREGS_OFFSET + 11*4)
     85 #define  MCONTEXT_TRAPNO_OFFSET    (MCONTEXT_GREGS_OFFSET + 12*4)
     86 #define  MCONTEXT_ERR_OFFSET       (MCONTEXT_GREGS_OFFSET + 13*4)
     87 #define  MCONTEXT_EIP_OFFSET       (MCONTEXT_GREGS_OFFSET + 14*4)
     88 #define  MCONTEXT_CS_OFFSET        (MCONTEXT_GREGS_OFFSET + 15*4)
     89 #define  MCONTEXT_EFL_OFFSET       (MCONTEXT_GREGS_OFFSET + 16*4)
     90 #define  MCONTEXT_UESP_OFFSET      (MCONTEXT_GREGS_OFFSET + 17*4)
     91 #define  MCONTEXT_SS_OFFSET        (MCONTEXT_GREGS_OFFSET + 18*4)
     92 
     93 #define  UCONTEXT_SIGMASK_OFFSET   108
     94 
     95 #define  UCONTEXT_FPREGS_OFFSET       96
     96 #define  UCONTEXT_FPREGS_MEM_OFFSET   116
     97 
     98 #elif defined(__mips__)
     99 
    100 #if _MIPS_SIM == _ABIO32
    101 #define  MCONTEXT_PC_OFFSET        32
    102 #define  MCONTEXT_GREGS_OFFSET     40
    103 #define  MCONTEXT_FPREGS_OFFSET    296
    104 #define  MCONTEXT_FPC_CSR          556
    105 #define  UCONTEXT_SIGMASK_OFFSET   616
    106 #else
    107 #define  MCONTEXT_GREGS_OFFSET     40
    108 #define  MCONTEXT_FPREGS_OFFSET    296
    109 #define  MCONTEXT_PC_OFFSET        616
    110 #define  MCONTEXT_FPC_CSR          624
    111 #define  UCONTEXT_SIGMASK_OFFSET   640
    112 #endif
    113 
    114 #elif defined(__x86_64__)
    115 
    116 #define MCONTEXT_GREGS_OFFSET     40
    117 #define UCONTEXT_SIGMASK_OFFSET   296
    118 
    119 #define MCONTEXT_GREGS_R8    40
    120 #define MCONTEXT_GREGS_R9    48
    121 #define MCONTEXT_GREGS_R10   56
    122 #define MCONTEXT_GREGS_R11   64
    123 #define MCONTEXT_GREGS_R12   72
    124 #define MCONTEXT_GREGS_R13   80
    125 #define MCONTEXT_GREGS_R14   88
    126 #define MCONTEXT_GREGS_R15   96
    127 #define MCONTEXT_GREGS_RDI   104
    128 #define MCONTEXT_GREGS_RSI   112
    129 #define MCONTEXT_GREGS_RBP   120
    130 #define MCONTEXT_GREGS_RBX   128
    131 #define MCONTEXT_GREGS_RDX   136
    132 #define MCONTEXT_GREGS_RAX   144
    133 #define MCONTEXT_GREGS_RCX   152
    134 #define MCONTEXT_GREGS_RSP   160
    135 #define MCONTEXT_GREGS_RIP   168
    136 #define MCONTEXT_FPREGS_PTR  224
    137 #define MCONTEXT_FPREGS_MEM  304
    138 #define FPREGS_OFFSET_MXCSR  24
    139 
    140 #else
    141 #error "This header has not been ported for your CPU"
    142 #endif
    143 
    144 #endif  // GOOGLEBREAKPAD_COMMON_ANDROID_UCONTEXT_CONSTANTS_H
    145