0

I'm trying to understand a program(Moveit!) connected with many other files. The program runs fine without any problem, but I want to know which function(from a different directory) calls the function I'm interested in. Since there are so many directories and functions of the same name, I can't just simply track them easily. So far, I've just tracked the caller function by manually opening all other files. Can I know how to track down the caller function(or file)?

For example, I've attached a code below that which caller function and file location I want to know.

bool ompl_interface::ModelBasedPlanningContext::solve(planning_interface::MotionPlanResponse& res) {   ...   }
  • 1
    Put a breakpoint in the function and look at the callstack during a debugging session. Assuming you can get the code to call this function. – drescherjm Mar 15 '22 at 13:36
  • replace `{...}` with `;` then read through a wall of errors to see where it is called, though using a debugger is more convenient – 463035818_is_not_an_ai Mar 15 '22 at 13:43
  • IDEs typically have the functionality to show all usages – 463035818_is_not_an_ai Mar 15 '22 at 13:44
  • 1
    That's not very C++ and since C++20 there actually is a way to do this. Example: `void log(std::string msg, const std::source_location location = std::source_location::current());` from https://en.cppreference.com/w/cpp/utility/source_location – Goswin von Brederlow Mar 15 '22 at 13:44

1 Answers1

0

Thank you guys! The program I've been using(ROS Moveit!) had a built-in gdb debugger and I could find the log file which showed all the directories .cpp file launched. This might not be applied to all for sure, but below is just an example of the location of the log file for my case.

~/.ros/log/cf90466c-a51d-11ec-b5e0-7085c253edd4/rosout.log