Is there a tool for listing global variables used and deduced using the C function?

I want to make a list of global variables / macros consumed by the function and displayed by the function. For example, for:

void myfn(void) { out1 = in + 1; out2 = 2; } 

.. the tool will list inputs as "in", and outputs as "out1" and "out2".

Does anyone know about such a tool?

+7
c global-variables code-analysis
source share
4 answers

Our DMS Software Reengineering Toolkit is a custom software analysis tool with C Front End product quality.

It analyzes C, builds AST tables and symbol tables, provides control and data flow analysis, and also builds global call diagrams and has points for analysis. It can be configured to extract this information; in fact, we supplied our own DMS-based tool for a major vehicle manufacturer to create a tool to get almost such information.

If you stick to character table information only, you can extract a β€œdirect read or write”, as in your example. If you use call schedule information, you may find reading or writing to global variables caused by calls to other functions. If you use point analysis, you can detect (conservatively) read or write to global variables by indirectness.

+3
source share
+3
source share

You can also try CppDepend , NDepend as for C \ C ++

+2
source share

Clang , at least, can do this, but it might not be the easiest way. You will need to interact with the C ++ API.

+1
source share

All Articles