From e456b3c25b46be974cf2d06f5e88f8eb79e23371 Mon Sep 17 00:00:00 2001 From: Huaqi Fang <578567190@qq.com> Date: Mon, 15 Apr 2024 16:39:41 +0800 Subject: [PATCH] components: add gdb scripts to dump gcov and gprof data Signed-off-by: Huaqi Fang <578567190@qq.com> --- Components/profiling/README.md | 6 ++++++ Components/profiling/dump_gcov.gdb | 12 ++++++++++++ Components/profiling/dump_gprof.gdb | 2 ++ 3 files changed, 20 insertions(+) create mode 100755 Components/profiling/dump_gcov.gdb create mode 100755 Components/profiling/dump_gprof.gdb diff --git a/Components/profiling/README.md b/Components/profiling/README.md index 97bd376d..3c6fec42 100644 --- a/Components/profiling/README.md +++ b/Components/profiling/README.md @@ -46,6 +46,12 @@ technology. - `parse.py`: a python script use to parse gcov and gprof dump log file, and generate gcov or gprof binary files. To run this script, need python3 installed in your host pc. +- `dump_gcov.gdb`: gdb script to dump coverage data when you execute `gcov_collect(0);` in your application code. + +- `dump_gprof.gdb`: gdb script to dump profiling data when you execute `gprof_collect(0);` in your application code. + +You can execute above gdb script in Debug Console like this `source /path/to/dump_gcov.gdb`. + ## How to use Add this `profiling` folder into your project, and do steps below: diff --git a/Components/profiling/dump_gcov.gdb b/Components/profiling/dump_gcov.gdb new file mode 100755 index 00000000..a9157aed --- /dev/null +++ b/Components/profiling/dump_gcov.gdb @@ -0,0 +1,12 @@ +define dump_gcov_data + set $node=gcov_data_head + while ($node != 0) + set $filename=$node->filename + set $bufstart=$node->buffer + set $bufend=$node->buffer + $node->size + printf "dump binary memory %s 0x%lx 0x%lx\n", $filename, $bufstart, $bufend + eval "dump binary memory %s 0x%lx 0x%lx\n", $filename, $bufstart, $bufend + set $node=$node->next + end +end +dump_gcov_data diff --git a/Components/profiling/dump_gprof.gdb b/Components/profiling/dump_gprof.gdb new file mode 100755 index 00000000..ddd300cb --- /dev/null +++ b/Components/profiling/dump_gprof.gdb @@ -0,0 +1,2 @@ +printf "dump binary memory gmon.out 0x%lx 0x%lx\n", gprof_data.buf, gprof_data.buf + gprof_data.size +dump binary memory gmon.out gprof_data.buf gprof_data.buf + gprof_data.size