blob: f3961b4b44c4be131768178a2e202ef78cd058da [file] [log] [blame]
Arnaud Patard0aac3522010-01-08 08:40:01 -05001#!/usr/bin/awk -f
Petr Machatae99af272012-10-26 00:29:52 +02002# This file is part of ltrace.
3# Copyright (C) 2010 Arnaud Patard, Mandriva SA
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
Arnaud Patard0aac3522010-01-08 08:40:01 -050019
20# hack expression to generate arch/syscallent.h from <asm/unistd.h>
21# It reads from stdin and writes to stdout
22# It should work OK on i386,m68k,arm,ia64
23# It does NOT work in mips, s390
24# It is untested in other architectures
25
26BEGIN {
27 max=0;
28 FS="[ \t\n()+]+";
29}
30
31{
32 #debug
33 #printf("/%s/%s/%s/%s/\n", $1, $2, $3, $4);
34 if ($2 ~ /__NR_Linux/ && $3 ~ /4000/) {
35 syscall=1;
36 }
37 if ($2 ~ /__NR_Linux_syscalls/) {
38 syscall=0;
39 }
40 if (syscall && ($1 ~ /^#define$/) && ($2 ~ /^__NR_/)) {
41 SYSCALL[$4]=substr($2,6);
42 if ($4 > max) {
43 max=$4;
44 }
45 }
46}
47
48END {
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