Merge "crash_reporter: use libmetricscollectorservice for user crash event reports" am: f2b8cb9023

am: 6fa162fdf3

* commit '6fa162fdf3d8810e9ffd7642011e183a1cf55952':
  crash_reporter: use libmetricscollectorservice for user crash event reports
This commit is contained in:
Todd Poynor 2015-12-10 15:43:45 -08:00 committed by android-build-merger
commit 7223e71bcd
2 changed files with 20 additions and 35 deletions

View File

@ -43,11 +43,12 @@ LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension)
LOCAL_C_INCLUDES := $(crash_reporter_includes)
LOCAL_RTTI_FLAG := -frtti
LOCAL_SHARED_LIBRARIES := libchrome \
libbinder \
libbrillo \
libcutils \
libdbus \
libmetrics \
libpcrecpp
LOCAL_STATIC_LIBRARIES := libmetricscollectorservice
LOCAL_SRC_FILES := $(crash_reporter_src)
include $(BUILD_STATIC_LIBRARY)
@ -60,18 +61,19 @@ LOCAL_C_INCLUDES := $(crash_reporter_includes)
LOCAL_REQUIRED_MODULES := core2md \
crash_reporter_logs.conf \
crash_sender \
crash_server \
dbus-send
crash_server
LOCAL_INIT_RC := crash_reporter.rc
LOCAL_RTTI_FLAG := -frtti
LOCAL_SHARED_LIBRARIES := libchrome \
libbinder \
libbrillo \
libcutils \
libdbus \
libmetrics \
libpcrecpp
libpcrecpp \
libutils
LOCAL_SRC_FILES := crash_reporter.cc
LOCAL_STATIC_LIBRARIES := libcrash
LOCAL_STATIC_LIBRARIES := libcrash \
libmetricscollectorservice
include $(BUILD_EXECUTABLE)
# Crash sender script.
@ -140,7 +142,6 @@ LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension)
LOCAL_SHARED_LIBRARIES := libchrome \
libbrillo \
libcutils \
libdbus \
libpcrecpp
LOCAL_SRC_FILES := $(crash_reporter_test_src)
LOCAL_STATIC_LIBRARIES := libcrash libgmock

View File

@ -25,10 +25,13 @@
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <binder/IServiceManager.h>
#include <brillo/flag_helper.h>
#include <brillo/process.h>
#include <brillo/syslog_logging.h>
#include <metrics/metrics_collector_service_client.h>
#include <metrics/metrics_library.h>
#include <utils/String16.h>
#include "kernel_collector.h"
#include "kernel_warning_collector.h"
@ -37,8 +40,6 @@
#include "user_collector.h"
static const char kCrashCounterHistogram[] = "Logging.CrashCounter";
static const char kUserCrashSignal[] =
"org.chromium.CrashReporter.UserCrash";
static const char kKernelCrashDetected[] = "/var/run/kernel-crash-detected";
static const char kUncleanShutdownDetected[] =
"/var/run/unclean-shutdown-detected";
@ -56,6 +57,7 @@ enum CrashKinds {
static MetricsLibrary s_metrics_lib;
using android::brillo::metrics::IMetricsCollectorService;
using base::FilePath;
using base::StringPrintf;
@ -88,32 +90,14 @@ static void CountUncleanShutdown() {
static void CountUserCrash() {
SendCrashMetrics(kCrashKindUser, "user");
// Announce through D-Bus whenever a user crash happens. This is
// used by the metrics daemon to log active use time between
// crashes.
//
// We run in the background in case dbus-daemon itself is crashed
// and not responding. This allows us to not block and potentially
// deadlock on a dbus-daemon crash. If dbus-daemon crashes without
// restarting, each crash will fork off a lot of dbus-send
// processes. Such a system is in a unusable state and will need
// to be restarted anyway.
//
// Note: This will mean that the dbus-send process will become a zombie and
// reparent to init for reaping, but that's OK -- see above.
// Tell the metrics collector about the user crash, in order to log active
// use time between crashes.
MetricsCollectorServiceClient metrics_collector_service;
brillo::ProcessImpl dbus_send;
dbus_send.AddArg("/system/bin/dbus-send");
dbus_send.AddArg("--type=signal");
dbus_send.AddArg("--system");
dbus_send.AddArg("/");
dbus_send.AddArg(kUserCrashSignal);
bool status = dbus_send.Start();
if (status) {
dbus_send.Release();
} else {
PLOG(WARNING) << "Sending UserCrash DBus signal failed";
}
if (metrics_collector_service.Init())
metrics_collector_service.notifyUserCrash();
else
LOG(ERROR) << "Failed to send user crash notification to metrics_collector";
}