llvm.org GIT mirror llvm / 0de2000
[llvm-readobj] Fix printing format 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. Differential Revision: https://reviews.llvm.org/D48271 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336058 91177308-0d34-0410-b5e6-96231b3b80d8 Paul Semel 2 years ago
2 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
0 RUN: llvm-readobj -p .text %p/Inputs/elf-groups.x86_64 \
1 RUN: | FileCheck %s
2
3 CHECK: [000000] UH..H....E.
4 CHECK: [00000f] .E.x.E..
5 CHECK: [00001a] ..}..
6 CHECK: [000023] .}..
7 CHECK: [00002b] 1.H...].
32743274 }
32753275 }
32763276
3277 void printAsPrintable(raw_ostream &W, StringRef S) {
3278 for (char C : S)
3279 W << (isprint(C) ? C : '.');
3280 }
3281
32773282 template
32783283 void GNUStyle::printSectionAsString(const ELFO *Obj,
32793284 StringRef SectionName) {
32973302 CurrentWord++;
32983303 continue;
32993304 }
3300 OS << format("[%6tx]", CurrentWord - SecContent);
3301 OS << format(" %.*s\n", WordSize, CurrentWord);
3305 OS << format("[%6tx] ", CurrentWord - SecContent);
3306 printAsPrintable(OS, StringRef(CurrentWord, WordSize));
3307 OS << '\n';
33023308 CurrentWord += WordSize + 1;
33033309 }
33043310 OS.flush();
43604366 W.startLine() << "["
43614367 << to_string(
43624368 format_hex_no_prefix((CurrentWord - SecContent), 6))
4363 << "]";
4364 W.startLine() << format(" %.*s\n", WordSize, CurrentWord);
4369 << "] ";
4370 printAsPrintable(W.startLine(), StringRef(CurrentWord, WordSize));
4371 W.startLine() << '\n';
43654372 CurrentWord += WordSize + 1;
43664373 }
43674374 }