[Prev][Next][Index]

callgraph problems



In producing my slides for the CONPAR talk, I found another "problem".
Consider the following code:

------------------------------------------------
int bar () {}

Processor_Main() {
  int foo (int);
  int x = foo(1);
}

int foo (int a) {
  bar();
  return 5;
}
------------------------------------------------

When you now do a "pC++2dep test.pc; cgm -dumpcg test.dep" you get

------------------------------------------------
4

  ftag: 4 Processor_Main
 ffile: 3 xx.pc 
fcalls: 0 - 5
 fline: 5
fclass: - - -2
 ftype: seq Ord used

  ftag: 5 foo
 ffile: 0 - 
fcalls: 1 -
fclass: - - -2
 ftype: seq Ord used
------------------------------------------------

"cgm -dumpcg" just prints out information about functions as it walks through
the call graph provided by the SgCallgraph module. The problem is that
SgCallgraph says, the child of function Processor_Main is function foo with
sage id == 4. But this is the function forward declaration, not the
definition later. As this function declaration has no body, it is not
investigated further, and "bar" is not found.

The funny thing is that if you do it version 1.3, you get the following:

------------------------------------------------
3

  ftag: 3 bar
 ffile: 1 xx.pc 
fcalls: 1 -
fclass: - - -2
 ftype: seq Ord used

  ftag: 4 Processor_Main
 ffile: 3 xx.pc 
fcalls: 0 - 5
fclass: - - -2
 ftype: seq Ord used

  ftag: 5 foo
 ffile: 8 xx.pc 
fcalls: 1 - 3
fclass: - - -2
 ftype: seq Ord used
------------------------------------------------

Note that with version 1.3, the forward declaration was ignored (it says
there are only 3 functions (the first number in the output)) and ffile
points now correctly the xx.pc line 6, and also bar is "found".

I cannot remember changing anything the Sgcallgraph module the last half
year.
Did anybody changed something in the parser how forward declarations are
handled, which could have produced the change?

Bernd

P.S. It is affecting my tools because e.g. in Sparse a lot of forward
     declartions are used, and now all functions which are called from
     these "foward declarated" functions (like bar) are no longer displayed
     in the call graph

-- 
Bernd Mohr   --   mohr@cs.uoregon.edu   --   http://www.cs.uoregon.edu/~mohr

echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc