gsshch / riscv-gprof

using gprof with RISC-V embedded 32 bit systems bare-metal . It can be modified to support 64 bit as well

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Download Toolchain:

https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.3.0-1.1/xpack-riscv-none-embed-gcc-8.3.0-1.1-linux-x64.tgz

Download openocd:

https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.10.0-13/xpack-openocd-0.10.0-13-linux-x64.tgz

Download the source:

git clone https://github.com/sbzpro/riscv-gprof.git
cd riscv-gprof

Add openocd

export PATH=<PATH/TO/OPENOCD>/bin:${PATH}

Run openocd and wait for connection

cd build && openocd -f ../config/openocd.cfg

Add toolchain to PATH and Compile:

open new terminal <ctrl>+<shift>+t; In new terminal type the following
export PATH=<PATH/TO/TOOLCHAIN>/bin:${PATH}
cd build && make 

Run GDB and connect to target:

$> riscv-none-embed-gdb riscv-gprof.elf	
		$ target extended-remote localhost:3333
		$ load riscv-gprof.elf
		$ c <ENTER>

If everything goes correct a message "done" is printed in openocd console.

Exit GDB and run cross gprof

riscv-none-embed-gprof riscv-gprof.elf gmon.out >> analysis.txt

Adding Your code to profile:

Code that needs to be instrumented should be present in  <PATH/TO>/riscv-gprof/src/ folder
Funtions needs to be instrumented should be prepended with "PROFILE" macro
prepend function with NO_INSTRUMENT macro to avoid instrumenting
if new file is added to <PATH/TO>/riscv-gprof/src/ folder edit <PATH/TO>/riscv-gprof/build/src/subdir.mk and 
add newly added filename for compilation.

About

using gprof with RISC-V embedded 32 bit systems bare-metal . It can be modified to support 64 bit as well

License:Other


Languages

Language:C 90.4%Language:Makefile 6.6%Language:Assembly 3.0%