Commit | Line | Data |
---|---|---|
4aa995e1 PA |
1 | /* Target-dependent code for GNU/Linux, architecture independent. |
2 | ||
3 | Copyright (C) 2009 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include "defs.h" | |
21 | #include "gdbtypes.h" | |
2c0b251b | 22 | #include "linux-tdep.h" |
4aa995e1 PA |
23 | |
24 | /* This function is suitable for architectures that don't | |
25 | extend/override the standard siginfo structure. */ | |
26 | ||
27 | struct type * | |
28 | linux_get_siginfo_type (struct gdbarch *gdbarch) | |
29 | { | |
30 | struct type *int_type, *uint_type, *long_type, *void_ptr_type; | |
31 | struct type *uid_type, *pid_type; | |
32 | struct type *sigval_type, *clock_type; | |
33 | struct type *siginfo_type, *sifields_type; | |
34 | struct type *type; | |
35 | ||
e9bb382b UW |
36 | int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), |
37 | 0, "int"); | |
38 | uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), | |
39 | 1, "unsigned int"); | |
40 | long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch), | |
41 | 0, "long"); | |
4aa995e1 PA |
42 | void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); |
43 | ||
44 | /* sival_t */ | |
e9bb382b | 45 | sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); |
4aa995e1 PA |
46 | TYPE_NAME (sigval_type) = xstrdup ("sigval_t"); |
47 | append_composite_type_field (sigval_type, "sival_int", int_type); | |
48 | append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); | |
49 | ||
50 | /* __pid_t */ | |
e9bb382b UW |
51 | pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, TYPE_LENGTH (int_type), |
52 | xstrdup ("__pid_t")); | |
4aa995e1 | 53 | TYPE_TARGET_TYPE (pid_type) = int_type; |
e9bb382b | 54 | TYPE_TARGET_STUB (pid_type) = 1; |
4aa995e1 PA |
55 | |
56 | /* __uid_t */ | |
e9bb382b UW |
57 | uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, TYPE_LENGTH (uint_type), |
58 | xstrdup ("__uid_t")); | |
4aa995e1 | 59 | TYPE_TARGET_TYPE (uid_type) = uint_type; |
e9bb382b | 60 | TYPE_TARGET_STUB (uid_type) = 1; |
4aa995e1 PA |
61 | |
62 | /* __clock_t */ | |
e9bb382b UW |
63 | clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, TYPE_LENGTH (long_type), |
64 | xstrdup ("__clock_t")); | |
4aa995e1 | 65 | TYPE_TARGET_TYPE (clock_type) = long_type; |
e9bb382b | 66 | TYPE_TARGET_STUB (clock_type) = 1; |
4aa995e1 PA |
67 | |
68 | /* _sifields */ | |
e9bb382b | 69 | sifields_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); |
4aa995e1 PA |
70 | |
71 | { | |
72 | const int si_max_size = 128; | |
73 | int si_pad_size; | |
74 | int size_of_int = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT; | |
75 | ||
76 | /* _pad */ | |
77 | if (gdbarch_ptr_bit (gdbarch) == 64) | |
78 | si_pad_size = (si_max_size / size_of_int) - 4; | |
79 | else | |
80 | si_pad_size = (si_max_size / size_of_int) - 3; | |
81 | append_composite_type_field (sifields_type, "_pad", | |
82 | init_vector_type (int_type, si_pad_size)); | |
83 | } | |
84 | ||
85 | /* _kill */ | |
e9bb382b | 86 | type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); |
4aa995e1 PA |
87 | append_composite_type_field (type, "si_pid", pid_type); |
88 | append_composite_type_field (type, "si_uid", uid_type); | |
89 | append_composite_type_field (sifields_type, "_kill", type); | |
90 | ||
91 | /* _timer */ | |
e9bb382b | 92 | type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); |
4aa995e1 PA |
93 | append_composite_type_field (type, "si_tid", int_type); |
94 | append_composite_type_field (type, "si_overrun", int_type); | |
95 | append_composite_type_field (type, "si_sigval", sigval_type); | |
96 | append_composite_type_field (sifields_type, "_timer", type); | |
97 | ||
98 | /* _rt */ | |
e9bb382b | 99 | type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); |
4aa995e1 PA |
100 | append_composite_type_field (type, "si_pid", pid_type); |
101 | append_composite_type_field (type, "si_uid", uid_type); | |
102 | append_composite_type_field (type, "si_sigval", sigval_type); | |
103 | append_composite_type_field (sifields_type, "_rt", type); | |
104 | ||
105 | /* _sigchld */ | |
e9bb382b | 106 | type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); |
4aa995e1 PA |
107 | append_composite_type_field (type, "si_pid", pid_type); |
108 | append_composite_type_field (type, "si_uid", uid_type); | |
109 | append_composite_type_field (type, "si_status", int_type); | |
110 | append_composite_type_field (type, "si_utime", clock_type); | |
111 | append_composite_type_field (type, "si_stime", clock_type); | |
112 | append_composite_type_field (sifields_type, "_sigchld", type); | |
113 | ||
114 | /* _sigfault */ | |
e9bb382b | 115 | type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); |
4aa995e1 PA |
116 | append_composite_type_field (type, "si_addr", void_ptr_type); |
117 | append_composite_type_field (sifields_type, "_sigfault", type); | |
118 | ||
119 | /* _sigpoll */ | |
e9bb382b | 120 | type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); |
4aa995e1 PA |
121 | append_composite_type_field (type, "si_band", long_type); |
122 | append_composite_type_field (type, "si_fd", int_type); | |
123 | append_composite_type_field (sifields_type, "_sigpoll", type); | |
124 | ||
125 | /* struct siginfo */ | |
e9bb382b | 126 | siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); |
4aa995e1 PA |
127 | TYPE_NAME (siginfo_type) = xstrdup ("siginfo"); |
128 | append_composite_type_field (siginfo_type, "si_signo", int_type); | |
129 | append_composite_type_field (siginfo_type, "si_errno", int_type); | |
130 | append_composite_type_field (siginfo_type, "si_code", int_type); | |
131 | append_composite_type_field_aligned (siginfo_type, | |
132 | "_sifields", sifields_type, | |
133 | TYPE_LENGTH (long_type)); | |
134 | ||
135 | return siginfo_type; | |
136 | } |