Skip to content

Commit

Permalink
components: add gdb scripts to dump gcov and gprof data
Browse files Browse the repository at this point in the history
Signed-off-by: Huaqi Fang <[email protected]>
  • Loading branch information
fanghuaqi committed Apr 15, 2024
1 parent 2617f6d commit e456b3c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Components/profiling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions Components/profiling/dump_gcov.gdb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions Components/profiling/dump_gprof.gdb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e456b3c

Please sign in to comment.