[PATCH] D48271: [llvm-readobj] Fix printing format
Paul Semel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 18 03:36:07 PDT 2018
paulsemel created this revision.
paulsemel added reviewers: echristo, dblaikie.
We were printing every character, even those that weren't printable. It doesn't really make sense for this option.
The string content was sticked to its address, added two spaces in between (this matches GNU readelf behavior)
Repository:
rL LLVM
https://reviews.llvm.org/D48271
Files:
tools/llvm-readobj/ELFDumper.cpp
Index: tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- tools/llvm-readobj/ELFDumper.cpp
+++ tools/llvm-readobj/ELFDumper.cpp
@@ -3243,8 +3243,14 @@
CurrentWord++;
continue;
}
- OS << format("[%6tx]", CurrentWord - SecContent);
- OS << format(" %.*s\n", WordSize, CurrentWord);
+ OS << format("[%6tx] ", CurrentWord - SecContent);
+ for (size_t i = 0; i < WordSize; ++i) {
+ if (isprint(CurrentWord[i]))
+ OS << CurrentWord[i];
+ else
+ OS << '.';
+ }
+ OS << '\n';
CurrentWord += WordSize + 1;
}
OS.flush();
@@ -4270,8 +4276,14 @@
W.startLine() << "["
<< to_string(
format_hex_no_prefix((CurrentWord - SecContent), 6))
- << "]";
- W.startLine() << format(" %.*s\n", WordSize, CurrentWord);
+ << "] ";
+ for (size_t i = 0; i < WordSize; ++i) {
+ if (isprint(CurrentWord[i]))
+ W.startLine() << CurrentWord[i];
+ else
+ W.startLine() << '.';
+ }
+ W.startLine() << '\n';
CurrentWord += WordSize + 1;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48271.151675.patch
Type: text/x-patch
Size: 1162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180618/23c8c545/attachment.bin>
More information about the llvm-commits
mailing list