Your technique could fail this way if there is some complex code
following the call to FJit_pHlpMyTest in the helper. The helper frame
interpreter needs to interpret its way out into the jitted code. If you
want to know more details, read the "How FCall works" paragraph in
clr\src\vm\fcall.h.

I do not see why there could be a problem in the example you gave. The
helper frame interpreter should be able to go through the code generated
by "*((int*) ((char*)(or_obj)+offset)) = val;".

If you give me exact steps to reproduce the problem (the version and
edition of the compiler you are using, the test you are getting this
failure with, etc.), I can take a look.

-Jan

This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Discussion of the Rotor Shared Source CLI implementation
[mailto:[EMAIL PROTECTED] On Behalf Of Yuan Yu
Sent: Friday, January 23, 2004 10:27 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET-ROTOR] Stacktrace

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(r)  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

===================================
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

Reply via email to