1
0

calls 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. .TH CALLS 1
  2. .SH NAME
  3. calls \- print static call graph of a C program
  4. .SH SYNOPSIS
  5. .B calls
  6. [
  7. .B \-ptv
  8. ] [
  9. .B \-f
  10. .I function
  11. ] [
  12. .B \-w
  13. .I width
  14. \&...
  15. ] [
  16. .B \-D
  17. .I def
  18. ] [
  19. .B \-U
  20. .I def
  21. ] [
  22. .B \-I
  23. .I dir
  24. ] [
  25. file ...
  26. ]
  27. .SH DESCRIPTION
  28. .I Calls
  29. reads
  30. .IR file s,
  31. which should be the source of C programs,
  32. and writes the analysed calling pattern to standard output.
  33. If no file names are given,
  34. standard input will be read.
  35. .I Calls
  36. is intended to help analyse the flow of a program by laying out the
  37. functions called in the hierarchical manner used in
  38. .I "Software Tools"
  39. by
  40. B. Kernighan and P. Plauger.
  41. .PP
  42. All input is first filtered through
  43. .IR cpp (1).
  44. Functions called but not defined within the source
  45. .IR file s
  46. are shown as:
  47. .PP
  48. .RS
  49. function
  50. .B [external]
  51. .RE
  52. .PP
  53. Recursive references are shown as:
  54. .PP
  55. .RS
  56. .B <<<
  57. function
  58. .RE
  59. .PP
  60. Options are:
  61. .TP 0.6i
  62. .B \-f
  63. Add
  64. .I function
  65. as a root of a call graph to be printed.
  66. .TP
  67. .B -p
  68. Make
  69. .I cpp
  70. search the APE
  71. .I include
  72. directories.
  73. .TP
  74. .B \-t
  75. Provides a terse form of output,
  76. in which the calling pattern for any
  77. function is printed only once on the first occurrence of the function.
  78. Subsequent occurrences output the function name and a notation
  79. .IP "" 1i
  80. \&...
  81. .BI "[see line " xx ]
  82. .IP "" 0.6i
  83. This is the default case.
  84. .TP 0.6i
  85. .B \-v
  86. Full output of function calling patterns on every occurrence.
  87. .TP
  88. .BI \-w n
  89. Set the output width to
  90. .IR n .
  91. The default is 80 columns.
  92. .TP
  93. .BI \-D name
  94. .PD 0
  95. .TP
  96. .PD 0.4v
  97. .BI \-D name=defn
  98. Define the
  99. .I name
  100. for
  101. .IR cpp ,
  102. as if by
  103. .BR #define .
  104. If no definition is given, the name is defined as 1.
  105. .TP
  106. .BI \-U name
  107. Remove any initial definition of
  108. .IR name ,
  109. where
  110. .I name
  111. is a reserved symbol that is predefined by
  112. .IR cpp .
  113. .TP
  114. .BI \-I dir
  115. Change the algorithm for searching for
  116. .B #include
  117. files whose names do not begin with
  118. .B /
  119. to look in
  120. .I dir
  121. before looking in the directories on the standard list.
  122. .SH EXAMPLES
  123. What does
  124. .I cat
  125. call?
  126. .IP
  127. .EX
  128. % calls -f main /sys/src/cmd/cat.c
  129. 1 main
  130. 2 cat
  131. 3 read [external]
  132. 4 write [external]
  133. 5 sysfatal [external]
  134. 6 open [external]
  135. 7 sysfatal [external]
  136. 8 close [external]
  137. 9 exits [external]
  138. .EE
  139. .br
  140. .ne 7
  141. .PP
  142. What internal functions does
  143. .I dd
  144. call?
  145. .IP
  146. .EX
  147. % calls -f main /sys/src/cmd/dd.c | grep -v '\e[external\e]'
  148. 1 main
  149. 5 number
  150. 6 <<< number
  151. 9 match
  152. 17 flsh
  153. 21 term
  154. 22 stats
  155. 25 term ... [see line 21]
  156. 26 stats ... [see line 22]
  157. .EE
  158. .PP
  159. Note the recursion in
  160. .IR number .
  161. .PP
  162. Generate the PC kernel's internal call graph.
  163. .IP
  164. .EX
  165. cd /sys/src/9/pc
  166. calls -f main -I../port -I. ../port/*.c ../ip/*.c *.c |
  167. grep -v external
  168. .EE
  169. .SH BUGS
  170. Forward declared functions defined within a function body which are not
  171. subsequently used within that function body will be listed as having been
  172. called.
  173. .PP
  174. Does not understand calls through function pointers.
  175. .PP
  176. Does not understand the restricted scope of
  177. .I static
  178. functions.