dotnet for mips64 的 ea 版本已经发布
https://github.com/gsvm/loongson-dotnet/releases
在龙芯上调试CoreCLR
由于lldb在龙芯上工作不正常[1],只有gdb可以用来调试CoreCLR。
因为需要调试JIT代码,所以我们关上gdb分页,不处理SIG34信号:
$ cat ~/.gdbinit
set pagination off
handle SIG34 nostop noprint
调试JIT代码
export CORE_LIBRARIES=/home/loongson/corefx-3.1-Linux.mips64.Debug
export COMPlus_JitFunctionTrace=1
export COMPlus_JitHalt="Main"
gdb -ex=r --args ./bin/Product/Linux.mips64.Debug/corerun /home/loongson/Hello.dll | tee gdb.log
JitHalt="Main"可以在Main方法的序言处插入break指令,然后我们跳过break指令:
(gdb) set $pc+=4
(gdb) x/22i $pc-44
0xff7c983aac: li zero,0x73
0xff7c983ab0: nop
0xff7c983ab4: 0xf20000
0xff7c983ab8: sdc1 $f2,-6100(s6)
0xff7c983abc: dsra32 zero,zero,0x3
0xff7c983ac0: 0x7cc11db8
0xff7c983ac4: dsra32 zero,zero,0x3
0xff7c983ac8: 0x7cc49458
0xff7c983acc: dsra32 zero,zero,0x3
0xff7c983ad0: nop
0xff7c983ad4: break
=> 0xff7c983ad8: daddiu sp,sp,-32
0xff7c983adc: sd s8,0(sp)
0xff7c983ae0: sd ra,8(sp)
0xff7c983ae4: move s8,sp
0xff7c983ae8: sd a0,24(s8)
0xff7c983aec: lui a0,0xff
0xff7c983af0: ori a0,a0,0x7caf
0xff7c983af4: dsll a0,a0,0x10
0xff7c983af8: ori a0,a0,0x7a88
0xff7c983afc: lw a0,0(a0)
0xff7c983b00: sltiu at,a0,1
查看一下传参整型寄存器的值:
(gdb) i r a0
a0: 0xff5800fa28
(gdb) x/g 0xff5800fa28
0xff5800fa28: 0x000000ff7caf7c30
然后用si指令级的单步跟踪。
还可以使用“硬”watchpoint[2]调试GC相关问题:
(gdb) watch *0xff68001bf8
Hardware watchpoint 1: *0xff68001bf8
(gdb) c
Continuing.
...
Thread 1 "corerun" hit Hardware watchpoint 1: *0xff68001bf8
Old value = 0
New value = 1476465840
JIT_WriteBarrier () at /hom