Merge "crash_reporter: use libmetricscollectorservice for user crash event reports"
am: f2b8cb9023
* commit 'f2b8cb9023c3f41f3655e8b34a5bee40ee70b948':
crash_reporter: use libmetricscollectorservice for user crash event reports
This commit is contained in:
commit
6fa162fdf3
2 changed files with 20 additions and 35 deletions
|
|
@ -43,11 +43,12 @@ LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension)
|
||||||
LOCAL_C_INCLUDES := $(crash_reporter_includes)
|
LOCAL_C_INCLUDES := $(crash_reporter_includes)
|
||||||
LOCAL_RTTI_FLAG := -frtti
|
LOCAL_RTTI_FLAG := -frtti
|
||||||
LOCAL_SHARED_LIBRARIES := libchrome \
|
LOCAL_SHARED_LIBRARIES := libchrome \
|
||||||
|
libbinder \
|
||||||
libbrillo \
|
libbrillo \
|
||||||
libcutils \
|
libcutils \
|
||||||
libdbus \
|
|
||||||
libmetrics \
|
libmetrics \
|
||||||
libpcrecpp
|
libpcrecpp
|
||||||
|
LOCAL_STATIC_LIBRARIES := libmetricscollectorservice
|
||||||
LOCAL_SRC_FILES := $(crash_reporter_src)
|
LOCAL_SRC_FILES := $(crash_reporter_src)
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
|
@ -60,18 +61,19 @@ LOCAL_C_INCLUDES := $(crash_reporter_includes)
|
||||||
LOCAL_REQUIRED_MODULES := core2md \
|
LOCAL_REQUIRED_MODULES := core2md \
|
||||||
crash_reporter_logs.conf \
|
crash_reporter_logs.conf \
|
||||||
crash_sender \
|
crash_sender \
|
||||||
crash_server \
|
crash_server
|
||||||
dbus-send
|
|
||||||
LOCAL_INIT_RC := crash_reporter.rc
|
LOCAL_INIT_RC := crash_reporter.rc
|
||||||
LOCAL_RTTI_FLAG := -frtti
|
LOCAL_RTTI_FLAG := -frtti
|
||||||
LOCAL_SHARED_LIBRARIES := libchrome \
|
LOCAL_SHARED_LIBRARIES := libchrome \
|
||||||
|
libbinder \
|
||||||
libbrillo \
|
libbrillo \
|
||||||
libcutils \
|
libcutils \
|
||||||
libdbus \
|
|
||||||
libmetrics \
|
libmetrics \
|
||||||
libpcrecpp
|
libpcrecpp \
|
||||||
|
libutils
|
||||||
LOCAL_SRC_FILES := crash_reporter.cc
|
LOCAL_SRC_FILES := crash_reporter.cc
|
||||||
LOCAL_STATIC_LIBRARIES := libcrash
|
LOCAL_STATIC_LIBRARIES := libcrash \
|
||||||
|
libmetricscollectorservice
|
||||||
include $(BUILD_EXECUTABLE)
|
include $(BUILD_EXECUTABLE)
|
||||||
|
|
||||||
# Crash sender script.
|
# Crash sender script.
|
||||||
|
|
@ -140,7 +142,6 @@ LOCAL_CPP_EXTENSION := $(crash_reporter_cpp_extension)
|
||||||
LOCAL_SHARED_LIBRARIES := libchrome \
|
LOCAL_SHARED_LIBRARIES := libchrome \
|
||||||
libbrillo \
|
libbrillo \
|
||||||
libcutils \
|
libcutils \
|
||||||
libdbus \
|
|
||||||
libpcrecpp
|
libpcrecpp
|
||||||
LOCAL_SRC_FILES := $(crash_reporter_test_src)
|
LOCAL_SRC_FILES := $(crash_reporter_test_src)
|
||||||
LOCAL_STATIC_LIBRARIES := libcrash libgmock
|
LOCAL_STATIC_LIBRARIES := libcrash libgmock
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,13 @@
|
||||||
#include <base/strings/string_split.h>
|
#include <base/strings/string_split.h>
|
||||||
#include <base/strings/string_util.h>
|
#include <base/strings/string_util.h>
|
||||||
#include <base/strings/stringprintf.h>
|
#include <base/strings/stringprintf.h>
|
||||||
|
#include <binder/IServiceManager.h>
|
||||||
#include <brillo/flag_helper.h>
|
#include <brillo/flag_helper.h>
|
||||||
#include <brillo/process.h>
|
|
||||||
#include <brillo/syslog_logging.h>
|
#include <brillo/syslog_logging.h>
|
||||||
|
#include <metrics/metrics_collector_service_client.h>
|
||||||
#include <metrics/metrics_library.h>
|
#include <metrics/metrics_library.h>
|
||||||
|
#include <utils/String16.h>
|
||||||
|
|
||||||
|
|
||||||
#include "kernel_collector.h"
|
#include "kernel_collector.h"
|
||||||
#include "kernel_warning_collector.h"
|
#include "kernel_warning_collector.h"
|
||||||
|
|
@ -37,8 +40,6 @@
|
||||||
#include "user_collector.h"
|
#include "user_collector.h"
|
||||||
|
|
||||||
static const char kCrashCounterHistogram[] = "Logging.CrashCounter";
|
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 kKernelCrashDetected[] = "/var/run/kernel-crash-detected";
|
||||||
static const char kUncleanShutdownDetected[] =
|
static const char kUncleanShutdownDetected[] =
|
||||||
"/var/run/unclean-shutdown-detected";
|
"/var/run/unclean-shutdown-detected";
|
||||||
|
|
@ -56,6 +57,7 @@ enum CrashKinds {
|
||||||
|
|
||||||
static MetricsLibrary s_metrics_lib;
|
static MetricsLibrary s_metrics_lib;
|
||||||
|
|
||||||
|
using android::brillo::metrics::IMetricsCollectorService;
|
||||||
using base::FilePath;
|
using base::FilePath;
|
||||||
using base::StringPrintf;
|
using base::StringPrintf;
|
||||||
|
|
||||||
|
|
@ -88,32 +90,14 @@ static void CountUncleanShutdown() {
|
||||||
|
|
||||||
static void CountUserCrash() {
|
static void CountUserCrash() {
|
||||||
SendCrashMetrics(kCrashKindUser, "user");
|
SendCrashMetrics(kCrashKindUser, "user");
|
||||||
// Announce through D-Bus whenever a user crash happens. This is
|
// Tell the metrics collector about the user crash, in order to log active
|
||||||
// used by the metrics daemon to log active use time between
|
// use time between crashes.
|
||||||
// crashes.
|
MetricsCollectorServiceClient metrics_collector_service;
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
brillo::ProcessImpl dbus_send;
|
if (metrics_collector_service.Init())
|
||||||
dbus_send.AddArg("/system/bin/dbus-send");
|
metrics_collector_service.notifyUserCrash();
|
||||||
dbus_send.AddArg("--type=signal");
|
else
|
||||||
dbus_send.AddArg("--system");
|
LOG(ERROR) << "Failed to send user crash notification to metrics_collector";
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue