[PATCH] D48271: [llvm-readobj] Fix printing format
Paul Semel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 1 14:59:09 PDT 2018
paulsemel updated this revision to Diff 153656.
paulsemel added a comment.
I got a build fail here : http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10648
As for now, I still don't know why I'm getting this error, but I guessed it was because I was passing the raw_stream..
This should fix this, I hope
Repository:
rL LLVM
https://reviews.llvm.org/D48271
Files:
test/tools/llvm-readobj/print-section.test
tools/llvm-readobj/ELFDumper.cpp
Index: tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- tools/llvm-readobj/ELFDumper.cpp
+++ tools/llvm-readobj/ELFDumper.cpp
@@ -3275,6 +3275,13 @@
}
}
+static std::string getAsPrintable(raw_ostream &W, StringRef S) {
+ std::string Res;
+ for (char C : S)
+ Res += (isprint(C) ? C : '.');
+ return Res;
+}
+
template <class ELFT>
void GNUStyle<ELFT>::printSectionAsString(const ELFO *Obj,
StringRef SectionName) {
@@ -3298,8 +3305,9 @@
CurrentWord++;
continue;
}
- OS << format("[%6tx]", CurrentWord - SecContent);
- OS << format(" %.*s\n", WordSize, CurrentWord);
+ OS << format("[%6tx] ", CurrentWord - SecContent);
+ OS << getAsPrintable(OS, StringRef(CurrentWord, WordSize));
+ OS << '\n';
CurrentWord += WordSize + 1;
}
OS.flush();
@@ -4361,8 +4369,10 @@
W.startLine() << "["
<< to_string(
format_hex_no_prefix((CurrentWord - SecContent), 6))
- << "]";
- W.startLine() << format(" %.*s\n", WordSize, CurrentWord);
+ << "] ";
+ W.startLine() << getAsPrintable(W.startLine(),
+ StringRef(CurrentWord, WordSize));
+ W.startLine() << '\n';
CurrentWord += WordSize + 1;
}
}
Index: test/tools/llvm-readobj/print-section.test
===================================================================
--- /dev/null
+++ test/tools/llvm-readobj/print-section.test
@@ -0,0 +1,8 @@
+RUN: llvm-readobj -p .text %p/Inputs/elf-groups.x86_64 \
+RUN: | FileCheck %s
+
+CHECK: [000000] UH..H....E.
+CHECK: [00000f] .E.x.E..
+CHECK: [00001a] ..}..
+CHECK: [000023] .}..
+CHECK: [00002b] 1.H...].
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48271.153656.patch
Type: text/x-patch
Size: 1782 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180701/bb8a3b3f/attachment.bin>
More information about the llvm-commits
mailing list