Skip to content

Generating Call Graph With CScout

Marios Papachristou edited this page Aug 30, 2018 · 3 revisions

Configure CScout definitions

CScout definitions are located under the .cscoutdirectory.

We will study the configuration of the linux kernel.

Create make.cs

Create the make.cs file via calling the csmake, that is

make defconfig #default config
csmake -j7

Call CScout

You can invoke cscout via

cscout make.cs

Fix dependencies

Consider the following scenario after calling cscout make.cs

No options file found; will use default options.
No ACL found.  Only localhost access will be allowed.
Processing project /dev/null
Done processing project /dev/null

Processing project scripts/basic/fixdep
Processing /home/marios/workspace/linux/scripts/basic/fixdep.c
Done processing /home/marios/workspace/linux/scripts/basic/fixdep.c
Done processing project scripts/basic/fixdep

Processing project /home/marios/workspace/linux/scripts/basic/fixdep
Done processing project /home/marios/workspace/linux/scripts/basic/fixdep

Processing project /home/marios/workspace/linux/tools/objtool/fixdep
Processing /home/marios/workspace/linux/tools/build/fixdep.c
/usr/include/x86_64-linux-gnu/bits/byteswap.h:47: warning: undeclared identifier: uint32_t
/usr/include/x86_64-linux-gnu/bits/byteswap.h:47: warning: assuming declaration int uint32_t(...)
/usr/include/x86_64-linux-gnu/bits/byteswap.h:111: warning: undeclared identifier: uint64_t
/usr/include/x86_64-linux-gnu/bits/byteswap.h:111: warning: assuming declaration int uint64_t(...)
/usr/include/x86_64-linux-gnu/bits/unistd.h:26: error: syntax error

There are clearly some definitions missing. Looking at unistd.h we can see the lines:

extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf,
                                          size_t __nbytes), read) __wur;

are causing the problem.

We can isolate it via backing up

cp make.cs make-inc.cs

And rewriting the #pragma macro as an #include for fixdep.c

We can delete the rest of the lines to the end of make-inc.cs after the include command.

We can then generate the preprocessed file with the -E flag:

cscout -E make-inc.cs > foo.c

Open foo.c and examine the problems.

Make the definitions to the csmake-post-defs.h file.

Clone this wiki locally