| OLD | NEW |
| 1 // Copyright (c) 2007, Google Inc. | 1 // Copyright (c) 2007, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // we did, the list of stack frames wouldn't properly match up with | 119 // we did, the list of stack frames wouldn't properly match up with |
| 120 // the list of return addresses. Note this means the top pc entry | 120 // the list of return addresses. Note this means the top pc entry |
| 121 // is probably bogus for linux/ppc (and other SYSV-ABI systems). | 121 // is probably bogus for linux/ppc (and other SYSV-ABI systems). |
| 122 #else | 122 #else |
| 123 // The LR save area is used by the callee, so the top entry is bogus. | 123 // The LR save area is used by the callee, so the top entry is bogus. |
| 124 skip_count++; | 124 skip_count++; |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 int n = 0; | 127 int n = 0; |
| 128 while (sp && n < max_depth) { | 128 while (sp && n < max_depth) { |
| 129 #if IS_STACK_FRAMES | |
| 130 // The GetStackFrames routine is called when we are in some | 129 // The GetStackFrames routine is called when we are in some |
| 131 // informational context (the failure signal handler for example). | 130 // informational context (the failure signal handler for example). |
| 132 // Use the non-strict unwinding rules to produce a stack trace | 131 // Use the non-strict unwinding rules to produce a stack trace |
| 133 // that is as complete as possible (even if it contains a few bogus | 132 // that is as complete as possible (even if it contains a few |
| 134 // entries in some rare cases). | 133 // bogus entries in some rare cases). |
| 135 void **next_sp = NextStackFrame<false>(sp); | 134 void **next_sp = NextStackFrame<!IS_STACK_FRAMES>(sp); |
| 136 #else | |
| 137 void **next_sp = NextStackFrame<true>(sp); | |
| 138 #endif | |
| 139 | 135 |
| 140 if (skip_count > 0) { | 136 if (skip_count > 0) { |
| 141 skip_count--; | 137 skip_count--; |
| 142 } else { | 138 } else { |
| 143 // PowerPC has 3 main ABIs, which say where in the stack the | 139 // PowerPC has 3 main ABIs, which say where in the stack the |
| 144 // Link Register is. For DARWIN and AIX (used by apple and | 140 // Link Register is. For DARWIN and AIX (used by apple and |
| 145 // linux ppc64), it's in sp[2]. For SYSV (used by linux ppc), | 141 // linux ppc64), it's in sp[2]. For SYSV (used by linux ppc), |
| 146 // it's in sp[1]. | 142 // it's in sp[1]. |
| 147 #if defined(_CALL_AIX) || defined(_CALL_DARWIN) | 143 #if defined(_CALL_AIX) || defined(_CALL_DARWIN) |
| 148 result[n++] = *(sp+2); | 144 result[n] = *(sp+2); |
| 149 #elif defined(_CALL_SYSV) | 145 #elif defined(_CALL_SYSV) |
| 150 result[n++] = *(sp+1); | 146 result[n] = *(sp+1); |
| 151 #elif defined(__APPLE__) || (defined(__linux) && defined(__PPC64__)) | 147 #elif defined(__APPLE__) || (defined(__linux) && defined(__PPC64__)) |
| 152 // This check is in case the compiler doesn't define _CALL_AIX/etc. | 148 // This check is in case the compiler doesn't define _CALL_AIX/etc. |
| 153 result[n++] = *(sp+2); | 149 result[n] = *(sp+2); |
| 154 #elif defined(__linux) | 150 #elif defined(__linux) |
| 155 // This check is in case the compiler doesn't define _CALL_SYSV. | 151 // This check is in case the compiler doesn't define _CALL_SYSV. |
| 156 result[n++] = *(sp+1); | 152 result[n] = *(sp+1); |
| 157 #else | 153 #else |
| 158 #error Need to specify the PPC ABI for your archiecture. | 154 #error Need to specify the PPC ABI for your archiecture. |
| 159 #endif | 155 #endif |
| 160 | 156 |
| 161 #if IS_STACK_FRAME | 157 #if IS_STACK_FRAMES |
| 162 if (next_sp > sp) { | 158 if (next_sp > sp) { |
| 163 sizes[n] = (uintptr_t)next_sp - (uintptr_t)sp; | 159 sizes[n] = (uintptr_t)next_sp - (uintptr_t)sp; |
| 164 } else { | 160 } else { |
| 165 // A frame-size of 0 is used to indicate unknown frame size. | 161 // A frame-size of 0 is used to indicate unknown frame size. |
| 166 sizes[n] = 0; | 162 sizes[n] = 0; |
| 167 } | 163 } |
| 168 #endif | 164 #endif |
| 165 n++; |
| 169 } | 166 } |
| 170 sp = next_sp; | 167 sp = next_sp; |
| 171 } | 168 } |
| 172 return n; | 169 return n; |
| 173 } | 170 } |
| OLD | NEW |