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 27 matching lines...) Expand all Loading... |
38 // Anything that should only be defined once should be here: | 38 // Anything that should only be defined once should be here: |
39 | 39 |
40 // We only need local unwinder. | 40 // We only need local unwinder. |
41 #define UNW_LOCAL_ONLY | 41 #define UNW_LOCAL_ONLY |
42 | 42 |
43 extern "C" { | 43 extern "C" { |
44 #include <assert.h> | 44 #include <assert.h> |
45 #include <string.h> // for memset() | 45 #include <string.h> // for memset() |
46 #include <libunwind.h> | 46 #include <libunwind.h> |
47 } | 47 } |
48 #include "gperftools/stacktrace.h" | 48 #include "google/stacktrace.h" |
49 #include "base/logging.h" | 49 #include "base/logging.h" |
50 | 50 |
51 // Sometimes, we can try to get a stack trace from within a stack | 51 // Sometimes, we can try to get a stack trace from within a stack |
52 // trace, because libunwind can call mmap (maybe indirectly via an | 52 // trace, because libunwind can call mmap (maybe indirectly via an |
53 // internal mmap based memory allocator), and that mmap gets trapped | 53 // internal mmap based memory allocator), and that mmap gets trapped |
54 // and causes a stack-trace request. If were to try to honor that | 54 // and causes a stack-trace request. If were to try to honor that |
55 // recursive request, we'd end up with infinite recursion or deadlock. | 55 // recursive request, we'd end up with infinite recursion or deadlock. |
56 // Luckily, it's safe to ignore those subsequent traces. In such | 56 // Luckily, it's safe to ignore those subsequent traces. In such |
57 // cases, we return 0 to indicate the situation. | 57 // cases, we return 0 to indicate the situation. |
58 static __thread int recursive; | 58 static __thread int recursive; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (unw_get_reg(&cursor, UNW_REG_SP, &next_sp) , 0) { | 119 if (unw_get_reg(&cursor, UNW_REG_SP, &next_sp) , 0) { |
120 break; | 120 break; |
121 } | 121 } |
122 sizes[n - 1] = next_sp - sp; | 122 sizes[n - 1] = next_sp - sp; |
123 #endif | 123 #endif |
124 } | 124 } |
125 out: | 125 out: |
126 --recursive; | 126 --recursive; |
127 return n; | 127 return n; |
128 } | 128 } |
OLD | NEW |