From 5ce418dc5eca354acb5c66dcbb47e7c0aa369ce8 Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Mon, 5 Feb 2018 16:43:53 -0800 Subject: Creating dumputils library. This moves methods and variables needed for stack trace dumps to a separate library so that incidentd can also get dumps without duplicating too much code. Bug: 72177715 Test: flash device and collect a regular bug report Change-Id: I68f367c32cbcac99f43305f73bb504ba7a1e4437 --- libs/dumputils/Android.bp | 34 ++++++++ libs/dumputils/dump_utils.cpp | 111 ++++++++++++++++++++++++++ libs/dumputils/include/dumputils/dump_utils.h | 28 +++++++ 3 files changed, 173 insertions(+) create mode 100644 libs/dumputils/Android.bp create mode 100644 libs/dumputils/dump_utils.cpp create mode 100644 libs/dumputils/include/dumputils/dump_utils.h (limited to 'libs/dumputils') diff --git a/libs/dumputils/Android.bp b/libs/dumputils/Android.bp new file mode 100644 index 0000000000..3412e14f17 --- /dev/null +++ b/libs/dumputils/Android.bp @@ -0,0 +1,34 @@ +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +cc_library { + name: "libdumputils", + + shared_libs: [ + "libbase", + "libbinder", + "libhidlbase", + "libhidltransport", + "liblog", + "libutils", + ], + + srcs: ["dump_utils.cpp"], + + cflags: ["-Wall", "-Werror"], + + export_include_dirs: [ + "include", + ], +} diff --git a/libs/dumputils/dump_utils.cpp b/libs/dumputils/dump_utils.cpp new file mode 100644 index 0000000000..0fd2b81e76 --- /dev/null +++ b/libs/dumputils/dump_utils.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include +#include +#include +#include +#include + +/* list of native processes to include in the native dumps */ +// This matches the /proc/pid/exe link instead of /proc/pid/cmdline. +static const char* native_processes_to_dump[] = { + "/system/bin/audioserver", + "/system/bin/cameraserver", + "/system/bin/drmserver", + "/system/bin/mediadrmserver", + "/system/bin/mediaextractor", // media.extractor + "/system/bin/mediametrics", // media.metrics + "/system/bin/mediaserver", + "/system/bin/sdcard", + "/system/bin/statsd", + "/system/bin/surfaceflinger", + "/system/bin/vehicle_network_service", + "/vendor/bin/hw/android.hardware.media.omx@1.0-service", // media.codec + NULL, +}; + +/* list of hal interface to dump containing process during native dumps */ +static const char* hal_interfaces_to_dump[] { + "android.hardware.audio@2.0::IDevicesFactory", + "android.hardware.bluetooth@1.0::IBluetoothHci", + "android.hardware.camera.provider@2.4::ICameraProvider", + "android.hardware.graphics.composer@2.1::IComposer", + "android.hardware.media.omx@1.0::IOmx", + "android.hardware.sensors@1.0::ISensors", + "android.hardware.vr@1.0::IVr", + NULL, +}; + +bool should_dump_hal_interface(const char* interface) { + for (const char** i = hal_interfaces_to_dump; *i; i++) { + if (!strcmp(*i, interface)) { + return true; + } + } + return false; +} + +bool should_dump_native_traces(const char* path) { + for (const char** p = native_processes_to_dump; *p; p++) { + if (!strcmp(*p, path)) { + return true; + } + } + return false; +} + +std::set get_interesting_hal_pids() { + using android::hidl::manager::V1_0::IServiceManager; + using android::sp; + using android::hardware::Return; + + sp manager = IServiceManager::getService(); + std::set pids; + + Return ret = manager->debugDump([&](auto& hals) { + for (const auto &info : hals) { + if (info.pid == static_cast(IServiceManager::PidConstant::NO_PID)) { + continue; + } + + if (!should_dump_hal_interface(info.interfaceName.c_str())) { + continue; + } + + pids.insert(info.pid); + } + }); + + if (!ret.isOk()) { + ALOGE("Could not get list of HAL PIDs: %s\n", ret.description().c_str()); + } + + return pids; // whether it was okay or not +} + +bool IsZygote(int pid) { + static const std::string kZygotePrefix = "zygote"; + + std::string cmdline; + if (!android::base::ReadFileToString(android::base::StringPrintf("/proc/%d/cmdline", pid), + &cmdline)) { + return true; + } + + return (cmdline.find(kZygotePrefix) == 0); +} diff --git a/libs/dumputils/include/dumputils/dump_utils.h b/libs/dumputils/include/dumputils/dump_utils.h new file mode 100644 index 0000000000..25f712733a --- /dev/null +++ b/libs/dumputils/include/dumputils/dump_utils.h @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DUMPUTILS_H_ +#define DUMPUTILS_H_ + +#include + +bool should_dump_native_traces(const char* path); + +std::set get_interesting_hal_pids(); + +bool IsZygote(int pid); + +#endif // DUMPUTILS_H_ -- cgit v1.2.3-59-g8ed1b From 5fce8821433738280535577a875377a62fff8608 Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Mon, 2 Apr 2018 17:24:41 -0700 Subject: Allow dumpstate to trace drm hals Change-Id: I4e78d264013de2e4eeff3c80a8f6dcbffd078c39 related-to-bug:74607984 test:adb bugreport and check for drm trace dumps --- libs/dumputils/dump_utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'libs/dumputils') diff --git a/libs/dumputils/dump_utils.cpp b/libs/dumputils/dump_utils.cpp index 0fd2b81e76..835da20347 100644 --- a/libs/dumputils/dump_utils.cpp +++ b/libs/dumputils/dump_utils.cpp @@ -44,6 +44,7 @@ static const char* hal_interfaces_to_dump[] { "android.hardware.audio@2.0::IDevicesFactory", "android.hardware.bluetooth@1.0::IBluetoothHci", "android.hardware.camera.provider@2.4::ICameraProvider", + "android.hardware.drm@1.0::IDrmFactory", "android.hardware.graphics.composer@2.1::IComposer", "android.hardware.media.omx@1.0::IOmx", "android.hardware.sensors@1.0::ISensors", -- cgit v1.2.3-59-g8ed1b From b4c85df12610cf93e7b080fb6d108c1a5890b6aa Mon Sep 17 00:00:00 2001 From: Pawin Vongmasa Date: Wed, 18 Apr 2018 07:00:30 -0700 Subject: Dump IOmxStore IOmxStore may be in a different process from IOmx. Test: adb bugreport Bug: 78218851 Change-Id: I836d8e2e200b97c5b6127798843a0d525054b4a4 --- libs/dumputils/dump_utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'libs/dumputils') diff --git a/libs/dumputils/dump_utils.cpp b/libs/dumputils/dump_utils.cpp index 835da20347..8f6b1bd5d6 100644 --- a/libs/dumputils/dump_utils.cpp +++ b/libs/dumputils/dump_utils.cpp @@ -47,6 +47,7 @@ static const char* hal_interfaces_to_dump[] { "android.hardware.drm@1.0::IDrmFactory", "android.hardware.graphics.composer@2.1::IComposer", "android.hardware.media.omx@1.0::IOmx", + "android.hardware.media.omx@1.0::IOmxStore", "android.hardware.sensors@1.0::ISensors", "android.hardware.vr@1.0::IVr", NULL, -- cgit v1.2.3-59-g8ed1b From ac1e32c371ed192072c37360d28d7505ced4dc9d Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Tue, 1 May 2018 09:03:40 -0700 Subject: dump_utils: add Audio HAL v4.0 to the dump list Bug: 78607184 Test: create a bugreport on a P device Change-Id: I1f823c9bb829945a82e35e6d03acb8aca9ed381d --- libs/dumputils/dump_utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'libs/dumputils') diff --git a/libs/dumputils/dump_utils.cpp b/libs/dumputils/dump_utils.cpp index 8f6b1bd5d6..8b2f842a44 100644 --- a/libs/dumputils/dump_utils.cpp +++ b/libs/dumputils/dump_utils.cpp @@ -42,6 +42,7 @@ static const char* native_processes_to_dump[] = { /* list of hal interface to dump containing process during native dumps */ static const char* hal_interfaces_to_dump[] { "android.hardware.audio@2.0::IDevicesFactory", + "android.hardware.audio@4.0::IDevicesFactory", "android.hardware.bluetooth@1.0::IBluetoothHci", "android.hardware.camera.provider@2.4::ICameraProvider", "android.hardware.drm@1.0::IDrmFactory", -- cgit v1.2.3-59-g8ed1b