Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: third_party/tcmalloc/chromium/src/stacktrace_with_context.cc

Issue 9323026: [NOT TO COMMIT!] r109: Diff of the current tcmalloc from the original google-perftools r109. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, 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
11 // copyright notice, this list of conditions and the following disclaimer 11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the 12 // in the documentation and/or other materials provided with the
13 // distribution. 13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its 14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from 15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission. 16 // this software without specific prior written permission.
17 // 17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 // --- 30 // ---
31 // Author: Andrew Fikes 31 // Author: Paul Pluzhnikov
32 // 32 //
33 // Utility class for coalescing sampled stack traces. Not thread-safe. 33 // This code logically belongs in stacktrace.cc, but
34 34 // it is moved into (this) separate file in order to
35 #ifndef TCMALLOC_STACK_TRACE_TABLE_H_ 35 // prevent inlining of routines defined here.
36 #define TCMALLOC_STACK_TRACE_TABLE_H_ 36 //
37 // Inlining causes skip_count to be incorrect, and there
38 // is no portable way to prevent it.
39 //
40 // Eventually LTO (link-time optimization) and/or LLVM
41 // may inline this code anyway. Let's hope they respect
42 // ATTRIBUTE_NOINLINE.
37 43
38 #include <config.h> 44 #include <config.h>
39 #include <stdint.h> // for uintptr_t 45 #include <google/stacktrace.h>
40 #include "common.h" 46 #include "stacktrace_config.h"
47 #include "base/basictypes.h"
41 48
42 namespace tcmalloc { 49 #if !defined(STACKTRACE_SKIP_CONTEXT_ROUTINES)
50 ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL
51 int GetStackFramesWithContext(void** pcs, int* sizes, int max_depth,
52 int skip_count, const void * /* uc */) {
53 return GetStackFrames(pcs, sizes, max_depth, skip_count + 1);
54 }
43 55
44 class PERFTOOLS_DLL_DECL StackTraceTable { 56 ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL
45 public: 57 int GetStackTraceWithContext(void** result, int max_depth,
46 // REQUIRES: L < pageheap_lock 58 int skip_count, const void * /* uc */) {
47 StackTraceTable(); 59 return GetStackTrace(result, max_depth, skip_count + 1);
48 ~StackTraceTable(); 60 }
49 61 #endif
50 // Adds stack trace "t" to table.
51 //
52 // REQUIRES: L >= pageheap_lock
53 void AddTrace(const StackTrace& t);
54
55 // Returns stack traces formatted per MallocExtension guidelines.
56 // May return NULL on error. Clears state before returning.
57 //
58 // REQUIRES: L < pageheap_lock
59 void** ReadStackTracesAndClear();
60
61 // Exposed for PageHeapAllocator
62 struct Bucket {
63 // Key
64 uintptr_t hash;
65 StackTrace trace;
66
67 // Payload
68 int count;
69 Bucket* next;
70
71 bool KeyEqual(uintptr_t h, const StackTrace& t) const;
72 };
73
74 // For testing
75 int depth_total() const { return depth_total_; }
76 int bucket_total() const { return bucket_total_; }
77
78 private:
79 static const int kHashTableSize = 1 << 14; // => table_ is 128k
80
81 bool error_;
82 int depth_total_;
83 int bucket_total_;
84 Bucket** table_;
85 };
86
87 } // namespace tcmalloc
88
89 #endif // TCMALLOC_STACK_TRACE_TABLE_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/stacktrace_win32-inl.h ('k') | third_party/tcmalloc/chromium/src/stacktrace_x86-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698