namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.04k stars 473 forks source link

Some functions are not recorded when tracing ORB_SLAM2 #1355

Open chengguo-msft opened 3 years ago

chengguo-msft commented 3 years ago

I am using uftrace to trace g2o::BlockSolver::solve's call graph in ORB_SLAM2, however, when program runs into this loop, functions in it are not being recorded, like the inverse function.

Steps to reproduce:

  1. Globally add -pg and -fno-omit-frame-pointer to gcc and g++ by replacing /usr/bin/gcc and /usr/bin/g++ with following bash script files. (I know this is not a recommended way)
    #!/bin/bash
    /usr/bin/gcc-5 "$@" -pg -fno-omit-frame-pointer
    #!/bin/bash
    /usr/bin/g++-5 "$@" -pg -fno-omit-frame-pointer
  2. Follow ORB_SLAM2's README.md to setup a running environment on Ubuntu16.04 with ARM64 based CPU.
  3. Download this dataset and extract all.
  4. Use uftrace to record a run
    uftrace record -F g2o::BlockSolver::solve --nest-libcall ./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml rgbd_dataset_freiburg1_xyz
  5. Print function call graph
    uftrace graph

The function call graph I got:

graph.txt

namhyung commented 3 years ago

Hello, thanks for using uftrace and reporting the issue.

It might be optimized by the compiler so you'd better check the assembly of the loop. Please make sure that it calls the function in the loop body and the functions have calls to the mcount.