toolkit/crashreporter/google-breakpad/src/common/android/breakpad_getcontext.S

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // Copyright (c) 2012, Google Inc.
michael@0 2 // All rights reserved.
michael@0 3 //
michael@0 4 // Redistribution and use in source and binary forms, with or without
michael@0 5 // modification, are permitted provided that the following conditions are
michael@0 6 // met:
michael@0 7 //
michael@0 8 // * Redistributions of source code must retain the above copyright
michael@0 9 // notice, this list of conditions and the following disclaimer.
michael@0 10 // * Redistributions in binary form must reproduce the above
michael@0 11 // copyright notice, this list of conditions and the following disclaimer
michael@0 12 // in the documentation and/or other materials provided with the
michael@0 13 // distribution.
michael@0 14 // * Neither the name of Google Inc. nor the names of its
michael@0 15 // contributors may be used to endorse or promote products derived from
michael@0 16 // this software without specific prior written permission.
michael@0 17 //
michael@0 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 29
michael@0 30 // A minimalistic implementation of getcontext() to be used by
michael@0 31 // Google Breakpad on Android.
michael@0 32
michael@0 33 #include "common/android/ucontext_constants.h"
michael@0 34
michael@0 35 /* int getcontext (ucontext_t *ucp) */
michael@0 36
michael@0 37 #ifdef __arm__
michael@0 38
michael@0 39 .text
michael@0 40 .global breakpad_getcontext
michael@0 41 .hidden breakpad_getcontext
michael@0 42 .type breakpad_getcontext, #function
michael@0 43 .align 0
michael@0 44 .fnstart
michael@0 45 breakpad_getcontext:
michael@0 46
michael@0 47 /* First, save r4-r11 */
michael@0 48 add r1, r0, #(MCONTEXT_GREGS_OFFSET + 4*4)
michael@0 49 stm r1, {r4-r11}
michael@0 50
michael@0 51 /* r12 is a scratch register, don't save it */
michael@0 52
michael@0 53 /* Save sp and lr explicitely. */
michael@0 54 /* - sp can't be stored with stmia in Thumb-2 */
michael@0 55 /* - STM instructions that store sp and pc are deprecated in ARM */
michael@0 56 str sp, [r0, #(MCONTEXT_GREGS_OFFSET + 13*4)]
michael@0 57 str lr, [r0, #(MCONTEXT_GREGS_OFFSET + 14*4)]
michael@0 58
michael@0 59 /* Save the caller's address in 'pc' */
michael@0 60 str lr, [r0, #(MCONTEXT_GREGS_OFFSET + 15*4)]
michael@0 61
michael@0 62 /* Save ucontext_t* pointer accross next call */
michael@0 63 mov r4, r0
michael@0 64
michael@0 65 /* Call sigprocmask(SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
michael@0 66 mov r0, #0 /* SIG_BLOCK */
michael@0 67 mov r1, #0 /* NULL */
michael@0 68 add r2, r4, #UCONTEXT_SIGMASK_OFFSET
michael@0 69 bl sigprocmask(PLT)
michael@0 70
michael@0 71 /* Intentionally do not save the FPU state here. This is because on
michael@0 72 * Linux/ARM, one should instead use ptrace(PTRACE_GETFPREGS) or
michael@0 73 * ptrace(PTRACE_GETVFPREGS) to get it.
michael@0 74 *
michael@0 75 * Note that a real implementation of getcontext() would need to save
michael@0 76 * this here to allow setcontext()/swapcontext() to work correctly.
michael@0 77 */
michael@0 78
michael@0 79 /* Restore the values of r4 and lr */
michael@0 80 mov r0, r4
michael@0 81 ldr lr, [r0, #(MCONTEXT_GREGS_OFFSET + 14*4)]
michael@0 82 ldr r4, [r0, #(MCONTEXT_GREGS_OFFSET + 4*4)]
michael@0 83
michael@0 84 /* Return 0 */
michael@0 85 mov r0, #0
michael@0 86 bx lr
michael@0 87
michael@0 88 .fnend
michael@0 89 .size breakpad_getcontext, . - breakpad_getcontext
michael@0 90
michael@0 91 #elif defined(__i386__)
michael@0 92
michael@0 93 .text
michael@0 94 .global breakpad_getcontext
michael@0 95 .hidden breakpad_getcontext
michael@0 96 .align 4
michael@0 97 .type breakpad_getcontext, @function
michael@0 98
michael@0 99 breakpad_getcontext:
michael@0 100
michael@0 101 movl 4(%esp), %eax /* eax = uc */
michael@0 102
michael@0 103 /* Save register values */
michael@0 104 movl %ecx, MCONTEXT_ECX_OFFSET(%eax)
michael@0 105 movl %edx, MCONTEXT_EDX_OFFSET(%eax)
michael@0 106 movl %ebx, MCONTEXT_EBX_OFFSET(%eax)
michael@0 107 movl %edi, MCONTEXT_EDI_OFFSET(%eax)
michael@0 108 movl %esi, MCONTEXT_ESI_OFFSET(%eax)
michael@0 109 movl %ebp, MCONTEXT_EBP_OFFSET(%eax)
michael@0 110
michael@0 111 movl (%esp), %edx /* return address */
michael@0 112 lea 4(%esp), %ecx /* exclude return address from stack */
michael@0 113 mov %edx, MCONTEXT_EIP_OFFSET(%eax)
michael@0 114 mov %ecx, MCONTEXT_ESP_OFFSET(%eax)
michael@0 115
michael@0 116 xorl %ecx, %ecx
michael@0 117 movw %fs, %cx
michael@0 118 mov %ecx, MCONTEXT_FS_OFFSET(%eax)
michael@0 119
michael@0 120 movl $0, MCONTEXT_EAX_OFFSET(%eax)
michael@0 121
michael@0 122 /* Save floating point state to fpregstate, then update
michael@0 123 * the fpregs pointer to point to it */
michael@0 124 leal UCONTEXT_FPREGS_MEM_OFFSET(%eax), %ecx
michael@0 125 fnstenv (%ecx)
michael@0 126 fldenv (%ecx)
michael@0 127 mov %ecx, UCONTEXT_FPREGS_OFFSET(%eax)
michael@0 128
michael@0 129 /* Save signal mask: sigprocmask(SIGBLOCK, NULL, &uc->uc_sigmask) */
michael@0 130 leal UCONTEXT_SIGMASK_OFFSET(%eax), %edx
michael@0 131 xorl %ecx, %ecx
michael@0 132 push %edx /* &uc->uc_sigmask */
michael@0 133 push %ecx /* NULL */
michael@0 134 push %ecx /* SIGBLOCK == 0 on i386 */
michael@0 135 call sigprocmask@PLT
michael@0 136 addl $12, %esp
michael@0 137
michael@0 138 movl $0, %eax
michael@0 139 ret
michael@0 140
michael@0 141 .size breakpad_getcontext, . - breakpad_getcontext
michael@0 142
michael@0 143 #else
michael@0 144 #error "This file has not been ported for your CPU!"
michael@0 145 #endif

mercurial