Clean up stack trace output: add displacements and remove spaces that sometimes appear in demangled symbols (so my perl script doesn't barf).

This commit is contained in:
waterson%netscape.com 1999-06-15 05:27:09 +00:00
parent 1ffc33fded
commit c621cde475
2 changed files with 26 additions and 12 deletions

View File

@ -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];

View File

@ -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];