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

Side by Side Diff: chrome/browser/renderer_host/render_crash_handler_host_linux.cc

Issue 118096: Generate GUIDs for users who wish to upload crash reports. Include it in cra... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « chrome/browser/google_update_settings_linux.cc ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/renderer_host/render_crash_handler_host_linux.h" 5 #include "chrome/browser/renderer_host/render_crash_handler_host_linux.h"
6 6
7 #define __STDC_FORMAT_MACROS 7 #define __STDC_FORMAT_MACROS
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <inttypes.h> 9 #include <inttypes.h>
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // for writing the minidump as well as a file descriptor and a credentials 75 // for writing the minidump as well as a file descriptor and a credentials
76 // block so that they can't lie about their pid. 76 // block so that they can't lie about their pid.
77 77
78 // The length of the control message: 78 // The length of the control message:
79 static const unsigned kControlMsgSize = 79 static const unsigned kControlMsgSize =
80 CMSG_SPACE(sizeof(int)) + CMSG_SPACE(sizeof(struct ucred)); 80 CMSG_SPACE(sizeof(int)) + CMSG_SPACE(sizeof(struct ucred));
81 // The length of the regular payload: 81 // The length of the regular payload:
82 static const unsigned kCrashContextSize = 82 static const unsigned kCrashContextSize =
83 sizeof(google_breakpad::ExceptionHandler::CrashContext); 83 sizeof(google_breakpad::ExceptionHandler::CrashContext);
84 static const unsigned kMaxActiveURLSize = 1024; 84 static const unsigned kMaxActiveURLSize = 1024;
85 static const unsigned kGuidSize = 32; // 128 bits = 32 chars in hex.
85 86
86 struct msghdr msg = {0}; 87 struct msghdr msg = {0};
87 struct iovec iov; 88 struct iovec iov;
88 char context[kCrashContextSize + kMaxActiveURLSize]; 89 char context[kCrashContextSize + kMaxActiveURLSize + kGuidSize];
89 char control[kControlMsgSize]; 90 char control[kControlMsgSize];
90 iov.iov_base = context; 91 iov.iov_base = context;
91 iov.iov_len = sizeof(context); 92 iov.iov_len = sizeof(context);
92 msg.msg_iov = &iov; 93 msg.msg_iov = &iov;
93 msg.msg_iovlen = 1; 94 msg.msg_iovlen = 1;
94 msg.msg_control = control; 95 msg.msg_control = control;
95 msg.msg_controllen = kControlMsgSize; 96 msg.msg_controllen = kControlMsgSize;
96 97
97 const ssize_t n = HANDLE_EINTR(recvmsg(browser_socket_, &msg, 0)); 98 const ssize_t n = HANDLE_EINTR(recvmsg(browser_socket_, &msg, 0));
98 if (n < 1) { 99 if (n < 1) {
(...skipping 10 matching lines...) Expand all
109 msg.msg_flags & ~MSG_TRUNC) { 110 msg.msg_flags & ~MSG_TRUNC) {
110 LOG(ERROR) << "Received death signal message with the wrong size;" 111 LOG(ERROR) << "Received death signal message with the wrong size;"
111 << " n:" << n 112 << " n:" << n
112 << " msg.msg_controllen:" << msg.msg_controllen 113 << " msg.msg_controllen:" << msg.msg_controllen
113 << " msg.msg_flags:" << msg.msg_flags 114 << " msg.msg_flags:" << msg.msg_flags
114 << " kCrashContextSize:" << kCrashContextSize 115 << " kCrashContextSize:" << kCrashContextSize
115 << " kControlMsgSize:" << kControlMsgSize; 116 << " kControlMsgSize:" << kControlMsgSize;
116 return; 117 return;
117 } 118 }
118 119
119 // Anything in the message contents after the crash context is the crashing 120 // After the message contents we have the guid.
120 // URL. 121 const char* const guid = &context[kCrashContextSize];
121 const char* const crash_url = &context[kCrashContextSize]; 122
122 const unsigned crash_url_len = n - kCrashContextSize; 123 // Anything in the guid after the crash context is the crashing URL.
124 const char* const crash_url = &context[kCrashContextSize + kGuidSize];
125 const unsigned crash_url_len = n - kCrashContextSize - kGuidSize;
123 126
124 // Walk the control payload an extract the file descriptor and validated pid. 127 // Walk the control payload an extract the file descriptor and validated pid.
125 pid_t crashing_pid = -1; 128 pid_t crashing_pid = -1;
126 int signal_fd = -1; 129 int signal_fd = -1;
127 for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr; 130 for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr;
128 hdr = CMSG_NXTHDR(&msg, hdr)) { 131 hdr = CMSG_NXTHDR(&msg, hdr)) {
129 if (hdr->cmsg_level != SOL_SOCKET) 132 if (hdr->cmsg_level != SOL_SOCKET)
130 continue; 133 continue;
131 if (hdr->cmsg_type == SCM_RIGHTS) { 134 if (hdr->cmsg_type == SCM_RIGHTS) {
132 const unsigned len = hdr->cmsg_len - 135 const unsigned len = hdr->cmsg_len -
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Send the done signal to the renderer: it can exit now. 175 // Send the done signal to the renderer: it can exit now.
173 memset(&msg, 0, sizeof(msg)); 176 memset(&msg, 0, sizeof(msg));
174 iov.iov_base = const_cast<char*>("\x42"); 177 iov.iov_base = const_cast<char*>("\x42");
175 iov.iov_len = 1; 178 iov.iov_len = 1;
176 msg.msg_iov = &iov; 179 msg.msg_iov = &iov;
177 msg.msg_iovlen = 1; 180 msg.msg_iovlen = 1;
178 181
179 HANDLE_EINTR(sendmsg(signal_fd, &msg, MSG_DONTWAIT | MSG_NOSIGNAL)); 182 HANDLE_EINTR(sendmsg(signal_fd, &msg, MSG_DONTWAIT | MSG_NOSIGNAL));
180 HANDLE_EINTR(close(signal_fd)); 183 HANDLE_EINTR(close(signal_fd));
181 184
182 UploadCrashDump(minidump_filename.c_str(), crash_url, crash_url_len); 185 UploadCrashDump(minidump_filename.c_str(),
186 crash_url, crash_url_len,
187 guid, kGuidSize);
183 } 188 }
184 189
185 void RenderCrashHandlerHostLinux::WillDestroyCurrentMessageLoop() { 190 void RenderCrashHandlerHostLinux::WillDestroyCurrentMessageLoop() {
186 file_descriptor_watcher_.StopWatchingFileDescriptor(); 191 file_descriptor_watcher_.StopWatchingFileDescriptor();
187 } 192 }
OLDNEW
« no previous file with comments | « chrome/browser/google_update_settings_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698