bcc: Use bpf_probe_read_str to read tracepoint data_loc field
authorHengqi Chen <chenhengqi@outlook.com>
Mon, 22 Nov 2021 13:49:03 +0000 (21:49 +0800)
committeryonghong-song <ys114321@gmail.com>
Mon, 22 Nov 2021 18:53:44 +0000 (10:53 -0800)
The data_loc field (defined as __string in kernel source) should
be treated as string NOT a fixed-size array, add a new macro
TP_DATA_LOC_READ_STR which use bpf_probe_read_str to reflect this.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
src/cc/export/helpers.h

index f300c1841af6403fb558950f9bef0cd93875524d..cc80cf0c6b08b71c614e27c8d9682435940bf6f7 100644 (file)
@@ -1356,5 +1356,11 @@ static int ____##name(unsigned long long *ctx, ##args)
             bpf_probe_read((void *)dst, __length, (char *)args + __offset); \
         } while (0);
 
+#define TP_DATA_LOC_READ_STR(dst, field, length)                                \
+        do {                                                                    \
+            unsigned short __offset = args->data_loc_##field & 0xFFFF;          \
+            bpf_probe_read_str((void *)dst, length, (char *)args + __offset);   \
+        } while (0);
+
 #endif
 )********"