| OLD | NEW |
| 1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 #include "base/logging.h" // for RAW_LOG | 168 #include "base/logging.h" // for RAW_LOG |
| 169 #ifndef HAVE_CYGWIN_SIGNAL_H | 169 #ifndef HAVE_CYGWIN_SIGNAL_H |
| 170 typedef int ucontext_t; | 170 typedef int ucontext_t; |
| 171 #endif | 171 #endif |
| 172 | 172 |
| 173 inline void* GetPC(const struct ucontext_t& signal_ucontext) { | 173 inline void* GetPC(const struct ucontext_t& signal_ucontext) { |
| 174 RAW_LOG(ERROR, "GetPC is not yet implemented on Windows\n"); | 174 RAW_LOG(ERROR, "GetPC is not yet implemented on Windows\n"); |
| 175 return NULL; | 175 return NULL; |
| 176 } | 176 } |
| 177 #elif defined(__ANDROID__) | 177 #elif defined(__ANDROID__) |
| 178 namespace tcmalloc { |
| 178 typedef struct _Unwind_Context ucontext_t; | 179 typedef struct _Unwind_Context ucontext_t; |
| 180 } |
| 179 | 181 |
| 180 inline void* GetPC(const ucontext_t& signal_ucontext) { | 182 inline void* GetPC(const tcmalloc::ucontext_t& signal_ucontext) { |
| 181 // Bionic doesn't export ucontext, see | 183 // Bionic doesn't export ucontext, see |
| 182 // https://code.google.com/p/android/issues/detail?id=34784. | 184 // https://code.google.com/p/android/issues/detail?id=34784. |
| 183 return reinterpret_cast<void*>(_Unwind_GetIP( | 185 return reinterpret_cast<void*>(_Unwind_GetIP( |
| 184 const_cast<ucontext_t*>(&signal_ucontext))); | 186 const_cast<tcmalloc::ucontext_t*>(&signal_ucontext))); |
| 185 } | 187 } |
| 186 // | 188 // |
| 187 // Normal cases. If this doesn't compile, it's probably because | 189 // Normal cases. If this doesn't compile, it's probably because |
| 188 // PC_FROM_UCONTEXT is the empty string. You need to figure out | 190 // PC_FROM_UCONTEXT is the empty string. You need to figure out |
| 189 // the right value for your system, and add it to the list in | 191 // the right value for your system, and add it to the list in |
| 190 // configure.ac (or set it manually in your config.h). | 192 // configure.ac (or set it manually in your config.h). |
| 191 #else | 193 #else |
| 192 inline void* GetPC(const ucontext_t& signal_ucontext) { | 194 inline void* GetPC(const ucontext_t& signal_ucontext) { |
| 193 return (void*)signal_ucontext.PC_FROM_UCONTEXT; // defined in config.h | 195 return (void*)signal_ucontext.PC_FROM_UCONTEXT; // defined in config.h |
| 194 } | 196 } |
| 195 | 197 |
| 196 #endif | 198 #endif |
| 197 | 199 |
| 198 #endif // BASE_GETPC_H_ | 200 #endif // BASE_GETPC_H_ |
| OLD | NEW |