Skip to content

Commit 6e6e569

Browse files
petr-bauchdanpoe
authored andcommitted
Address comments about user documentation
Will be squashed.
1 parent 16e31c0 commit 6e6e569

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

doc/cprover-manual/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
[A Short Tutorial](cbmc/tutorial/),
1010
[Loop Unwinding](cbmc/unwinding/),
11-
[Assertion Checking](cbmc/assertions/)
11+
[Assertion Checking](cbmc/assertions/),
12+
[Memory Analyzer](cbmc/memory-analyzer/),
13+
[Program Harness](cbmc/goto-harness/)
1214

1315
## 4. [Test Suite Generation](test-suite/)
1416

doc/cprover-manual/memory-analyzer.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
## Memory Analyzer
44

55
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.
1113

1214
## Usage
1315

@@ -16,18 +18,24 @@ debugging symbols and a symbol table information understandable by CBMC, e.g.
1618
(having `goto-gcc` on the `PATH`):
1719

1820
```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
2022
```
2123

2224
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/).
2427

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.
3139

3240
Take for example the following program:
3341

@@ -51,7 +59,7 @@ Say we are interested in the evaluation of `array` at the call-site of
5159
`checkpoint`. We compile the program with
5260
5361
```sh
54-
$ goto-gcc -g -std=c11 main.c -o main_exe
62+
$ goto-gcc -g main.c -o main_exe
5563
```
5664

5765
And then we call `memory-analyzer` with:
@@ -60,17 +68,20 @@ And then we call `memory-analyzer` with:
6068
$ memory-analyzer --breakpoint checkpoint --symbols array main_exe
6169
```
6270

63-
to obtain as output:
71+
to obtain as output the human readable list of values for each requested symbol:
6472

6573
```
6674
{
6775
array = { 1, 4, 3 };
6876
}
6977
```
7078

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`.
7485

7586
```sh
7687
$ memory-analyzer --symtab-snapshot --json-ui \

0 commit comments

Comments
 (0)