[Mono-list] Adding Solaris/amd64 support

Andreas Färber andreas.faerber at web.de
Wed Mar 7 13:39:31 EST 2007


Hello,

>> This is where the explanation I gave you is important: the routine in
>> question basically needs to understand the generated code and
>> modify it
>> on the flight.
>>
>> So you need to look at the code and see why it would generate the
>> exception, the address to disassemble is precisely the one that it
>> will
>> try to decode and its failing to.
>
> So given the code in amd64_patch:
> http://svn.myrealbox.com/source/trunk/mono/mono/mini/mini-amd64.c
> Would this be disp, code or target? That was my question. Through
> printf("%x\n", ) I could then look at the value.

I've done code and target as follows (disp didn't make sense on  
second thoughts).

Adding:

printf("code=%p\ntarget=%p\ndisp=%#tx\n", code, target, disp);

prints:

TYPE: 1
code=fffffd7ffe3f077b
target=4e53e4
disp=0x280020f4c69

Program received signal SIGTRAP, Trace/breakpoint trap.
amd64_patch (_field_data=0xfffffd7ffe3f077b "[...]", her=0x4e53e4)
     at mini-amd64.c:183
183                     x86_patch (code, (unsigned char*)target);


(non-ASCII characters not copied)

gdb output:

(gdb) x/20i 0xfffffd7ffe3f077b
0xfffffd7ffe3f077b:     callq  0xfffffd7ffdd04a90
0xfffffd7ffe3f0780:     mov    %r12,%rax
0xfffffd7ffe3f0783:     jmp    0xfffffd7ffe3f0785
0xfffffd7ffe3f0785:     mov    0xfffffffffffffff8(%rbp),%r12
0xfffffd7ffe3f0789:     leaveq
0xfffffd7ffe3f078a:     retq
0xfffffd7ffe3f078b:     add    %al,(%rax)
0xfffffd7ffe3f078d:     add    %al,(%rax)
0xfffffd7ffe3f078f:     add    %al,(%rax)
0xfffffd7ffe3f0791:     add    %al,(%rax)
0xfffffd7ffe3f0793:     add    %al,(%rax)
0xfffffd7ffe3f0795:     add    %al,(%rax)
0xfffffd7ffe3f0797:     add    %al,(%rax)
0xfffffd7ffe3f0799:     add    %al,(%rax)
0xfffffd7ffe3f079b:     add    %al,(%rax)
0xfffffd7ffe3f079d:     add    %al,(%rax)
0xfffffd7ffe3f079f:     add    %al,(%rax)
0xfffffd7ffe3f07a1:     add    %al,(%rax)
0xfffffd7ffe3f07a3:     add    %al,(%rax)
0xfffffd7ffe3f07a5:     add    %al,(%rax)



(gdb) x/20i 0x4e53e4
0x4e53e4 <ves_icall_System_Threading_Thread_ResetAbort>:         
push   %rbp
0x4e53e5 <ves_icall_System_Threading_Thread_ResetAbort+1>:
     mov    %rsp,%rbp
0x4e53e8 <ves_icall_System_Threading_Thread_ResetAbort+4>:       
push   %rbx
0x4e53e9 <ves_icall_System_Threading_Thread_ResetAbort+5>:
     sub    $0x8,%rsp
0x4e53ed <ves_icall_System_Threading_Thread_ResetAbort+9>:
     callq  0x4e481a <mono_thread_current>
0x4e53f2 <ves_icall_System_Threading_Thread_ResetAbort+14>:
     mov    %rax,%rbx
0x4e53f5 <ves_icall_System_Threading_Thread_ResetAbort+17>:
     mov    0xc8(%rax),%rdi
0x4e53fc <ves_icall_System_Threading_Thread_ResetAbort+24>:
     callq  0x4e3651 <mono_monitor_enter>
0x4e5401 <ves_icall_System_Threading_Thread_ResetAbort+29>:
     andl   $0xffffff7f,0x44(%rbx)
0x4e5408 <ves_icall_System_Threading_Thread_ResetAbort+36>:
     cmpq   $0x0,0x48(%rbx)
0x4e540d <ves_icall_System_Threading_Thread_ResetAbort+41>:
     jne    0x4e542f <ves_icall_System_Threading_Thread_ResetAbort+75>
0x4e540f <ves_icall_System_Threading_Thread_ResetAbort+43>:
     mov    0xc8(%rbx),%rdi
0x4e5416 <ves_icall_System_Threading_Thread_ResetAbort+50>:
---Type <return> to continue, or q <return> to quit---
     callq  0x4e3688 <mono_monitor_exit>
0x4e541b <ves_icall_System_Threading_Thread_ResetAbort+55>:
     mov    $0x619030,%edi
0x4e5420 <ves_icall_System_Threading_Thread_ResetAbort+60>:
     callq  0x4ed27a <mono_get_exception_thread_state>
0x4e5425 <ves_icall_System_Threading_Thread_ResetAbort+65>:
     mov    %rax,%rdi
0x4e5428 <ves_icall_System_Threading_Thread_ResetAbort+68>:
     callq  0x4b84bc <mono_raise_exception>
0x4e542d <ves_icall_System_Threading_Thread_ResetAbort+73>:
     jmp    0x4e543f <ves_icall_System_Threading_Thread_ResetAbort+91>
0x4e542f <ves_icall_System_Threading_Thread_ResetAbort+75>:
     movq   $0x0,0x48(%rbx)
0x4e5437 <ves_icall_System_Threading_Thread_ResetAbort+83>:
     movq   $0x0,0x50(%rbx)


Andreas


More information about the Mono-list mailing list