|
@@ -21,13 +21,11 @@ struct event
|
|
|
__u64 caller_bp;
|
|
__u64 caller_bp;
|
|
|
__u64 time_ns_start;
|
|
__u64 time_ns_start;
|
|
|
__u64 time_ns_end;
|
|
__u64 time_ns_end;
|
|
|
- __u64 nid;
|
|
|
|
|
- __u64 fpid;
|
|
|
|
|
- __u64 level;
|
|
|
|
|
__u8 location;
|
|
__u8 location;
|
|
|
}__attribute__((packed));
|
|
}__attribute__((packed));
|
|
|
|
|
|
|
|
struct trace_stack_entry_key_t {
|
|
struct trace_stack_entry_key_t {
|
|
|
|
|
+ __u64 trace_id;
|
|
|
__u64 caller_bp;
|
|
__u64 caller_bp;
|
|
|
__u64 bp;
|
|
__u64 bp;
|
|
|
};
|
|
};
|
|
@@ -105,17 +103,25 @@ int ent(struct pt_regs *ctx)
|
|
|
|
|
|
|
|
cw_bpf_debug("[Go] [uprobe/ent]: goid: %llu", e->goid);
|
|
cw_bpf_debug("[Go] [uprobe/ent]: goid: %llu", e->goid);
|
|
|
|
|
|
|
|
- cw_bpf_debug("[Go] [uprobe/ent]: event: location:%x,ip:%lx,time_ns_start:%lld\n", e->location, e->ip, e->time_ns_start);
|
|
|
|
|
|
|
+ cw_bpf_debug("[Go] [uprobe/ent]: event: location:%x,ip:%lx,time_ns_start:%llu\n", e->location, e->ip, e->time_ns_start);
|
|
|
cw_bpf_debug("[Go] [uprobe/ent]: event: bp:%x,caller_bp:%x,caller_ip:%x\n", e->bp,e->caller_bp,e->caller_ip);
|
|
cw_bpf_debug("[Go] [uprobe/ent]: event: bp:%x,caller_bp:%x,caller_ip:%x\n", e->bp,e->caller_bp,e->caller_ip);
|
|
|
|
|
|
|
|
struct trace_stack_entry_key_t trace_key = {};
|
|
struct trace_stack_entry_key_t trace_key = {};
|
|
|
trace_key.caller_bp = e->caller_bp % 0x800 + (e->goid << 12);
|
|
trace_key.caller_bp = e->caller_bp % 0x800 + (e->goid << 12);
|
|
|
trace_key.bp = e->bp % 0x800 + (e->goid << 12);
|
|
trace_key.bp = e->bp % 0x800 + (e->goid << 12);
|
|
|
|
|
+ trace_key.trace_id = trace_id;
|
|
|
|
|
|
|
|
// trace_key.caller_bp = e->caller_bp;
|
|
// trace_key.caller_bp = e->caller_bp;
|
|
|
// trace_key.bp = e->bp;
|
|
// trace_key.bp = e->bp;
|
|
|
// cw_bpf_debug("[Go] [uprobe/ent]: trace_keytrace_keytrace_key: bp: %x", trace_key.bp);
|
|
// cw_bpf_debug("[Go] [uprobe/ent]: trace_keytrace_keytrace_key: bp: %x", trace_key.bp);
|
|
|
- cw_bpf_debug("[Go] [uprobe/ent]: trace_keytrace_keytrace_key: caller_bp: %x, bp: %x", trace_key.caller_bp, trace_key.bp);
|
|
|
|
|
|
|
+ bpf_printk("[Go] [uprobe/ent]: trace_keytrace_keytrace_key: caller_bp: %x, bp: %x, %lld", trace_key.caller_bp, trace_key.bp, trace_key.trace_id);
|
|
|
|
|
+
|
|
|
|
|
+ struct event *event_p = bpf_map_lookup_elem(&trace_stack_entry, &trace_key);
|
|
|
|
|
+
|
|
|
|
|
+ if (event_p) {
|
|
|
|
|
+ cw_bpf_debug("[Go] [uprobe/ent]:Error get alike funEntry %x, %x, %x", event_p->ip, event_p->caller_bp, event_p->bp);
|
|
|
|
|
+ // return 0;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
struct event event_current = {};
|
|
struct event event_current = {};
|
|
|
event_current.bp = e->bp,
|
|
event_current.bp = e->bp,
|
|
@@ -127,8 +133,6 @@ int ent(struct pt_regs *ctx)
|
|
|
event_current.ip = e->ip,
|
|
event_current.ip = e->ip,
|
|
|
event_current.time_ns_start = e->time_ns_start,
|
|
event_current.time_ns_start = e->time_ns_start,
|
|
|
event_current.location = e->location,
|
|
event_current.location = e->location,
|
|
|
- event_current.nid = ((e->ip % 0x1000) << 24) + e->bp % 0x800 + (e->goid << 12),
|
|
|
|
|
- event_current.fpid = e->caller_bp % 0x800 + (e->goid << 12),
|
|
|
|
|
|
|
|
|
|
bpf_map_update_elem(&trace_stack_entry, &trace_key, &event_current, BPF_ANY);
|
|
bpf_map_update_elem(&trace_stack_entry, &trace_key, &event_current, BPF_ANY);
|
|
|
|
|
|
|
@@ -167,20 +171,22 @@ int ret(struct pt_regs *ctx)
|
|
|
cw_bpf_debug("[Go] [uprobe/ret]: yes");
|
|
cw_bpf_debug("[Go] [uprobe/ret]: yes");
|
|
|
e->pid = pid;
|
|
e->pid = pid;
|
|
|
e->trace_id = trace_id;
|
|
e->trace_id = trace_id;
|
|
|
- e->location = RETPOINT;
|
|
|
|
|
|
|
+ e->location = ENTPOINT;
|
|
|
e->ip = PT_REGS_IP(ctx);
|
|
e->ip = PT_REGS_IP(ctx);
|
|
|
e->time_ns_end = bpf_ktime_get_ns();
|
|
e->time_ns_end = bpf_ktime_get_ns();
|
|
|
e->bp = PT_REGS_SP(ctx) - 8;
|
|
e->bp = PT_REGS_SP(ctx) - 8;
|
|
|
|
|
+ e->caller_bp = PT_REGS_FP(ctx);
|
|
|
|
|
|
|
|
- __u64 caller_bp = PT_REGS_FP(ctx);
|
|
|
|
|
- cw_bpf_debug("[Go] [uprobe/ret]: e->ip:%lx,bp:%x,caller_bp:%x", e->ip, e->bp, caller_bp);
|
|
|
|
|
|
|
+ // __u64 caller_bp = PT_REGS_FP(ctx);
|
|
|
|
|
+ cw_bpf_debug("[Go] [uprobe/ret]: e->ip:%lx,bp:%x,caller_bp:%x", e->ip, e->bp, e->caller_bp);
|
|
|
cw_bpf_debug("[Go] [uprobe/ret]: sp:%x, goid: %llu, goid:0x:%x", PT_REGS_SP(ctx), e->goid, e->goid);
|
|
cw_bpf_debug("[Go] [uprobe/ret]: sp:%x, goid: %llu, goid:0x:%x", PT_REGS_SP(ctx), e->goid, e->goid);
|
|
|
|
|
|
|
|
- cw_bpf_debug("[Go] [uprobe/ret]: event: location:%x,ip:%x,time_ns_end:%lld\n", e->location, e->ip, e->time_ns_end);
|
|
|
|
|
|
|
+ cw_bpf_debug("[Go] [uprobe/ret]: event: location:%x,ip:%x,time_ns_end:%llu\n", e->location, e->ip, e->time_ns_end);
|
|
|
|
|
|
|
|
struct trace_stack_entry_key_t trace_key = {};
|
|
struct trace_stack_entry_key_t trace_key = {};
|
|
|
- trace_key.caller_bp = caller_bp % 0x800 + (e->goid << 12);
|
|
|
|
|
|
|
+ trace_key.caller_bp = e->caller_bp % 0x800 + (e->goid << 12);
|
|
|
trace_key.bp = e->bp % 0x800 + (e->goid << 12);
|
|
trace_key.bp = e->bp % 0x800 + (e->goid << 12);
|
|
|
|
|
+ trace_key.trace_id = trace_id;
|
|
|
|
|
|
|
|
// trace_key.caller_bp = caller_bp;
|
|
// trace_key.caller_bp = caller_bp;
|
|
|
// trace_key.bp = e->bp;
|
|
// trace_key.bp = e->bp;
|
|
@@ -197,21 +203,26 @@ int ret(struct pt_regs *ctx)
|
|
|
|
|
|
|
|
event_p->time_ns_end = e->time_ns_end;
|
|
event_p->time_ns_end = e->time_ns_end;
|
|
|
|
|
|
|
|
- cw_bpf_debug("[Go] [uprobe/ret]: ent:event: location:%d,ip:%x,time_ns_start:%lld\n", event_p->location, event_p->ip, event_p->time_ns_start);
|
|
|
|
|
|
|
+ cw_bpf_debug("[Go] [uprobe/ret]: ent:event: location:%d,ip:%x,time_ns_start:%llu\n", event_p->location, event_p->ip, event_p->time_ns_start);
|
|
|
cw_bpf_debug("[Go] [uprobe/ret]: ent:event: bp:%x,caller_bp:%x,caller_ip:%x\n", event_p->bp,event_p->caller_bp,event_p->caller_ip);
|
|
cw_bpf_debug("[Go] [uprobe/ret]: ent:event: bp:%x,caller_bp:%x,caller_ip:%x\n", event_p->bp,event_p->caller_bp,event_p->caller_ip);
|
|
|
- cw_bpf_debug("[Go] [uprobe/ret]: ent:event: nid:%llx,fpid:%llx,level:%d\n", event_p->nid,event_p->fpid,event_p->level);
|
|
|
|
|
-
|
|
|
|
|
- bpf_map_delete_elem(&trace_stack_entry, &trace_key);
|
|
|
|
|
|
|
|
|
|
|
|
+ e->time_ns_start = event_p->time_ns_start;
|
|
|
|
|
+ // e->caller_ip = event_p->caller_ip;
|
|
|
|
|
+ // e->ip = event_p->ip;
|
|
|
|
|
+
|
|
|
// return bpf_map_push_elem(&event_queue, e, BPF_EXIST);
|
|
// return bpf_map_push_elem(&event_queue, e, BPF_EXIST);
|
|
|
- cw_bpf_debug("[Go] [uprobe/ret]: ent:event_ret push: nid:%llx,fpid:%llx,level:%d\n", event_p->nid,event_p->fpid,event_p->level);
|
|
|
|
|
- long err = bpf_perf_event_output(ctx, &event_queue, BPF_F_CURRENT_CPU, event_p, sizeof(*e));
|
|
|
|
|
- if (err ==0) {
|
|
|
|
|
|
|
+ cw_bpf_debug("[Go] [uprobe/ret]: ent:event_ret push: event_p->ip:%llx,ip:%llx\n", event_p->ip, e->ip);
|
|
|
|
|
+ long err = bpf_perf_event_output(ctx, &event_queue, BPF_F_CURRENT_CPU, e, sizeof(*e));
|
|
|
|
|
+ if (err == 0) {
|
|
|
__u32 count = cw_add_event_count(trace_id);
|
|
__u32 count = cw_add_event_count(trace_id);
|
|
|
- if (count > 0) {
|
|
|
|
|
- cw_bpf_debug("count->%d",count);
|
|
|
|
|
|
|
+ if (event_p->trace_id != trace_id) {
|
|
|
|
|
+ cw_bpf_debug("[pref] fuck err<%d> ip->%x->%x", err, PT_REGS_IP(ctx), e->ip);
|
|
|
}
|
|
}
|
|
|
|
|
+ cw_bpf_debug("[pref] err<%d> count->%d trace_id->%llu", err, count, trace_id);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ cw_bpf_debug("[pref] err<%d> trace_id->%d", err, trace_id);
|
|
|
}
|
|
}
|
|
|
|
|
+ bpf_map_delete_elem(&trace_stack_entry, &trace_key);
|
|
|
cw_bpf_debug("[Go] [uprobe/ret] end");
|
|
cw_bpf_debug("[Go] [uprobe/ret] end");
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
@@ -275,6 +286,7 @@ int dotnetent(struct pt_regs *ctx)
|
|
|
struct trace_stack_entry_key_t trace_key = {};
|
|
struct trace_stack_entry_key_t trace_key = {};
|
|
|
trace_key.caller_bp = e->caller_bp % 0x800 + (e->goid << 12);
|
|
trace_key.caller_bp = e->caller_bp % 0x800 + (e->goid << 12);
|
|
|
trace_key.bp = e->bp % 0x800 + (e->goid << 12);
|
|
trace_key.bp = e->bp % 0x800 + (e->goid << 12);
|
|
|
|
|
+ trace_key.trace_id = trace_id;
|
|
|
|
|
|
|
|
// trace_key.caller_bp = e->caller_bp;
|
|
// trace_key.caller_bp = e->caller_bp;
|
|
|
// trace_key.bp = e->bp;
|
|
// trace_key.bp = e->bp;
|
|
@@ -291,8 +303,6 @@ int dotnetent(struct pt_regs *ctx)
|
|
|
event_current.ip = e->ip,
|
|
event_current.ip = e->ip,
|
|
|
event_current.time_ns_start = e->time_ns_start,
|
|
event_current.time_ns_start = e->time_ns_start,
|
|
|
event_current.location = e->location,
|
|
event_current.location = e->location,
|
|
|
- event_current.nid = ((e->ip % 0x1000) << 24) + e->bp % 0x800 + (e->goid << 12),
|
|
|
|
|
- event_current.fpid = e->caller_bp % 0x800 + (e->goid << 12),
|
|
|
|
|
|
|
|
|
|
bpf_map_update_elem(&trace_stack_entry, &trace_key, &event_current, BPF_ANY);
|
|
bpf_map_update_elem(&trace_stack_entry, &trace_key, &event_current, BPF_ANY);
|
|
|
|
|
|