gdb/syscalls/arm-linux.py - gdb

Global variables defined

Functions defined

Source code

  1. # Copyright (C) 2013-2015 Free Software Foundation, Inc.

  2. # Copying and distribution of this file, with or without modification,
  3. # are permitted in any medium without royalty provided the copyright
  4. # notice and this notice are preserved.  This file is offered as-is,
  5. # without any warranty.

  6. import sys
  7. import re
  8. import time

  9. infname = sys.argv[1]
  10. inf = file(infname)

  11. print("""\
  12. <?xml version="1.0"?>
  13. <!-- Copyright (C) 2009-%s Free Software Foundation, Inc.

  14.      Copying and distribution of this file, with or without modification,
  15.      are permitted in any medium without royalty provided the copyright
  16.      notice and this notice are preserved.  This file is offered as-is,
  17.      without any warranty. -->

  18. <!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">

  19. <!-- This file was generated using the following file:

  20.      %s

  21.      The file mentioned above belongs to the Linux Kernel.
  22.      Some small hand-edits were made. -->

  23. <syscalls_info>""" % (time.strftime("%Y"), infname))

  24. def record(name, number, comment=None):
  25.     #nm = 'name="%s"' % name
  26.     #s = '  <syscall %-30s number="%d"/>' % (nm, number)
  27.     s = '  <syscall name="%s" number="%d"/>' % (name, number)
  28.     if comment:
  29.         s += ' <!-- %s -->' % comment
  30.     print(s)

  31. for line in inf:
  32.     m = re.match(r'^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE\+\s*(\d+)\)',
  33.                  line)
  34.     if m:
  35.         record(m.group(1), int(m.group(2)))
  36.         continue

  37.     m = re.match(r'^\s+/\* (\d+) was sys_(\w+) \*/$', line)
  38.     if m:
  39.         record(m.group(2), int(m.group(1)), 'removed')

  40.     m = re.match(r'^#define __ARM_NR_(\w+)\s+\(__ARM_NR_BASE\+\s*(\d+)\)',
  41.                  line)
  42.     if m:
  43.         record('ARM_'+m.group(1), 0x0f0000+int(m.group(2)))
  44.         continue

  45. print('</syscalls_info>')