Sometimes, I'd like to print out the stack trace inside a jit helper. As an example, I tried it on HELPER_CALL STFLD_I4_helper in fjit\fjitdef.h:
void HELPER_CALL STFLD_I4_helper(unsigned int offset, int val, CORINFO_Object* or_obj) { if (or_obj == NULL) { THROW_FROM_HELPER(CORINFO_NullReferenceException); } // Added to print stack trace: FJit_pHlpMyTest(NULL); *((int*) ((char*)(or_obj)+offset)) = val; } As a first cut, I wanted to call PrintStackTraceToStdout() in vm\debughelp.cpp. To do that, I defined the following function in vm\jitinterface.cpp: HCIMPL1(void, JIT_MyTest, void* arg) { HELPER_METHOD_FRAME_BEGIN_0(); printf("My test to print stack trace.\n"); void PrintStackTraceToStdout(); PrintStackTraceToStdout(); HELPER_METHOD_FRAME_END(); } HCIMPLEND And then made the needed changes in inc\corinfo.h, fjit\fjit.h, and fjit\fjitcompiler.cpp so that my function could be called in fjit\fjitdef.h. It compiled successfully. However, when I tried it on some simple c# programs, it failed with the following message: Assert failure(PID 5220 [0x00001464], Thread: 4876 [0x130c]): !"Bad opcode" File: c:\yuan\proj\rotor\sscli-0\clr\src\vm\rotor_x86 \../i386/gmsx86.cpp, Line: 533 Image: What did I do wrong? Thanks, -Yuan =================================== This list is hosted by DevelopMentorŪ http://www.develop.com NEW! ASP.NET courses you may be interested in: 2 Days of ASP.NET, 29 Sept 2003, in Redmond http://www.develop.com/courses/2daspdotnet Guerrilla ASP.NET, 13 Oct 2003, in Boston http://www.develop.com/courses/gaspdotnet View archives and manage your subscription(s) at http://discuss.develop.com