Changeset 51 in libcf for trunk/test/debug.c


Ignore:
Timestamp:
04/02/13 10:23:52 (11 years ago)
Author:
cheese
Message:

#1 change the debugging utiltity to support single context with mutex

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/debug.c

    r35 r51  
    77#include "cf_debug.h"
    88
    9 CF_Debug_Ctx gDebugCtx;
     9#include <string.h>
    1010
    1111void callee (void) {
    12     CF_Debug_CallStack callstack;
    13    
    14     CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
    15     CF_DEBUG_CALLSTACK_POP (gDebugCtx, &callstack);
     12    CF_DEBUG_BEGIN_FUNCTION;
     13
     14    CF_Debug_PrintCallStack (stdout);
     15
     16    CF_DEBUG_END_FUNCTION;
    1617}
    1718
    1819int main (void) {
    19     int fd = 0;
    20     gDebugCtx = CF_Debug_CreateCtx ();
     20    char data[] =
     21        "【 曲名 : 사랑하고 있는데 】\n"
     22        "《 歌 : Kylee 》\n"
     23        "『 절원의 템페스트 OP2 Theme 』\n";
    2124
    22     CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
     25    CF_DEBUG_BEGIN_FUNCTION;
    2326
    24     CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to stderr\n");
     27    CF_DEBUG_PRINT (stderr, "print message with context to stderr\n");
    2528
    26     fd = CF_File_Create ("debug.txt");
    27     if (fd < 0) {
    28         CF_DEBUG_PRINT (stderr, "error ...\n");
    29         // error
    30     }
    31     CF_Debug_SetOutputFD (gDebugCtx, fd);
     29    CF_DEBUG_PRINT_BIN (stdout, (unsigned char *) data, (int) sizeof (data), "hehehehe\n");
    3230
    33     CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to debug.txt\n");
     31    callee ();
    3432
    35     CF_DEBUG_CALLSTACK_POP (gDebugCtx, NULL);
    36 
    37     CF_Debug_DestroyCtx (gDebugCtx);
     33    CF_DEBUG_END_FUNCTION;
    3834
    3935    return 0;
Note: See TracChangeset for help on using the changeset viewer.