+ Fixes
[opsoft.git] / silentbob / usage.html
blob2c253b085bd7b63685d16aab5b568ef950349240
1 <html><body>
2 <style>
3 code {COLOR: #800000; FONT-FAMILY: "Courier New", Courier, monospace}
4 </style>
6 <p> <b>SilentBob</b> </p>
8 <p><p> <table style="width: 32%; background: #C2D6FF; border: solid thin; padding: 6px; margin-bottom: 10px; margin-right: 10px; float: right;">
9 <tr> <th>Why using SilentBob for generating tags?</th> </tr>
10 <tr> <td>
12 </p> <p>SilentBob uses syntax analysis to parse source files, which makes it faster than a utility like Exuberant Ctags, which uses regular expressions to locate the appropriate line in a file. In a test run on the sources for the Linux kernel (version 2.6.19) Exuberant Ctags generated the tags table in 90 seconds, while SilentBob did its job in 10 seconds (on a 2.6MHz Celeron). SilentBob also supports multithreading optimizations.</p>
14 <p>Another difference is the format of tags tables: In tables created by Exuberant Ctags, regular expressions are used to locate the appropriate line in a file. This means that if you edit the file, and the position of some definition is changed, you don't need to rebuild the tags table. This is good for Exuberant Ctags because it means you don't need to regenerate the table often, but it also means that if you are viewing huge files, jumping to a tag definition will be much slower than if line numbers were used. That's why SilentBob uses line number in its tags tables; however, that means you have to update the tags table after every major edit. </p>
16 </td>
17 </tr>
18 </table>
24 <a href="http://silentbob.sourceforge.net/">SilentBob</a> is another new tool for analyzing source code. It currently supports C/C++, Perl, and Python, but its plugin framework (which is not documented at the moment) enables users to add support for new languages and other features easily.
26 <p>You can get source tarball and deb packages from the downloads section of the software's site. After installation, invoke SilentBob three times in the directory with source code:</p>
28 <pre>
29 bob --make-ctags
30 bob --cfiles
31 bob -L cfiles --call-tags
32 </pre>
34 <p>This will generate three files: <code>tags</code>, the common tags table; <code>cfiles</code>, a list of C/C++ files; and <code>call_tags</code>, the call tags table. The call tags table contains tags for function calls, so if you want to find all the calls of some function, you can point Vim to use the call tags table (<code>:set tags=./call_tags</code>) and use the same commands as for searching tags (<code>:tag <em>function-name</em> </code> and <code>:tnext</code> and <code>:tprevious</code> to cycle through results). These index files can be used by SilentBob to build call trees and backward call trees. </p>
36 <p>For Perl and Python, only tags tables and file lists are supported:</p>
38 <pre>
39 bob &lt;--perl | --python&gt; --make-ctags
40 bob &lt;--perl | --python&gt; --files
41 </pre>
44 The second command will generate a <code>perl_files</code> or <code>python_files</code> file.
46 <p>Once you have a tags table, SilentBob can show you a call tree:</p>
48 <pre>
49 bob [--depth <em>N</em>] <em>function</em>
50 </pre>
52 <p> <code>--depth</code> option allows you to limit the depth of the tree. If the only thing you need to know is which functions are called by <em>function</em>, specify <code>--depth 0</code>. Otherwise, you will be shown which functions are called by functions called by functions (...) called by <em>function</em>. </p>
54 <p>Note that you can use this option with the tags table generated by SilentBob for Python and Perl files. Tables generated by Exuberant Ctags are not supported.</p>
56 <p>The call tags table is used to generate a backward call tree:</p>
58 <pre>
59 bob [--depth <em>N</em>] -u <em>function</em>
60 </pre>
62 <p>This will show functions which call functions (...) which call <em>function</em>. In this case specify <code>--depth 1</code> to see only functions which call <em>function</em> </p>
64 <p>SilentBob can also use the created cfiles file to search for text within C/C++ code. It checks operators; strings and comments are ignored.</p>
66 <pre>
67 bob <em>list of files</em> --cgrep <em>pieces of text, separated by comma</em>
68 </pre>
70 <p>You can specify <code>-L ./cfiles</code> to use generated file list. Pieces of text should be from one operator, so if you are looking for testing of T variable, use:</p>
72 <pre>
73 bob -L ./cfiles --cgrep if,T
74 </pre>
76 <p>SilentBob also includes a <code>tags</code> utility that lets you to view the tag definitions in a C/C++ file in a console. Invoke <code>tags <em>tag1 tag2 ... tagN</em> </code> to strip the fragments of code you are interested in from code -- function definitions, global variable declarations, etc. -- and you will see the fragments of code you need. </p></div>
78 </body></html>