| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // Set or clear a specific key-value pair from the crash metadata. | 25 // Set or clear a specific key-value pair from the crash metadata. |
| 26 BASE_EXPORT void SetCrashKeyValue(const base::StringPiece& key, | 26 BASE_EXPORT void SetCrashKeyValue(const base::StringPiece& key, |
| 27 const base::StringPiece& value); | 27 const base::StringPiece& value); |
| 28 BASE_EXPORT void ClearCrashKey(const base::StringPiece& key); | 28 BASE_EXPORT void ClearCrashKey(const base::StringPiece& key); |
| 29 | 29 |
| 30 // Records the given StackTrace into a crash key. | 30 // Records the given StackTrace into a crash key. |
| 31 BASE_EXPORT void SetCrashKeyToStackTrace(const base::StringPiece& key, | 31 BASE_EXPORT void SetCrashKeyToStackTrace(const base::StringPiece& key, |
| 32 const StackTrace& trace); | 32 const StackTrace& trace); |
| 33 | 33 |
| 34 // Formats |count| instruction pointers from |addresses| using %p and | 34 // Formats |count| instruction pointers from |addresses| using %p and |
| 35 // sets the resulting string as a value for crash key |key. A maximum of 23 | 35 // sets the resulting string as a value for crash key |key|. A maximum of 23 |
| 36 // items will be encoded, since breakpad limits values to 255 bytes. | 36 // items will be encoded, since breakpad limits values to 255 bytes. |
| 37 BASE_EXPORT void SetCrashKeyFromAddresses(const base::StringPiece& key, | 37 BASE_EXPORT void SetCrashKeyFromAddresses(const base::StringPiece& key, |
| 38 const void* const* addresses, | 38 const void* const* addresses, |
| 39 size_t count); | 39 size_t count); |
| 40 | 40 |
| 41 // A scoper that sets the specified key to value for the lifetime of the | 41 // A scoper that sets the specified key to value for the lifetime of the |
| 42 // object, and clears it on destruction. | 42 // object, and clears it on destruction. |
| 43 class BASE_EXPORT ScopedCrashKey { | 43 class BASE_EXPORT ScopedCrashKey { |
| 44 public: | 44 public: |
| 45 ScopedCrashKey(const base::StringPiece& key, const base::StringPiece& value); | 45 ScopedCrashKey(const base::StringPiece& key, const base::StringPiece& value); |
| 46 ~ScopedCrashKey(); | 46 ~ScopedCrashKey(); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 std::string key_; | 49 std::string key_; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(ScopedCrashKey); | 51 DISALLOW_COPY_AND_ASSIGN(ScopedCrashKey); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // Before setting values for a key, all the keys must be registered. | 54 // Before setting values for a key, all the keys must be registered. |
| 55 struct BASE_EXPORT CrashKey { | 55 struct BASE_EXPORT CrashKey { |
| 56 // The name of the crash key, used in the above functions. | 56 // The name of the crash key, used in the above functions. |
| 57 const char* const key_name; | 57 const char* const key_name; |
| 58 | 58 |
| 59 // For values longer than chunk_max_length, the value can be chunked into | 59 // The maximum length for a value. If the value is longer than this, it will |
| 60 // values named "key_name-1", "key_name-2", etc. This is the maximum number of | 60 // be truncated. If the value is larger than the |chunk_max_length| passed to |
| 61 // numbered chunks to use before the value is truncated. | 61 // InitCrashKeys() but less than this value, it will be split into multiple |
| 62 size_t num_chunks; | 62 // numbered chunks. |
| 63 size_t max_length; |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 // Before the crash key logging mechanism can be used, all crash keys must be | 66 // Before the crash key logging mechanism can be used, all crash keys must be |
| 66 // registered with this function. The function returns the amount of space | 67 // registered with this function. The function returns the amount of space |
| 67 // the crash reporting implementation should allocate space for the registered | 68 // the crash reporting implementation should allocate space for the registered |
| 68 // crash keys. |chunk_max_length| is the maximum size that a value in a single | 69 // crash keys. |chunk_max_length| is the maximum size that a value in a single |
| 69 // chunk can be. | 70 // chunk can be. |
| 70 BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count, | 71 BASE_EXPORT size_t InitCrashKeys(const CrashKey* const keys, size_t count, |
| 71 size_t chunk_max_length); | 72 size_t chunk_max_length); |
| 72 | 73 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 90 const base::StringPiece& value, | 91 const base::StringPiece& value, |
| 91 size_t chunk_max_length); | 92 size_t chunk_max_length); |
| 92 | 93 |
| 93 // Resets the crash key system so it can be reinitialized. For testing only. | 94 // Resets the crash key system so it can be reinitialized. For testing only. |
| 94 BASE_EXPORT void ResetCrashLoggingForTesting(); | 95 BASE_EXPORT void ResetCrashLoggingForTesting(); |
| 95 | 96 |
| 96 } // namespace debug | 97 } // namespace debug |
| 97 } // namespace base | 98 } // namespace base |
| 98 | 99 |
| 99 #endif // BASE_DEBUG_CRASH_LOGGING_H_ | 100 #endif // BASE_DEBUG_CRASH_LOGGING_H_ |
| OLD | NEW |