Skip to content

Commit af89a1e

Browse files
committed
Add "Configuration" section to READMEBump Clade version to 2.0
1 parent 38301ed commit af89a1e

File tree

2 files changed

+167
-2
lines changed

2 files changed

+167
-2
lines changed

README.rst

Lines changed: 166 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,126 @@ Other options are available through --help option.
807807
Configuration
808808
-------------
809809
810-
*not written yet*
810+
There is a bunch of options that can be changed to alter the behaviour
811+
of various tools available in Clade. If you execute these tools from the
812+
command line (tools like *clade-cc*, *clade-callgraph*, *clade-cmd-graph*,
813+
and so on), then the configuration can be passed via the "-c" option like this:
814+
815+
.. code-block:: bash
816+
817+
$ clade-cc -c conf.json cmds.txt
818+
819+
where *conf.json* is a json file with some configuration options:
820+
821+
.. code-block:: json
822+
823+
{
824+
"PidGraph.as_picture": true,
825+
"CmdGraph.requires": [
826+
"CC",
827+
"LD",
828+
"MV",
829+
"AR",
830+
"Objcopy"
831+
],
832+
"CC.which_list": ["/usr.bin.gcc", "^.*clang$"]
833+
}
834+
835+
The configuration can be also passed as a Python dictionary:
836+
837+
.. code-block:: python
838+
839+
from clade.extensions.cc import CC
840+
841+
conf = {"PidGraph.as_picture": True}
842+
c = CC(work_dir="clade", conf=conf)
843+
844+
which list
845+
~~~~~~~~~~
846+
847+
Let's highlight some notable configuration options and let's start with
848+
options for extensions that parse intercepted commands to search for input
849+
and output files, and options. These extensions need to know which commands
850+
to parse. They have a list of predefined regular expressions that they try
851+
to match with the *which* field of an intercepted command.
852+
For example, *CC* extension have the following list:
853+
854+
.. code-block:: python
855+
856+
which_list = [
857+
r"^.*cc$",
858+
r"^.*[mg]cc(-?\d+(\.\d+){0,2})?$",
859+
r"^.*clang(-?\d+(\.\d+){0,2})?$"
860+
]
861+
862+
Obviously, execution of */usr/bin/gcc* will be matched, as well as
863+
*/usr/bin/clade*, or */usr/local/bin/powerpc-elf-gcc-7*, so all such commands
864+
will be treated as compilation commands and parsed accordingly.
865+
Sometimes this list is not enough, so there is an option to change it:
866+
867+
::
868+
869+
"CC.which_list": ["regexp_to_match_your_compiler"]
870+
871+
Options for other such extensions look the same, you just need to replace *CC*
872+
by the name of the extension, so, for example, "LD.which_list" will be the
873+
option to change the list of regexes for *LD* extension.
874+
875+
Visualization options
876+
~~~~~~~~~~~~~~~~~~~~~
877+
878+
Currently there are two small options to visualize *pid graph* and *cmd graph*
879+
using Graphviz:
880+
881+
.. code-block:: json
882+
883+
{
884+
"PidGraph.as_picture": true,
885+
"CmdGraph.as_picture": true
886+
}
887+
888+
If they are set, then next to *pid_graph.json* and *cmd_graph.json* files
889+
respectively pdf files containing Graphviz output will appear.
890+
891+
List of commands to parse
892+
~~~~~~~~~~~~~~~~~~~~~~~~~
893+
894+
If you want to generate *command graph*, or *source graph*, or *call graph*,
895+
then you need to specify which commands to parse via "CmdGraph.requires"
896+
option. If you want to parse all commands that are supported now, then
897+
the value of this option will be:
898+
899+
.. code-block:: json
900+
901+
{
902+
"CmdGraph.requires": ["CC", "LD", "MV", "AR", "Objcopy"]
903+
}
904+
905+
Presets
906+
~~~~~~~
907+
908+
There is predefined set of options for the following projects that can be used
909+
in addition to user-defined configuration:
910+
911+
- Linux kernel (preset linux_kernel)
912+
- Busybox (presets busybox_linux, busybox_macos)
913+
- Apache (presets apache_linux, apache_macos)
914+
915+
If you want to execute Clade on one of these projects then it might be a *good
916+
idea* to use this presets, since they will definitely save you from having
917+
to deal with various problems and mess with the configuration:
918+
919+
.. code-block:: bash
920+
921+
$ clade-cc -p linux_kernel cmds.txt
922+
923+
or
924+
925+
.. code-block:: python
926+
927+
from clade.extensions.cc import CC
928+
929+
c = CC(work_dir="clade", preset="linux_kernel")
811930
812931
Troubleshooting
813932
---------------
@@ -849,6 +968,52 @@ You need to install *gcc-multilib* (Ubuntu) or *gcc-32bit* (openSUSE) package
849968
and **reinstall Clade**. *libinterceptor* library will be recompiled and your
850969
issue will be fixed.
851970
971+
Not all intercepted compilation commands are parsed
972+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
973+
974+
The reason is because *CC* extension that parse intercepted commands cannot
975+
identify a command as a compilation command. You can help it by specifying
976+
"CC.which_list" configuration option, in which you should write a list of
977+
regexes that will match your compiler. For example, if path to your compiler
978+
is *~/.local/bin/c_compiler*, than "CC.which_list" may be set like this:
979+
980+
::
981+
982+
"CC.which_list": ["^.*?c_compiler$"]
983+
984+
If you want to parse not only commands executed by your compiler, but by system
985+
*gcc* as well, then you can add it to the list too:
986+
987+
::
988+
989+
"CC.which_list": ["^.*?c_compiler$", ""^.*gcc$"]
990+
991+
How to set configuration option is described in *Configuration* section of
992+
this readme.
993+
994+
Compilation database miss some commands
995+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
996+
997+
Same as above.
998+
999+
Command graph is not connected properly
1000+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1001+
1002+
Most certainly it is due to the fact that some type of commands is unparsed.
1003+
If there is an extension in Clade that can parse them, then you will need
1004+
to specify it via the option "CmdGraph.requires":
1005+
1006+
.. code-block:: json
1007+
1008+
{
1009+
"CmdGraph.requires": ["CC", "LD", "MV", "AR", "Objcopy"]
1010+
}
1011+
1012+
Otherwise such extension should be developed.
1013+
1014+
Similar problems with the *source graph* and the *call graph* can be fixed
1015+
via the same option, since they use the *command graph* internally.
1016+
8521017
Acknowledgments
8531018
---------------
8541019

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def finalize_options(self):
5656

5757
setuptools.setup(
5858
name="clade",
59-
version="1.0",
59+
version="2.0",
6060
author="Ilya Shchepetkov",
6161
author_email="ilya.shchepetkov@yandex.ru",
6262
url="https://github.com/17451k/clade",

0 commit comments

Comments
 (0)