Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HACKING-scripts 2.8KB

  1. Each strace port relies heavily on port-specific headers:
  2. - errnoent.h - map error number to error name like strerror()
  3. - ioctlent.h - map ioctl number to symbolic define
  4. - signalent.h - map signal number to signal name like strsignal()
  5. - syscallent.h - map syscall number to name and function signature
  6. Since generating these headers from scratch (or even just updating them) can be
  7. a big pain, there are a few scripts to help automate the process. Since each
  8. port organizes their kernel sources differently, there may be a specific script
  9. for your kernel.
  10. We will use the Linux kernel (2.6.20+) as an example below (the Blackfin
  11. architecture to be specific). Hopefully, it'll be obvious how to swap out a
  12. different system or architecture as your circumstances apply.
  13. ksrc=/usr/src/linux
  14. asrc=$ksrc/arch/blackfin/include
  15. To use the errnoent.sh script, give it all the headers that might contain
  16. appropriate errno values. Excessive headers are not a problem. The resulting
  17. output should be directly usable without modification.
  18. sh ./maint/errnoent.sh \
  19. $ksrc/include/linux/*errno*.h \
  20. $ksrc/include/asm-generic/*errno*.h \
  21. $asrc/asm/*errno*.h \
  22. > errnoent.h
  23. To use the ioctls_gen.sh script, give it all the base include directories. The
  24. script will crawl all the headers and try to discover appropriate ioctls.
  25. Unlike the other scripts, this one creates files for further processing. This
  26. is because ioctls tend to have a lot of define indirection, and the ioctlent0.h
  27. header needs to be fully expanded into numeric form and sorted properly. So
  28. first we process all of the ioctls with the ioctls_gen.sh into ioctls_inc.h and
  29. ioctls_arch.h, and then we compile them into ioctlsort.c. The resulting
  30. output, while directly usable, only contains definitions that match exactly the
  31. current kernel version that the script ran against. That means older/newer
  32. ioctl defines that might be present in the existing ioctlent0.h header will be
  33. lost if things are copied directly. A little creative use of `diff` and manual
  34. merging should be used to produce the final ioctlent0.h header.
  35. sh ./maint/ioctls_gen.sh $ksrc/include $asrc
  36. gcc -Wall -I. ioctlsort.c -o ioctlsort
  37. ./ioctlsort > ioctlent0.h
  38. To use the signalent.sh script, give it all the headers that might contain
  39. appropriate signal values. Excessive headers are not a problem. The resulting
  40. output should be directly usable without modification.
  41. sh ./maint/signalent.sh \
  42. $asrc/asm/signal.h \
  43. > signalent.h
  44. To use the syscallent.sh script, give it the header with the list of your
  45. system call numbers. The resulting output is useful as a template for creating
  46. a proper header as it can really only detect the system call number and its
  47. name. It has no way of knowing the number of arguments or strace flags for
  48. decoding them (yet?).
  49. sh ./maint/syscallent.sh \
  50. $asrc/asm/unistd.h \
  51. > syscallent.h