@@ -294,6 +294,37 @@ show_kprobe_multi_json(struct bpf_link_info *info, json_writer_t *wtr)
294
294
jsonw_end_array (json_wtr );
295
295
}
296
296
297
+ static __u64 * u64_to_arr (__u64 val )
298
+ {
299
+ return (__u64 * ) u64_to_ptr (val );
300
+ }
301
+
302
+ static void
303
+ show_uprobe_multi_json (struct bpf_link_info * info , json_writer_t * wtr )
304
+ {
305
+ __u32 i ;
306
+
307
+ jsonw_bool_field (json_wtr , "retprobe" ,
308
+ info -> uprobe_multi .flags & BPF_F_UPROBE_MULTI_RETURN );
309
+ jsonw_string_field (json_wtr , "path" , (char * ) u64_to_ptr (info -> uprobe_multi .path ));
310
+ jsonw_uint_field (json_wtr , "func_cnt" , info -> uprobe_multi .count );
311
+ jsonw_int_field (json_wtr , "pid" , (int ) info -> uprobe_multi .pid );
312
+ jsonw_name (json_wtr , "funcs" );
313
+ jsonw_start_array (json_wtr );
314
+
315
+ for (i = 0 ; i < info -> uprobe_multi .count ; i ++ ) {
316
+ jsonw_start_object (json_wtr );
317
+ jsonw_uint_field (json_wtr , "offset" ,
318
+ u64_to_arr (info -> uprobe_multi .offsets )[i ]);
319
+ jsonw_uint_field (json_wtr , "ref_ctr_offset" ,
320
+ u64_to_arr (info -> uprobe_multi .ref_ctr_offsets )[i ]);
321
+ jsonw_uint_field (json_wtr , "cookie" ,
322
+ u64_to_arr (info -> uprobe_multi .cookies )[i ]);
323
+ jsonw_end_object (json_wtr );
324
+ }
325
+ jsonw_end_array (json_wtr );
326
+ }
327
+
297
328
static void
298
329
show_perf_event_kprobe_json (struct bpf_link_info * info , json_writer_t * wtr )
299
330
{
@@ -465,6 +496,9 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
465
496
case BPF_LINK_TYPE_KPROBE_MULTI :
466
497
show_kprobe_multi_json (info , json_wtr );
467
498
break ;
499
+ case BPF_LINK_TYPE_UPROBE_MULTI :
500
+ show_uprobe_multi_json (info , json_wtr );
501
+ break ;
468
502
case BPF_LINK_TYPE_PERF_EVENT :
469
503
switch (info -> perf_event .type ) {
470
504
case BPF_PERF_EVENT_EVENT :
@@ -674,6 +708,33 @@ static void show_kprobe_multi_plain(struct bpf_link_info *info)
674
708
}
675
709
}
676
710
711
+ static void show_uprobe_multi_plain (struct bpf_link_info * info )
712
+ {
713
+ __u32 i ;
714
+
715
+ if (!info -> uprobe_multi .count )
716
+ return ;
717
+
718
+ if (info -> uprobe_multi .flags & BPF_F_UPROBE_MULTI_RETURN )
719
+ printf ("\n\turetprobe.multi " );
720
+ else
721
+ printf ("\n\tuprobe.multi " );
722
+
723
+ printf ("path %s " , (char * ) u64_to_ptr (info -> uprobe_multi .path ));
724
+ printf ("func_cnt %u " , info -> uprobe_multi .count );
725
+
726
+ if (info -> uprobe_multi .pid )
727
+ printf ("pid %d " , info -> uprobe_multi .pid );
728
+
729
+ printf ("\n\t%-16s %-16s %-16s" , "offset" , "ref_ctr_offset" , "cookies" );
730
+ for (i = 0 ; i < info -> uprobe_multi .count ; i ++ ) {
731
+ printf ("\n\t0x%-16llx 0x%-16llx 0x%-16llx" ,
732
+ u64_to_arr (info -> uprobe_multi .offsets )[i ],
733
+ u64_to_arr (info -> uprobe_multi .ref_ctr_offsets )[i ],
734
+ u64_to_arr (info -> uprobe_multi .cookies )[i ]);
735
+ }
736
+ }
737
+
677
738
static void show_perf_event_kprobe_plain (struct bpf_link_info * info )
678
739
{
679
740
const char * buf ;
@@ -807,6 +868,9 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
807
868
case BPF_LINK_TYPE_KPROBE_MULTI :
808
869
show_kprobe_multi_plain (info );
809
870
break ;
871
+ case BPF_LINK_TYPE_UPROBE_MULTI :
872
+ show_uprobe_multi_plain (info );
873
+ break ;
810
874
case BPF_LINK_TYPE_PERF_EVENT :
811
875
switch (info -> perf_event .type ) {
812
876
case BPF_PERF_EVENT_EVENT :
@@ -846,8 +910,10 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
846
910
847
911
static int do_show_link (int fd )
848
912
{
913
+ __u64 * ref_ctr_offsets = NULL , * offsets = NULL , * cookies = NULL ;
849
914
struct bpf_link_info info ;
850
915
__u32 len = sizeof (info );
916
+ char path_buf [PATH_MAX ];
851
917
__u64 * addrs = NULL ;
852
918
char buf [PATH_MAX ];
853
919
int count ;
@@ -889,6 +955,39 @@ static int do_show_link(int fd)
889
955
goto again ;
890
956
}
891
957
}
958
+ if (info .type == BPF_LINK_TYPE_UPROBE_MULTI &&
959
+ !info .uprobe_multi .offsets ) {
960
+ count = info .uprobe_multi .count ;
961
+ if (count ) {
962
+ offsets = calloc (count , sizeof (__u64 ));
963
+ if (!offsets ) {
964
+ p_err ("mem alloc failed" );
965
+ close (fd );
966
+ return - ENOMEM ;
967
+ }
968
+ info .uprobe_multi .offsets = ptr_to_u64 (offsets );
969
+ ref_ctr_offsets = calloc (count , sizeof (__u64 ));
970
+ if (!ref_ctr_offsets ) {
971
+ p_err ("mem alloc failed" );
972
+ free (offsets );
973
+ close (fd );
974
+ return - ENOMEM ;
975
+ }
976
+ info .uprobe_multi .ref_ctr_offsets = ptr_to_u64 (ref_ctr_offsets );
977
+ cookies = calloc (count , sizeof (__u64 ));
978
+ if (!cookies ) {
979
+ p_err ("mem alloc failed" );
980
+ free (cookies );
981
+ free (offsets );
982
+ close (fd );
983
+ return - ENOMEM ;
984
+ }
985
+ info .uprobe_multi .cookies = ptr_to_u64 (cookies );
986
+ info .uprobe_multi .path = ptr_to_u64 (path_buf );
987
+ info .uprobe_multi .path_size = sizeof (path_buf );
988
+ goto again ;
989
+ }
990
+ }
892
991
if (info .type == BPF_LINK_TYPE_PERF_EVENT ) {
893
992
switch (info .perf_event .type ) {
894
993
case BPF_PERF_EVENT_TRACEPOINT :
@@ -924,8 +1023,10 @@ static int do_show_link(int fd)
924
1023
else
925
1024
show_link_close_plain (fd , & info );
926
1025
927
- if (addrs )
928
- free (addrs );
1026
+ free (ref_ctr_offsets );
1027
+ free (cookies );
1028
+ free (offsets );
1029
+ free (addrs );
929
1030
close (fd );
930
1031
return 0 ;
931
1032
}
0 commit comments