arm: handling size type differences between arm host and bpf 22/158022/3
authorAdrian Szyndela <adrian.s@samsung.com>
Thu, 26 Oct 2017 10:21:21 +0000 (10:21 +0000)
committerAdrian Szyndela <adrian.s@samsung.com>
Thu, 9 Nov 2017 12:11:14 +0000 (13:11 +0100)
Change-Id: I977bb03332040df8f49c06645abca7233a90aaac

16 files changed:
packaging/bcc-tools.spec
src/cc/CMakeLists.txt
src/cc/export/helpers.h
src/cc/export/host32.h [new file with mode: 0644]
src/cc/export/host64.h [new file with mode: 0644]
src/cc/exported_files.cc
src/cc/frontends/clang/loader.cc
src/cc/hostcompat/linux/sched.h [new file with mode: 0644]
src/cc/hostcompat/uapi/linux/ptrace.h [new file with mode: 0644]
tools/dbus-connection-message-size.c
tools/dbus-glib-top.py
tools/dbus-latency.c
tools/dbus-message-size.c
tools/dbus-message-type.c
tools/dbus-messages-sent.py
tools/dbus-top.c

index 134af9966c37b902d1c8c70524c3ea3ef4c7c64c..7898480e98d00e9b4263fab4fa1728ce0ef629db 100644 (file)
@@ -61,6 +61,7 @@ rm -rf %{buildroot}
 %{_libdir}/libbcc.so.*
 %{_prefix}/lib/python2.7/site-packages/bcc*
 %{_datadir}/bcc/*
+%{_includedir}/bcc/hostcompat/*
 
 %files dbus
 %{_datadir}/bcc/tools/dbus-*
index 7a4647c75620481cbf70fa08f53d2b07cd664f24..ad8c4312f9e38581d88975c34702b0b90be7ae36 100644 (file)
@@ -72,6 +72,7 @@ install(TARGETS bcc-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 install(FILES ${bcc_table_headers} DESTINATION include/bcc)
 install(FILES ${bcc_api_headers} DESTINATION include/bcc)
 install(DIRECTORY compat/linux/ DESTINATION include/bcc/compat/linux FILES_MATCHING PATTERN "*.h")
+install(DIRECTORY hostcompat/ DESTINATION include/bcc/hostcompat FILES_MATCHING PATTERN "*.h")
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 endif(ENABLE_CLANG_JIT)
 install(FILES ${bcc_common_headers} DESTINATION include/bcc)
index dbedb48e5bfe589d2daffb9f107a8d29c6e04f3a..c8a19de19c9e4a050710e661fc803eeb92e6f2f1 100644 (file)
@@ -18,7 +18,9 @@ R"********(
 #define __BPF_HELPERS_H
 
 #include <uapi/linux/bpf.h>
+#ifndef __arm__
 #include <uapi/linux/if_packet.h>
+#endif
 #include <linux/version.h>
 
 #ifndef CONFIG_BPF_SYSCALL
diff --git a/src/cc/export/host32.h b/src/cc/export/host32.h
new file mode 100644 (file)
index 0000000..7ad5912
--- /dev/null
@@ -0,0 +1,10 @@
+R"*****(#ifndef HOST32_H
+#define HOST32_H
+
+typedef uint32_t uint_t;
+typedef int32_t  int_t;
+typedef uint32_t ptr_t;
+typedef uint32_t ulong_t;
+typedef int32_t  long_t;
+
+#endif // HOST32_H)*****"
diff --git a/src/cc/export/host64.h b/src/cc/export/host64.h
new file mode 100644 (file)
index 0000000..213a9bb
--- /dev/null
@@ -0,0 +1,10 @@
+R"*****(#ifndef HOST64_H
+#define HOST64_H
+
+typedef uint64_t uint_t;
+typedef int64_t  int_t;
+typedef uint64_t ptr_t;
+typedef uint64_t ulong_t;
+typedef int64_t  long_t;
+
+#endif // HOST64_H)*****"
index 448a6977f768b32c0f5b3300e2373f282340bc45..c440b74e259c73f166fdc53f47e6f720dc576c7e 100644 (file)
@@ -41,6 +41,14 @@ map<string, const char *> ExportedFiles::headers_ = {
     "/virtual/lib/clang/include/stdarg.h",
     #include "clang/include/stdarg.h"
   },
+  {
+    "/virtual/include/bcc/host32.h",
+    #include "export/host32.h"
+  },
+  {
+    "/virtual/include/bcc/host64.h",
+    #include "export/host64.h"
+  },
 };
 
 }
index c255dba48432ee2cbbd752a3d2c7c3b02b1f26fa..23f1edcfc3661b1a66fdde2e4df759a9e0d8a9cd 100644 (file)
@@ -137,6 +137,8 @@ int ClangLoader::parse(unique_ptr<llvm::Module> *mod, TableStorage &ts, const st
   // noinline and optnone (if not always inlining).
   // Note that first argument is ignored in clang compilation invocation.
   vector<const char *> flags_cstr({"-O0", "-O2", "-emit-llvm", "-I", dstack.cwd(),
+                                   "-I/usr/include/bcc",
+                                   "-I/usr/local/include/bcc",
                                    "-Wno-deprecated-declarations",
                                    "-Wno-gnu-variable-sized-type-not-at-end",
                                    "-Wno-pragma-once-outside-header",
@@ -155,6 +157,13 @@ int ClangLoader::parse(unique_ptr<llvm::Module> *mod, TableStorage &ts, const st
   kflags.push_back("/virtual/include/bcc/bpf.h");
   kflags.push_back("-include");
   kflags.push_back("/virtual/include/bcc/helpers.h");
+#ifdef __arm__
+  kflags.push_back("-include");
+  kflags.push_back("/virtual/include/bcc/host32.h");
+#else
+  kflags.push_back("-include");
+  kflags.push_back("/virtual/include/bcc/host64.h");
+#endif
   kflags.push_back("-isystem");
   kflags.push_back("/virtual/include");
   for (auto it = kflags.begin(); it != kflags.end(); ++it)
@@ -187,7 +196,8 @@ int ClangLoader::parse(unique_ptr<llvm::Module> *mod, TableStorage &ts, const st
 #elif defined(__aarch64__)
   driver::Driver drv("", "aarch64-unknown-linux-gnu", diags);
 #elif defined(__arm__)
-  driver::Driver drv("", "armv7l-tizen-linux-gnueabi", diags);
+  driver::Driver drv("", "bpf-pc-linux", diags);
+  flags_cstr.push_back("-D__arm__");
 #else
   driver::Driver drv("", "x86_64-unknown-linux-gnu", diags);
 #endif
diff --git a/src/cc/hostcompat/linux/sched.h b/src/cc/hostcompat/linux/sched.h
new file mode 100644 (file)
index 0000000..ecaccfa
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef COMPAT_SCHED_H
+#define COMPAT_SCHED_H
+
+#ifdef __arm__
+#define TASK_COMM_LEN 40
+#else
+#include <linux/sched.h>
+#endif
+
+#endif // COMPAT_SCHED_H
diff --git a/src/cc/hostcompat/uapi/linux/ptrace.h b/src/cc/hostcompat/uapi/linux/ptrace.h
new file mode 100644 (file)
index 0000000..21c4c2d
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef COMPAT_PTRACE_H
+#define COMPAT_PTRACE_H
+
+#ifdef __arm__
+struct pt_regs
+{
+        uint32_t uregs[18];
+};
+#else
+#include <uapi/linux/ptrace.h>
+#endif
+
+#endif // COMPAT_PTRACE_H
index 1bdc3cc746dc5d5eb215d427c19a91dc77ac012a..dd47d54ade47917d464025706e8a17d4100bf5dc 100644 (file)
@@ -1,18 +1,18 @@
-#include <uapi/linux/ptrace.h>
-#include <linux/sched.h>
+#include <hostcompat/uapi/linux/ptrace.h>
+#include <hostcompat/linux/sched.h>
 
 struct DBusString {
-       void *str;
-       int len;
-       unsigned int allocated;
-       unsigned int constant : 1;
-       unsigned int locked : 1;
-       unsigned int invalid : 1;
-       unsigned int align_offset : 3;
+       ptr_t str;
+       int_t len;
+       uint_t allocated;
+       uint_t constant : 1;
+       uint_t locked : 1;
+       uint_t invalid : 1;
+       uint_t align_offset : 3;
 };
 
 struct DBusHeaderFields {
-       int value_pos;
+       int_t value_pos;
 };
 
 struct DBusHeader {
@@ -26,32 +26,32 @@ struct DBusHeader {
 };
 
 struct DBusMessage {
-       int refcount;
+       int_t refcount;
        struct DBusHeader header;
        struct DBusString body;
 
-       unsigned int locked : 1;
+       uint_t locked : 1;
 
-       void * list;
-       long size_counter_delta;
-       int timeout_ms;
+       ptr_t list;             // void *
+       long_t size_counter_delta;
+       int_t timeout_ms;
 
        u32 changed_stamp : 21;
-       void *slot_list;
+       ptr_t slot_list;        // void *
 
-       int generation;
+       int_t generation;
 
-       int *unix_fds;
+       ptr_t unix_fds; // int *
 
-       unsigned n_unix_fds;
-       unsigned n_unix_fds_allocated;
+       uint_t n_unix_fds;
+       uint_t n_unix_fds_allocated;
 
-       long unix_fd_counter_delta;
+       long_t unix_fd_counter_delta;
 
-       struct DBusString *signature;
-       struct DBusString *unique_sender;
-       size_t gvariant_body_last_offset;
-       size_t gvariant_body_last_pos;
+       ptr_t signature; // struct DBusString *signature;
+       ptr_t unique_sender; // struct DBusString *unique_sender;
+       ulong_t gvariant_body_last_offset;
+       ulong_t gvariant_body_last_pos;
 };
 
 struct data_t {
@@ -106,8 +106,7 @@ int g_get_message_size(struct pt_regs *ctx) {
        if (ptr_gsize == 0) {
                return 0;
        }
-       unsigned long *gsize = 0;
-       bpf_probe_read(&gsize, sizeof(gsize), ptr_gsize);
+       unsigned long *gsize = *ptr_gsize;
        unsigned long size  = 0;
        bpf_probe_read(&size, sizeof(size), gsize);
        if(size > 0 && size < 1000000) {
@@ -118,14 +117,12 @@ int g_get_message_size(struct pt_regs *ctx) {
 
 int dbus_message_size(struct pt_regs *ctx, void *conn, struct DBusMessage *message) {
        unsigned long size = 0;
-       int header_len = 0;
-       int body_len = 0;
+       int header_len = message->header.data.len;
+       int body_len = message->body.len;
 
-       bpf_probe_read(&header_len, sizeof(header_len), (char*)message + offsetof(struct DBusMessage, header.data.len));
         if (header_len > 0) {
                 size += header_len;
         }
-       bpf_probe_read(&body_len, sizeof(body_len), (char*)message + offsetof(struct DBusMessage, body.len));
         if (body_len > 0) {
                 size += body_len;
         }
index 3be925be316944b1231a9eeae1d501322164c2b6..8ac6312c75e2de9424eee03d334c766c285bac10 100755 (executable)
@@ -11,8 +11,9 @@ count = 100
 interval = 5
 loop = 0
 # load BPF program
-bpf_text="""#include <uapi/linux/ptrace.h>
-#include <linux/sched.h>
+bpf_text="""
+#include <hostcompat/linux/sched.h>
+#include <hostcompat/uapi/linux/ptrace.h>
 
 typedef struct pdata_T {
        u32 pid;
@@ -36,7 +37,7 @@ int do_entry_dbus(struct pt_regs *ctx) {
        u64 time = 0;
        pdata_t pdata;
        pdata_t new_pdata = {0, ' ', 0, 0, 0, 0, 0};
-       u64 ts, *tsp, delta;
+       u64 ts, *tsp, delta;
        u32 pid;
 
        ts = bpf_ktime_get_ns() / 1000;
@@ -68,7 +69,7 @@ int do_return_dbus(struct pt_regs *ctx) {
        u64 time = 0;
        pdata_t pdata;
        pdata_t new_pdata = {0, ' ', 0, 0, 0, 0, 0};
-       u64 ts, *tsp, delta;
+       u64 ts, *tsp, delta;
        u32 pid;
 
        ts = bpf_ktime_get_ns() / 1000;
@@ -99,7 +100,7 @@ int do_entry_glib(struct pt_regs *ctx) {
        u64 time = 0;
        pdata_t pdata;
        pdata_t new_pdata = {0, ' ', 0, 0, 0, 0, 0};
-       u64 ts, *tsp, delta;
+       u64 ts, *tsp, delta;
        u32 pid;
 
        ts = bpf_ktime_get_ns() / 1000;
@@ -131,7 +132,7 @@ int do_return_glib(struct pt_regs *ctx) {
        u64 time = 0;
        pdata_t pdata;
        pdata_t new_pdata = {0, ' ', 0, 0, 0, 0, 0};
-       u64 ts, *tsp, delta;
+       u64 ts, *tsp, delta;
        u32 pid;
 
        ts = bpf_ktime_get_ns() / 1000;
index 82f093c6d77779932f12ca2ef130013f0cdbd825..976206b1cbc826b42936c62af63e1c10738bdeb6 100644 (file)
@@ -1,5 +1,5 @@
-#include <uapi/linux/ptrace.h>
-#include <linux/sched.h>
+#include <hostcompat/linux/sched.h>
+#include <hostcompat/uapi/linux/ptrace.h>
 
 typedef enum {
   G_DBUS_MESSAGE_TYPE_INVALID,
@@ -28,14 +28,14 @@ typedef enum
 } GDBusSendMessageFlags;
 
 struct GTypeInstance {
-       void *g_class;
+       ptr_t g_class;  // void *
 };
 
 struct GObject {
        struct GTypeInstance g_type_instance;
 
-       volatile unsigned int ref_count;
-       void *qdata;
+       volatile uint_t ref_count;
+       ptr_t qdata;    // void *
 };
 
 struct GDBusMessage {
@@ -43,17 +43,17 @@ struct GDBusMessage {
        GDBusMessageType type;
        GDBusMessageFlags flags;
        bool locked;
-       GDBusMessageByteOrder byte_order;
+       uint_t byte_order; // GDBusMessageByteOrder byte_order;
        unsigned char major_protocol_version;
        unsigned int serial;
-       void *headers;
-       void *body;
+       ptr_t headers; // void *headers;
+       ptr_t body; // void *body;
 };
 
 struct DBusString {
-       void *str;
-       int len;
-       unsigned int allocated;
+       ptr_t str;
+       int_t len;
+       uint_t allocated;
        unsigned int constant : 1;
        unsigned int locked : 1;
        unsigned int invalid : 1;
@@ -61,13 +61,13 @@ struct DBusString {
 };
 
 struct DBusLink {
-       struct DBusLink *prev;
-       struct DBusLink *next;
-       void *data;
+       ptr_t prev; // struct DBusLink *prev;
+       ptr_t next; // struct DBusLink *next;
+       ptr_t data; // void *data;
 };
 
 struct DBusHeaderFields {
-       int value_pos;
+       int_t value_pos;
 };
 
 struct DBusHeader {
@@ -81,69 +81,69 @@ struct DBusHeader {
 };
 
 struct DBusDataSlot {
-       void *data;
-       void *dummy1;
+       ptr_t data; // void *data;
+       ptr_t dummy1; // void *dummy1;
 };
 
 struct DBusDataSlotList {
-       struct DBusDataSlot *slots;
-       int n_slots;
+       ptr_t slots; // struct DBusDataSlot *slots;
+       int_t n_slots;
 };
 
 struct DBusList {
-       struct DBusList *prev;
-       struct DbusList *next;
-       void *data;
+       ptr_t prev; // struct DBusList *prev;
+       ptr_t next; // struct DbusList *next;
+       ptr_t data; // void *data;
 };
 
 struct DBusMessage {
-       int refcount;
+       int_t refcount;
        struct DBusHeader header;
        struct DBusString body;
 
-       unsigned int locked : 1;
-       unsigned int in_cache : 1;
+       uint_t locked : 1;
+       uint_t in_cache : 1;
 
-       void *counters;
-       long size_counter_delta;
-       int timeout_ms;
+       ptr_t counters; // void *counters;
+       long_t size_counter_delta;
+       int_t timeout_ms;
 
        u32 changed_stamp : 21;
-       struct DBusDataSlotList *slot_list;
+       ptr_t slot_list; // struct DBusDataSlotList *slot_list;
 
-       int generation;
+       int_t generation;
 
-       int *unix_fds;
+       ptr_t unix_fds; // int *unix_fds;
 
-       unsigned n_unix_fds;
-       unsigned n_unix_fds_allocated;
+       uint_t n_unix_fds;
+       uint_t n_unix_fds_allocated;
 
-       long unix_fd_counter_delta;
+       long_t unix_fd_counter_delta;
 
-       struct DBusString *signature;
-       struct DBusString *unique_sender;
-       size_t gvariant_body_last_offset;
-       size_t gvariant_body_last_pos;
+       ptr_t signature; // struct DBusString *signature;
+       ptr_t unique_sender; // struct DBusString *unique_sender;
+       long_t gvariant_body_last_offset;
+       long_t gvariant_body_last_pos;
 };
 
 struct DBusConnection {
-       int refcount;
+       int_t refcount;
 
-       void *mutex;
+       ptr_t mutex; // void *mutex;
 
-       void *dispatch_mutex;
-       void *dispatch_cond;
-       void *io_path_mutex;
-       void *io_path_cond;
+       ptr_t dispatch_mutex; // void *dispatch_mutex;
+       ptr_t dispatch_cond; // void *dispatch_cond;
+       ptr_t io_path_mutex; // void *io_path_mutex;
+       ptr_t io_path_cond; // void *io_path_cond;
 
-       struct DBusList *outgoing_messages;
-       struct DBusList *incoming_messages;
-       struct DBusList *expired_messages;
+       ptr_t outgoing_messages; // struct DBusList *outgoing_messages;
+       ptr_t incoming_messages; // struct DBusList *incoming_messages;
+       ptr_t expired_messages; // struct DBusList *expired_messages;
 
-       struct DBusMessage *message_borrowed;
+       ptr_t message_borrowed; // struct DBusMessage *message_borrowed;
 
-       int n_outgoing;
-       int n_incoming;
+       int_t n_outgoing;
+       int_t n_incoming;
 };
 
 struct data_t {
@@ -224,10 +224,8 @@ static int get_delay(int serial, struct data_t receiver_data) {
 int get_msg_addr(struct pt_regs *ctx, struct DBusConnection *conn, struct DBusMessage *msg){
        struct data_t data = {};
        get_process_data(&data);
-       struct header_data *header = 0;
-       bpf_probe_read(&header, sizeof(header), (char*)msg + offsetof(struct DBusMessage, header.data.str));
-       u32 serial = 0;
-       bpf_probe_read(&serial, sizeof(serial), (char*)header + offsetof(struct header_data, serial));
+       struct header_data *header = msg->header.data.str;
+       u32 serial = header->serial;
        msg_sent_addr.update(&serial,&data);
        return 0;
 }
@@ -237,18 +235,16 @@ int get_msg_latency(struct pt_regs *ctx, struct DBusConnection *conn) {
        struct DBusMessage *msg = 0;
        struct header_data *header = 0;
        int serial = 0;
-       struct DBusList *link = 0;
-
-       bpf_probe_read(&link, sizeof(link), (char *)conn + offsetof(struct DBusConnection, incoming_messages));
+       struct DBusList *link = conn->incoming_messages;
 
        if (link == 0) {
                return 0;
        }
 
        get_process_data(&receiver_data);
-       bpf_probe_read(&msg, sizeof(msg), (char *)link + offsetof(struct DBusList, data));
-       bpf_probe_read(&header, sizeof(header), (char*)msg + offsetof(struct DBusMessage, header.data.str));
-       bpf_probe_read(&serial, sizeof(serial), (char*)header + offsetof(struct header_data, serial));
+       msg = link->data;
+       header = msg->header.data.str;
+       serial = header->serial;
        get_delay(serial, receiver_data);
        return 0;
 }
index b25fb8896aa68a9d53063d5c3a1d8b7b61e2dd0b..592b3c0d429e5ae8d884f288b3d6732a639fadaf 100644 (file)
@@ -1,5 +1,5 @@
-#include <uapi/linux/ptrace.h>
-#include <linux/sched.h>
+#include <hostcompat/linux/sched.h>
+#include <hostcompat/uapi/linux/ptrace.h>
 
 #define COUNTS COUNTS_T
 
@@ -12,7 +12,7 @@ struct bytes_t {
        u64 bytes;
 };
 
-BPF_HASH(size_sent, struct data_t, struct bytes_t)
+BPF_HASH(size_sent, struct data_t, struct bytes_t);
 
 BPF_HISTOGRAM(sizes);
 
index bf79e7c92ecbd9549dfd3ed0b6471b9d0f91c0f4..6246d637ec7215b292b68f17b30c8f748bec3143 100644 (file)
@@ -1,5 +1,5 @@
-#include <uapi/linux/ptrace.h>
-#include <linux/sched.h>
+#include <hostcompat/linux/sched.h>
+#include <hostcompat/uapi/linux/ptrace.h>
 
 #define DBUS_TYPE_OFFSET 1
 
@@ -24,64 +24,64 @@ typedef enum
 } GDBusMessageByteOrder;
 
 struct GTypeInstance {
-       void *g_class;
+       ptr_t g_class; // void *g_class;
 };
 
 struct GObject {
        struct GTypeInstance g_type_instance;
 
-       volatile unsigned int ref_count;
-       void *qdata;
+       volatile uint_t ref_count;
+       ptr_t qdata; // void *qdata;
 };
 
 struct GHashTable {
-       int size;
-       int mod;
-       unsigned int mask;
-       int nnodes;
-       int noccupied;
-
-       void *keys;
-       void *hashes;
-       void *values;
+       int_t size;
+       int_t mod;
+       uint_t mask;
+       int_t nnodes;
+       int_t noccupied;
+
+       ptr_t keys; // void *keys;
+       ptr_t hashes; // void *hashes;
+       ptr_t values; // void *values;
 };
 
 struct GVariant {
-       void *type_info;
-       unsigned long size;
+       ptr_t type_info; // void *type_info;
+       ulong_t size;
 
        union {
                struct {
-                       void *bytes;
-                       const char *gconstpointer;
+                       ptr_t bytes; // void *bytes;
+                       ptr_t gconstpointer; // const char *gconstpointer;
                } serialised;
 
                struct {
-                       struct GVariant **children;
-                       unsigned long n_children;
+                       ptr_t children; // struct GVariant **children;
+                       ulong_t n_children;
                } tree;
        } content;
 
-       int state;
-       int ref_count;
+       int_t state;
+       int_t ref_count;
 };
 
 struct GDBusMessage {
        struct GObject parent_instance;
-       GDBusMessageType type;
-       GDBusMessageFlags flags;
+       uint_t type; // GDBusMessageType type;
+       uint_t flags; // GDBusMessageFlags flags;
        bool locked;
-       GDBusMessageByteOrder byte_order;
+       uint_t byte_order; // GDBusMessageByteOrder byte_order;
        unsigned char major_protocol_version;
-       unsigned int serial;
-       struct GHashTable *headers;
-       struct GVariant *body;
+       uint_t serial;
+       ptr_t headers; // struct GHashTable *headers;
+       ptr_t body; // struct GVariant *body;
 };
 
 struct DBusString {
-       void *str;
-       int len;
-       unsigned int allocated;
+       ptr_t str; // void *str;
+       int_t len;
+       uint_t allocated;
        unsigned int constant : 1;
        unsigned int locked : 1;
        unsigned int invalid : 1;
@@ -89,7 +89,7 @@ struct DBusString {
 };
 
 struct DBusHeaderFields {
-       int value_pos;
+       int_t value_pos;
 };
 
 struct DBusHeader {
@@ -103,32 +103,32 @@ struct DBusHeader {
 };
 
 struct DBusMessage {
-       int refcount;
+       int_t refcount;
        struct DBusHeader header;
        struct DBusString body;
 
-       unsigned int locked : 1;
+       uint_t locked : 1;
 
-       void * list;
-       long size_counter_delta;
-       int timeout_ms;
+       ptr_t list; // void * list;
+       long_t size_counter_delta;
+       int_t timeout_ms;
 
        u32 changed_stamp : 21;
-       void *slot_list;
+       ptr_t slot_list; // void *slot_list;
 
-       int generation;
+       int_t generation;
 
-       int *unix_fds;
+       ptr_t unix_fds; // int *unix_fds;
 
-       unsigned n_unix_fds;
-       unsigned n_unix_fds_allocated;
+       uint_t n_unix_fds;
+       uint_t n_unix_fds_allocated;
 
-       long unix_fd_counter_delta;
+       long_t unix_fd_counter_delta;
 
-       struct DBusString *signature;
-       struct DBusString *unique_sender;
-       size_t gvariant_body_last_offset;
-       size_t gvariant_body_last_pos;
+       ptr_t signature; // struct DBusString *signature;
+       ptr_t unique_sender; // struct DBusString *unique_sender;
+       uint_t gvariant_body_last_offset;
+       uint_t gvariant_body_last_pos;
 };
 
 struct data_t {
@@ -150,10 +150,8 @@ int dbus_get_message_type(struct pt_regs *ctx, void *conn, struct DBusMessage *m
 }
 
 int message_type(struct pt_regs *ctx, void *conn, struct DBusMessage *message) {
-       char *addr = 0;
-       bpf_probe_read(&addr, sizeof(addr), (char*)message + offsetof(struct DBusMessage, header.data.str));
-       char type;
-       bpf_probe_read(&type, sizeof(type), addr + 1);
-       msg_type.increment(type);
+       const char *c = message->header.data.str;
+       c++;
+       msg_type.increment(*c);
        return 0;
 }
index 2e9159337076919033eed29945dc4ee8d8b855a1..b2f9dbe50b90bdc158dc91fc23753c1d46ce78ea 100755 (executable)
@@ -11,11 +11,12 @@ count = 100
 interval = 5
 loop = 0
 # load BPF program
-bpf_text="""#include <uapi/linux/ptrace.h>
-#include <linux/sched.h>
+bpf_text="""
+#include <hostcompat/linux/sched.h>
+#include <hostcompat/uapi/linux/ptrace.h>
 
 struct p_name{
-       char buf[80];
+       char buf[TASK_COMM_LEN];
        u32 pid;
 };
 
index 76fe5dab4111a0e812d3307763268ce24deb5a78..a31b44dba4e9034d1da44ae4701b197ae8850282 100644 (file)
@@ -1,5 +1,5 @@
-#include <uapi/linux/ptrace.h>
-#include <linux/sched.h>
+#include <hostcompat/uapi/linux/ptrace.h>
+#include <hostcompat/linux/sched.h>
 
 typedef struct pdata_T {
        u32 pid;
@@ -58,4 +58,3 @@ int do_return(struct pt_regs *ctx) {
        stats.update(&pid, &pdata);
        return 0;
 }
-