prctl_option.sh 744 B

123456789101112131415161718
  1. #!/bin/sh
  2. # SPDX-License-Identifier: LGPL-2.1
  3. [ $# -eq 1 ] && beauty_uapi_linux_dir=$1 || beauty_uapi_linux_dir=tools/perf/trace/beauty/include/uapi/linux/
  4. printf "static const char *prctl_options[] = {\n"
  5. regex='^#define[[:space:]]{1}PR_(\w+)[[:space:]]*([[:xdigit:]]+)([[:space:]]*/.*)?$'
  6. grep -E $regex ${beauty_uapi_linux_dir}/prctl.h | grep -v PR_SET_PTRACER | \
  7. sed -E "s%$regex%\2 \1%g" | \
  8. sort -n | xargs printf "\t[%s] = \"%s\",\n"
  9. printf "};\n"
  10. printf "static const char *prctl_set_mm_options[] = {\n"
  11. regex='^#[[:space:]]+define[[:space:]]+PR_SET_MM_(\w+)[[:space:]]*([[:digit:]]+).*'
  12. grep -E $regex ${beauty_uapi_linux_dir}/prctl.h | \
  13. sed -r "s/$regex/\2 \1/g" | \
  14. sort -n | xargs printf "\t[%s] = \"%s\",\n"
  15. printf "};\n"