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