0
votes

I am writing some assembly code and assembling them using GNU assembler. I have realized that there is no way to compile with -pg flags so that I can profile.

Is there any other way or any other assembler through which I can profile?

Thanks

1

1 Answers

1
votes

Consider a profiler from google-perftools. Let's assume we've got an executable main built from two object files: one compiled from C and one from assembly. There's no need to add any extra flags for compilation, assembling or linking.

$ LD_PRELOAD=path/to/libprofiler.so CPUPROFILE=main.prof ./main
$ pprof main main.prof  --text
Using local file main.
Using local file main.prof.
Removing killpg from all stack traces.
Total: 435 samples
     348  80.0%  80.0%      348  80.0% label_from_assembly_file
      37   8.5%  88.5%       37   8.5% exit
      29   6.7%  95.2%       29   6.7% another_label_from_assembly_file
      15   3.4%  98.6%      435 100.0% main
       4   0.9%  99.5%        4   0.9% another_label_defined_in_asm
       2   0.5% 100.0%        2   0.5% and_a_fourth_asm_label
       0   0.0% 100.0%      435 100.0% __libc_start_main
       0   0.0% 100.0%      435 100.0% _start

Here's all there is to know about the profiler.