// no limit.
static const off_t kMaxMinidumpFileSize = 1258291;
-uint64_t g_process_start_time = 0;
-pid_t g_pid = 0;
-ExceptionHandler* g_breakpad = NULL;
-
-// The following helper functions are for calculating uptime.
-
-// Converts a struct timeval to milliseconds.
-uint64_t timeval_to_ms(struct timeval *tv) {
- uint64_t ret = tv->tv_sec; // Avoid overflow by explicitly using a uint64_t.
- ret *= 1000;
- ret += tv->tv_usec / 1000;
- return ret;
-}
+} // namespace
-void SetProcessStartTime() {
+CrashReporterLinux::CrashReporterLinux()
+ : process_start_time_(0),
+ pid_(getpid()) {
// Set the base process start time value.
struct timeval tv;
- if (!gettimeofday(&tv, NULL))
- g_process_start_time = timeval_to_ms(&tv);
- else
- g_process_start_time = 0;
-}
-
-// Populates the passed in allocated string and its size with the distro of
-// the crashing process.
-// The passed string is expected to be at least kDistroSize bytes long.
-void PopulateDistro(char* distro, size_t* distro_len_param) {
- size_t distro_len = std::min(my_strlen(base::g_linux_distro), kDistroSize);
- memcpy(distro, base::g_linux_distro, distro_len);
- if (distro_len_param)
- *distro_len_param = distro_len;
-}
-
-#if defined(ADDRESS_SANITIZER)
-extern "C"
-void __asan_set_error_report_callback(void (*cb)(const char*));
-
-extern "C"
-void AsanLinuxBreakpadCallback(const char* report) {
- // Send minidump here.
- g_breakpad->SimulateSignalDelivery(SIGKILL);
-}
-#endif
-
-} // namespace
-
-CrashReporterLinux::CrashReporterLinux() {
- SetProcessStartTime();
- g_pid = getpid();
+ if (!gettimeofday(&tv, NULL)) {
+ uint64_t ret = tv.tv_sec;
+ ret *= 1000;
+ ret += tv.tv_usec / 1000;
+ process_start_time_ = ret;
+ }
// Make base::g_linux_distro work.
base::SetLinuxDistro(base::GetLinuxDistro());
bool skip_system_crash_handler) {
EnableCrashDumping();
-#if defined(ADDRESS_SANITIZER)
- // Register the callback for AddressSanitizer error reporting.
- __asan_set_error_report_callback(AsanLinuxBreakpadCallback);
-#endif
+ crash_keys_.SetKeyValue("prod", "Atom-Shell");
+ crash_keys_.SetKeyValue("ver", version.c_str());
+ upload_url_ = submit_url;
for (StringMap::const_iterator iter = upload_parameters_.begin();
iter != upload_parameters_.end(); ++iter)
PathService::Get(base::DIR_TEMP, &tmp_path);
base::FilePath dumps_path(tmp_path);
- DCHECK(!g_breakpad);
MinidumpDescriptor minidump_descriptor(dumps_path.value());
minidump_descriptor.set_size_limit(kMaxMinidumpFileSize);
- g_breakpad = new ExceptionHandler(
+ breakpad_.reset(new ExceptionHandler(
minidump_descriptor,
NULL,
CrashDone,
this,
true, // Install handlers.
- -1); // Server file descriptor. -1 for in-process.
+ -1));
}
bool CrashReporterLinux::CrashDone(const MinidumpDescriptor& minidump,
BreakpadInfo info = {0};
info.filename = minidump.path();
info.fd = minidump.fd();
-#if defined(ADDRESS_SANITIZER)
- google_breakpad::PageAllocator allocator;
- const size_t log_path_len = my_strlen(minidump.path());
- char* log_path = reinterpret_cast<char*>(allocator.Alloc(log_path_len + 1));
- my_memcpy(log_path, minidump.path(), log_path_len);
- my_memcpy(log_path + log_path_len - 4, ".log", 4);
- log_path[log_path_len] = '\0';
- info.log_filename = log_path;
-#endif
- // TODO(zcbenz): Set the correct process_type here.
info.distro = base::g_linux_distro;
info.distro_length = my_strlen(base::g_linux_distro);
info.upload = true;
- info.process_start_time = g_process_start_time;
+ info.process_start_time = self->process_start_time_;
info.oom_size = base::g_oom_size;
- info.pid = g_pid;
+ info.pid = self->pid_;
+ info.upload_url = self->upload_url_.c_str();
info.crash_keys = &self->crash_keys_;
HandleCrashDump(info);
return true;
namespace {
-const char kUploadURL[] = "https://clients2.google.com/cr/report";
-
// String buffer size to use to convert a uint64_t to string.
const size_t kUint64StringSize = 21;
const char g_quote_msg[] = "\"";
const char g_dashdash_msg[] = "--";
const char g_dump_msg[] = "upload_file_minidump\"; filename=\"dump\"";
-#if defined(ADDRESS_SANITIZER)
-const char g_log_msg[] = "upload_file_log\"; filename=\"log\"";
-#endif
const char g_content_type_msg[] = "Content-Type: application/octet-stream";
// MimeWriter manages an iovec for writing MIMEs to a file.
header,
post_file,
// TODO(zcbenz): Enabling custom upload url.
- kUploadURL,
+ info.upload_url,
"--timeout=10", // Set a timeout so we don't hang forever.
"--tries=1", // Don't retry if the upload fails.
"-O", // output reply to fd 3
LoadDataFromFile(allocator, info.filename, &dumpfd, &dump_data, &dump_size);
}
- // TODO(jcivelli): make log work when using FDs.
-#if defined(ADDRESS_SANITIZER)
- int logfd;
- size_t log_size;
- uint8_t* log_data;
- // Load the AddressSanitizer log into log_data.
- LoadDataFromFile(allocator, info.log_filename, &logfd, &log_data, &log_size);
-#endif
-
// We need to build a MIME block for uploading to the server. Since we are
// going to fork and run wget, it needs to be written to a temp file.
const int ufd = sys_open("/dev/urandom", O_RDONLY, 0);
MimeWriter writer(temp_file_fd, mime_boundary);
{
- // TODO(zcbenz): Set version and product_name from JS API.
- std::string product_name("Atom-Shell");
- std::string version("0.1.0");
-
- writer.AddBoundary();
- writer.AddPairString("prod", product_name.c_str());
- writer.AddBoundary();
- writer.AddPairString("ver", version.c_str());
writer.AddBoundary();
if (info.pid > 0) {
char pid_value_buf[kUint64StringSize];
}
writer.AddFileContents(g_dump_msg, dump_data, dump_size);
-#if defined(ADDRESS_SANITIZER)
- // Append a multipart boundary and the contents of the AddressSanitizer log.
- writer.AddBoundary();
- writer.AddFileContents(g_log_msg, log_data, log_size);
-#endif
writer.AddEnd();
writer.Flush();
// Helper process.
IGNORE_RET(sys_unlink(info.filename));
-#if defined(ADDRESS_SANITIZER)
- IGNORE_RET(sys_unlink(info.log_filename));
-#endif
IGNORE_RET(sys_unlink(temp_file));
sys__exit(0);
}