From 2585dbebde96c6a2fc50922a37d960c2bfcd88c5 Mon Sep 17 00:00:00 2001 From: Youngwan Kim Date: Thu, 10 May 2018 19:53:41 +0900 Subject: [PATCH] [COMMON] lib: dss: Add dss-reader. Change-Id: I346b3016eb6c2b100ef920fc5e735649e7654bde Signed-off-by: Youngwan Kim --- .gitignore | 1 + Makefile | 1 + lib/debug-snapshot-log.h | 5 +++- lib/dss-reader-build.sh | 28 ++++++++++++++++++ lib/dss-reader.c | 63 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100755 lib/dss-reader-build.sh create mode 100644 lib/dss-reader.c diff --git a/.gitignore b/.gitignore index be92dfa89957..fae8d143bc91 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ modules.builtin /vmlinuz /System.map /Module.markers +/dss-reader # # RPM spec file (make rpm-pkg) diff --git a/Makefile b/Makefile index c78c0467444e..a8ef69a479b5 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ NAME = Petit Gorille # That's our default target when none is given on the command line PHONY := _all _all: + @lib/dss-reader-build.sh # o Do not use make's built-in rules and variables # (this increases performance and avoids hard-to-debug behaviour); diff --git a/lib/debug-snapshot-log.h b/lib/debug-snapshot-log.h index 1655fa0bc641..c9cb385ecc9d 100644 --- a/lib/debug-snapshot-log.h +++ b/lib/debug-snapshot-log.h @@ -2,15 +2,18 @@ #ifndef DEBUG_SNAPSHOT_LOG_H #define DEBUG_SNAPSHOT_LOG_H +#include + #ifdef DSS_ANALYZER #define TASK_COMM_LEN 16 #define NR_CPUS 8 #undef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD +#include +#include #else // DSS_ANALYZER -#include #include #include #include diff --git a/lib/dss-reader-build.sh b/lib/dss-reader-build.sh new file mode 100755 index 000000000000..d959eaafc44d --- /dev/null +++ b/lib/dss-reader-build.sh @@ -0,0 +1,28 @@ +clang \ +--target=aarch64-linux-gnu \ +-I/usr/aarch64-linux-gnu/include \ +-Iinclude \ +-mlittle-endian \ +-Qunused-arguments \ +-fno-strict-aliasing \ +-fno-common \ +-fshort-wchar \ +-std=gnu89 \ +-DDSS_ANALYZER \ +-fno-PIE \ +-mno-implicit-float \ +-DCONFIG_BROKEN_GAS_INST=1 \ +-fno-asynchronous-unwind-tables \ +-fno-pic \ +-Oz \ +-Wframe-larger-than=4096 \ +-fno-stack-protector \ +-mno-global-merge \ +-no-integrated-as \ +-fno-omit-frame-pointer \ +-fno-optimize-sibling-calls \ +-g \ +-fno-strict-overflow \ +-fno-merge-all-constants \ +-fno-stack-check \ +-g lib/dss-reader.c -o dss-reader diff --git a/lib/dss-reader.c b/lib/dss-reader.c new file mode 100644 index 000000000000..9e981a176bc2 --- /dev/null +++ b/lib/dss-reader.c @@ -0,0 +1,63 @@ +#include "debug-snapshot-log.h" + +struct dbg_snapshot_log *p; + +int main(int argc, char *argv[]) +{ + FILE *f; + int ch; + long fsize; + char *string; + int i, j; + + f = fopen(argv[1], "rb"); + if (f == NULL) { + fputs("file read error!", stderr); + exit(1); + } + fseek(f, 0, SEEK_END); + fsize = ftell(f); + fseek(f, 0, SEEK_SET); //same as rewind(f); + + string = malloc(fsize + 1); + fread(string, fsize, 1, f); + fclose(f); + p = (struct dbg_snapshot_log *)string; + + printf("log = {}\n"); + for (i = 0; i < DSS_NR_CPUS; i++) { + for (j = 0; j < DSS_LOG_MAX_NUM; j++) { + printf("log[%.9f] = { 'type' : 'sched', 'cpu' : %d, 'comm' : '%s'}\n", + p->task[i][j].time/1.0e9, i, p->task[i][j].task_comm); + if (p->task[i][j].time == 0) + break; + } + } + + for (i = 0; i < DSS_LOG_MAX_NUM; i++) { + printf("log[%.9f] = { 'type' : 'freq', 'cpu' : %d, 'freq' : %lu }\n", + p->freq[i].time/1.0e9, p->freq[i].cpu, p->freq[i].target_freq); + if (p->freq[i].time == 0) + break; + } + + for (i = 0; i < DSS_NR_CPUS; i++) { + for (j = 0; j < DSS_LOG_MAX_NUM; j++) { + printf("log[%.9f] = { 'type' : 'irq', 'cpu' : %d, 'num' : '%d'}\n", + p->irq[i][j].time/1.0e9, i, p->irq[i][j].irq); + if (p->irq[i][j].time == 0) + break; + } + } + + for (i = 0; i < DSS_NR_CPUS; i++) { + for (j = 0; j < DSS_LOG_MAX_NUM; j++) { + printf("log[%.9f] = { 'type' : 'cpuidle', 'cpu' : %d, 'state' : '%d'}\n", + p->cpuidle[i][j].time/1.0e9, i, p->cpuidle[i][j].state); + if (p->cpuidle[i][j].time == 0) + break; + } + } + return 0; +} + -- 2.20.1