Add debugd GYP file
BUG=chromium:220003
TEST=Run emerge-<board> -v platform2 with and without platform2 USE
flag on a range of boards plus the host
Change-Id: If17cac7d8b0cada492c42c1c504a25df2b2630a1
Reviewed-on: https://gerrit.chromium.org/gerrit/57356
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Elly Jones <ellyjones@chromium.org>
Commit-Queue: Liam McLoughlin <lmcloughlin@chromium.org>
Tested-by: Liam McLoughlin <lmcloughlin@chromium.org>
diff --git a/debugd.gyp b/debugd.gyp
new file mode 100644
index 0000000..38fe234
--- /dev/null
+++ b/debugd.gyp
@@ -0,0 +1,163 @@
+{
+ 'target_defaults': {
+ 'dependencies': [
+ '../libchromeos/libchromeos-<(libbase_ver).gyp:libchromeos-<(libbase_ver)',
+ ],
+ 'variables': {
+ 'deps': [
+ 'dbus-1',
+ 'dbus-c++-1',
+ 'glib-2.0',
+ 'libpcrecpp',
+ 'libchrome-<(libbase_ver)',
+ ],
+ },
+ "cflags": [
+ '-fvisibility=hidden',
+ ],
+ },
+ 'targets': [
+ {
+ 'target_name': 'debugd-adaptors',
+ 'type': 'none',
+ 'variables': {
+ 'xml2cpp_type': 'adaptor',
+ 'xml2cpp_out_dir': 'include/adaptors',
+ },
+ 'sources': [
+ 'share/org.chromium.debugd.xml',
+ ],
+ 'includes': ['../common-mk/xml2cpp.gypi'],
+ },
+ {
+ 'target_name': 'debugd-proxies',
+ 'type': 'none',
+ 'variables': {
+ 'xml2cpp_type': 'proxy',
+ 'xml2cpp_in_dir': '<(sysroot)/usr/share/dbus-1/interfaces',
+ 'xml2cpp_out_dir': 'include/proxies',
+ },
+ 'sources': [
+ '<(xml2cpp_in_dir)/org.chromium.flimflam.Device.xml',
+ '<(xml2cpp_in_dir)/org.chromium.flimflam.IPConfig.xml',
+ '<(xml2cpp_in_dir)/org.chromium.flimflam.Manager.xml',
+ '<(xml2cpp_in_dir)/org.chromium.flimflam.Service.xml',
+ '<(xml2cpp_in_dir)/org.freedesktop.DBus.Properties.xml',
+ '<(xml2cpp_in_dir)/org.freedesktop.ModemManager.xml',
+ '<(xml2cpp_in_dir)/org.freedesktop.ModemManager1.xml',
+ '<(xml2cpp_in_dir)/org.freedesktop.ModemManager.Modem.xml',
+ '<(xml2cpp_in_dir)/org.freedesktop.ModemManager.Modem.Simple.xml',
+ ],
+ 'includes': ['../common-mk/xml2cpp.gypi'],
+ },
+ {
+ 'target_name': 'libdebugd',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'debugd-proxies',
+ 'debugd-adaptors',
+ ],
+ 'link_settings': {
+ 'libraries': [
+ '-lminijail',
+ ],
+ },
+ 'sources': [
+ 'src/anonymizer_tool.cc',
+ 'src/cpu_info_parser.cc',
+ 'src/debug_daemon.cc',
+ 'src/debug_logs_tool.cc',
+ 'src/debug_mode_tool.cc',
+ 'src/example_tool.cc',
+ 'src/icmp_tool.cc',
+ 'src/log_tool.cc',
+ 'src/memory_tool.cc',
+ 'src/modem_status_tool.cc',
+ 'src/netif_tool.cc',
+ 'src/network_status_tool.cc',
+ 'src/packet_capture_tool.cc',
+ 'src/ping_tool.cc',
+ 'src/perf_tool.cc',
+ 'src/process_with_id.cc',
+ 'src/process_with_output.cc',
+ 'src/random_selector.cc',
+ 'src/route_tool.cc',
+ 'src/sandboxed_process.cc',
+ 'src/storage_tool.cc',
+ 'src/subprocess_tool.cc',
+ 'src/systrace_tool.cc',
+ 'src/tracepath_tool.cc',
+ ],
+ },
+ {
+ 'target_name': 'debugd',
+ 'type': 'executable',
+ 'dependencies': ['libdebugd'],
+ 'sources': [
+ 'src/main.cc',
+ ]
+ },
+ {
+ 'target_name': 'capture_packets',
+ 'type': 'executable',
+ 'libraries': [
+ '-lminijail',
+ '-lpcap',
+ ],
+ 'sources': [
+ 'src/helpers/capture_packets.cc',
+ ]
+ },
+ {
+ 'target_name': 'icmp',
+ 'type': 'executable',
+ 'sources': [
+ 'src/helpers/icmp.cc',
+ ]
+ },
+ {
+ 'target_name': 'netif',
+ 'type': 'executable',
+ 'dependencies': ['debugd-proxies'],
+ 'sources': [
+ 'src/helpers/netif.cc',
+ ]
+ },
+ {
+ 'target_name': 'modem_status',
+ 'type': 'executable',
+ 'dependencies': ['debugd-proxies'],
+ 'sources': [
+ 'src/helpers/modem_status.cc',
+ ]
+ },
+ {
+ 'target_name': 'network_status',
+ 'type': 'executable',
+ 'dependencies': ['debugd-proxies'],
+ 'sources': [
+ 'src/helpers/network_status.cc',
+ ]
+ },
+ ],
+ 'conditions': [
+ ['USE_test == 1', {
+ 'targets': [
+ {
+ 'target_name': 'debugd_testrunner',
+ 'type': 'executable',
+ 'dependencies': ['libdebugd'],
+ 'includes': ['../common-mk/common_test.gypi'],
+ 'sources': [
+ 'src/anonymizer_tool_test.cc',
+ 'src/log_tool_test.cc',
+ 'src/modem_status_tool_test.cc',
+ 'src/process_with_id_test.cc',
+ 'src/random_selector_test.cc',
+ 'src/testrunner.cc',
+ ]
+ },
+ ],
+ }],
+ ],
+}
diff --git a/share/debugd.conf b/share/debugd.conf
new file mode 100644
index 0000000..e81fe4a
--- /dev/null
+++ b/share/debugd.conf
@@ -0,0 +1,30 @@
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description "Chromium OS debug daemon"
+author "chromium-os-dev@chromium.org"
+
+start on started ui
+stop on stopping ui or starting halt or starting reboot
+respawn
+
+pre-start script
+ TRACING=/sys/kernel/debug/tracing
+ # NB: check for tracing dir in case the kernel config changes
+ if [ -d "${TRACING}" ]; then
+ # enable debugfs-access write access for systrace helper
+ for file in buffer_size_kb set_event trace trace_clock trace_marker \
+ tracing_on; do
+ chgrp debugfs-access ${TRACING}/${file} && chmod g+w ${TRACING}/${file}
+ done
+ fi
+ # NB: only on exynos5
+ MALI_HWC_ENABLE=/sys/devices/platform/mali.0/hwc_enable
+ if [ -f "${MALI_HWC_ENABLE}" ]; then
+ chgrp debugd ${MALI_HWC_ENABLE} && chmod g+w ${MALI_HWC_ENABLE}
+ fi
+end script
+
+exec /sbin/debugd
+
diff --git a/share/org.chromium.debugd.conf b/share/org.chromium.debugd.conf
new file mode 100644
index 0000000..f0c30d0
--- /dev/null
+++ b/share/org.chromium.debugd.conf
@@ -0,0 +1,19 @@
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy context="default">
+ <allow send_destination="org.chromium.debugd"/>
+ </policy>
+
+ <policy user="debugd">
+ <allow own="org.chromium.debugd"/>
+ </policy>
+
+ <policy user="root">
+ <allow own="org.chromium.debugd"/>
+ </policy>
+
+ <limit name="max_replies_per_connection">512</limit>
+</busconfig>
+
diff --git a/share/perf_commands/arm.txt b/share/perf_commands/arm.txt
new file mode 100644
index 0000000..1feb545
--- /dev/null
+++ b/share/perf_commands/arm.txt
@@ -0,0 +1,3 @@
+90 perf record -a -e cycles -c 1000003
+5 perf record -a -e cycles -g -c 4000037
+5 perf record -a -e cycles -b -c 1000003
diff --git a/share/perf_commands/core.txt b/share/perf_commands/core.txt
new file mode 100644
index 0000000..0c9d7f1
--- /dev/null
+++ b/share/perf_commands/core.txt
@@ -0,0 +1,5 @@
+80 perf record -a -e cycles -c 1000003
+5 perf record -a -e cycles -g -c 4000037
+5 perf record -a -e cycles -b -c 1000003
+5 perf record -a -e iTLB-misses -c 100003
+5 perf record -a -e dTLB-misses -c 100003
diff --git a/share/perf_commands/unknown.txt b/share/perf_commands/unknown.txt
new file mode 100644
index 0000000..9ed561d
--- /dev/null
+++ b/share/perf_commands/unknown.txt
@@ -0,0 +1 @@
+1 perf record -a -e cycles -c 1000003
diff --git a/share/trace_marker-test.conf b/share/trace_marker-test.conf
new file mode 100644
index 0000000..b4c6e19
--- /dev/null
+++ b/share/trace_marker-test.conf
@@ -0,0 +1,20 @@
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description "Chromium OS debug daemon trace_marker helper"
+author "chromium-os-dev@chromium.org"
+
+# This lets us log trace events to the kernel trace buffer on test images
+# where non-Chrome libraries can do logging to the trace_marker file.
+# We need this to integrate third-party tracing into combined Chrome
+# and system traces.
+
+#for_test start on starting debugd
+stop on stopping ui or starting halt or starting reboot
+respawn
+
+pre-start script
+ chmod a+w /sys/kernel/debug/tracing/trace_marker
+end script
+
diff --git a/src/helpers/capture_utility_test.sh b/src/helpers/capture_utility_test.sh
old mode 100644
new mode 100755