cctree.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. *CCTree.txt* Plugin for C Call-Tree Explorer *CCTree*
  2. Author: Hari Rangarajan (First.Last AT gmail DOT com)
  3. Last Change: 17 June 2011
  4. CCTree version 1.53
  5. For Vim version 7.0 and above
  6. ==============================================================================
  7. 1. Overview |CCTree-overview|
  8. 2. Downloads |CCTree-download|
  9. 3. Installation |CCTree-installation|
  10. 4. Configuration |CCTree-configuration|
  11. 5. Features |CCTree-features|
  12. 6. Limitations |CCTree-limitations|
  13. 7. FAQ & TIPS |CCTree-faq|
  14. 8. History |CCTree-history|
  15. 9. Thanks |CCTree-thanks|
  16. ==============================================================================
  17. 1. Overview~
  18. *CCTree-overview*
  19. Plugin generates dependency-trees for symbols using a cscope database in Vim.
  20. Basic cross-referencing includes functions and macros. Enhanced symbol
  21. processing covers macros, typedefs, enums, and global variables.
  22. Requires Cscope and works best with C code.
  23. ==============================================================================
  24. 2. Downloads~
  25. *CCTree-download*
  26. You can download the latest release of the script from this url :
  27. http://www.vim.org/scripts/script.php?script_id=2368
  28. Cscope packages can be found here:
  29. http://cscope.sourceforge.net/
  30. http://code.google.com/p/cscope-win32/
  31. ==============================================================================
  32. 3. Installation~
  33. *CCTree-installation*
  34. Copy this file to ~/.vim/plugins/ or to /vimfiles/plugins/ (on Win32
  35. platforms)
  36. It should also be possible to load it as a filetype plugin ~/.vim/ftplugin/c/
  37. Need to set :filetype plugin on
  38. ==============================================================================
  39. CONFIGURATION *CCTree-configuration*
  40. 4. Options~
  41. You can customize behavior by changing the following variable settings
  42. 4.1.1 Cscope Symbol Database~
  43. *CCTreeCscopeDb*
  44. Cscope database file, g:CCTreeCscopeDb = "cscope.out"
  45. 4.1.2 Call-tree Depth~
  46. *CCTreeRecursiveDepth*
  47. Maximum call levels, g:CCTreeRecursiveDepth = 3
  48. 4.1.3 Call-tree Minimum Visible Depth~
  49. *CCTreeMinVisibleDepth*
  50. Maximum visible(unfolded) level, g:CCTreeMinVisibleDepth = 3
  51. 4.1.4 Call-tree window display~
  52. 4.4.1 Orientation~
  53. *CCTreeOrientation*
  54. Orientation of window, g:CCTreeOrientation = "leftabove"
  55. (standard vim options for split: [right|left][above|below])
  56. 4.5 Direction~
  57. *CCTreeWindowVertical*
  58. Use Vertical window, g:CCTreeWindowVertical = 1
  59. 4.5.1 Dimensions~
  60. These settings determine the layout of the CCTree preview window.
  61. 4.5.2 Horizontal Window Settings~
  62. *CCTreeWindowHeight*
  63. Horizontal window, g:CCTreeWindowHeight, default is -1.
  64. 4.5.2 Vertical Window Settings~
  65. *CCTreeWindowMinWidth*
  66. *CCTreeWindowWidth*
  67. Minimum width for window, g:CCTreeWindowMinWidth = 40.
  68. g:CCTreeWindowWidth = -1, auto-select best width to fit.
  69. 4.6 Call-tree display format~
  70. *CCTreeDisplayMode*
  71. Display format, g:CCTreeDisplayMode, default: 1
  72. Values: 1 -- Ultra-compact (takes minimum screen width)
  73. 2 -- Compact (Takes little more space)
  74. 3 -- Wide (Takes copious amounts of space)
  75. For vertical splits, 1 and 2 are good, while 3 is good for horizontal
  76. displays.
  77. 4.7. Dynamic Call-tree highlighting~
  78. *CCTreeHilightCallTree*
  79. Enable/disable dynamic call-tree highlighting, default: 1
  80. 4.7.1 Syntax items~
  81. *CCTreeSymbol* *CCTreeHiSymbol*
  82. CCTreeSymbol is the symbol name.
  83. CCTreeHiSymbol is the highlighted call tree functions.
  84. *CCTreeMarkers* *CCTreeHiMarkers*
  85. CCTreeMarkers include "|","+--->".
  86. CCTreeHiMarkers is the same as CCTreeMarkers except these denote the
  87. highlighted call-tree.
  88. ==============================================================================
  89. COMMAND LIST *CCTree-commands-list*
  90. Database Management~
  91. CCTreeLoadDB <dbname>
  92. CCTreeAppendDB <dbname>
  93. CCTreeUnLoadDB
  94. CCTreeShowLoadedDBs
  95. Refer to |CCTree-usage|
  96. Native Xref Database~
  97. CCTreeLoadXRefDB <dbname>
  98. CCTreeSaveXRefDB <dbname>
  99. CCTreeLoadXRefDBFromDisk <dbname>
  100. Refer to |CCTree-fast-loading|
  101. Symbol tracing~
  102. CCTreeTraceForward <symbolname>
  103. CCTreeTraceReverse <symbolname>
  104. CCTreeRecurseDepthPlus
  105. CCTreeRecurseDepthMinus
  106. Refer to |CCTree-explore-source|
  107. Trace Management~
  108. CCTreeWindowSaveCopy
  109. CCTreeWindowHiCallTree
  110. Refer to |CCTree-preview-window|
  111. Dynamic configuration~
  112. CCTreeOptsEnable <option> (<tab> for auto-complete)
  113. CCTreeOptsDisable <option> (<tab> for auto-complete)
  114. CCTreeOptsToggle <option> (<tab> for auto-complete)
  115. Options~
  116. DynamicTreeHiLights: Control dynamic tree highlighting
  117. UseUnicodeSymbols: Use of UTF-8 special characters for tree
  118. UseConceal: Use (+Conceal) feature instead of 'ignore'
  119. syntax highlighting. Allows CCTree window
  120. to be exported in HTML without syntax markup
  121. characters. (Vim 7.3+ only)
  122. *CCTree-Enhanced-Symbol-Processing*
  123. EnhancedSymbolProcessing: Cross-reference enums, macros,
  124. global variables, typedefs
  125. (WARNING: Database processing speeds will be slow.
  126. Feature is DISABLED by default for this reason)
  127. SHORTCUT KEYS *CCTree-Key-Map*
  128. Default Mappings~
  129. *CCTree-Default-Key-Map*
  130. Get reverse call tree for symbol <C-\><
  131. Get forward call tree for symbol <C-\>>
  132. Increase depth of tree and update <C-\>=
  133. Decrease depth of tree and update <C-\>-
  134. Open symbol in other window <CR>
  135. Preview symbol in other window <Ctrl-P>
  136. Save copy of preview window <C-\>y
  137. Highlight current call-tree flow <C-l>
  138. Compress(Fold) call tree view zs
  139. (This is useful for viewing long
  140. call trees which span across
  141. multiple pages)
  142. Custom user-mappings
  143. *CCTree-Custom-Key-Map*
  144. Users can custom-map the short-cut keys by
  145. overriding the following variables in their
  146. Vim start-up configuration
  147. >
  148. let g:CCTreeKeyTraceForwardTree = '<C-\>>'
  149. let g:CCTreeKeyTraceReverseTree = '<C-\><'
  150. let g:CCTreeKeyHilightTree = '<C-l>' " Static highlighting
  151. let g:CCTreeKeySaveWindow = '<C-\>y'
  152. let g:CCTreeKeyToggleWindow = '<C-\>w'
  153. let g:CCTreeKeyCompressTree = 'zs' " Compress call-tree
  154. let g:CCTreeKeyDepthPlus = '<C-\>='
  155. let g:CCTreeKeyDepthMinus = '<C-\>-'
  156. <
  157. ==============================================================================
  158. FEATURES *CCTree-features*
  159. 5.1. Symbol database~
  160. *CCTree-usage*
  161. Build cscope database, for example:
  162. > cscope -b -i cscope.files
  163. [Tip: add -c option to build uncompressed databases for faster
  164. load speeds]
  165. Load database~
  166. >
  167. :CCTreeLoadDB
  168. <
  169. (Please note that it might take a while depending on the
  170. database size)
  171. A database name, i.e., my_cscope.out, can be specified with the command. If
  172. not provided, a prompt will ask for the filename; default is cscope.out.
  173. Unload database ~
  174. >
  175. :CCTreeUnLoadDB
  176. <
  177. Append database~
  178. >
  179. :CCTreeAppendDB
  180. <
  181. Allows multiple cscope files to be loaded and cross-referenced
  182. Illustration: >
  183. :CCTreeAppendDB ./cscope.out
  184. :CCTreeAppendDB ./dir1/cscope.out
  185. :CCTreeAppendDB ./dir2/cscope.out
  186. <
  187. A database name, i.e., my_cscope.out, can be specified with
  188. the command. If not provided, a prompt will ask for the
  189. filename; default is cscope.out.
  190. FASTER DATABASE LOADING *CCTree-fast-loading*
  191. 5.7. Session serialization *CCTree-Database-Serialization*
  192. Save native Xref Db~
  193. >
  194. :CCTreeSaveXRefDb cctree.out
  195. <
  196. This command will save the cross-referenced symbols currently loaded into
  197. memory into a serialized format for faster loading.
  198. Load native XRef Db~
  199. >
  200. :CCTreeLoadXRefDb cctree.out
  201. <
  202. This command will load cross-referenced symbols from the previously saved
  203. native format database.
  204. Notes: No merging database support for CCTree native DB's [at present].
  205. Trace native XRef Db from disk~
  206. *CCTree-Database-Load-Instantaneously*
  207. Load and trace CCTree native XRefDb directly from disk, use command
  208. ":CCTreeLoadXRefDBFromDisk "
  209. >
  210. :CCTreeLoadXRefDBFromDisk cctree.out
  211. <
  212. The command traces symbols on-demand from disk; occupies no memory and
  213. is pretty quick under reasonable usage.
  214. Load database from memory or disk~
  215. *CCTree-Database-Memory-Speed-Trade-off*
  216. |CCTreeLoadXRefDB| loads the symbols on disk into memory, this will
  217. result in faster construction of call-trees, whereas the
  218. |CCTreeLoadXRefDBFromDisk| command traces the call-trees from disk,
  219. saving memory while sacrificing speed. Users can choose between the
  220. two depending on requirements.
  221. Writing large Xref Databases~
  222. *CCTree-Large-Xref-Databases*
  223. CCTree can use external utilities to write extremely large files beyond
  224. VimScripts capabilities. It requires the use of an external tool that can
  225. join text files (i.e., 'cat' in unix). This utility is triggered if the size
  226. of the file being written exceeds g:CCTreeDbFileMaxSize (40 Mb or as
  227. configured)
  228. The join utility command is configured by default as follows:
  229. let CCTreeJoinProgCmd = 'PROG_JOIN JOIN_OPT IN_FILES > OUT_FILE'
  230. let g:CCTreeJoinProg = 'cat' " PROG_JOIN
  231. let g:CCTreeJoinProgOpts = "" " JOIN_OPT
  232. ccglue~
  233. *CCTree-ccglue*
  234. Check out the ccglue project at http://ccglue.sourceforge.net for an external
  235. tool that can build cctree-compatible xref databases, which can be loaded
  236. and updated very quickly.
  237. 5.2. Exploring source-code~
  238. *CCTree-explore-source*
  239. Get reverse call tree for symbol <C-\><
  240. >
  241. :CCTreeTraceReverse <symbolname>
  242. <
  243. Get forward call tree for symbol <C-\>>
  244. >
  245. :CCTreeTraceForward <symbolname>
  246. <
  247. Increase depth of tree and update <C-\>=
  248. >
  249. :CCTreeRecurseDepthPlus
  250. <
  251. Decrease depth of tree and update <C-\>-
  252. >
  253. :CCTreeRecurseDepthMinus
  254. <
  255. 5.3. Preview Window~
  256. *CCTree-preview-window*
  257. Open symbol in other window <CR>
  258. Preview symbol in other window <Ctrl-P>
  259. 5.4. Syntax Coloring~
  260. *CCTree-Syntax*
  261. CCTreeHiXXXX allows dynamic highlighting of the call-tree. To observe the
  262. effect, move the cursor to the function to highlight the current call-tree.
  263. This option can be turned off using the setting, |CCTreeHilightCallTree|.
  264. For faster highlighting, the value of 'updatetime' can be changed.
  265. 5.5 Support for large database files~
  266. *CCTree-LargeDatabase* *CCTree-LargeFile*
  267. Vimscript does not have an API for reading files line-by-line. This
  268. becomes a problem when parsing large databases. CCTree can overcome
  269. the limitation using an external utility (i.e., GNU coreutils: split)
  270. or VimScript's perl interpreter interface (:version must indicate +perl)
  271. 5.5.1 Using GNU Coreutils (split/cat)~
  272. *CCTree-Tools-split* *CCTree-Tools-cat*
  273. The following settings are tailored to suit GNU coreutils split; the
  274. default settings should work with no changes on typical linux/unix distros.
  275. Monopoly OSes will require installation of unixutils or equivalent.
  276. External command is setup with the following parameters~
  277. >
  278. let g:CCTreeSplitProgCmd =
  279. 'PROG_SPLIT SPLIT_OPT SPLIT_SIZE IN_FILE OUT_FILE_PREFIX'
  280. <
  281. Break-down of individual parameters~
  282. The split utility is assumed to be on the path; otherwise, specify full path
  283. g:CCTreeSplitProg = 'split'
  284. Option for splitting files (-C or -l)~
  285. >
  286. let g:CCTreeSplitProgOption = '-C'
  287. <
  288. If split program does not support -C, then this parameter must be set to
  289. the number of lines in the split files
  290. >
  291. let g:CCTreeDbFileSplitLines = -1
  292. <
  293. Largest filesize Vimscript can handle; file sizes greater than this will
  294. be temporarily split
  295. >
  296. let g:CCTreeDbFileMaxSize = 40000000 (40 Mbytes)
  297. <
  298. Sample system command~
  299. Typical:
  300. >
  301. split -C 40000000 inputFile outputFilePrefix
  302. <
  303. When g:CCTreeDbFileSplitLines is set to 10000 (-C options will be ignored)
  304. >
  305. split -l 10000 inputFile outputFilePrefix
  306. <
  307. *CCTree-Tools-Perl*
  308. *CCTree-Tools-Perl-LargeFile*
  309. Enabling perl interface~
  310. By default, perl usage is disabled. Set
  311. >
  312. let g:CCTreeUsePerl = 1
  313. < to enable the perl interface.
  314. Perl interface is typically faster than native Vimscript.
  315. This option can be used independent of the file size
  316. For more info on setting up perl interface
  317. :help |perl-using| or :help |perl-dynamic|
  318. 5.6. Miscellaneous *CCTree-Miscellaneous*
  319. UTF-8 usage *CCTree-UTF8-Symbols*
  320. UTF-8 symbols should work fine on the majority of
  321. X11 systems; however, some terminals might cause problems.
  322. To use symbols for drawing the tree, this option can be enabled.
  323. >
  324. let g:CCTreeUseUTF8Symbols = 1
  325. <
  326. The options interface (CCTreeOptsxxx) can be used to
  327. modify options on-the-fly.
  328. ==============================================================================
  329. 6. Limitations~
  330. *CCTree-limitations*
  331. The following are known limitations:
  332. Basic Symbol Processing:
  333. (1) The accuracy of the call-tree will only be as good as the cscope database
  334. generation. (NOTE: Different flavors of Cscope have some known limitations
  335. due to the lexical analysis engine. This results in incorrectly identified
  336. function blocks, etc.)
  337. Enhanced Symbol Processing:
  338. (1) Cscope does not mark-up nameless enums correctly; hence,
  339. CCTree cannot recognize nameless enum symbols.
  340. ==============================================================================
  341. 7. FAQ~
  342. *CCTree-faq*
  343. + I see strange characters "!#@" on my screen when dynamic highlighting is
  344. enabled. Why do I see them?
  345. Check :hi ignore. You will see something like
  346. hi ignore ctermfg=white guifg=bg
  347. For console, white must be your background color; for GUI, guifg must be set
  348. to bg.
  349. ==============================================================================
  350. 8. History~
  351. *CCTree-history*
  352. Version 1.53: June 17, 2011
  353. 1. Bug fix related to appending cscope databases
  354. 2. Bug fix related to loading xref databases
  355. Version 1.51: May 18, 2011
  356. 1. Robust error reporting when external (split/cat) utils fail
  357. Version 1.50: May 6, 2011
  358. 1. Support cross-referencing of global variables, macros,
  359. enums, and typedefs.
  360. Version 1.40: April 22, 2011
  361. 1. Maintain order of functions called during forward tracing
  362. Version 1.39: April 18, 2011
  363. 1. Use +Conceal feature for highlighting (only Vim 7.3)
  364. Version 1.33: April 5, 2011
  365. 1. Load and trace CCTree native XRefDb directly from disk
  366. 2. Fix AppendDB command when 'ignorecase' is set
  367. Version 1.26: March 28, 2011
  368. 1. Fix macro cross-referencing limitation
  369. 2. Correct native xref file format
  370. Version 1.21: March 21, 2011
  371. 1. Support serialization of loaded
  372. cscope databases (for faster loading)
  373. Version 1.07: March 09, 2011
  374. 1. Fix new keymaps incorrectly applied to buffer
  375. 2. CCTreeOptsToggle command for toggling options
  376. Version 1.04: March 06, 2011
  377. 1. Customization for key mappings
  378. 2. Dynamic configuration of UI variables
  379. 3. Folding long call-trees to show current path dynamically
  380. Version 1.01: March 04, 2011
  381. 1. Make UTF-8 symbols for tree optional
  382. Version 1.00: March 02, 2011
  383. 1. Staging release for upcoming features
  384. - Complete refactoring of code to take
  385. advantage of VimScript's OO features
  386. 2. Faster decompression of symbols
  387. 3. Display related changes
  388. - Use of unicode symbols for tree
  389. 4. Bugfixes related to multi-database loading
  390. Version 0.90: February 18, 2011
  391. 1. Support for large databases using external split utility or perl
  392. interface
  393. Version 0.85: February 9, 2011
  394. 1. Significant increase in database loading and decompression speeds
  395. Version 0.80: February 4, 2011
  396. 1. Reduce memory usage by removing unused xref symbols
  397. Version 0.75: June 23, 2010
  398. 1. Support for saving CCTree preview window; multiple
  399. CCTree windows can now be open
  400. ersion 0.71: May 11, 2010
  401. 1. Fix script bug
  402. Version 0.70: May 8, 2010
  403. 1. Functionality to load multiple cscope databases
  404. Version 0.65: July 12, 2009
  405. 1. Toggle preview window
  406. Version 0.61: December 24, 2008
  407. 1. Fixed bug when processing include files
  408. 2. Remove 'set ruler' option
  409. Version 0.60: November 26, 2008
  410. 1. Added support for source-file dependency tree
  411. Version 0.50: October 17, 2008
  412. 1. Optimizations for compact memory foot-print and
  413. improved compressed-database load speeds
  414. Version 0.41: October 6, 2008
  415. 1. Minor fix: Compressed cscope databases will load
  416. incorrectly if encoding is not 8-bit
  417. Version 0.4: September 28, 2008
  418. 1. Rewrite of display-related code
  419. 2. New syntax hightlighting
  420. 3. Dynamic highlighting for call-trees
  421. 4. Support for new window modes (vertical, horizontal)
  422. 5. New display format option for compact or wide call-trees
  423. 6. Preview window fix
  424. Version 0.3: September 21, 2008
  425. 1. Support compressed cscope databases
  426. 2. Display window related bugs fixed
  427. 3. More intuitive display and folding capabilities
  428. Version 0.2: September 12, 2008
  429. (Patches from Yegappan Lakshmanan, thanks!)
  430. 1. Support for using the plugin in Vi-compatible mode
  431. 2. Filtering out unwanted lines before processing the db
  432. 3. Command-line completion for the commands
  433. 4. Using the cscope db from any directory
  434. Version 0.1: August 31,2008
  435. 1. Cross-referencing support for only functions and macros
  436. (Note: Functions inside macro definitions will be incorrectly
  437. attributed to the top level calling function)
  438. ==============================================================================
  439. 9. Thanks~
  440. *CCTree-thanks*
  441. Ben Fritz (ver 1.53 -- Bug reports on database append/load)
  442. Qaiser Durrani (ver 1.51 -- Reporting issues with SunOS)
  443. Ben Fritz (ver 1.39 -- Suggestion/Testing for
  444. conceal feature)
  445. Ben Fritz (ver 1.26 -- Bug report)
  446. Frank Chang (ver 1.0x -- testing/UI enhancement
  447. ideas/bug fixes)
  448. Arun Chaganty/Timo Tiefel (Ver 0.60 -- bug report)
  449. Michael Wookey (Ver 0.40 -- Testing/bug report/patches)
  450. Yegappan Lakshmanan (Ver 0.20 -- Patches)
  451. The Vim Community, ofcourse :)
  452. vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: