GDB (API)
/home/stan/gdb/src/gdb/syscalls/arm-linux.py
Go to the documentation of this file.
00001 # Copyright (C) 2013 Free Software Foundation, Inc.
00002 
00003 # Copying and distribution of this file, with or without modification,
00004 # are permitted in any medium without royalty provided the copyright
00005 # notice and this notice are preserved.  This file is offered as-is,
00006 # without any warranty.
00007 
00008 import sys
00009 import re
00010 import time
00011 
00012 infname = sys.argv[1]
00013 inf = file(infname)
00014 
00015 print("""\
00016 <?xml version="1.0"?>
00017 <!-- Copyright (C) 2009-%s Free Software Foundation, Inc.
00018 
00019      Copying and distribution of this file, with or without modification,
00020      are permitted in any medium without royalty provided the copyright
00021      notice and this notice are preserved.  This file is offered as-is,
00022      without any warranty. -->
00023 
00024 <!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
00025 
00026 <!-- This file was generated using the following file:
00027 
00028      %s
00029 
00030      The file mentioned above belongs to the Linux Kernel.
00031      Some small hand-edits were made. -->
00032 
00033 <syscalls_info>""" % (time.strftime("%Y"), infname))
00034 
00035 def record(name, number, comment=None):
00036     #nm = 'name="%s"' % name
00037     #s = '  <syscall %-30s number="%d"/>' % (nm, number)
00038     s = '  <syscall name="%s" number="%d"/>' % (name, number)
00039     if comment:
00040         s += ' <!-- %s -->' % comment
00041     print(s)
00042 
00043 for line in inf:
00044     m = re.match(r'^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE\+\s*(\d+)\)',
00045                  line)
00046     if m:
00047         record(m.group(1), int(m.group(2)))
00048         continue
00049 
00050     m = re.match(r'^\s+/\* (\d+) was sys_(\w+) \*/$', line)
00051     if m:
00052         record(m.group(2), int(m.group(1)), 'removed')
00053 
00054     m = re.match(r'^#define __ARM_NR_(\w+)\s+\(__ARM_NR_BASE\+\s*(\d+)\)',
00055                  line)
00056     if m:
00057         record('ARM_'+m.group(1), 0x0f0000+int(m.group(2)))
00058         continue
00059 
00060 print('</syscalls_info>')
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines