Skip to content

Commit ed78835

Browse files
committed
Cosmetics for print_stacktrace()
1 parent dd76aa4 commit ed78835

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ static const char *signal_name(int signo)
230230
/*
231231
* Try to print the callstack.
232232
* That is very sensitive to the operating system, hardware, compiler and runtime!
233+
* The code is not meant for production environment, it's using functions not whitelisted for usage in a signal handler function.
233234
*/
234235
static void print_stacktrace(FILE* f, bool demangling)
235236
{
@@ -249,7 +250,6 @@ static void print_stacktrace(FILE* f, bool demangling)
249250
const char * const beginAddress = firstBracketAddress+3;
250251
const int addressLen = int(secondBracketAddress-beginAddress);
251252
const int padLen = int(ADDRESSDISPLAYLENGTH-addressLen);
252-
//fprintf(f, "AddressDisplayLength=%d addressLen=%d padLen=%d\n", ADDRESSDISPLAYLENGTH, addressLen, padLen);
253253
if (demangling && firstBracketName) {
254254
const char * const plus = strchr(firstBracketName, '+');
255255
if (plus && (plus>(firstBracketName+1))) {
@@ -261,8 +261,9 @@ static void print_stacktrace(FILE* f, bool demangling)
261261
realname = abi::__cxa_demangle(input_buffer, output_buffer, &length, &status); // non-NULL on success
262262
}
263263
}
264-
fprintf(f, "#%d 0x",
265-
i-offset);
264+
const int ordinal=i-offset;
265+
fprintf(f, "#%-2d 0x",
266+
ordinal);
266267
if (padLen>0)
267268
fprintf(f, "%0*d",
268269
padLen, 0);

0 commit comments

Comments
 (0)