Skip to content

Commit 05a4127

Browse files
committed
test
1 parent 5f3890a commit 05a4127

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

cli/stacktrace.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ void print_stacktrace(FILE* output, int start_idx, bool demangling, int maxdepth
3636
void *callstackArray[32]= {nullptr}; // the less resources the better...
3737
fputs("backtrace\n", output);
3838
const int currentdepth = backtrace(callstackArray, static_cast<int>(getArrayLength(callstackArray)));
39-
fprintf(output, "currentdepth %d", currentdepth);
39+
fprintf(output, "currentdepth %d\n", currentdepth);
4040
// set offset to 1 to omit the printing function itself
4141
int offset=start_idx+1; // some entries on top are within our own exception handling code or libc
42-
fprintf(output, "offset %d", offset);
42+
fprintf(output, "offset %d\n", offset);
4343
if (maxdepth<0)
4444
maxdepth=currentdepth-offset;
4545
else
4646
maxdepth = std::min(maxdepth, currentdepth);
47-
fprintf(output, "maxdepth %d", maxdepth);
47+
fprintf(output, "maxdepth %d\n", maxdepth);
4848

4949
fputs("backtrace_symbols\n", output);
5050
char **symbolStringList = backtrace_symbols(callstackArray, currentdepth);
@@ -57,22 +57,31 @@ void print_stacktrace(FILE* output, int start_idx, bool demangling, int maxdepth
5757
bool own_code = false;
5858
char demangle_buffer[2048]= {0};
5959
for (int i = offset; i < maxdepth; ++i) {
60+
fprintf(output, "offset %d\n", offset);
6061
const char * const symbolString = symbolStringList[i];
61-
fprintf(output, "symbolString %p", symbolString);
62+
fprintf(output, "symbolString %p\n", (void*)symbolString);
63+
fprintf(output, "%s\n", symbolString);
6264
// skip all leading libc symbols so the first symbol is our code
6365
if (omit_above_own && !own_code) {
6466
if (strstr(symbolString, "/libc.so.6") != nullptr)
6567
continue;
6668
own_code = true;
67-
offset = i; // make sure the numbering is continous if we omit frames
69+
offset = i; // make sure the numbering is continuous if we omit frames
6870
}
71+
fprintf(output, "offset %d\n", offset);
6972
const char * realnameString = nullptr;
7073
const char * const firstBracketName = strchr(symbolString, '(');
74+
fprintf(output, "firstBracketName %p\n", (void*)firstBracketName);
7175
const char * const firstBracketAddress = strchr(symbolString, '[');
76+
fprintf(output, "firstBracketAddress %p\n", (void*)firstBracketAddress);
7277
const char * const secondBracketAddress = strchr(firstBracketAddress, ']');
78+
fprintf(output, "secondBracketAddress %p\n", (void*)secondBracketAddress);
7379
const char * const beginAddress = firstBracketAddress+3;
80+
fprintf(output, "beginAddress %p\n", (void*)beginAddress);
7481
const int addressLen = int(secondBracketAddress-beginAddress);
82+
fprintf(output, "addressLen %d\n", addressLen);
7583
const int padLen = (ADDRESSDISPLAYLENGTH-addressLen);
84+
fprintf(output, "padLen %d\n", padLen);
7685
if (demangling && firstBracketName) {
7786
const char * const plus = strchr(firstBracketName, '+');
7887
if (plus && (plus>(firstBracketName+1))) {

0 commit comments

Comments
 (0)