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

Side by Side Diff: base/debug/crash_logging.h

Issue 12211080: Change crash keys to be registered with a maximum length instead of number of chunks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Link chrome_app_unittests.exe Created 7 years, 9 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
« no previous file with comments | « no previous file | base/debug/crash_logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_DEBUG_CRASH_LOGGING_H_ 5 #ifndef BASE_DEBUG_CRASH_LOGGING_H_
6 #define BASE_DEBUG_CRASH_LOGGING_H_ 6 #define BASE_DEBUG_CRASH_LOGGING_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 15 matching lines...) Expand all
26 // Set or clear a specific key-value pair from the crash metadata. 26 // Set or clear a specific key-value pair from the crash metadata.
27 BASE_EXPORT void SetCrashKeyValue(const base::StringPiece& key, 27 BASE_EXPORT void SetCrashKeyValue(const base::StringPiece& key,
28 const base::StringPiece& value); 28 const base::StringPiece& value);
29 BASE_EXPORT void ClearCrashKey(const base::StringPiece& key); 29 BASE_EXPORT void ClearCrashKey(const base::StringPiece& key);
30 30
31 // Records the given StackTrace into a crash key. 31 // Records the given StackTrace into a crash key.
32 BASE_EXPORT void SetCrashKeyToStackTrace(const base::StringPiece& key, 32 BASE_EXPORT void SetCrashKeyToStackTrace(const base::StringPiece& key,
33 const StackTrace& trace); 33 const StackTrace& trace);
34 34
35 // Formats |count| instruction pointers from |addresses| using %p and 35 // Formats |count| instruction pointers from |addresses| using %p and
36 // sets the resulting string as a value for crash key |key. A maximum of 23 36 // sets the resulting string as a value for crash key |key|. A maximum of 23
37 // items will be encoded, since breakpad limits values to 255 bytes. 37 // items will be encoded, since breakpad limits values to 255 bytes.
38 BASE_EXPORT void SetCrashKeyFromAddresses(const base::StringPiece& key, 38 BASE_EXPORT void SetCrashKeyFromAddresses(const base::StringPiece& key,
39 const void* const* addresses, 39 const void* const* addresses,
40 size_t count); 40 size_t count);
41 41
42 // A scoper that sets the specified key to value for the lifetime of the 42 // A scoper that sets the specified key to value for the lifetime of the
43 // object, and clears it on destruction. 43 // object, and clears it on destruction.
44 class BASE_EXPORT ScopedCrashKey { 44 class BASE_EXPORT ScopedCrashKey {
45 public: 45 public:
46 ScopedCrashKey(const base::StringPiece& key, const base::StringPiece& value); 46 ScopedCrashKey(const base::StringPiece& key, const base::StringPiece& value);
47 ~ScopedCrashKey(); 47 ~ScopedCrashKey();
48 48
49 private: 49 private:
50 std::string key_; 50 std::string key_;
51 51
52 DISALLOW_COPY_AND_ASSIGN(ScopedCrashKey); 52 DISALLOW_COPY_AND_ASSIGN(ScopedCrashKey);
53 }; 53 };
54 54
55 // Before setting values for a key, all the keys must be registered. 55 // Before setting values for a key, all the keys must be registered.
56 struct BASE_EXPORT CrashKey { 56 struct BASE_EXPORT CrashKey {
57 // The name of the crash key, used in the above functions. 57 // The name of the crash key, used in the above functions.
58 const char* const key_name; 58 const char* const key_name;
59 59
60 // For values longer than chunk_max_length, the value can be chunked into 60 // The maximum length for a value. If the value is longer than this, it will
61 // values named "key_name-1", "key_name-2", etc. This is the maximum number of 61 // be truncated. If the value is larger than the |chunk_max_length| passed to
62 // numbered chunks to use before the value is truncated. 62 // InitCrashKeys() but less than this value, it will be split into multiple
63 size_t num_chunks; 63 // numbered chunks.
64 size_t max_length;
64 }; 65 };
65 66
66 // Before the crash key logging mechanism can be used, all crash keys must be 67 // Before the crash key logging mechanism can be used, all crash keys must be
67 // registered with this function. The function returns the amount of space 68 // registered with this function. The function returns the amount of space
68 // the crash reporting implementation should allocate space for the registered 69 // the crash reporting implementation should allocate space for the registered
69 // crash keys. |chunk_max_length| is the maximum size that a value in a single 70 // crash keys. |chunk_max_length| is the maximum size that a value in a single
70 // chunk can be. 71 // chunk can be.
71 BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count, 72 BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count,
72 size_t chunk_max_length); 73 size_t chunk_max_length);
73 74
(...skipping 17 matching lines...) Expand all
91 const base::StringPiece& value, 92 const base::StringPiece& value,
92 size_t chunk_max_length); 93 size_t chunk_max_length);
93 94
94 // Resets the crash key system so it can be reinitialized. For testing only. 95 // Resets the crash key system so it can be reinitialized. For testing only.
95 BASE_EXPORT void ResetCrashLoggingForTesting(); 96 BASE_EXPORT void ResetCrashLoggingForTesting();
96 97
97 } // namespace debug 98 } // namespace debug
98 } // namespace base 99 } // namespace base
99 100
100 #endif // BASE_DEBUG_CRASH_LOGGING_H_ 101 #endif // BASE_DEBUG_CRASH_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | base/debug/crash_logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698