From 29e6fa110d422f6993a60d476cd2b7e8e6e95126 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Tue, 15 Jun 1999 05:27:09 +0000 Subject: [PATCH] Clean up stack trace output: add displacements and remove spaces that sometimes appear in demangled symbols (so my perl script doesn't barf). git-svn-id: svn://10.0.0.236/trunk@35377 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/base/nsTraceRefcnt.cpp | 19 +++++++++++++------ mozilla/xpcom/base/nsTraceRefcntImpl.cpp | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/mozilla/xpcom/base/nsTraceRefcnt.cpp b/mozilla/xpcom/base/nsTraceRefcnt.cpp index 20fac2d80b8..047c138e441 100644 --- a/mozilla/xpcom/base/nsTraceRefcnt.cpp +++ b/mozilla/xpcom/base/nsTraceRefcnt.cpp @@ -199,16 +199,23 @@ nsTraceRefcnt::WalkTheStack(char* aBuffer, int aBufLen) if (ok) { int nameLen = strlen(symbol->Name); - if (nameLen + 2 > aBufLen) { + if (nameLen + 12 > aBufLen) { // 12 == strlen("+0x12345678 ") break; } - memcpy(cp, symbol->Name, nameLen); - cp += nameLen; - *cp++ = ' '; - aBufLen -= nameLen + 1; + char* cp2 = symbol->Name; + while (*cp2) { + if (*cp2 == ' ') *cp2 = '_'; // replace spaces with underscores + *cp++ = *cp2++; + } + aBufLen -= nameLen; + char tmp[30]; + PR_snprintf(tmp, sizeof(tmp), "+0x%08x ", displacement); + memcpy(cp, tmp, 12); + cp += 12; + aBufLen -= nameLen + 12; } else { - if (11 > aBufLen) { + if (11 > aBufLen) { // 11 == strlen("0x12345678 ") break; } char tmp[30]; diff --git a/mozilla/xpcom/base/nsTraceRefcntImpl.cpp b/mozilla/xpcom/base/nsTraceRefcntImpl.cpp index 20fac2d80b8..047c138e441 100644 --- a/mozilla/xpcom/base/nsTraceRefcntImpl.cpp +++ b/mozilla/xpcom/base/nsTraceRefcntImpl.cpp @@ -199,16 +199,23 @@ nsTraceRefcnt::WalkTheStack(char* aBuffer, int aBufLen) if (ok) { int nameLen = strlen(symbol->Name); - if (nameLen + 2 > aBufLen) { + if (nameLen + 12 > aBufLen) { // 12 == strlen("+0x12345678 ") break; } - memcpy(cp, symbol->Name, nameLen); - cp += nameLen; - *cp++ = ' '; - aBufLen -= nameLen + 1; + char* cp2 = symbol->Name; + while (*cp2) { + if (*cp2 == ' ') *cp2 = '_'; // replace spaces with underscores + *cp++ = *cp2++; + } + aBufLen -= nameLen; + char tmp[30]; + PR_snprintf(tmp, sizeof(tmp), "+0x%08x ", displacement); + memcpy(cp, tmp, 12); + cp += 12; + aBufLen -= nameLen + 12; } else { - if (11 > aBufLen) { + if (11 > aBufLen) { // 11 == strlen("0x12345678 ") break; } char tmp[30];