Reputation: 1365
I'm using a large software package that doesn't have any consistent method error handling. I see error messages like this:
ERROR: stupid message
Now, using grep
etc., I was able to find the function where this message is emitted, i.e.
void somefunc(Arg1 arg1, Arg2 arg2, ...){
// ...
std::cout << "ERROR: stupid message" << std::endl;
}
However, I have difficulties finding out where this function is called in my usecase. If this was an exception or segfault, I could see the stack trace - but like this, I'm a bit lost.
I can't touch the code of somefunc
, so I guess I'll have to use valgrind
or something like that to find the offending function call, but I wouldn't know how to do this. I'm using a Linux system and compile my code with g++
, but I can't change or recompile the code section containing somefunc
. Any suggestions?
Upvotes: 0
Views: 1118
Reputation: 57749
Here are some techniques (tools) to help you:
Place a breakpoint at the output statement. When the breakpoint is reached, print a back trace or view the call stack.
Some documentation tools, like Doxygen, can generate a "caller" and "callee" graph. You can use these to search for possible execution paths.
Upvotes: 1