OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
16 | 16 |
17 // These functions add metadata to the upload payload when sending crash reports | 17 // These functions add metadata to the upload payload when sending crash reports |
18 // to the crash server. | 18 // to the crash server. |
19 // | 19 // |
20 // IMPORTANT: On OS X and Linux, the key/value pairs are only sent as part of | 20 // IMPORTANT: On OS X and Linux, the key/value pairs are only sent as part of |
21 // the upload and are not included in the minidump! | 21 // the upload and are not included in the minidump! |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 namespace debug { | 24 namespace debug { |
25 | 25 |
26 class StackTrace; | 26 class StackTrace; |
27 | 27 |
28 // Set or clear a specific key-value pair from the crash metadata. Keys and | 28 // Sets or clears a specific key-value pair from the crash metadata. Keys and |
29 // values are terminated at the null byte. | 29 // values are terminated at the null byte. |
30 BASE_EXPORT void SetCrashKeyValue(const base::StringPiece& key, | 30 BASE_EXPORT void SetCrashKeyValue(const base::StringPiece& key, |
31 const base::StringPiece& value); | 31 const base::StringPiece& value); |
32 BASE_EXPORT void ClearCrashKey(const base::StringPiece& key); | 32 BASE_EXPORT void ClearCrashKey(const base::StringPiece& key); |
33 | 33 |
34 // Records the given StackTrace into a crash key. | 34 // Records the given StackTrace into a crash key. |
35 BASE_EXPORT void SetCrashKeyToStackTrace(const base::StringPiece& key, | 35 BASE_EXPORT void SetCrashKeyToStackTrace(const base::StringPiece& key, |
36 const StackTrace& trace); | 36 const StackTrace& trace); |
37 | 37 |
38 // Formats |count| instruction pointers from |addresses| using %p and | 38 // Formats |count| instruction pointers from |addresses| using %p and |
(...skipping 29 matching lines...) Expand all Loading... |
68 }; | 68 }; |
69 | 69 |
70 // Before the crash key logging mechanism can be used, all crash keys must be | 70 // Before the crash key logging mechanism can be used, all crash keys must be |
71 // registered with this function. The function returns the amount of space | 71 // registered with this function. The function returns the amount of space |
72 // the crash reporting implementation should allocate space for the registered | 72 // the crash reporting implementation should allocate space for the registered |
73 // crash keys. |chunk_max_length| is the maximum size that a value in a single | 73 // crash keys. |chunk_max_length| is the maximum size that a value in a single |
74 // chunk can be. | 74 // chunk can be. |
75 BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count, | 75 BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count, |
76 size_t chunk_max_length); | 76 size_t chunk_max_length); |
77 | 77 |
78 // Returns the correspnding crash key object or NULL for a given key. | 78 // Returns the corresponding crash key object or NULL for a given key. |
79 BASE_EXPORT const CrashKey* LookupCrashKey(const base::StringPiece& key); | 79 BASE_EXPORT const CrashKey* LookupCrashKey(const base::StringPiece& key); |
80 | 80 |
81 // In the platform crash reporting implementation, these functions set and | 81 // In the platform crash reporting implementation, these functions set and |
82 // clear the NUL-termianted key-value pairs. | 82 // clear the NUL-terminated key-value pairs. |
83 typedef void (*SetCrashKeyValueFuncT)(const base::StringPiece&, | 83 typedef void (*SetCrashKeyValueFuncT)(const base::StringPiece&, |
84 const base::StringPiece&); | 84 const base::StringPiece&); |
85 typedef void (*ClearCrashKeyValueFuncT)(const base::StringPiece&); | 85 typedef void (*ClearCrashKeyValueFuncT)(const base::StringPiece&); |
86 | 86 |
87 // Sets the function pointers that are used to integrate with the platform- | 87 // Sets the function pointers that are used to integrate with the platform- |
88 // specific crash reporting libraries. | 88 // specific crash reporting libraries. |
89 BASE_EXPORT void SetCrashKeyReportingFunctions( | 89 BASE_EXPORT void SetCrashKeyReportingFunctions( |
90 SetCrashKeyValueFuncT set_key_func, | 90 SetCrashKeyValueFuncT set_key_func, |
91 ClearCrashKeyValueFuncT clear_key_func); | 91 ClearCrashKeyValueFuncT clear_key_func); |
92 | 92 |
93 // Helper function that breaks up a value according to the parameters | 93 // Helper function that breaks up a value according to the parameters |
94 // specified by the crash key object. | 94 // specified by the crash key object. |
95 BASE_EXPORT std::vector<std::string> ChunkCrashKeyValue( | 95 BASE_EXPORT std::vector<std::string> ChunkCrashKeyValue( |
96 const CrashKey& crash_key, | 96 const CrashKey& crash_key, |
97 const base::StringPiece& value, | 97 const base::StringPiece& value, |
98 size_t chunk_max_length); | 98 size_t chunk_max_length); |
99 | 99 |
100 // Resets the crash key system so it can be reinitialized. For testing only. | 100 // Resets the crash key system so it can be reinitialized. For testing only. |
101 BASE_EXPORT void ResetCrashLoggingForTesting(); | 101 BASE_EXPORT void ResetCrashLoggingForTesting(); |
102 | 102 |
103 } // namespace debug | 103 } // namespace debug |
104 } // namespace base | 104 } // namespace base |
105 | 105 |
106 #endif // BASE_DEBUG_CRASH_LOGGING_H_ | 106 #endif // BASE_DEBUG_CRASH_LOGGING_H_ |
OLD | NEW |