705e726679ae61686338ec90ab17d3b1ce963f8e
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

1) # UProcTrace: User-space Process Tracing
2) 
3) UProcTrace traces process executions and process ends on Linux systems.
4) 
5) On process starts, UProcTrace records the time, the entire command line,
6) working directory and environment. On process end, it logs the CPU time used by
7) the process (split by user and kernel time) and the peak memory usage.
8) 
9) UProcTrace is implemented in user-space, so does not reuire any special kernel
10) modules.  This means it can also be used in containers (e.g. docker) without
11) any changes the to conteiner host.  The implementation is based on the
12) `LD_PRELOAD` mechanism.  A shared library is injected into each process
13) started. This libarary records trace events at begin of the process (when the
14) preload library is initialized) and at the end of the process (when the library
15) is de-initiazlied).
16) 
17) ## Building
18) 
19) UProcTrace is developed on Debian Linux 10 "buster".
20) 
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

21) Install the dependencies:
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

22) 
23) ```
24) apt-get install -y build-essential cmake gcc \
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

25)                    libprotobuf-c-dev libprotobuf-dev \
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

26)                    ninja-build \
27)                    protobuf-c-compiler protobuf-compiler \
Florian Walbroel add additional tool command...

Florian Walbroel authored 3 years ago

28)                    pylint3 python3 python3-protobuf python3-tabulate
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

29) ```
30) 
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

31) For the graphical user interface, install the additional dependencies:
32) 
33) ```
34) apt-get install -y glade libglib2.0-dev libgtk-3-dev python3-gi
35) ```
36) 
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

37) Change to the directory of this `REAMDE.md` file.
38) 
39) Configure a build directory:
40) 
41) ```
42) mkdir build
43) cd build
44) cmake -G Ninja -D CMAKE_BUILD_TYPE=Release ..
45) ```
46) 
47) Build:
48) 
49) ```
50) ninja
51) ```
52) 
53) Run tests:
54) 
55) ```
56) ctest
57) ```
58) 
Stefan Schuermans python3 module, exports, up...

Stefan Schuermans authored 3 years ago

59) Set up for direct usage from build directory (to be done in each shell):
60) 
61) ```
62) source exports
63) ```
64) 
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

65) ## Tracing Applications
66) 
67) To trace an application, prefix the command with `upt-trace` and the
68) file name for the trace.  For example, to trace the command
69) ```
70) /usr/bin/printf "trace me"
71) ```
72) run the following command:
73) ```
Stefan Schuermans call trace file <trace.upt>...

Stefan Schuermans authored 3 years ago

74) upt-trace mytrace.upt /usr/bin/printf "trace me"
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

75) ```
76) 
77) To show the recorded events, run:
78) ```
Stefan Schuermans call trace file <trace.upt>...

Stefan Schuermans authored 3 years ago

79) upt-tool mytrace.upt dump
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

80) ```
81) 
82) ## Graphical User interface
83) 
Stefan Schuermans implement double click on p...

Stefan Schuermans authored 3 years ago

84) To explore a trace in the graphical user interface (GUI), run:
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

85) ```
Stefan Schuermans call trace file <trace.upt>...

Stefan Schuermans authored 3 years ago

86) upt-tool mytrace.upt gui
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

87) ```
88) 
Stefan Schuermans implement double click on p...

Stefan Schuermans authored 3 years ago

89) The left half of the GUI shows the process tree with a few selected details
90) about each process.  The right half shows further details of the process
91) selected on the left side.
92) 
93) By double-clicking on the entries in the right tree view, their content can be
94) copied to the clipboard. If a row with subordinate rows is double-clicked, the
95) contents of all the subordinate entries are copied to the clipboard, using
96) proper shell-escaping of the individual entries. If a process row on the left
97) side is double-clicked, a shell command for repeating the execution of the
98) process (including working directory, environment variables and command line)
99) is copied to the clipboard.
100) 
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

101) ## Example: Trace Build Process
102) 
103) To show the capabilities of the UProcTrace, a process that calls several child
104) processes is required. In this example, the build of UProcTrace is used for
105) this purpose.
106) 
107) Change to the build directory.
108) 
109) Start a new shell to be traced:
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

110) 
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

111) ```
Stefan Schuermans call trace file <trace.upt>...

Stefan Schuermans authored 3 years ago

112) upt-trace mytrace.upt bash
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

113) ```
114) 
115) Configure another build directory for this tracing example and run the build:
116) 
117) ```
118) mkdir example_trace_build
119) cd example_trace_build
120) cmake -G Ninja -D CMAKE_BUILD_TYPE=Release ../..
121) ninja
122) ```
123) 
124) Stop tracing by ending the shell:
125) 
126) ```
127) exit
128) ```
129) 
130) Show traced information:
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

131) 
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

132) ```
Stefan Schuermans call trace file <trace.upt>...

Stefan Schuermans authored 3 years ago

133) upt-tool mytrace.upt dump
Stefan Schuermans implement upt-trace wrapper

Stefan Schuermans authored 3 years ago

134) ```
135) 
Stefan Schuermans update README: upt-tool, up...

Stefan Schuermans authored 3 years ago

136) To explore the trace in the graphical user interface, run:
137) 
138) ```
Stefan Schuermans call trace file <trace.upt>...

Stefan Schuermans authored 3 years ago

139) upt-tool mytrace.upt gui