Hello to all,
I am looking for a way to display only the names of function (calls & definition) of a C++ source code.There is already a post related to this, but the script is to find the functions using a specific variable, and the replies are not that convincing since they cannot be used for all combinations of function calls/definitions. Kindly help me.
Is there any command in linux that can print the function calls/definitions, variables etc used in a C++ source code ?
Input
-----
File:Sample.cpp
Content:
void display_here() {
cdef
}
int sample() {
abcd
process_somewhere(nowhere(abc),
abc)
display_here()
rstuv
}
Output
-------
void display_here()
int sample()
process_somewhere(nowhere(abc),
abc)
display_here()
Thanks.
:)
You need to use a debugger to look at the code to see all function calls/definitions, variables, etc. You can use strace to look at the system calls to help debug some things the programs are doing. But a debugger like gdb would be the only thing that will give you indepth analysis of a c++.
I'm really annoyed at myself, because this should be a pure awk solution, but I have only a passing understanding of awk... so we're stuck with this abomination:
(03:59:46+deco@DeCoBuntu)
[~]:cat sample
File:Sample.cpp
Content:
void display_here() {
cdef
}
int sample() {
abcd
process_somewhere(nowhere(abc),
abc
(04:00:40+deco@DeCoBuntu)
[~]:grep "(*)" sample |awk -F\{ '{print $1}'
void display_here()
int sample()
process_somewhere(nowhere(abc),
abc)
display_here()
I know that it should be something more along the lines of:
(04:04:52+deco@DeCoBuntu)
[~]:awk -F\{ /"\(*\)"/ '{print $1}' sample
awk: cannot open {print $1} (No such file or directory)
But obviously I've done something wrong, and I'm too tired to figure it out. (Note, I know nothing about C++ so this may have nothing to do with the type of solution you're looking for...I just treated it like a flat file)