Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright (C) 2013-2022 Free Software Foundation, Inc. |
a5829458 SDJ |
2 | |
3 | # Copying and distribution of this file, with or without modification, | |
4 | # are permitted in any medium without royalty provided the copyright | |
5 | # notice and this notice are preserved. This file is offered as-is, | |
6 | # without any warranty. | |
7 | ||
8 | import sys | |
9 | import re | |
10 | import time | |
11 | ||
12 | infname = sys.argv[1] | |
13 | inf = file(infname) | |
14 | ||
13123da8 SM |
15 | print( |
16 | """\ | |
a5829458 SDJ |
17 | <?xml version="1.0"?> |
18 | <!-- Copyright (C) 2009-%s Free Software Foundation, Inc. | |
19 | ||
20 | Copying and distribution of this file, with or without modification, | |
21 | are permitted in any medium without royalty provided the copyright | |
22 | notice and this notice are preserved. This file is offered as-is, | |
23 | without any warranty. --> | |
24 | ||
25 | <!DOCTYPE feature SYSTEM "gdb-syscalls.dtd"> | |
26 | ||
27 | <!-- This file was generated using the following file: | |
28 | ||
29 | %s | |
30 | ||
31 | The file mentioned above belongs to the Linux Kernel. | |
32 | Some small hand-edits were made. --> | |
33 | ||
13123da8 SM |
34 | <syscalls_info>""" |
35 | % (time.strftime("%Y"), infname) | |
36 | ) | |
37 | ||
a5829458 SDJ |
38 | |
39 | def record(name, number, comment=None): | |
13123da8 SM |
40 | # nm = 'name="%s"' % name |
41 | # s = ' <syscall %-30s number="%d"/>' % (nm, number) | |
a5829458 SDJ |
42 | s = ' <syscall name="%s" number="%d"/>' % (name, number) |
43 | if comment: | |
13123da8 | 44 | s += " <!-- %s -->" % comment |
a5829458 SDJ |
45 | print(s) |
46 | ||
13123da8 | 47 | |
a5829458 | 48 | for line in inf: |
13123da8 | 49 | m = re.match(r"^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE\+\s*(\d+)\)", line) |
a5829458 SDJ |
50 | if m: |
51 | record(m.group(1), int(m.group(2))) | |
52 | continue | |
53 | ||
13123da8 | 54 | m = re.match(r"^\s+/\* (\d+) was sys_(\w+) \*/$", line) |
a5829458 | 55 | if m: |
13123da8 | 56 | record(m.group(2), int(m.group(1)), "removed") |
a5829458 | 57 | |
13123da8 | 58 | m = re.match(r"^#define __ARM_NR_(\w+)\s+\(__ARM_NR_BASE\+\s*(\d+)\)", line) |
a5829458 | 59 | if m: |
13123da8 | 60 | record("ARM_" + m.group(1), 0x0F0000 + int(m.group(2))) |
a5829458 SDJ |
61 | continue |
62 | ||
13123da8 | 63 | print("</syscalls_info>") |