257
53 pobj::pool pop;
54
55 int main(int argc, char *argv[]) {
56
57
pop = pobj::pool::open("/mnt/pmem/file",
58
"RECORDS");
59
auto proot = pop.root();
60
pobj::persistent_ptr header
61
= proot->header;
62
pobj::persistent_ptr records
63
= proot->records;
64
65
for (uint8_t i = 0; i < header->counter; i++) {
66
if (records[i].valid < 1 or
67
records[i].valid > 2)
68
return 1; // data struc. corrupted
69
}
70
71
pop.close();
72
return 0; // everything ok
73 }
The program in Listing 12-42 iterates over all the records that we expect should have
been written correctly to persistent memory (lines 65-69). It checks the valid flag for
each record, which should be either 1 or 2 for the record to be correct (line 66). If an
issue is detected, the checker will return 1 indicating data corruption.
Listing 12-43 shows a three-step process for analyzing the program:
1. Create an object type persistent memory pool, known as a
memory-mapped file, on /mnt/pmem/file of size 100MiB, and
name the internal layout “RECORDS.”
2. Use the pmemcheck Valgrind tool to record data and call stacks
while the program is running.
3. The pmreorder utility processes the store.log output file from
pmemcheck using the ReorderFull engine to produce a final report.
Chapter 12 Debugging persistent MeMory appliCations
Précédent

- 281/457

Suivant