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
。。。。。。
}