[PATCH v1] print the raw kernel version when using -Xraw

shankarapailoor shankarapailoor at gmail.com
Sat Dec 1 19:50:57 UTC 2018


>From 06b32228156338edc9958fb4f86a2bdd188abc48 Mon Sep 17 00:00:00 2001
From: Shankara Pailoor <shankarapailoor at gmail.com>
Date: Sat, 1 Dec 2018 11:47:27 -0800
Subject: [PATCH v1] print the raw kernel version when using -Xraw

---
 bpf.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/bpf.c b/bpf.c
index e5dc4eeb..261c68be 100644
--- a/bpf.c
+++ b/bpf.c
@@ -292,10 +292,22 @@ BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)
     /* kern_version field was added in Linux commit v4.1-rc1~84^2~50.  */
     if (len <= offsetof(struct BPF_PROG_LOAD_struct, kern_version))
         break;
-    tprintf(", kern_version=KERNEL_VERSION(%u, %u, %u)",
-        attr.kern_version >> 16,
-        (attr.kern_version >> 8) & 0xFF,
-        attr.kern_version & 0xFF);
+    if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) {
+        tprintf(", kernel_version=%u", attr.kern_version);
+        if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) {
+            tprints(" /* ");
+            tprintf("KERNEL_VERSION(%u, %u, %u)",
+                attr.kern_version >> 16,
+                (attr.kern_version >> 8) & 0xFF,
+                attr.kern_version & 0xFF);
+            tprints("*/");
+        }
+    } else {
+        tprintf(", kern_version=KERNEL_VERSION(%u, %u, %u)",
+            attr.kern_version >> 16,
+            (attr.kern_version >> 8) & 0xFF,
+            attr.kern_version & 0xFF);
+    }

     /* prog_flags field was added in Linux commit v4.12-rc2~34^2~29^2~2.  */
     if (len <= offsetof(struct BPF_PROG_LOAD_struct, prog_flags))
-- 
2.17.1


More information about the Strace-devel mailing list