Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 170
 2012 Microchip Technology Inc.
Fundamental to the generation of the compiled stack is the call graph, which defines a 
tree-like hierarchy of function calls, i.e it shows what functions may be called by each 
function.
There will be one graph produced for each root function. A root function is typically not 
called, but which is executed via other means and contains a program entry point. The 
function main() is an example of a root function that will be in every project. Interrupt 
functions which are executed when a hardware interrupt occurs, are another example.
FIGURE 5-2:
FORMATION OF CALL GRAPH
Figure 5-2 shows sections of a program being analyzed by the code generator to form 
a call graph. In the original source code, the function main() calls F1(), F2() and 
F3()
. F1() calls F4(), but the other two functions make no calls. The call graph for 
main()
 indicates these calls. The symbols F1, F2 and F3 are all indented one level 
under main. F4 is indented one level under F1.
This is a static call graph which shows all possible calls. If the exact code for function 
F1()
 looked like:
int F1(void) {
  if(PORTA == 44)
    return F4();
  return 55;
}
the function F4() will always appear in the call graph, even though it is conditionally 
executed in the actual source code. Thus, the call graph indicates all functions that 
might be called.
In the diagram, there is also an interrupt function, isr(), and it too has a separate 
graph generated.
The term main-line code is often used, and refers to any code that is executed as a 
result of the main() function being executed. In the above figure, F1(), F2(), F3() 
and F4() are only ever called by main-line code.
The term interrupt code refers to any code that is executed as a result of an interrupt 
being generated, in the above figure, F5() and F6() are called by interrupt code.
Analysis of program
main
    F1
        F4
    F2
    F3
isr
    F5
    F6
Call graph
code 
generator
main {
  F1(…);
  F2(…);
  F3(…);
}
F1 {
  F4(…);
}
isr {
  F5(…);
  F6(…);
}