Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[runtime/trace] create stackwalker #15

Merged
13 commits merged into from
Oct 26, 2017
Merged

[runtime/trace] create stackwalker #15

13 commits merged into from
Oct 26, 2017

Conversation

ghost
Copy link

@ghost ghost commented Oct 26, 2017

No description provided.

@ghost ghost closed this Oct 26, 2017
@ghost ghost reopened this Oct 26, 2017
@ghost ghost closed this Oct 26, 2017
@ghost ghost reopened this Oct 26, 2017
@ghost ghost closed this Oct 26, 2017
@ghost ghost reopened this Oct 26, 2017
@isuruf
Copy link
Owner

isuruf commented Oct 26, 2017

Added you to the appveyor team

@ghost ghost merged commit c0dfdc9 into windows Oct 26, 2017
@ghost ghost deleted the trace branch October 26, 2017 19:50
@ghost
Copy link
Author

ghost commented Oct 26, 2017

@isuruf I think cmake is passing the fortran files -DLINUX and such. I tried to kill that but failed. Do you have any ideas there?

@ghost
Copy link
Author

ghost commented Oct 26, 2017

Also, heres, _fortio_binary_mode:

int
__io_binary_mode(void *fp)
{
#if defined(WINNT)
#include <fcntl.h>

#if defined(WIN64) || defined(WIN32)
#define O_BINARY _O_BINARY
#endif

 int mode;

 mode = setmode(fileno((FILE *)fp), O_BINARY);
 if (mode == -1) {
   /* The mode argument is clearly legal, so this should not
    * happen.  But, in a console app, setmode will fail on
    * the fd representing stdout.
    */
   return 0;
 }
 (void)setmode(fileno((FILE *)fp), mode);
 return (mode & O_BINARY);
#else
 return 1;
#endif
}

@isuruf
Copy link
Owner

isuruf commented Oct 26, 2017

@ghost
Copy link
Author

ghost commented Oct 26, 2017

That's not what I'm talking about. This is nmake output:

C:\Miniconda36-x64\Library\bin\flang.exe -DGTEST_HAS_RTTI=0 -DHOST_WIN -DLINUX -DMAXCPUS=256 -DMAXCPUSL=8 -DMAXCPUSR=8 -DNATIVE_FPCVT -DPGF90 -DPGFLANG -DPGI_LITTLE_ENDIAN -DTARGET_LINUX -DTARGET_WIN -DTARGET_WIN_X86 -DTARGET_WIN_X8664 -DTARGET_X8664 -DUNICODE -DWIN32 -DWIN64 -DWINNT -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dflang_shared_EXPORTS -DHAVE_LONG_LONG_INT -DINT32PTR64 -DTARGET_WIN_X8664 -DTM_I8 -IC:\projects\flang\include -IC:\projects\flang\build\include -IC:\Miniconda36-x64\Library\include -IC:\projects\flang\runtime\include -IC:\projects\flang\runtime\flang -IC:\projects\flang\build\runtime\flang -B C:/projects/flang/build/./bin    -Mreentrant -c C:\projects\flang\runtime\flang\vmmul_real8.F95 -o CMakeFiles\flang_shared.dir\vmmul_real8.F9

}
char szUserName[1024] = {0};
DWORD dwSize = 1024;
GetUserNameA(szUserName, &dwSize);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghost
Copy link
Author

ghost commented Oct 29, 2017

@isuruf this approach is completely wrong, should be

void printStack( void )
{
     unsigned int   i;
     void         * stack[ 100 ];
     unsigned short frames;
     SYMBOL_INFO  * symbol;
     HANDLE         process;

     process = GetCurrentProcess();

     SymInitialize( process, NULL, TRUE );

     frames               = CaptureStackBackTrace( 0, 100, stack, NULL );
     symbol               = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 );
     symbol->MaxNameLen   = 255;
     symbol->SizeOfStruct = sizeof( SYMBOL_INFO );

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

         printf( "%i: %s - 0x%0X\n", frames - i - 1, symbol->Name, symbol->Address );
     }

     free( symbol );
}

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants