summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-01-09 15:05:46 -0800
committerAndreas Gampe <agampe@google.com>2015-01-09 15:05:46 -0800
commit00bd2da6ea009dedafc677229b485923f49ad61b (patch)
treea01999d4da5aec08f83fa468c0b01576a0aad94a
parentb9b26e1b036308e18113e37dfa5b81a64d1a7bd4 (diff)
downloadart-00bd2da6ea009dedafc677229b485923f49ad61b.zip
art-00bd2da6ea009dedafc677229b485923f49ad61b.tar.gz
art-00bd2da6ea009dedafc677229b485923f49ad61b.tar.bz2
ART: Fix prefix issues in Addr2line dump
The code incorrectly wrote the prefix twice for overly long lines. Bug: 18933933 Change-Id: I4bc7c2cde435bd966276ca2dae6a5d060aa2d0f3
-rw-r--r--runtime/utils.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/runtime/utils.cc b/runtime/utils.cc
index ef12d6e..a71f1e9 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -1122,11 +1122,24 @@ std::string GetSchedulerGroupName(pid_t tid) {
}
#if defined(__linux__)
+
+ALWAYS_INLINE
+static inline void WritePrefix(std::ostream* os, const char* prefix, bool odd) {
+ if (prefix != nullptr) {
+ *os << prefix;
+ }
+ *os << " ";
+ if (!odd) {
+ *os << " ";
+ }
+}
+
static bool RunCommand(std::string cmd, std::ostream* os, const char* prefix) {
FILE* stream = popen(cmd.c_str(), "r");
if (stream) {
if (os != nullptr) {
bool odd_line = true; // We indent them differently.
+ bool wrote_prefix = false; // Have we already written a prefix?
constexpr size_t kMaxBuffer = 128; // Relatively small buffer. Should be OK as we're on an
// alt stack, but just to be sure...
char buffer[kMaxBuffer];
@@ -1139,22 +1152,16 @@ static bool RunCommand(std::string cmd, std::ostream* os, const char* prefix) {
if (new_line == nullptr) {
// Print the rest.
if (*tmp != 0) {
- if (prefix != nullptr) {
- *os << prefix;
- }
- if (!odd_line) {
- *os << " ";
+ if (!wrote_prefix) {
+ WritePrefix(os, prefix, odd_line);
}
+ wrote_prefix = true;
*os << tmp;
}
break;
}
- if (prefix != nullptr) {
- *os << prefix;
- }
- *os << " ";
- if (!odd_line) {
- *os << " ";
+ if (!wrote_prefix) {
+ WritePrefix(os, prefix, odd_line);
}
char saved = *(new_line + 1);
*(new_line + 1) = 0;
@@ -1162,6 +1169,7 @@ static bool RunCommand(std::string cmd, std::ostream* os, const char* prefix) {
*(new_line + 1) = saved;
tmp = new_line + 1;
odd_line = !odd_line;
+ wrote_prefix = false;
}
}
}