0
votes

I am trying to do profiling of the code written in C++ with the target Architecture RISC-V. The code has been cross-compiled using RISC-V GNU Toolchain. My executable is unit_tests "ELF 64-bit LSB executable, UCB RISC-V, version 1 (GNU/Linux), dynamically linked,nterpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped" this information is retrieved using the file command.

What I am trying to do is the profiling of this using gprof. But to do the gprof gmon.out needs to be generated, to generate gmon.out the executable should be run first. I cannot run the binary elf of other architecture in some different architecture. I need a suggestion for this on which emulator or simulator does this for me or I can run on?

I have tried installing qemu using the follwing link:

https://www.google.com/url?q=https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html&sa=D&source=hangouts&ust=1597422417473000&usg=AFQjCNERr6pHYmj0SU6an3WkBRGQI52aTw

but not able to successfully install it. Also have tried with spike but got "bad synccall" error. Any leads how can I resolve this issue.

1
Profiling may not be too useful with an emulator, as the emulator's performance may not be anything like that of the actual machine. AFAIK qemu should be able to do this; questions about how to install it are probably more appropriate to a site about general usage and administration of your OS (which you haven't specified).Nate Eldredge
I am using Ubuntu. In which I am facing error while installing qemu which I specified above.Yulia
You didn't specify what error you got. But on Ubuntu you should be able to simply apt install qemu-user; you do not need to compile qemu from source as your link describes.Nate Eldredge
If I just execute the above command will qemu get installed? Any leads on how to do profiling using qemu? I tried with many sources nothing worked.Yulia
Yes, apt install qemu-user as root (sudo if needed) will install qemu. You may have to do apt update first. Sorry, I do not know about profiling specifically. I believe that gprof just uses standard OS features that I would expect the emulator to support. I'm just not sure that the data you gather will be very useful.Nate Eldredge

1 Answers

0
votes

I solved this issue using qemu in user mode. Following the instructions in the below link: Manual-qemu-user

Where I could run the binary elf generated for target RISC-V, which I could run on x86 Linux machine.