ngx_backtrace_module.c for winddows 补丁

ngx_backtrace_module.c

#ifdef __CYGWIN__
#include <windows.h>
#include <dbghelp.h>
#else
#include <execinfo.h>
#endif
。。。。。。
static void
ngx_error_signal_handler(int signo){
。。。。。。
#ifdef __CYGWIN__

     unsigned int   i;
     unsigned short frames;
	 void         ** stack=buffer;
     SYMBOL_INFO  * symbol;
     HANDLE         process;

     process = GetCurrentProcess();
     SymInitialize( process, NULL, TRUE );
     frames               = CaptureStackBackTrace( 0, bcf->max_stack_size, stack, NULL );
     symbol               = ( SYMBOL_INFO * )ngx_pcalloc(ngx_cycle->pool, sizeof( SYMBOL_INFO ) + 256 * sizeof( char ));
     symbol->MaxNameLen   = 255;
     symbol->SizeOfStruct = sizeof( SYMBOL_INFO );

     for( i = 0; i < frames; i++ )
     {
         SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );

         //fprintf(log->file->fd, "[%02d] %s [0x%0X]\n", frames - i - 1, symbol->Name, symbol->Address );
     }

     ngx_pfree(ngx_cycle->pool, symbol);
#else	
    size_t size = backtrace(buffer, bcf->max_stack_size);
    backtrace_symbols_fd(buffer, size, log->file->fd);
#endif
。。。。。。
}

发布了84 篇原创文章 · 获赞 15 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/TDGX2004/article/details/100911432