14 #include "boost/io/ios_state.hpp"
22 constexpr
unsigned int width = 16;
39 const char*
ptr =
reinterpret_cast<const char*
> (addr);
42 boost::io::ios_all_saver saver (
s);
46 char cbuf[
width + 1] = {0};
53 if ((ipos %
width) == 0) {
54 s << std::setw(16) << reinterpret_cast<uintptr_t>(
ptr + ipos) -
offset <<
" ";
56 if ((ipos % 4) == 0) {
59 bbuf.uc[ipos % 4] =
ptr[ipos];
60 cbuf[ipos %
width] = std::isgraph (
ptr[ipos]) ?
ptr[ipos] :
'.';
63 if ((ipos % 4) == 0) {
64 s << std::setw(8) << static_cast<unsigned int>(bbuf.u32);
66 if ((ipos %
width) == 0) {
67 s <<
" " << cbuf <<
"\n";
71 if ((ipos %
width) > 0) {
72 unsigned ntrail = (ipos % 4);
74 for (
unsigned i = ntrail;
i < 4;
i++) {
77 s << std::setw(2*ntrail) << static_cast<unsigned int>(bbuf.u32);
79 while ((ipos %
width) != 0) {
80 if ((ipos % 4) == 0) {
84 cbuf[ipos %
width] =
' ';
87 s <<
" " << cbuf <<
"\n";
106 const char*
ptr =
reinterpret_cast<const char*
> (addr);
109 size_t nadj =
reinterpret_cast<uintptr_t
>(
ptr) %
width;
115 size_t pagesize = sysconf (_SC_PAGESIZE);
121 uintptr_t iptr =
reinterpret_cast<uintptr_t
>(
ptr);
122 size_t thispage = ((iptr + pagesize) & ~(pagesize-1)) - iptr;
131 boost::io::ios_all_saver saver (
s);
134 s << std::setw(16) << reinterpret_cast<uintptr_t>(
ptr) -
offset
135 <<
" --- is not readable\n";