3
3
## Memory Analyzer
4
4
5
5
The memory analyzer is a front-end for running and querying GDB in order to
6
- obtain a state of the input program. A common application would be to obtain a
7
- snapshot of a program under analysis at a particular state of execution. Such a
8
- snapshot could be useful on its own: to query about values of particular
9
- variables. Furthermore, since that snapshot is a state of a valid concrete
10
- execution, it can also be used for subsequent analyses.
6
+ obtain a state of the input program. The GDB is not needed to be executed
7
+ directly but is rather used as a back-end for the memory analysis. A common
8
+ application would be to obtain a snapshot of a program under analysis at a
9
+ particular state of execution. Such a snapshot could be useful on its own: to
10
+ query about values of particular variables. Furthermore, since that snapshot is
11
+ a state of a valid concrete execution, it can also be used for subsequent
12
+ analyses.
11
13
12
14
## Usage
13
15
@@ -16,18 +18,24 @@ debugging symbols and a symbol table information understandable by CBMC, e.g.
16
18
(having ` goto-gcc ` on the ` PATH ` ):
17
19
18
20
``` sh
19
- $ goto-gcc -g -std=c11 input_program.c -o input_program_exe
21
+ $ goto-gcc -g input_program.c -o input_program_exe
20
22
```
21
23
22
24
Calling ` goto-gcc ` instead of simply compiling with ` gcc ` produces an ELF binary
23
- with a goto section that contains the goto model (goto program + symbol table).
25
+ with a goto section that contains the goto model (goto program + symbol table)
26
+ [ goto-cc-variants] ( ../goto-cc/variants/ ) .
24
27
25
- The user can choose to either run GDB from a core-file ` --core-file cf ` or to a
26
- break-point ` --breakpoint bp ` (and only one of those). The tool also expects a
27
- comma-separated list of symbols to be analysed ` --symbols s1, s2, .. ` . Given its
28
- dependence on GDB, ` memory-analyzer ` is a Unix-only tool. The tool calls ` gdb `
29
- to obtain the snapshot which is why the ` -g ` option is necessary for the program
30
- symbols to be visible.
28
+ The memory analyzer supports two workflows to initiate the GDB with user code:
29
+ either to run the code from a core-file or up to a break-point. If the user
30
+ already has a core-file, they can specify it with the option ` --core-file cf ` .
31
+ If the user knows the point of their program from where they want to run the
32
+ analysis, they can specify it with the option ` --breakpoint bp ` . Only one of
33
+ core-file/break-point option can be used.
34
+
35
+ The tool also expects a comma-separated list of symbols to be analysed
36
+ ` --symbols s1, s2, .. ` . Given its dependence on GDB, ` memory-analyzer ` is a
37
+ Unix-only tool. The tool calls ` gdb ` to obtain the snapshot which is why the
38
+ ` -g ` option is necessary for the program symbols to be visible.
31
39
32
40
Take for example the following program:
33
41
@@ -51,7 +59,7 @@ Say we are interested in the evaluation of `array` at the call-site of
51
59
`checkpoint`. We compile the program with
52
60
53
61
```sh
54
- $ goto-gcc -g -std=c11 main.c -o main_exe
62
+ $ goto-gcc -g main.c -o main_exe
55
63
```
56
64
57
65
And then we call ` memory-analyzer ` with:
@@ -60,17 +68,20 @@ And then we call `memory-analyzer` with:
60
68
$ memory-analyzer --breakpoint checkpoint --symbols array main_exe
61
69
```
62
70
63
- to obtain as output:
71
+ to obtain as output the human readable list of values for each requested symbol :
64
72
65
73
```
66
74
{
67
75
array = { 1, 4, 3 };
68
76
}
69
77
```
70
78
71
- Finally, to obtain an output in JSON format, e.g. for further analyses by
72
- ` goto-harness ` pass the additional option ` --json-ui ` together with requesting
73
- the output to be a symbol table by ` --symtab-snapshot ` .
79
+ The above option is useful for the user and their preliminary analysis but does
80
+ not contain enough information for further computer-based analyses. To that end,
81
+ memory analyzer has an option to request the result to be a snapshot of the
82
+ whole symbol table ` --symtab-snapshot ` . Finally, to obtain an output in JSON
83
+ format, e.g. for further analyses by ` goto-harness ` pass the additional option
84
+ ` --json-ui ` .
74
85
75
86
``` sh
76
87
$ memory-analyzer --symtab-snapshot --json-ui \
0 commit comments