Re: Simple list of functions ever called

Paul Floyd via Valgrind-users <[email protected]> Sat, 17 Aug 2024 16:39:14 +0000
Newsgroups gmane.comp.debugging.valgrind
Message-ID <[email protected]>

On 06-06-24 15:43, Byron Hawkins wrote:
> For the purposes of studying dead-code elimination in LLVM, I'd like to 
> generate a simple list of all the functions that are ever called by the 
> target program. There's no need for any timing or frequency reports or 
> backtraces or any other details. So far, the best solution I can find is 
> to filter callgrind output like this:
> 
>      grep -E "^c?fn" callgrind/output.raw | cut -d " " -f 2- | grep -Ev 
> "^0x|^c?fn"
> 
> It doesn't seem highly reliable, since I'm just picking out entries by 
> sort of guessing, then checking the results with gdb (setting a 
> breakpoint on every symbol not encountered by callgrind). All target 
> programs are trivial unit tests with rigid, deterministic behavior, but 
> it would still be nicer to have a more formally defined approach for 
> extracting a precise set of function symbols for which invocation was 
> observed during the execution. Thanks in advance for any suggestions.

There are various ways to get the function names. I usually use a train 
of commands like

awk '/^fn=.* .*/{print $2}' callgrind.out.3727 | sort | uniq -c | sort -n

(only printing the first field with the fn name from awk so not getting 
the full arg list).

A+
Paul


_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users