Blob Blame History Raw
commit c7029a89f5f1ff6d6a7008e8bccb797046f8af50
Author: David Smith <dsmith@redhat.com>
Date:   Tue May 9 16:32:25 2017 -0500

    Add missing @cast() calls for 4.11 kernels.
    
    * tapset/linux/task.stp: Add a "signal_struct" cast to
      _task_rlimit_cur().
    * tapset/linux/task.stpm: Fix @mm() macro for kernels >= 2.6.34, where the
      mm_struct definition has moved to <linux/mm_types.h>
    * tapset/linux/proc_mem.stp (proc_mem_size): Use the @mm() macro to cast
      values to a mm_struct.
      (proc_mem_txt): Ditto.
      (proc_mem_data): Ditto.
    * tapset/linux/context.stp (cmdline_args): Ditto.
    * tapset/linux/context-envvar.stp (env_var): Ditto.

diff --git a/tapset/linux/context-envvar.stp b/tapset/linux/context-envvar.stp
index 4d4c648..2ceb6c8 100644
--- a/tapset/linux/context-envvar.stp
+++ b/tapset/linux/context-envvar.stp
@@ -28,8 +28,8 @@ function env_var:string(name:string)
   mm = task_current()->mm;
   if (mm)
     {
-      env_start = mm->env_start;
-      env_end = mm->env_end;
+      env_start = @mm(mm)->env_start;
+      env_end = @mm(mm)->env_end;
       if (env_start != 0 && env_end != 0)
         {
           len = env_end - env_start;
diff --git a/tapset/linux/context.stp b/tapset/linux/context.stp
index e563983..8ab81b4 100644
--- a/tapset/linux/context.stp
+++ b/tapset/linux/context.stp
@@ -559,8 +559,8 @@ function cmdline_args:string(n:long, m:long, delim:string)
   if (__mm == 0)
     return "";
 
-  __arg_start = __mm->arg_start;
-  __arg_end = __mm->arg_end;
+  __arg_start = @mm(__mm)->arg_start;
+  __arg_end = @mm(__mm)->arg_end;
   if (__arg_start == 0 || __arg_end == 0)
     return "";
 
diff --git a/tapset/linux/proc_mem.stp b/tapset/linux/proc_mem.stp
index de6f423..161033d 100644
--- a/tapset/linux/proc_mem.stp
+++ b/tapset/linux/proc_mem.stp
@@ -124,7 +124,7 @@ function proc_mem_size:long ()
    if (_stp_valid_task(task)) {
      mm = task->mm
      if (mm != 0)
-       return mm->total_vm
+       return @mm(mm)->total_vm
    }
    return 0
 }
@@ -144,7 +144,7 @@ function proc_mem_size:long (pid:long)
   if (_stp_valid_task(task)) {
     mm = task->mm
     if (mm != 0)
-      return mm->total_vm
+      return @mm(mm)->total_vm
   }
   return 0
 }
@@ -260,8 +260,8 @@ function proc_mem_txt:long ()
   if (_stp_valid_task(task)) {
     mm = task->mm
     if (mm != 0) {
-      s = mm->start_code
-      e = mm->end_code
+      s = @mm(mm)->start_code
+      e = @mm(mm)->end_code
       return _stp_mem_txt_adjust(s, e)
     }
   }
@@ -283,8 +283,8 @@ function proc_mem_txt:long (pid:long)
   if (_stp_valid_task(task)) {
     mm = task->mm
     if (mm != 0) {
-      s = mm->start_code
-      e = mm->end_code
+      s = @mm(mm)->start_code
+      e = @mm(mm)->end_code
       return _stp_mem_txt_adjust (s, e)
     }
   }
@@ -308,8 +308,9 @@ function proc_mem_data:long ()
   if (_stp_valid_task(task)) {
     mm = task->mm
     if (mm != 0) {
-      return (@defined(&@mm(0)->data_vm) ? (mm->data_vm + mm->stack_vm)
-	      : (mm->total_vm - mm->shared_vm))
+      return (@defined(&@mm(0)->data_vm)
+	      ? (@mm(mm)->data_vm + @mm(mm)->stack_vm)
+	      : (@mm(mm)->total_vm - @mm(mm)->shared_vm))
     }
   }
   return 0
@@ -330,8 +331,9 @@ function proc_mem_data:long (pid:long)
   if (_stp_valid_task(task)) {
     mm = task->mm
     if (mm != 0) {
-      return (@defined(&@mm(0)->data_vm) ? (mm->data_vm + mm->stack_vm)
-	      : (mm->total_vm - mm->shared_vm))
+      return (@defined(&@mm(0)->data_vm)
+              ? (@mm(mm)->data_vm + @mm(mm)->stack_vm)
+	      : (@mm(mm)->total_vm - @mm(mm)->shared_vm))
     }
   }
   return 0
diff --git a/tapset/linux/task.stp b/tapset/linux/task.stp
index 5467e05..f7c852e 100644
--- a/tapset/linux/task.stp
+++ b/tapset/linux/task.stp
@@ -40,7 +40,7 @@ function task_current:long () {
         return -1;
     }
     sig = @task(task)->signal;
-    return sig->rlim[nd_limit]->rlim_cur;
+    return @cast(sig, "signal_struct")->rlim[nd_limit]->rlim_cur;
 }
 
 /* sfunction task_rlimit - The current resource limit of the task
diff --git a/tapset/linux/task.stpm b/tapset/linux/task.stpm
index 7df04e3..f1bfb8e 100644
--- a/tapset/linux/task.stpm
+++ b/tapset/linux/task.stpm
@@ -3,5 +3,9 @@
 %)
 
 @define mm(ptr) %(
+  %( kernel_v >= "2.6.34" %?
+    @cast(@ptr, "mm_struct", "kernel<linux/mm_types.h>")
+  %:
     @cast(@ptr, "mm_struct", "kernel<linux/sched.h>")
+  %)
 %)