Changeset 52 in libcf


Ignore:
Timestamp:
04/03/13 16:34:22 (12 years ago)
Author:
cheese
Message:

#1 fix debugging util bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_debug.c

    r51 r52  
    308308    push->line = line;
    309309    push->caller = context->callstack.caller;
    310     push->frameIndex = context->callstack.frameIndex + 1;
     310    push->frameIndex = push->caller == NULL
     311                     ? 0
     312                     : push->caller->frameIndex + 1;
    311313    context->callstack.caller = push;
    312314
     
    410412        return CF_ERROR_DEBUG_INVALID_CTX;
    411413
    412     callstack = &ctx->callstack;
    413 
    414     do
    415     {
    416         if (callstack == NULL)
    417             break;
    418 
    419         fprintf (fp, "#%04d %s (%s:%d)\n",
    420                      iter,
     414    for (callstack = ctx->callstack.caller ; callstack ; callstack = callstack->caller)
     415    {
     416        fprintf (fp, "#%-4d %s <%s:%d>\n",
     417                     iter++,
    421418                     callstack->func,
    422419                     callstack->file,
    423420                     callstack->line);
    424 
    425         callstack = callstack->caller;
    426     } while (iter++ < ctx->callstack.frameIndex);
     421    }
    427422
    428423    return CF_OK;
Note: See TracChangeset for help on using the changeset viewer.