• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大熊的口袋

             

            vc6下支持格式化輸出的調試輸出功能的簡單實現

            VC下沒有支持可變參數的調試輸出實現.今天搗鼓了半天做了一個簡單的:)


            // dgb_prt.h

            #include <windows.h>

            #define _DEBUG_INFO_FILE  "gfx_dbg_info.txt" // 修改這里的輸出文件

            VOID _cdecl __DPrt(
            const WCHAR *fmt, );
            VOID _cdecl __RPrt(
            const WCHAR *fmt, );
            VOID _cdecl __ADPrt(BOOL, 
            const WCHAR *fmt, );
            VOID _cdecl __ARPrt(BOOL, 
            const WCHAR *fmt, );

            #ifndef NDEBUG
            # define _DbgPrt __DPrt
            #else
            # define _DbgPrt __RPrt
            #endif

            #ifndef NDEBUG
            # define _AstPrt __ADPrt
            #else
            # define _AstPrt __ARPrt
            #endif

             

            // dbg_prt.cpp

            // -------------------------------------------------------------------------
            #define _STDOUT_FP        (1)

            #define _DEBUG_INFO_FILE  "dbg_info.txt"

            // -------------------------------------------------------------------------
            typedef struct __DbgPrtPara
            {
             FILE 
            *pfp;
             
            int   pfd;
             unsigned 
            long pret;
            }
             _DbgPrtPara, *_PDbgPrtPara;

            _PDbgPrtPara __stdcall __DPrtInit()
            {
             _PDbgPrtPara pDbgPara 
            = (_PDbgPrtPara)malloc(sizeof(_DbgPrtPara));
             pDbgPara
            ->pfd = _dup(_STDOUT_FP);
             pDbgPara
            ->pfp = freopen(_DEBUG_INFO_FILE, "a+", stdout);
             unsigned 
            short buff[128= {'\0'};
             _wstrtime(buff);
             wprintf(L
            "%s: ", buff);
             
            return pDbgPara;
            }


            void __stdcall __DPrtClose(_PDbgPrtPara pDbgPara)
            {
             fflush(pDbgPara
            ->pfp);
             fclose(pDbgPara
            ->pfp);
             _dup2(pDbgPara
            ->pfd, _STDOUT_FP);
             free(pDbgPara);
             pDbgPara 
            = NULL;
            }


            // -------------------------------------------------------------------------
            __declspec(naked) void __DPrt(const unsigned short *fmt, )
            {
             
            #ifdef _M_IX86
             
             __asm
            {
              call    __DPrtInit
              pop     ebx
              mov     dword ptr [eax 
            + 8], ebx
              mov     ebx, eax
              
              call    dword ptr [wprintf]
              
              push    ebx
              mov     eax, dword ptr [ebx 
            + 8]
              mov     ebx, eax
              call    __DPrtClose
              push    ebx
              ret
             }

             
            #endif
             
            }


            // -------------------------------------------------------------------------
            void __RPrt(const unsigned short *fmt, )
            {
             
            }



            // -------------------------------------------------------------------------
            __declspec(naked) void __ADPrt(unsigned longconst unsigned short *fmt, )
            {
             
            #ifdef _M_IX86
             
             __asm
            {
              mov     eax, dword ptr [esp 
            + 4]
              cmp     eax, 
            0
              je      EXE_TRUE
              ret
            EXE_TRUE:
              call    __DPrtInit
              pop     ebx
              mov     dword ptr [eax 
            + 8], ebx
              mov     ebx, eax
              pop     eax
              
              call    dword ptr [wprintf]
              
              push    ebx
              mov     eax, dword ptr [ebx 
            + 8]
              mov     ebx, eax
              call    __DPrtClose
              sub     esp, 
            4
              push    ebx
              ret
             }

             
            #endif
             
            }


            // -------------------------------------------------------------------------
            void _cdecl __ARPrt(unsigned longconst unsigned short *fmt, )
            {
             
            }


            // -------------------------------------------------------------------------

             

             

              當然,如果要實時看到輸出,可以用 FindFirstChangeNotification、FindNextChangeNotification、FILE_NOTIFY_CHANGE_LAST_WRITE等來實現一個動態監視并輸出的程序.

              這樣就有點象ddk里的DbgPrint了,呵呵.

            posted on 2008-08-27 12:24 大熊的口袋 閱讀(1668) 評論(0)  編輯 收藏 引用 所屬分類: cpp

            導航

            統計

            公告

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            win32 & debug

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲午夜福利精品久久| 久久亚洲国产精品123区| 色婷婷综合久久久久中文| 久久精品99久久香蕉国产色戒| 久久精品国产亚洲77777| 伊人热人久久中文字幕| 久久人人青草97香蕉| 国产精品女同久久久久电影院| 久久青青草原综合伊人| 手机看片久久高清国产日韩| 色综合久久久久无码专区 | 久久高潮一级毛片免费| 中文成人久久久久影院免费观看| 久久婷婷激情综合色综合俺也去 | 久久夜色精品国产| 无码AV中文字幕久久专区| 国产一区二区精品久久岳| 久久久久久国产精品免费无码 | 少妇精品久久久一区二区三区| 国产激情久久久久影院小草 | 青草久久久国产线免观| 国产精品久久久久久久久免费| 久久www免费人成看片| 狠狠久久综合| 91久久香蕉国产熟女线看| 久久精品a亚洲国产v高清不卡| 国产aⅴ激情无码久久| 午夜视频久久久久一区| 久久91这里精品国产2020| 99久久久国产精品免费无卡顿| 亚洲精品国产字幕久久不卡| 香蕉久久夜色精品国产尤物| 久久午夜福利电影| 久久亚洲精品无码观看不卡| 久久99精品九九九久久婷婷| 中文字幕成人精品久久不卡| 999久久久国产精品| 久久播电影网| 国产欧美久久久精品影院| 四虎影视久久久免费观看| 色99久久久久高潮综合影院|