28 lines · bash
1#!/bin/sh2# Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>3# SPDX-License-Identifier: LGPL-2.14 5[ $# -eq 1 ] && beauty_x86_arch_asm_uapi_dir=$1 || beauty_x86_arch_asm_uapi_dir=tools/perf/trace/beauty/arch/x86/include/uapi/asm/6 7prctl_arch_header=${beauty_x86_arch_asm_uapi_dir}/prctl.h8 9print_range () {10 idx=$111 prefix=$212 first_entry=$313 14 printf "#define x86_arch_prctl_codes_%d_offset %s\n" $idx $first_entry15 printf "static const char *x86_arch_prctl_codes_%d[] = {\n" $idx16 regex=`printf '^[[:space:]]*#[[:space:]]*define[[:space:]]+ARCH_([[:alnum:]_]+)[[:space:]]+(%s[[:xdigit:]]+).*' ${prefix}`17 fmt="\t[%#x - ${first_entry}]= \"%s\",\n"18 grep -E -q $regex ${prctl_arch_header} && \19 (grep -E $regex ${prctl_arch_header} | \20 sed -r "s/$regex/\2 \1/g" | \21 xargs printf "$fmt")22 printf "};\n\n"23}24 25print_range 1 0x1 0x100126print_range 2 0x2 0x200127print_range 3 0x4 0x400128