241
54
data = (int *)mmap(NULL, sizeof(int),
55
PROT_READ | PROT_WRITE,
56
MAP_SHARED_VALIDATE | MAP_SYNC,
57
fd, 0);
58
VALGRIND_PMC_REGISTER_PMEM_MAPPING(data,
59
sizeof(int));
60
61
// writing twice before flushing
62
*data = 1234;
63
*data = 4321;
64
flush((void *)data, sizeof(int));
65
66
munmap(data, sizeof(int));
67
VALGRIND_PMC_REMOVE_PMEM_MAPPING(data,
68
sizeof(int));
69
return 0;
70 }
Listing 12-32 shows the report from pmemcheck with the code from Listing 12-31.
To make pmemcheck look for overwrites, we must use the --mult-stores=yes option.
Listing 12-32. Running pmemcheck with Listing 12-31
$ valgrind --tool=pmemcheck --mult-stores=yes ./listing_12-31
==25609== pmemcheck-1.0, a simple persistent store checker
==25609== Copyright (c) 2014-2016, Intel Corporation
==25609== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==25609== Command: ./listing_12-31
==25609==
==25609==
==25609== Number of stores not made persistent: 0
==25609==
==25609== Number of overwritten stores: 1
==25609== Overwritten stores before they were made persistent:
==25609== [0]
at 0x400962: main (listing_12-31.c:62)
==25609==
Address: 0x4023000
size: 4 state: DIRTY
==25609== ERROR SUMMARY: 1 errors
Chapter 12 Debugging persistent MeMory appliCations
Précédent

- 265/457

Suivant