1 #!/usr/bin/awk -f 2 # This file is part of ltrace. 3 # Copyright (C) 2008 Juan Cespedes 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of the 8 # License, or (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, but 11 # WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 # General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 # 02110-1301 USA 19 20 # hack expression to generate arch_syscallent.h from <asm/unistd.h> 21 # It reads from stdin and writes to stdout 22 # Currently (linux-2.6.16), it works OK on arm 23 # It is untested in other architectures 24 25 BEGIN { 26 max=0; 27 FS="[ \t\n()+]+"; 28 } 29 30 { 31 # printf("/%s/%s/%s/%s/\n", $1, $2, $3, $4); 32 if (($1 ~ /^#define$/) && ($2 ~ /^__[A-Z]+_NR_/)) { 33 sub(/^__[A-Z]+_NR_/,"",$2); 34 if (($3>=0) && ($3<=1000)) { 35 SYSCALL[$3]=$2; 36 if ($3 > max) { 37 max=$3; 38 } 39 } else if (($3 ~ /^__[A-Z]+_NR_BASE$/) && ($4>=0) && ($4<=1000)) { 40 SYSCALL[$4]=$2; 41 if ($4 > max) { 42 max=$4; 43 } 44 } 45 } 46 } 47 48 END { 49 for(i=0; i<=max; i++) { 50 if (!SYSCALL[i]) { 51 SYSCALL[i] = i; 52 } 53 pad = 32 - length(SYSCALL[i]); 54 if (pad<1) { 55 pad=1; 56 } 57 printf("\t\"%s\",%*s/* %d */\n", SYSCALL[i], pad, "", i); 58 } 59 } 60