Saeshnikov / Linux-monitoring-utility

MIT License
2 stars 0 forks source link

Problem with semaphore script on bpftrace v0.17.0 #132

Open sonix14 opened 3 weeks ago

sonix14 commented 3 weeks ago

When trying to run a script with semaphore capture on a system with bpftrace v0.17.0 (after changing the dots to arrows), the following errors occur: image At the same time, bpftrace does not output any errors to the same piece of code from other scripts.

The script itself:

#ifndef BPFTRACE_HAVE_BTF
#include <linux/sched.h>
#endif

tracepoint:syscalls:sys_enter_semget
{
  @semkey[tid] = args->key;
}

tracepoint:syscalls:sys_exit_semget
/@semkey[tid]/
{
  @semid[tid] = args->ret;
}

tracepoint:syscalls:sys_enter_semop,
tracepoint:syscalls:sys_enter_semtimedop,
/@semid[tid]/
{
  $task = (struct task_struct *)curtask;
  $part_path = $task->mm->exe_file->f_path.dentry->d_parent;
  $i = 0;
  @full_path_comm[$i] = $part_path->d_name.name;
  $i = 1;
  while ($i != 3000) {
    $part_path = $part_path->d_parent;
    @full_path_comm[$i] = $part_path->d_name.name;
    if ((uint64)$part_path->d_inode->i_ino == 256) {
      break;
    }
    $i = $i + 1;
  }
  printf("\n/");
  while ($i != -1) {
    $str_ = @full_path_comm[$i];
    printf("%s/", str($str_));
    $i = $i - 1;
  }
  printf("%s ",comm);

  printf("%x %d",@semkey[tid], @semid[tid]);
}

END
{
  clear(@semkey);
  clear(@semid);
  clear(@full_path_comm);
}
sonix14 commented 3 weeks ago

When adding the following to the script:

#include <net/sock.h>
#else
#include <sys/socket.h>

Then on a system with bpftrace v0.17.0, the script does not produce errors :\

denis-koptev commented 1 week ago

Попробую потом раздобыть 17-й bpftrace, но на 20-м все работает, если подключить заголовок linux/mm.h