blob: a3e0088292aef2ec17a50a7c19914053653d3bd3 [file] [log] [blame]
Adam Shihee779b92022-10-11 15:36:26 +08001/*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <stdio.h>
17#include <string>
18#include <android-base/file.h>
19#include <fstream>
20#include <iostream>
21
22// Format title and content output.
23void dumpFileContent(const char* title, const char* file_path) {
24 std::string content;
25 printf("------ %s (%s) ------\n", title, file_path);
26 if (android::base::ReadFileToString(file_path, &content)) {
27 printf("%s\n", content.c_str());
28 } else {
29 printf("Unable to read %s\n", file_path);
30 }
31 return;
32}
33
34void command(const char* title, const char* cmd){
35 printf("------ %s (%s) ------\n", title, cmd);
36 system(cmd);
37 return;
38}
39
40// Dump Aoc.
41int main() {
42 setbuf(stdout, NULL);
43 dumpFileContent("AoC Service Status", "/sys/devices/platform/19000000.aoc/services");
44 dumpFileContent("AoC Restarts", "/sys/devices/platform/19000000.aoc/restart_count");
45 dumpFileContent("AoC Coredumps", "/sys/devices/platform/19000000.aoc/coredump_count");
46 dumpFileContent("AoC ring buf wake", "/sys/devices/platform/19000000.aoc/control/ring_buffer_wakeup");
47 dumpFileContent("AoC host ipc wake", "/sys/devices/platform/19000000.aoc/control/host_ipc_wakeup");
48 dumpFileContent("AoC usf wake", "/sys/devices/platform/19000000.aoc/control/usf_wakeup");
49 dumpFileContent("AoC audio wake", "/sys/devices/platform/19000000.aoc/control/audio_wakeup");
50 dumpFileContent("AoC logging wake", "/sys/devices/platform/19000000.aoc/control/logging_wakeup");
51 dumpFileContent("AoC hotword wake", "/sys/devices/platform/19000000.aoc/control/hotword_wakeup");
52 dumpFileContent("AoC memory exception wake", "/sys/devices/platform/19000000.aoc/control/memory_exception");
53 dumpFileContent("AoC memory votes", "/sys/devices/platform/19000000.aoc/control/memory_votes_a32");
54 dumpFileContent("AoC memory votes", "/sys/devices/platform/19000000.aoc/control/memory_votes_ff1");
55 command("clean AoC buffer","echo ' ' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
56 command("AoC Heap Stats (A32)", "echo 'dbg heap -c 1' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
57 command("AoC Heap Stats (F1)", "echo 'dbg heap -c 2' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
58 command("AoC Heap Stats (HF0)", "echo 'dbg heap -c 3' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
59 command("AoC Heap Stats (HF1)", "echo 'dbg heap -c 4' > /dev/acd-debug; timeout 0.1 cat /dev/acd-debug");
60 return 0;
61}