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