Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 5 | #include "debugd/src/log_tool.h" |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 6 | |
Ben Chan | 8e9f6d0 | 2017-09-26 23:04:21 -0700 | [diff] [blame] | 7 | #include <memory> |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
Ben Chan | ab93abf | 2017-01-24 13:32:51 -0800 | [diff] [blame] | 10 | #include <base/base64.h> |
Ben Chan | cd8fda4 | 2014-09-05 08:21:06 -0700 | [diff] [blame] | 11 | #include <base/files/file_util.h> |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 12 | #include <base/json/json_writer.h> |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 13 | #include <base/logging.h> |
Ben Chan | 9953a59 | 2014-02-05 23:32:00 -0800 | [diff] [blame] | 14 | #include <base/strings/string_split.h> |
| 15 | #include <base/strings/string_util.h> |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 16 | #include <base/values.h> |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 17 | |
Rebecca Silberstein | e78af40 | 2014-10-02 10:55:04 -0700 | [diff] [blame] | 18 | #include <chromeos/dbus/service_constants.h> |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 19 | #include <shill/dbus-proxies.h> |
Rebecca Silberstein | e78af40 | 2014-10-02 10:55:04 -0700 | [diff] [blame] | 20 | |
Ben Chan | af12586 | 2017-02-08 23:11:18 -0800 | [diff] [blame] | 21 | #include "debugd/src/constants.h" |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 22 | #include "debugd/src/process_with_output.h" |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 23 | |
| 24 | namespace debugd { |
| 25 | |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 26 | using std::string; |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 27 | |
Eric Caruso | 96d03d3 | 2017-04-25 18:01:17 -0700 | [diff] [blame] | 28 | using Strings = std::vector<string>; |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 29 | |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 30 | namespace { |
| 31 | |
Ben Chan | af12586 | 2017-02-08 23:11:18 -0800 | [diff] [blame] | 32 | const char kRoot[] = "root"; |
| 33 | const char kShell[] = "/bin/sh"; |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 34 | |
| 35 | // Minimum time in seconds needed to allow shill to test active connections. |
| 36 | const int kConnectionTesterTimeoutSeconds = 5; |
Ben Chan | f6cd93a | 2012-10-14 19:37:00 -0700 | [diff] [blame] | 37 | |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 38 | struct Log { |
| 39 | const char *name; |
| 40 | const char *command; |
| 41 | const char *user; |
| 42 | const char *group; |
Ricky Zhou | 4c473ca | 2016-06-21 17:46:58 -0700 | [diff] [blame] | 43 | const char *size_cap; // passed as arg to 'tail' |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 44 | }; |
| 45 | |
Eric Caruso | a879fd9 | 2017-10-11 12:57:10 -0700 | [diff] [blame] | 46 | #define CMD_KERNEL_MODULE_PARAMS(module_name) \ |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 47 | "cd /sys/module/" #module_name "/parameters 2>/dev/null && grep -sH ^ *" |
Eric Caruso | a879fd9 | 2017-10-11 12:57:10 -0700 | [diff] [blame] | 48 | |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 49 | const Log kCommandLogs[] = { |
Mike Frysinger | c3e835a | 2017-01-06 04:09:34 -0500 | [diff] [blame] | 50 | { "CLIENT_ID", "/usr/bin/metrics_client -i"}, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 51 | { "LOGDATE", "/bin/date" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 52 | { "atrus_logs", "cat /var/log/atrus.log 2>/dev/null" }, |
| 53 | { "authpolicy", "cat /var/log/authpolicy.log" }, |
| 54 | { "bios_info", "cat /var/log/bios_info.txt" }, |
Vadim Bendebury | 64aeeed | 2013-09-16 13:16:49 -0700 | [diff] [blame] | 55 | { "bios_log", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 56 | "cat /sys/firmware/log " |
| 57 | "/proc/device-tree/chosen/ap-console-buffer 2>/dev/null" }, |
| 58 | { "bios_times", "cat /var/log/bios_times.txt" }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 59 | { "board-specific", |
Thiemo Nagel | a269ad2 | 2014-11-27 17:13:01 +0100 | [diff] [blame] | 60 | "/usr/share/userfeedback/scripts/get_board_specific_info" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 61 | { "buddyinfo", "cat /proc/buddyinfo" }, |
Daisuke Nojiri | 3d832ee | 2017-02-17 14:21:28 -0800 | [diff] [blame] | 62 | { "cbi_info", "/usr/share/userfeedback/scripts/cbi_info", kRoot, }, |
Olof Johansson | e5d0fd3 | 2016-01-29 14:40:34 -0800 | [diff] [blame] | 63 | { "cheets_log", "/usr/bin/collect-cheets-logs 2>&1" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 64 | { "clobber.log", "cat /var/log/clobber.log 2>/dev/null" }, |
| 65 | { "clobber-state.log", "cat /var/log/clobber-state.log 2>/dev/null" }, |
| 66 | { "chrome_system_log", "cat /var/log/chrome/chrome" }, |
Mike Frysinger | 32cdf3e | 2017-08-14 18:17:06 -0400 | [diff] [blame] | 67 | // There might be more than one record, so grab them all. |
| 68 | // Plus, for <linux-3.19, it's named "console-ramoops", but for newer |
| 69 | // versions, it's named "console-ramoops-#". |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 70 | { "console-ramoops", "cat /sys/fs/pstore/console-ramoops* 2>/dev/null" }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 71 | { "cpu", "/usr/bin/uname -p" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 72 | { "cpuinfo", "cat /proc/cpuinfo" }, |
| 73 | { "cr50_version", "cat /var/cache/cr50-version" }, |
Eric Caruso | 57333f1 | 2015-09-08 12:50:32 -0700 | [diff] [blame] | 74 | { "cros_ec", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 75 | "cat /var/log/cros_ec.previous /var/log/cros_ec.log 2>/dev/null" }, |
Nicolas Boichat | 083795f | 2016-08-16 11:16:49 +0200 | [diff] [blame] | 76 | { "cros_ec_panicinfo", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 77 | "cat /sys/kernel/debug/cros_ec/panicinfo 2>/dev/null", |
Nicolas Boichat | d51092b | 2016-09-01 10:36:46 +0800 | [diff] [blame] | 78 | SandboxedProcess::kDefaultUser, |
| 79 | kDebugfsGroup |
| 80 | }, |
Shawn Nematbakhsh | 6081373 | 2017-07-13 10:46:23 -0700 | [diff] [blame] | 81 | { "cros_ec_pdinfo", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 82 | "cat /sys/kernel/debug/cros_ec/pdinfo 2>/dev/null", |
Shawn Nematbakhsh | 6081373 | 2017-07-13 10:46:23 -0700 | [diff] [blame] | 83 | SandboxedProcess::kDefaultUser, |
| 84 | kDebugfsGroup |
| 85 | }, |
Vincent Palatin | e358804 | 2018-04-04 17:02:38 +0200 | [diff] [blame] | 86 | { "cros_fp", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 87 | "cat /var/log/cros_fp.previous /var/log/cros_fp.log 2>/dev/null" }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 88 | { "dmesg", "/bin/dmesg" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 89 | { "ec_info", "cat /var/log/ec_info.txt" }, |
Miguel Casas | 8d4e54f | 2018-03-29 09:42:52 -0400 | [diff] [blame] | 90 | // The sed command replaces the EDID serial number (4 bytes at position 12) |
| 91 | // with zeroes. See https://en.wikipedia.org/wiki/EDID#EDID_1.4_data_format. |
| 92 | { "edid-decode", |
| 93 | "for f in /sys/class/drm/card0-*/edid; do" |
| 94 | "echo \"----------- ${f}\"; " |
| 95 | "sed -E 's/.{4}/\x00\x00\x00\x00/4' \"${f}\" | edid-decode;" |
| 96 | "done" |
| 97 | }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 98 | { "eventlog", "cat /var/log/eventlog.txt" }, |
Elly Fong-Jones | 215b562 | 2013-03-20 14:32:18 -0400 | [diff] [blame] | 99 | { |
| 100 | "exynos_gem_objects", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 101 | "cat /sys/kernel/debug/dri/0/exynos_gem_objects 2>/dev/null", |
Elly Fong-Jones | 215b562 | 2013-03-20 14:32:18 -0400 | [diff] [blame] | 102 | SandboxedProcess::kDefaultUser, |
| 103 | kDebugfsGroup |
| 104 | }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 105 | { "font_info", "/usr/share/userfeedback/scripts/font_info" }, |
Daisuke Nojiri | debede0e | 2017-02-17 14:21:28 -0800 | [diff] [blame] | 106 | { "sensor_info", "/usr/share/userfeedback/scripts/sensor_info" }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 107 | { "hardware_class", "/usr/bin/crossystem hwid" }, |
| 108 | { "hostname", "/bin/hostname" }, |
| 109 | { "hw_platform", "/usr/bin/uname -i" }, |
Elly Fong-Jones | 215b562 | 2013-03-20 14:32:18 -0400 | [diff] [blame] | 110 | { |
| 111 | "i915_gem_gtt", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 112 | "cat /sys/kernel/debug/dri/0/i915_gem_gtt 2>/dev/null", |
Elly Fong-Jones | 215b562 | 2013-03-20 14:32:18 -0400 | [diff] [blame] | 113 | SandboxedProcess::kDefaultUser, |
| 114 | kDebugfsGroup |
| 115 | }, |
| 116 | { |
| 117 | "i915_gem_objects", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 118 | "cat /sys/kernel/debug/dri/0/i915_gem_objects 2>/dev/null", |
Elly Fong-Jones | 215b562 | 2013-03-20 14:32:18 -0400 | [diff] [blame] | 119 | SandboxedProcess::kDefaultUser, |
| 120 | kDebugfsGroup |
| 121 | }, |
| 122 | { |
| 123 | "i915_error_state", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 124 | "/usr/bin/xz -c /sys/kernel/debug/dri/0/i915_error_state 2>/dev/null", |
Elly Fong-Jones | 215b562 | 2013-03-20 14:32:18 -0400 | [diff] [blame] | 125 | SandboxedProcess::kDefaultUser, |
| 126 | kDebugfsGroup, |
| 127 | }, |
Daniel Erat | 982ab4b | 2014-04-09 07:32:38 -0700 | [diff] [blame] | 128 | { "ifconfig", "/bin/ifconfig -a" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 129 | { "input_devices", "cat /proc/bus/input/devices" }, |
Eric Caruso | b1820c0 | 2017-08-24 15:39:56 -0700 | [diff] [blame] | 130 | // Information about the wiphy device, such as current channel. |
| 131 | { "iw_dev", "/usr/sbin/iw dev" }, |
| 132 | // Hardware capabilities of the wiphy device. |
| 133 | { "iw_list", "/usr/sbin/iw list" }, |
Eric Caruso | a879fd9 | 2017-10-11 12:57:10 -0700 | [diff] [blame] | 134 | #if USE_IWLWIFI_DUMP |
| 135 | { "iwlmvm_module_params", CMD_KERNEL_MODULE_PARAMS(iwlmvm) }, |
| 136 | { "iwlwifi_module_params", CMD_KERNEL_MODULE_PARAMS(iwlwifi) }, |
| 137 | #endif // USE_IWLWIFI_DUMP |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 138 | { "kernel-crashes", "cat /var/spool/crash/kernel.*.kcrash 2>/dev/null" }, |
| 139 | { "logcat", |
| 140 | "/usr/sbin/android-sh -c '/system/bin/logcat -d'", |
Kevin Cernekee | 143e2af | 2018-03-20 13:28:20 -0700 | [diff] [blame] | 141 | kRoot, |
| 142 | kRoot, |
| 143 | }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 144 | { "lsmod", "lsmod" }, |
| 145 | { "lspci", "/usr/sbin/lspci" }, |
Simon Que | 41c88b5 | 2017-06-19 14:05:07 -0400 | [diff] [blame] | 146 | { "lsusb", "lsusb && lsusb -t" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 147 | { "mali_memory", "cat /sys/class/misc/mali0/device/memory 2>/dev/null" }, |
Luigi Semenzato | 7f00dfb | 2018-06-26 11:34:02 -0700 | [diff] [blame] | 148 | { "memd.parameters", "cat /var/log/memd/memd.parameters 2>/dev/null" }, |
| 149 | { "memd clips", "cat /var/log/memd/memd.clip* 2>/dev/null" }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 150 | { "meminfo", "cat /proc/meminfo" }, |
Mike Frysinger | 8fd2eee | 2017-11-03 14:35:26 -0400 | [diff] [blame] | 151 | { |
| 152 | "memory_spd_info", |
| 153 | // mosys may use 'i2c-dev', which may not be loaded yet. |
| 154 | "modprobe i2c-dev 2>/dev/null && " |
| 155 | "mosys -l memory spd print all 2>/dev/null", |
| 156 | kRoot, |
| 157 | kDebugfsGroup, |
| 158 | }, |
Simon Que | cb63b9c | 2017-06-19 14:53:31 -0400 | [diff] [blame] | 159 | // The sed command finds the EDID blob (starting the line after "value:") and |
| 160 | // replaces the serial number with all zeroes. |
| 161 | // |
| 162 | // The EDID is printed as a hex dump over several lines, each line containing |
| 163 | // the contents of 16 bytes. The first 16 bytes are broken down as follows: |
| 164 | // uint64_t fixed_pattern; // Always 00 FF FF FF FF FF FF 00. |
| 165 | // uint16_t manufacturer_id; // Manufacturer ID, encoded as PNP IDs. |
| 166 | // uint16_t product_code; // Manufacturer product code, little-endian. |
| 167 | // uint32_t serial_number; // Serial number, little-endian. |
| 168 | // Source: https://en.wikipedia.org/wiki/EDID#EDID_1.3_data_format |
| 169 | // |
| 170 | // The subsequent substitution command looks for the fixed pattern followed by |
| 171 | // two 32-bit fields (manufacturer + product, serial number). It replaces the |
| 172 | // latter field with 8 bytes of zeroes. |
| 173 | // |
| 174 | // TODO(crbug.com/731133): Remove the sed command once modetest itself can |
| 175 | // remove serial numbers. |
| 176 | { |
| 177 | "modetest", |
| 178 | "(modetest; modetest -M evdi; modetest -M udl) | " |
| 179 | "sed -E '/EDID/ {:a;n;/value:/!ba;n;" |
| 180 | "s/(00f{12}00)([0-9a-f]{8})([0-9a-f]{8})/\\1\\200000000/}'", |
| 181 | kRoot, |
| 182 | kRoot, |
| 183 | }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 184 | { "mount-encrypted", "cat /var/log/mount-encrypted.log" }, |
| 185 | { "mountinfo", "cat /proc/1/mountinfo" }, |
Nicolas Boichat | 0230b0b | 2017-08-17 11:20:19 +0800 | [diff] [blame] | 186 | { "netlog", "/usr/share/userfeedback/scripts/getmsgs /var/log/net.log" }, |
Kevin Cernekee | 143e2af | 2018-03-20 13:28:20 -0700 | [diff] [blame] | 187 | // --processes requires root. |
| 188 | { "netstat", "/sbin/ss --all --query inet --numeric --processes", |
| 189 | kRoot, |
| 190 | kRoot, |
| 191 | }, |
henryhsu | fa6daa1 | 2014-09-24 13:26:30 +0800 | [diff] [blame] | 192 | { |
| 193 | "nvmap_iovmm", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 194 | "cat /sys/kernel/debug/nvmap/iovmm/allocations 2>/dev/null", |
henryhsu | fa6daa1 | 2014-09-24 13:26:30 +0800 | [diff] [blame] | 195 | SandboxedProcess::kDefaultUser, |
| 196 | kDebugfsGroup, |
| 197 | }, |
Todd Broch | a0c1376 | 2018-05-03 11:31:25 -0700 | [diff] [blame] | 198 | { "oemdata", "/usr/share/cros/oemdata.sh", kRoot, kRoot, }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 199 | { "pagetypeinfo", "cat /proc/pagetypeinfo" }, |
Mike Frysinger | 8fd2eee | 2017-11-03 14:35:26 -0400 | [diff] [blame] | 200 | { |
| 201 | "platform_info", |
| 202 | // mosys may use 'i2c-dev', which may not be loaded yet. |
| 203 | "modprobe i2c-dev 2>/dev/null && " |
| 204 | "for param in " |
| 205 | "vendor " |
| 206 | "name " |
| 207 | "version " |
| 208 | "family " |
| 209 | "model " |
| 210 | "sku " |
| 211 | "customization " |
| 212 | "; do " |
| 213 | "mosys -l platform \"${param}\" 2>/dev/null; " |
| 214 | "done", |
| 215 | kRoot, |
| 216 | kDebugfsGroup, |
| 217 | }, |
Daniel Erat | 9b58b6d | 2013-04-30 14:58:56 -0700 | [diff] [blame] | 218 | { "power_supply_info", "/usr/bin/power_supply_info" }, |
Daniel Erat | d8b8499 | 2017-03-13 17:30:00 -0600 | [diff] [blame] | 219 | { "power_supply_sysfs", "/usr/bin/print_sysfs_power_supply_data" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 220 | { "powerd.LATEST", "cat /var/log/power_manager/powerd.LATEST" }, |
| 221 | { "powerd.PREVIOUS", "cat /var/log/power_manager/powerd.PREVIOUS" }, |
| 222 | { "powerd.out", "cat /var/log/powerd.out" }, |
| 223 | { "powerwash_count", "cat /var/log/powerwash_count 2>/dev/null" }, |
Mattias Nissler | 887dce2 | 2017-07-03 14:44:35 +0200 | [diff] [blame] | 224 | // Changed from 'ps ux' to 'ps aux' since we're running as debugd, |
| 225 | // not chronos. |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 226 | { "ps", "/bin/ps aux" }, |
yusukes | 34171ba | 2017-04-27 15:46:01 -0700 | [diff] [blame] | 227 | // /proc/slabinfo is owned by root and has 0400 permission. |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 228 | { "slabinfo", "cat /proc/slabinfo", kRoot, kRoot, }, |
| 229 | { "storage_info", "cat /var/log/storage_info.txt" }, |
Alexis Savery | bbb8513 | 2018-05-18 17:41:10 -0700 | [diff] [blame] | 230 | { "swap_info", |
| 231 | "/usr/share/cros/init/swap.sh status 2>/dev/null", |
| 232 | SandboxedProcess::kDefaultUser, |
| 233 | kDebugfsGroup |
| 234 | }, |
Nicolas Boichat | 0230b0b | 2017-08-17 11:20:19 +0800 | [diff] [blame] | 235 | { "syslog", "/usr/share/userfeedback/scripts/getmsgs /var/log/messages" }, |
Brandon Mayer | e24c7a2 | 2017-08-04 13:58:48 -0400 | [diff] [blame] | 236 | { "system_log_stats", "echo 'BLOCK_SIZE=1024'; " |
| 237 | "find /var/log/ -type f -exec du --block-size=1024 {} + | sort -n -r", |
| 238 | kRoot, kRoot}, |
Kuo-Hsin Yang | 379846b | 2018-06-04 11:16:55 +0800 | [diff] [blame] | 239 | { "threads", "/bin/ps -T axo pid,ppid,spid,pcpu,ni,stat,time,comm" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 240 | { "tlsdate", "cat /var/log/tlsdate.log" }, |
Hsu-Cheng Tsai | e8c31d5 | 2017-03-31 12:34:55 +0800 | [diff] [blame] | 241 | { "top thread", "/usr/bin/top -Hb -n 1 | head -n 40"}, |
| 242 | { "top memory", "/usr/bin/top -o \"+%MEM\" -bn 1 | head -n 57"}, |
Andrew de los Reyes | c060c34 | 2013-04-10 13:46:30 -0700 | [diff] [blame] | 243 | { "touch_fw_version", "grep -E" |
Charlie Mooney | bb08f98 | 2016-02-04 15:35:56 -0800 | [diff] [blame] | 244 | " -e 'synaptics: Touchpad model'" |
| 245 | " -e 'chromeos-[a-z]*-touch-[a-z]*-update'" |
Andrew de los Reyes | c060c34 | 2013-04-10 13:46:30 -0700 | [diff] [blame] | 246 | " /var/log/messages | tail -n 20" }, |
Mattias Nissler | 483d76f | 2017-08-23 16:53:36 +0200 | [diff] [blame] | 247 | { |
| 248 | "tpm-firmware-updater", |
| 249 | "/usr/share/userfeedback/scripts/getmsgs /var/log/tpm-firmware-updater.log" |
| 250 | }, |
Mattias Nissler | 887dce2 | 2017-07-03 14:44:35 +0200 | [diff] [blame] | 251 | // TODO(jorgelo,mnissler): Don't run this as root. |
| 252 | // On TPM 1.2 devices this will likely require adding a new user to the 'tss' |
| 253 | // group. |
| 254 | // On TPM 2.0 devices 'get_version_info' uses D-Bus and therefore can run as |
| 255 | // any user. |
| 256 | { "tpm_version", "/usr/sbin/tpm-manager get_version_info", kRoot, kRoot }, |
Charlie Mooney | 69f5670 | 2017-05-02 14:55:41 -0700 | [diff] [blame] | 257 | { "atmel_ts_refs", "/opt/google/touch/scripts/atmel_tools.sh ts r", |
| 258 | kRoot, kRoot}, |
| 259 | { "atmel_tp_refs", "/opt/google/touch/scripts/atmel_tools.sh tp r", |
| 260 | kRoot, kRoot}, |
| 261 | { "atmel_ts_deltas", "/opt/google/touch/scripts/atmel_tools.sh ts d", |
| 262 | kRoot, kRoot}, |
| 263 | { "atmel_tp_deltas", "/opt/google/touch/scripts/atmel_tools.sh tp d", |
| 264 | kRoot, kRoot}, |
Gwendal Grignou | 427d94e | 2016-10-25 11:34:51 -0700 | [diff] [blame] | 265 | { |
| 266 | "trim", |
| 267 | "cat /var/lib/trim/stateful_trim_state /var/lib/trim/stateful_trim_data" |
| 268 | }, |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 269 | { "ui_log", "/usr/share/userfeedback/scripts/get_log /var/log/ui/ui.LATEST" }, |
| 270 | { "uname", "/bin/uname -a" }, |
| 271 | { "update_engine.log", "cat $(ls -1tr /var/log/update_engine | tail -5 | sed" |
Thiemo Nagel | a269ad2 | 2014-11-27 17:13:01 +0100 | [diff] [blame] | 272 | " s.^./var/log/update_engine/.)" }, |
Dariusz Marcinkiewicz | c412688 | 2017-10-13 16:07:36 +0200 | [diff] [blame] | 273 | { "uptime", "/usr/bin/cut -d' ' -f1 /proc/uptime" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 274 | { "verified boot", "cat /var/log/debug_vboot_noisy.log" }, |
| 275 | { "vmlog.1.LATEST", "cat /var/log/vmlog/vmlog.1.LATEST" }, |
| 276 | { "vmlog.1.PREVIOUS", "cat /var/log/vmlog/vmlog.1.PREVIOUS" }, |
| 277 | { "vmlog.LATEST", "cat /var/log/vmlog/vmlog.LATEST" }, |
| 278 | { "vmlog.PREVIOUS", "cat /var/log/vmlog/vmlog.PREVIOUS" }, |
| 279 | { "vmstat", "cat /proc/vmstat" }, |
| 280 | { "vpd_2.0", "cat /var/log/vpd_2.0.txt" }, |
Samuel Tan | 107b6c8 | 2014-07-10 15:33:44 -0700 | [diff] [blame] | 281 | { "wifi_status", "/usr/bin/network_diag --wifi-internal --no-log" }, |
Sonny Rao | ab5f995 | 2013-07-17 14:13:53 -0700 | [diff] [blame] | 282 | { "zram compressed data size", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 283 | "cat /sys/block/zram0/compr_data_size 2>/dev/null" }, |
Sonny Rao | ab5f995 | 2013-07-17 14:13:53 -0700 | [diff] [blame] | 284 | { "zram original data size", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 285 | "cat /sys/block/zram0/orig_data_size 2>/dev/null" }, |
Sonny Rao | ab5f995 | 2013-07-17 14:13:53 -0700 | [diff] [blame] | 286 | { "zram total memory used", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 287 | "cat /sys/block/zram0/mem_used_total 2>/dev/null" }, |
Sonny Rao | ab5f995 | 2013-07-17 14:13:53 -0700 | [diff] [blame] | 288 | { "zram total reads", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 289 | "cat /sys/block/zram0/num_reads 2>/dev/null" }, |
Sonny Rao | ab5f995 | 2013-07-17 14:13:53 -0700 | [diff] [blame] | 290 | { "zram total writes", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 291 | "cat /sys/block/zram0/num_writes 2>/dev/null" }, |
| 292 | { "zram new stats names", |
| 293 | "echo orig_size compr_size used_total limit " |
Luigi Semenzato | 4164de4 | 2017-07-06 10:42:54 -0700 | [diff] [blame] | 294 | "used_max zero_pages migrated" }, |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 295 | { "zram new stats values", "cat /sys/block/zram0/mm_stat 2>/dev/null" }, |
| 296 | { "cros_tp version", "cat /sys/class/chromeos/cros_tp/version" }, |
Wei-Ning Huang | 230b7d8 | 2017-07-14 16:19:13 +0800 | [diff] [blame] | 297 | { "cros_tp console", "/usr/sbin/ectool --name=cros_tp console", |
| 298 | kRoot, kRoot }, |
Wei-Ning Huang | 23ffdcf | 2017-08-04 11:30:39 +0800 | [diff] [blame] | 299 | { "cros_tp frame", "/usr/sbin/ectool --name=cros_tp tpframeget", |
| 300 | kRoot, kRoot }, |
Gaurav Shah | 6e8fd89 | 2012-10-01 11:51:08 -0700 | [diff] [blame] | 301 | |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 302 | // Stuff pulled out of the original list. These need access to the running X |
| 303 | // session, which we'd rather not give to debugd, or return info specific to |
| 304 | // the current session (in the setsid(2) sense), which is not useful for |
| 305 | // debugd |
| 306 | // { "env", "set" }, |
| 307 | // { "setxkbmap", "/usr/bin/setxkbmap -print -query" }, |
| 308 | // { "xrandr", "/usr/bin/xrandr --verbose" } |
Ben Chan | 64d19b2 | 2017-02-06 14:03:47 -0800 | [diff] [blame] | 309 | { nullptr, nullptr } |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 310 | }; |
| 311 | |
Kevin Cernekee | 143e2af | 2018-03-20 13:28:20 -0700 | [diff] [blame] | 312 | // netstat and logcat should appear in chrome://system but not in feedback |
| 313 | // reports. Open sockets may have privacy implications, and logcat is |
| 314 | // already incorporated via arc-bugreport. |
| 315 | const std::vector<string> kCommandLogsExclude = {"netstat", "logcat"}; |
| 316 | |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 317 | const Log kExtraLogs[] = { |
Ben Chan | 36e4228 | 2014-02-12 22:32:34 -0800 | [diff] [blame] | 318 | #if USE_CELLULAR |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 319 | { "mm-status", "/usr/bin/modem status" }, |
Ben Chan | 36e4228 | 2014-02-12 22:32:34 -0800 | [diff] [blame] | 320 | #endif // USE_CELLULAR |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 321 | { "network-devices", "/usr/bin/connectivity show devices" }, |
| 322 | { "network-services", "/usr/bin/connectivity show services" }, |
Ben Chan | 64d19b2 | 2017-02-06 14:03:47 -0800 | [diff] [blame] | 323 | { nullptr, nullptr } |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 324 | }; |
| 325 | |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 326 | const Log kFeedbackLogs[] = { |
Ben Chan | 36e4228 | 2014-02-12 22:32:34 -0800 | [diff] [blame] | 327 | #if USE_CELLULAR |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 328 | { "mm-status", "/usr/bin/modem status-feedback" }, |
Ben Chan | 36e4228 | 2014-02-12 22:32:34 -0800 | [diff] [blame] | 329 | #endif // USE_CELLULAR |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 330 | { "network-devices", "/usr/bin/connectivity show-feedback devices" }, |
| 331 | { "network-services", "/usr/bin/connectivity show-feedback services" }, |
Ben Chan | 64d19b2 | 2017-02-06 14:03:47 -0800 | [diff] [blame] | 332 | { nullptr, nullptr } |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 333 | }; |
| 334 | |
Ahmed Fakhry | 1498b4e | 2016-03-30 12:42:20 -0700 | [diff] [blame] | 335 | // List of log files needed to be part of the feedback report that are huge and |
| 336 | // must be sent back to the client via the file descriptor using |
| 337 | // LogTool::GetBigFeedbackLogs(). |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 338 | const Log kBigFeedbackLogs[] = { |
Eric Caruso | e3166f2 | 2016-06-10 15:36:02 -0700 | [diff] [blame] | 339 | { "arc-bugreport", |
Luigi Semenzato | 7e2c08f | 2018-06-26 14:58:49 -0700 | [diff] [blame^] | 340 | "cat /run/arc/bugreport/pipe 2>/dev/null", |
Eric Caruso | e3166f2 | 2016-06-10 15:36:02 -0700 | [diff] [blame] | 341 | // ARC bugreport permissions are weird. Since we're just running cat, this |
| 342 | // shouldn't cause any issues. |
| 343 | kRoot, |
Ricky Zhou | 4c473ca | 2016-06-21 17:46:58 -0700 | [diff] [blame] | 344 | kRoot, |
| 345 | "10M", |
Eric Caruso | e3166f2 | 2016-06-10 15:36:02 -0700 | [diff] [blame] | 346 | }, |
Ben Chan | 64d19b2 | 2017-02-06 14:03:47 -0800 | [diff] [blame] | 347 | { nullptr, nullptr } |
Ahmed Fakhry | 1498b4e | 2016-03-30 12:42:20 -0700 | [diff] [blame] | 348 | }; |
| 349 | |
Gaurav Shah | f6c8f2a | 2012-10-11 17:22:43 -0700 | [diff] [blame] | 350 | // List of log files that must directly be collected by Chrome. This is because |
| 351 | // debugd is running under a VFS namespace and does not have access to later |
| 352 | // cryptohome mounts. |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 353 | const Log kUserLogs[] = { |
Elly Fong-Jones | 6456ce5 | 2013-04-17 13:31:13 -0400 | [diff] [blame] | 354 | {"chrome_user_log", "log/chrome"}, |
| 355 | {"login-times", "login-times"}, |
| 356 | {"logout-times", "logout-times"}, |
Ben Chan | 64d19b2 | 2017-02-06 14:03:47 -0800 | [diff] [blame] | 357 | { nullptr, nullptr} |
Gaurav Shah | f6c8f2a | 2012-10-11 17:22:43 -0700 | [diff] [blame] | 358 | }; |
| 359 | |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 360 | // Returns |value| if |value| is a valid UTF-8 string or a base64-encoded |
| 361 | // string of |value| otherwise. |
| 362 | string EnsureUTF8String(const string& value) { |
| 363 | if (base::IsStringUTF8(value)) |
| 364 | return value; |
| 365 | |
Eric Caruso | 96d03d3 | 2017-04-25 18:01:17 -0700 | [diff] [blame] | 366 | string encoded_value; |
Ben Chan | ab93abf | 2017-01-24 13:32:51 -0800 | [diff] [blame] | 367 | base::Base64Encode(value, &encoded_value); |
| 368 | return "<base64>: " + encoded_value; |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | // TODO(ellyjones): sandbox. crosbug.com/35122 |
| 372 | string Run(const Log& log) { |
| 373 | string output; |
| 374 | ProcessWithOutput p; |
Eric Caruso | 96d03d3 | 2017-04-25 18:01:17 -0700 | [diff] [blame] | 375 | string tailed_cmdline = string(log.command) + " | tail -c " + |
Ahmed Fakhry | e4a0b50 | 2016-09-19 18:18:49 -0700 | [diff] [blame] | 376 | (log.size_cap ? log.size_cap : "512K"); |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 377 | if (log.user && log.group) |
| 378 | p.SandboxAs(log.user, log.group); |
| 379 | if (!p.Init()) |
| 380 | return "<not available>"; |
| 381 | p.AddArg(kShell); |
| 382 | p.AddStringOption("-c", tailed_cmdline); |
| 383 | if (p.Run()) |
| 384 | return "<not available>"; |
| 385 | p.GetOutput(&output); |
| 386 | if (!output.size()) |
| 387 | return "<empty>"; |
| 388 | return EnsureUTF8String(output); |
| 389 | } |
| 390 | |
| 391 | // Fills |dictionary| with the anonymized contents of the logs in |logs|. |
| 392 | void GetLogsInDictionary(const struct Log* logs, |
| 393 | AnonymizerTool* anonymizer, |
| 394 | base::DictionaryValue* dictionary) { |
| 395 | for (size_t i = 0; logs[i].name; ++i) { |
| 396 | dictionary->SetStringWithoutPathExpansion( |
| 397 | logs[i].name, anonymizer->Anonymize(Run(logs[i]))); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | // Serializes the |dictionary| into the file with the given |fd| in a JSON |
| 402 | // format. |
| 403 | void SerializeLogsAsJSON(const base::DictionaryValue& dictionary, |
Eric Caruso | 0b24188 | 2018-04-04 13:43:46 -0700 | [diff] [blame] | 404 | const base::ScopedFD& fd) { |
Eric Caruso | 96d03d3 | 2017-04-25 18:01:17 -0700 | [diff] [blame] | 405 | string logs_json; |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 406 | base::JSONWriter::WriteWithOptions(dictionary, |
| 407 | base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 408 | &logs_json); |
Eric Caruso | 0b24188 | 2018-04-04 13:43:46 -0700 | [diff] [blame] | 409 | base::WriteFileDescriptor(fd.get(), logs_json.c_str(), logs_json.size()); |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 412 | bool GetNamedLogFrom(const string& name, const struct Log* logs, |
| 413 | string* result) { |
| 414 | for (size_t i = 0; logs[i].name; i++) { |
| 415 | if (name == logs[i].name) { |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 416 | *result = Run(logs[i]); |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 417 | return true; |
| 418 | } |
| 419 | } |
| 420 | *result = "<invalid log name>"; |
| 421 | return false; |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 422 | } |
| 423 | |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 424 | void GetLogsFrom(const struct Log* logs, LogTool::LogMap* map) { |
| 425 | for (size_t i = 0; logs[i].name; i++) |
| 426 | (*map)[logs[i].name] = Run(logs[i]); |
| 427 | } |
| 428 | |
| 429 | } // namespace |
| 430 | |
Eric Caruso | f9091f8 | 2017-04-28 14:18:59 -0700 | [diff] [blame] | 431 | void LogTool::CreateConnectivityReport() { |
Rebecca Silberstein | e78af40 | 2014-10-02 10:55:04 -0700 | [diff] [blame] | 432 | // Perform ConnectivityTrial to report connection state in feedback log. |
Ben Chan | 8e9f6d0 | 2017-09-26 23:04:21 -0700 | [diff] [blame] | 433 | auto shill = std::make_unique<org::chromium::flimflam::ManagerProxy>(bus_); |
Rebecca Silberstein | e78af40 | 2014-10-02 10:55:04 -0700 | [diff] [blame] | 434 | // Give the connection trial time to test the connection and log the results |
| 435 | // before collecting the logs for feedback. |
| 436 | // TODO(silberst): Replace the simple approach of a single timeout with a more |
| 437 | // coordinated effort. |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 438 | if (shill && shill->CreateConnectivityReport(nullptr)) |
| 439 | sleep(kConnectionTesterTimeoutSeconds); |
Rebecca Silberstein | e78af40 | 2014-10-02 10:55:04 -0700 | [diff] [blame] | 440 | } |
| 441 | |
Eric Caruso | c93a15c | 2017-04-24 16:15:12 -0700 | [diff] [blame] | 442 | string LogTool::GetLog(const string& name) { |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 443 | string result; |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 444 | GetNamedLogFrom(name, kCommandLogs, &result) |
| 445 | || GetNamedLogFrom(name, kExtraLogs, &result) |
| 446 | || GetNamedLogFrom(name, kFeedbackLogs, &result); |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 447 | return result; |
| 448 | } |
| 449 | |
Eric Caruso | f9091f8 | 2017-04-28 14:18:59 -0700 | [diff] [blame] | 450 | LogTool::LogMap LogTool::GetAllLogs() { |
| 451 | CreateConnectivityReport(); |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 452 | LogMap result; |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 453 | GetLogsFrom(kCommandLogs, &result); |
| 454 | GetLogsFrom(kExtraLogs, &result); |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 455 | return result; |
| 456 | } |
| 457 | |
Brian Norris | ca4fc04 | 2018-04-03 00:24:26 -0700 | [diff] [blame] | 458 | LogTool::LogMap LogTool::GetAllDebugLogs() { |
| 459 | CreateConnectivityReport(); |
| 460 | LogMap result; |
| 461 | GetLogsFrom(kCommandLogs, &result); |
| 462 | GetLogsFrom(kExtraLogs, &result); |
| 463 | GetLogsFrom(kBigFeedbackLogs, &result); |
| 464 | return result; |
| 465 | } |
| 466 | |
Eric Caruso | f9091f8 | 2017-04-28 14:18:59 -0700 | [diff] [blame] | 467 | LogTool::LogMap LogTool::GetFeedbackLogs() { |
| 468 | CreateConnectivityReport(); |
Elly Jones | 533c7c4 | 2012-08-10 15:07:05 -0400 | [diff] [blame] | 469 | LogMap result; |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 470 | GetLogsFrom(kCommandLogs, &result); |
Kevin Cernekee | 143e2af | 2018-03-20 13:28:20 -0700 | [diff] [blame] | 471 | for (const auto& key : kCommandLogsExclude) { |
| 472 | result.erase(key); |
| 473 | } |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 474 | GetLogsFrom(kFeedbackLogs, &result); |
Darin Petkov | ce9b3a1 | 2013-01-10 16:38:54 +0100 | [diff] [blame] | 475 | AnonymizeLogMap(&result); |
Elly Jones | 03cd6d7 | 2012-06-11 13:04:28 -0400 | [diff] [blame] | 476 | return result; |
| 477 | } |
| 478 | |
Eric Caruso | 0b24188 | 2018-04-04 13:43:46 -0700 | [diff] [blame] | 479 | void LogTool::GetBigFeedbackLogs(const base::ScopedFD& fd) { |
Eric Caruso | f9091f8 | 2017-04-28 14:18:59 -0700 | [diff] [blame] | 480 | CreateConnectivityReport(); |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 481 | base::DictionaryValue dictionary; |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 482 | GetLogsInDictionary(kCommandLogs, &anonymizer_, &dictionary); |
Kevin Cernekee | 143e2af | 2018-03-20 13:28:20 -0700 | [diff] [blame] | 483 | for (const auto& key : kCommandLogsExclude) { |
| 484 | dictionary.Remove(key, nullptr); |
| 485 | } |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 486 | GetLogsInDictionary(kFeedbackLogs, &anonymizer_, &dictionary); |
| 487 | GetLogsInDictionary(kBigFeedbackLogs, &anonymizer_, &dictionary); |
Ahmed Fakhry | 21140cf | 2016-03-04 17:15:19 -0800 | [diff] [blame] | 488 | SerializeLogsAsJSON(dictionary, fd); |
| 489 | } |
| 490 | |
Eric Caruso | c93a15c | 2017-04-24 16:15:12 -0700 | [diff] [blame] | 491 | LogTool::LogMap LogTool::GetUserLogFiles() { |
Gaurav Shah | f6c8f2a | 2012-10-11 17:22:43 -0700 | [diff] [blame] | 492 | LogMap result; |
Ben Chan | cf7d641 | 2017-08-10 22:30:09 -0700 | [diff] [blame] | 493 | for (size_t i = 0; kUserLogs[i].name; ++i) |
| 494 | result[kUserLogs[i].name] = kUserLogs[i].command; |
Gaurav Shah | f6c8f2a | 2012-10-11 17:22:43 -0700 | [diff] [blame] | 495 | return result; |
| 496 | } |
| 497 | |
Darin Petkov | ce9b3a1 | 2013-01-10 16:38:54 +0100 | [diff] [blame] | 498 | void LogTool::AnonymizeLogMap(LogMap* log_map) { |
Ben Chan | e2fa357 | 2017-02-08 22:46:18 -0800 | [diff] [blame] | 499 | for (auto& entry : *log_map) |
| 500 | entry.second = anonymizer_.Anonymize(entry.second); |
Darin Petkov | ce9b3a1 | 2013-01-10 16:38:54 +0100 | [diff] [blame] | 501 | } |
| 502 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 503 | } // namespace debugd |