1 | .. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. Copyright (C) 2018 Vidushi Vashishth <vidushivashishth96@gmail.com> |
---|
4 | |
---|
5 | .. _examples: |
---|
6 | |
---|
7 | Tracing Examples |
---|
8 | **************** |
---|
9 | |
---|
10 | The following example executes RTEMS trace using trace buffering for the |
---|
11 | `fileio` sample testcase. |
---|
12 | |
---|
13 | Features |
---|
14 | -------- |
---|
15 | |
---|
16 | Tracing using trace buffering consists of the following sets of features: |
---|
17 | |
---|
18 | - Individual entry and exit records. |
---|
19 | - Task details such as CPU, current priority, real priority, task state and |
---|
20 | interrupt state. |
---|
21 | - Nano-second timestamp. |
---|
22 | - Interrupt safe buffer management. |
---|
23 | - Function argument capture. |
---|
24 | - Return value capture. |
---|
25 | - Shell command support to report to the console, save a buffer, assess status |
---|
26 | of tracing, or view buffers between specified index ranges. |
---|
27 | |
---|
28 | Prerequisites |
---|
29 | ------------- |
---|
30 | |
---|
31 | 1. Setup RTEMS for the `sparc/erc32` architecture-bsp pair to run the |
---|
32 | following example. |
---|
33 | 2. Download the fileio `configuration file <https://devel.rtems.org/attachment |
---|
34 | /wiki/Developer/Tracing/Trace_Buffering/fileio-trace.ini>`_ and store it on |
---|
35 | the top of the installed BSP's directory. |
---|
36 | 3. Change the value of the keys: `rtems-path` and `prefix` according to your |
---|
37 | rtems installation. The `rtems-path` is the path to the bsp installation |
---|
38 | and `prefix` is the path to the tools used to build rtems. Also set the |
---|
39 | value of the `rtems-bsp` key to `sparc/erc32`. |
---|
40 | |
---|
41 | Demonstration |
---|
42 | ------------- |
---|
43 | |
---|
44 | Inside the RTEMS build directory (the directory where the fileio configuration |
---|
45 | has been stored) run the following commands to generate traces: |
---|
46 | |
---|
47 | BSP is configured with the following command - |
---|
48 | |
---|
49 | .. code-block:: shell |
---|
50 | |
---|
51 | ../rtems/configure --target=sparc-rtems5 --prefix=/development/rtems/5 \ |
---|
52 | --enable-networking --enable-tests --enable-rtemsbsp=erc32 --enable-cxx |
---|
53 | |
---|
54 | The next two commands are used to link the fileio executable.The `-B` option |
---|
55 | signifies the use of the complete path to the required directory or file. Write |
---|
56 | the full path instead of the path file: `sparc-rtems5/erc32/lib/` in the |
---|
57 | following commands according to your installation. Also confirm the path of the |
---|
58 | fileio's executable and object files in the last line of the command according |
---|
59 | to your installation. |
---|
60 | |
---|
61 | .. code-block:: shell |
---|
62 | |
---|
63 | sparc-rtems5-gcc -Bsparc-rtems5/erc32/lib/ \ |
---|
64 | -specs bsp_specs -qrtems -mcpu=cypress -O2 -g -ffunction-sections \ |
---|
65 | -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration \ |
---|
66 | -Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -mcpu=cypress \ |
---|
67 | -o sparc-rtems5/c/erc32/testsuites/samples/fileio.exe sparc-rtems5/c/erc32/\ |
---|
68 | testsuites/samples/fileio/fileio-init.o |
---|
69 | |
---|
70 | This is the trace linker command to generate and compile the wrapper c file for |
---|
71 | the application. The link command follows the escape sequence "--". "-C" option |
---|
72 | denotes the name of the user configuration file and "-W" specifies the name of |
---|
73 | the wrapper c file. |
---|
74 | |
---|
75 | .. code-block:: shell |
---|
76 | |
---|
77 | rtems-tld -C fileio-trace.ini -W fileio-wrapper -- -Bsparc-rtems5/erc32/lib/ \ |
---|
78 | -specs bsp_specs -qrtems -mcpu=cypress -O2 -g -ffunction-sections \ |
---|
79 | -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration \ |
---|
80 | -Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -mcpu=cypress \ |
---|
81 | -o sparc-rtems5/c/erc32/testsuites/samples/fileio.exe sparc-rtems5/c/erc32/\ |
---|
82 | testsuites/samples/fileio/fileio-init.o |
---|
83 | |
---|
84 | The following command is used to run the application. Hit enter key quickly and |
---|
85 | type "s" and "root" and "pwd" to run the rtems shell. Use the `rtrace status`, |
---|
86 | `rtrace trace` and `rtrace save` commands to know the status of the tracing, |
---|
87 | display the contents of the trace buffer and save the buffer to disk in the form |
---|
88 | of binary files. Use `rtrace -l` to list the availalble options for commands |
---|
89 | with `rtrace`. |
---|
90 | |
---|
91 | .. code-block:: shell |
---|
92 | |
---|
93 | sparc-rtems5-run sparc-rtems5/c/erc32/testsuites/samples/fileio.exe |
---|
94 | |
---|
95 | The output from the above commands will be as follows: |
---|
96 | |
---|
97 | .. code-block:: shell |
---|
98 | |
---|
99 | *** BEGIN OF TEST FILE I/O *** |
---|
100 | *** TEST VERSION: 5.0.0.de9b7d712bf5da6593386fd4fbca0d5f8b8431d8 |
---|
101 | *** TEST STATE: USER_INPUT |
---|
102 | *** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API |
---|
103 | *** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB a3a6c34c150a357e57769a26a460c475e188438f, Newlib 3.0.0) |
---|
104 | Press any key to start file I/O sample (20s remaining) |
---|
105 | Press any key to start file I/O sample (19s remaining) |
---|
106 | Press any key to start file I/O sample (18s remaining) |
---|
107 | Press any key to start file I/O sample (17s remaining) |
---|
108 | Press any key to start file I/O sample (16s remaining) |
---|
109 | Press any key to start file I/O sample (15s remaining) |
---|
110 | Press any key to start file I/O sample (14s remaining) |
---|
111 | ========================= |
---|
112 | RTEMS FILE I/O Test Menu |
---|
113 | ========================= |
---|
114 | p -> part_table_initialize |
---|
115 | f -> mount all disks in fs_table |
---|
116 | l -> list file |
---|
117 | r -> read file |
---|
118 | w -> write file |
---|
119 | s -> start shell |
---|
120 | Enter your selection ==>s |
---|
121 | Creating /etc/passwd and group with four useable accounts: |
---|
122 | root/pwd |
---|
123 | test/pwd |
---|
124 | rtems/NO PASSWORD |
---|
125 | chroot/NO PASSWORD |
---|
126 | Only the root user has access to all available commands. |
---|
127 | ========================= |
---|
128 | starting shell |
---|
129 | ========================= |
---|
130 | |
---|
131 | Welcome to rtems-5.0.0 (SPARC/w/FPU/erc32) |
---|
132 | COPYRIGHT (c) 1989-2008. |
---|
133 | On-Line Applications Research Corporation (OAR). |
---|
134 | |
---|
135 | Login into RTEMS |
---|
136 | /dev/foobar login: root |
---|
137 | Password: |
---|
138 | |
---|
139 | RTEMS Shell on /dev/foobar. Use 'help' to list commands. |
---|
140 | SHLL [/] # rtrace status |
---|
141 | RTEMS Trace Bufferring: status |
---|
142 | Running: yes |
---|
143 | Triggered: yes |
---|
144 | Level: 0% |
---|
145 | Traces: 25 |
---|
146 | SHLL [/] # rtrace stop |
---|
147 | RTEMS Trace Bufferring: stop |
---|
148 | SHLL [/] # rtrace trace |
---|
149 | RTEMS Trace Bufferring: trace |
---|
150 | Trace buffer: 0x20921d8 |
---|
151 | Words traced: 1487 |
---|
152 | Traces: 25 |
---|
153 | 0:00:40.983197010 2081910 0a010002 [ 2/ 2] > malloc((size_t) 00000130) |
---|
154 | 0:00:40.983333119 136109 0a010002 [ 2/ 2] < malloc => (void*) 0x219bb88 |
---|
155 | 0:00:40.983471669 138550 0a010002 [ 2/ 2] > malloc((size_t) 00000006) |
---|
156 | 0:00:40.983606557 134888 0a010002 [ 2/ 2] < malloc => (void*) 0x219bcc0 |
---|
157 | 0:00:40.983684682 78125 0a010002 [ 2/ 2] > malloc((size_t) 00000007) |
---|
158 | 0:00:40.983819569 134887 0a010002 [ 2/ 2] < malloc => (void*) 0x219bcd0 |
---|
159 | 0:00:40.983909901 90332 0a010002 [ 2/ 2] > malloc((size_t) 000003fc) |
---|
160 | 0:00:40.984046620 136719 0a010002 [ 2/ 2] < malloc => (void*) 0x219bce0 |
---|
161 | 0:00:40.986624137 2577517 0a010003 [200/200] > malloc((size_t) 00000080) |
---|
162 | 0:00:40.986767569 143432 0a010003 [200/200] < malloc => (void*) 0x219bce0 |
---|
163 | 0:00:40.987531119 763550 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 0000005d) |
---|
164 | 0:00:40.987603751 72632 0a010003 [200/200] > malloc((size_t) 0000005d) |
---|
165 | 0:00:40.987744743 140992 0a010003 [200/200] < malloc => (void*) 0x219bce0 |
---|
166 | 0:00:40.987824699 79956 0a010003 [200/200] < calloc => (void*) 0x219bce0 |
---|
167 | 0:00:40.988302604 477905 0a010003 [200/200] > malloc((size_t) 00000080) |
---|
168 | 0:00:40.988446647 144043 0a010003 [200/200] < malloc => (void*) 0x219bd48 |
---|
169 | 0:00:40.988667595 220948 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080) |
---|
170 | 0:00:40.988740837 73242 0a010003 [200/200] > malloc((size_t) 00000080) |
---|
171 | 0:00:40.988884880 144043 0a010003 [200/200] < malloc => (void*) 0x219bdd0 |
---|
172 | 0:00:40.988964836 79956 0a010003 [200/200] < calloc => (void*) 0x219bdd0 |
---|
173 | 0:00:40.989042961 78125 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080) |
---|
174 | 0:00:40.989110100 67139 0a010003 [200/200] > malloc((size_t) 00000080) |
---|
175 | 0:00:40.989254143 144043 0a010003 [200/200] < malloc => (void*) 0x219be58 |
---|
176 | 0:00:40.989334099 79956 0a010003 [200/200] < calloc => (void*) 0x219be58 |
---|
177 | 0:00:40.990118401 784302 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000061) |
---|
178 | 0:00:40.990176995 58594 0a010003 [200/200] > malloc((size_t) 00000061) |
---|
179 | 0:00:40.990309441 132446 0a010003 [200/200] < malloc => (void*) 0x219bd48 |
---|
180 | 0:00:40.990384515 75074 0a010003 [200/200] < calloc => (void*) 0x219bd48 |
---|
181 | 0:00:40.990870355 485840 0a010003 [200/200] > malloc((size_t) 00000080) |
---|
182 | 0:00:40.991011346 140991 0a010003 [200/200] < malloc => (void*) 0x219bee0 |
---|
183 | 0:00:40.991227411 216065 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080) |
---|
184 | 0:00:40.991296380 68969 0a010003 [200/200] > malloc((size_t) 00000080) |
---|
185 | 0:00:40.991438593 142213 0a010003 [200/200] < malloc => (void*) 0x219bf68 |
---|
186 | 0:00:40.991514276 75683 0a010003 [200/200] < calloc => (void*) 0x219bf68 |
---|
187 | 0:00:40.991589349 75073 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080) |
---|
188 | 0:00:40.991653437 64088 0a010003 [200/200] > malloc((size_t) 00000080) |
---|
189 | 0:00:40.991794428 140991 0a010003 [200/200] < malloc => (void*) 0x219bff0 |
---|
190 | 0:00:40.991871332 76904 0a010003 [200/200] < calloc => (void*) 0x219bff0 |
---|
191 | 0:00:40.992283320 411988 0a010003 [200/200] > malloc((size_t) 00000008) |
---|
192 | SHLL [/] # rtrace save fileio-trace.bin |
---|
193 | RTEMS Trace Bufferring: trace |
---|
194 | Trace File: fileio-trace.bin |
---|
195 | Trace buffer: 0x20921d8 |
---|
196 | Words traced: 1487 |
---|
197 | Traces: 25 |
---|
198 | SHLL [/] # |
---|