Просмотр исходного кода

Fixed #TASK_QT-9810 解决Java server场景arm的兼容性问题。

rock 1 год назад
Родитель
Сommit
bc4cd9d4b2
2 измененных файлов с 17 добавлено и 1 удалено
  1. 2 1
      ebpftracer/ebpf/utrace/java/net/server.probe.bpf.c
  2. 15 0
      ebpftracer/jvm.go

+ 2 - 1
ebpftracer/ebpf/utrace/java/net/server.probe.bpf.c

@@ -62,7 +62,8 @@ int uprobe_ret_Java_sun_nio_ch_FileDispatcherImpl_read0(struct pt_regs *ctx) {
 	//计算 rbp-0x30
 	//计算 rbp-0x30
 	bpf_printk("enter the ret uprobe_Java_sun_nio_ch_FileDispatcherImpl_read0\n");
 	bpf_printk("enter the ret uprobe_Java_sun_nio_ch_FileDispatcherImpl_read0\n");
 	unsigned long jhttpdata_ptr;
 	unsigned long jhttpdata_ptr;
-	jhttpdata_ptr = (ctx)->rsi;
+	// jhttpdata_ptr = (ctx)->rsi;
+	jhttpdata_ptr = PT_REGS_PARM2(ctx);
 	bpf_printk("enter rsi is %llx.\n", jhttpdata_ptr);
 	bpf_printk("enter rsi is %llx.\n", jhttpdata_ptr);
 	
 	
 	//x/s addr
 	//x/s addr

+ 15 - 0
ebpftracer/jvm.go

@@ -13,6 +13,7 @@ import (
 
 
 	"github.com/cilium/ebpf/link"
 	"github.com/cilium/ebpf/link"
 	"golang.org/x/arch/x86/x86asm"
 	"golang.org/x/arch/x86/x86asm"
+	"golang.org/x/arch/arm64/arm64asm"
 )
 )
 
 
 const (
 const (
@@ -179,6 +180,20 @@ func getCallNextMoveOffsets(machine elf.Machine, instructions []byte) []int {
 			}
 			}
 			i += ins.Len
 			i += ins.Len
 		}
 		}
+	case elf.EM_AARCH64:
+		for i := 0; i < len(instructions); {
+			ins, err := arm64asm.Decode(instructions[i:])
+			if err == nil && ins.Op == arm64asm.BL {
+				if firstCall == 0{
+					firstCall = 1
+				}else{
+					i += 4
+					res = append(res, i)
+					return res
+				}
+			}
+			i += 4
+		}
 	}
 	}
 	return res
 	return res
 }
 }