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

Side by Side Diff: src/client/linux/handler/minidump_descriptor.h

Issue 1125153008: [microdump] Add build fingerprint and product info metadata. (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk
Patch Set: Addressing changes from https://breakpad.appspot.com/9794002 Created 5 years, 7 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) 2012 Google Inc. 1 // Copyright (c) 2012 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // - Writing a reduced microdump to the console (logcat on Android). 44 // - Writing a reduced microdump to the console (logcat on Android).
45 namespace google_breakpad { 45 namespace google_breakpad {
46 46
47 class MinidumpDescriptor { 47 class MinidumpDescriptor {
48 public: 48 public:
49 struct MicrodumpOnConsole {}; 49 struct MicrodumpOnConsole {};
50 static const MicrodumpOnConsole kMicrodumpOnConsole; 50 static const MicrodumpOnConsole kMicrodumpOnConsole;
51 51
52 MinidumpDescriptor() : mode_(kUninitialized), 52 MinidumpDescriptor() : mode_(kUninitialized),
53 fd_(-1), 53 fd_(-1),
54 size_limit_(-1) {} 54 size_limit_(-1),
55 microdump_build_fingerprint_(NULL),
56 microdump_product_info_(NULL) {}
55 57
56 explicit MinidumpDescriptor(const string& directory) 58 explicit MinidumpDescriptor(const string& directory)
57 : mode_(kWriteMinidumpToFile), 59 : mode_(kWriteMinidumpToFile),
58 fd_(-1), 60 fd_(-1),
59 directory_(directory), 61 directory_(directory),
60 c_path_(NULL), 62 c_path_(NULL),
61 size_limit_(-1) { 63 size_limit_(-1),
64 microdump_build_fingerprint_(NULL),
65 microdump_product_info_(NULL) {
62 assert(!directory.empty()); 66 assert(!directory.empty());
63 } 67 }
64 68
65 explicit MinidumpDescriptor(int fd) 69 explicit MinidumpDescriptor(int fd)
66 : mode_(kWriteMinidumpToFd), 70 : mode_(kWriteMinidumpToFd),
67 fd_(fd), 71 fd_(fd),
68 c_path_(NULL), 72 c_path_(NULL),
69 size_limit_(-1) { 73 size_limit_(-1),
74 microdump_build_fingerprint_(NULL),
75 microdump_product_info_(NULL) {
70 assert(fd != -1); 76 assert(fd != -1);
71 } 77 }
72 78
73 explicit MinidumpDescriptor(const MicrodumpOnConsole&) 79 explicit MinidumpDescriptor(const MicrodumpOnConsole&)
74 : mode_(kWriteMicrodumpToConsole), 80 : mode_(kWriteMicrodumpToConsole),
75 fd_(-1), 81 fd_(-1),
76 size_limit_(-1) {} 82 size_limit_(-1),
83 microdump_build_fingerprint_(NULL),
84 microdump_product_info_(NULL) {}
77 85
78 explicit MinidumpDescriptor(const MinidumpDescriptor& descriptor); 86 explicit MinidumpDescriptor(const MinidumpDescriptor& descriptor);
79 MinidumpDescriptor& operator=(const MinidumpDescriptor& descriptor); 87 MinidumpDescriptor& operator=(const MinidumpDescriptor& descriptor);
80 88
81 static MinidumpDescriptor getMicrodumpDescriptor(); 89 static MinidumpDescriptor getMicrodumpDescriptor();
82 90
83 bool IsFD() const { return mode_ == kWriteMinidumpToFd; } 91 bool IsFD() const { return mode_ == kWriteMinidumpToFd; }
84 92
85 int fd() const { return fd_; } 93 int fd() const { return fd_; }
86 94
87 string directory() const { return directory_; } 95 string directory() const { return directory_; }
88 96
89 const char* path() const { return c_path_; } 97 const char* path() const { return c_path_; }
90 98
91 bool IsMicrodumpOnConsole() const { 99 bool IsMicrodumpOnConsole() const {
92 return mode_ == kWriteMicrodumpToConsole; 100 return mode_ == kWriteMicrodumpToConsole;
93 } 101 }
94 102
95 // Updates the path so it is unique. 103 // Updates the path so it is unique.
96 // Should be called from a normal context: this methods uses the heap. 104 // Should be called from a normal context: this methods uses the heap.
97 void UpdatePath(); 105 void UpdatePath();
98 106
99 off_t size_limit() const { return size_limit_; } 107 off_t size_limit() const { return size_limit_; }
100 void set_size_limit(off_t limit) { size_limit_ = limit; } 108 void set_size_limit(off_t limit) { size_limit_ = limit; }
101 109
110 // TODO(primiano): make this and product info (below) just part of the
111 // microdump ctor once it is rolled stably into Chrome. ETA: June 2015.
112 void SetMicrodumpBuildFingerprint(const char* build_fingerprint);
113 const char* microdump_build_fingerprint() const {
114 return microdump_build_fingerprint_;
115 }
116
117 void SetMicrodumpProductInfo(const char* product_info);
118 const char* microdump_product_info() const {
119 return microdump_product_info_;
120 }
121
102 private: 122 private:
103 enum DumpMode { 123 enum DumpMode {
104 kUninitialized = 0, 124 kUninitialized = 0,
105 kWriteMinidumpToFile, 125 kWriteMinidumpToFile,
106 kWriteMinidumpToFd, 126 kWriteMinidumpToFd,
107 kWriteMicrodumpToConsole 127 kWriteMicrodumpToConsole
108 }; 128 };
109 129
110 // Specifies the dump mode (see DumpMode). 130 // Specifies the dump mode (see DumpMode).
111 DumpMode mode_; 131 DumpMode mode_;
112 132
113 // The file descriptor where the minidump is generated. 133 // The file descriptor where the minidump is generated.
114 int fd_; 134 int fd_;
115 135
116 // The directory where the minidump should be generated. 136 // The directory where the minidump should be generated.
117 string directory_; 137 string directory_;
138
118 // The full path to the generated minidump. 139 // The full path to the generated minidump.
119 string path_; 140 string path_;
141
120 // The C string of |path_|. Precomputed so it can be access from a compromised 142 // The C string of |path_|. Precomputed so it can be access from a compromised
121 // context. 143 // context.
122 const char* c_path_; 144 const char* c_path_;
123 145
124 off_t size_limit_; 146 off_t size_limit_;
147
148 // The product name/version and build fingerprint that should be appended to
149 // the dump (microdump only). Microdumps don't have the ability of appending
150 // extra metadata after the dump is generated (as opposite to minidumps
151 // MIME fields), therefore the product details must be provided upfront.
152 // The string pointers are supposed to be valid through all the lifetime of
153 // the process (read: the caller has to guarantee that they are stored in
154 // global static storage).
155 const char* microdump_build_fingerprint_;
156 const char* microdump_product_info_;
125 }; 157 };
126 158
127 } // namespace google_breakpad 159 } // namespace google_breakpad
128 160
129 #endif // CLIENT_LINUX_HANDLER_MINIDUMP_DESCRIPTOR_H_ 161 #endif // CLIENT_LINUX_HANDLER_MINIDUMP_DESCRIPTOR_H_
OLDNEW
« no previous file with comments | « src/client/linux/handler/exception_handler.cc ('k') | src/client/linux/handler/minidump_descriptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698