259
The report states that the problem resides at line 91 of the listing_12-38.cpp writer
program. To fix listing_12-38.cpp, move the counter incrementation after all the data
in the record has been flushed all the way to persistent media. Listing 12-45 shows the
corrected part of the code.
Listing 12-45. Fix Listing 12-38 by moving the incrementation of the counter to
the end of the loop (line 95)
86
for (uint8_t i = 0; i < 10; i++) {
87
if (rand() % 2 == 0) {
88
snprintf(records[i].name, 63,
89
"record #%u", i + 1);
90
pop.persist(records[i].name, 63);
91
records[i].valid = 2;
92
} else
93
records[i].valid = 1;
94
pop.persist(&(records[i].valid), 1);
95
header->counter++;
96
}
Summary
This chapter provided an introduction to each tool and described how to use them.
Catching issues early in the development cycle can save countless hours of debugging
complex code later on. This chapter introduced three valuable tools – Persistence
Inspector, pmemcheck, and pmreorder – that persistent memory programmers will want
to integrate into their development and testing cycles to detect issues. We demonstrated
how useful these tools are at detecting many different types of common programming
errors.
The Persistent Memory Development Kit (PMDK) uses the tools described here to
ensure each release is fully validated before it is shipped. The tools are tightly integrated
into the PMDK continuous integration (CI) development cycle, so you can quickly catch
and fix issues.
Chapter 12 Debugging persistent MeMory appliCations
Précédent

- 283/457

Suivant