~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/test_uprobe_from_different_cu.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # test perf probe of function from different CU
  3 # SPDX-License-Identifier: GPL-2.0
  4 
  5 set -e
  6 
  7 # Skip if there's no probe command.
  8 if ! perf | grep probe
  9 then
 10         echo "Skip: probe command isn't present"
 11         exit 2
 12 fi
 13 
 14 # skip if there's no gcc
 15 if ! [ -x "$(command -v gcc)" ]; then
 16         echo "failed: no gcc compiler"
 17         exit 2
 18 fi
 19 
 20 temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
 21 
 22 cleanup()
 23 {
 24         trap - EXIT TERM INT
 25         if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
 26                 echo "--- Cleaning up ---"
 27                 perf probe -x ${temp_dir}/testfile -d foo || true
 28                 rm -f "${temp_dir}/"*
 29                 rmdir "${temp_dir}"
 30         fi
 31 }
 32 
 33 trap_cleanup()
 34 {
 35         cleanup
 36         exit 1
 37 }
 38 
 39 trap trap_cleanup EXIT TERM INT
 40 
 41 cat > ${temp_dir}/testfile-foo.h << EOF
 42 struct t
 43 {
 44   int *p;
 45   int c;
 46 };
 47 
 48 extern int foo (int i, struct t *t);
 49 EOF
 50 
 51 cat > ${temp_dir}/testfile-foo.c << EOF
 52 #include "testfile-foo.h"
 53 
 54 int
 55 foo (int i, struct t *t)
 56 {
 57   int j, res = 0;
 58   for (j = 0; j < i && j < t->c; j++)
 59     res += t->p[j];
 60 
 61   return res;
 62 }
 63 EOF
 64 
 65 cat > ${temp_dir}/testfile-main.c << EOF
 66 #include "testfile-foo.h"
 67 
 68 static struct t g;
 69 
 70 int
 71 main (int argc, char **argv)
 72 {
 73   int i;
 74   int j[argc];
 75   g.c = argc;
 76   g.p = j;
 77   for (i = 0; i < argc; i++)
 78     j[i] = (int) argv[i][0];
 79   return foo (3, &g);
 80 }
 81 EOF
 82 
 83 gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o
 84 gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
 85 gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
 86 
 87 perf probe -x ${temp_dir}/testfile --funcs foo | grep "foo"
 88 perf probe -x ${temp_dir}/testfile foo
 89 
 90 cleanup

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php