1 From 9cf12d57c58a82cfe3e6fee26d1ea55dfe49f9c4 Mon Sep 17 00:00:00 2001
2 From: Pedro Alves <palves@redhat.com>
3 Date: Tue, 26 Jul 2016 19:35:40 +0100
4 Subject: [PATCH] Fix PR gdb/20287 - x32 and "gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t))"
6 Content-Type: text/plain; charset=utf8
7 Content-Transfer-Encoding: 8bit
9 Building an x32 gdb trips on a static assertion:
11 In file included from .../src/gdb/common/common-defs.h:71:0,
12 from .../src/gdb/nat/amd64-linux-siginfo.c:21:
13 .../src/gdb/common/gdb_assert.h:26:66: error: size of array â
\80\98never_defined_just_used_for_checkingâ
\80\99 is negative
14 extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]
16 .../src/gdb/nat/amd64-linux-siginfo.c:113:1: note: in expansion of macro â
\80\98gdb_static_assertâ
\80\99
17 gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
20 The problem is that the way nat_siginfo_t is defined, it can only
21 match the host's siginfo_t object when gdb is built as a 64-bit
24 Several bits of nat_siginfo_t are off:
26 - nat_siginfo_t's _pad field's definition is:
28 int _pad[((128 / sizeof (int)) - 4)];
30 while /usr/include/bits/siginfo.h has:
32 # define __SI_MAX_SIZE 128
34 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4)
36 # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
39 and __WORDSIZE == 32 for x32. This is what causes the size of
40 nat_siginfo_t to be wrong and the assertion to fail.
42 - the nat_clock_t type is incorrect for 64-bit. We have this:
44 /* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4 bytes. */
45 typedef long __attribute__ ((__aligned__ (4))) nat_clock_t;
47 however, /usr/include/bits/siginfo.h has:
49 # if defined __x86_64__ && __WORDSIZE == 32
50 /* si_utime and si_stime must be 4 byte aligned for x32 to match the
51 kernel. We align siginfo_t to 8 bytes so that si_utime and si_stime
52 are actually aligned to 8 bytes since their offsets are multiple of
54 typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t;
55 # define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
57 typedef __clock_t __sigchld_clock_t;
58 # define __SI_ALIGNMENT
61 So we're currently forcing 4-byte alignment on clock_t, when it
62 should only be so for x32, not 64-bit.
66 - Leaves nat_siginfo_t strictly for the 64-bit ABI.
68 - Adds a new typedef for the siginfo type that ptrace uses
69 (ptrace_siginfo_t). An x32 gdb always gets/sets an x32 siginfo_t
70 type with PTRACE_GETSIGINFO/PTRACE_SETSIGINFO.
72 - Uses this new ptrace_siginfo_t type instead of nat_siginfo_t as the
73 intermediate conversion type.
75 diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
76 index 391a646..fea6ee2 100644
77 --- a/gdb/amd64-linux-nat.c
78 +++ b/gdb/amd64-linux-nat.c
79 @@ -321,25 +321,25 @@ ps_get_thread_area (const struct ps_prochandle *ph,
83 -/* Convert a native/host siginfo object, into/from the siginfo in the
84 +/* Convert a ptrace/host siginfo object, into/from the siginfo in the
85 layout of the inferiors' architecture. Returns true if any
86 conversion was done; false otherwise. If DIRECTION is 1, then copy
87 - from INF to NATIVE. If DIRECTION is 0, copy from NATIVE to
88 + from INF to PTRACE. If DIRECTION is 0, copy from PTRACE to
92 -amd64_linux_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
93 +amd64_linux_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
95 struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
97 /* Is the inferior 32-bit? If so, then do fixup the siginfo
99 if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
100 - return amd64_linux_siginfo_fixup_common (native, inf, direction,
101 + return amd64_linux_siginfo_fixup_common (ptrace, inf, direction,
103 /* No fixup for native x32 GDB. */
104 else if (gdbarch_addr_bit (gdbarch) == 32 && sizeof (void *) == 8)
105 - return amd64_linux_siginfo_fixup_common (native, inf, direction,
106 + return amd64_linux_siginfo_fixup_common (ptrace, inf, direction,
110 diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
111 index 5080dec..4e6dbce 100644
112 --- a/gdb/gdbserver/linux-x86-low.c
113 +++ b/gdb/gdbserver/linux-x86-low.c
114 @@ -624,14 +624,14 @@ x86_debug_reg_state (pid_t pid)
115 as debugging it with a 32-bit GDBSERVER, we do the 32-bit <-> 64-bit
116 conversion in-place ourselves. */
118 -/* Convert a native/host siginfo object, into/from the siginfo in the
119 +/* Convert a ptrace/host siginfo object, into/from the siginfo in the
120 layout of the inferiors' architecture. Returns true if any
121 conversion was done; false otherwise. If DIRECTION is 1, then copy
122 - from INF to NATIVE. If DIRECTION is 0, copy from NATIVE to
123 + from INF to PTRACE. If DIRECTION is 0, copy from PTRACE to
127 -x86_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
128 +x86_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction)
131 unsigned int machine;
132 @@ -640,11 +640,11 @@ x86_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction)
134 /* Is the inferior 32-bit? If so, then fixup the siginfo object. */
135 if (!is_64bit_tdesc ())
136 - return amd64_linux_siginfo_fixup_common (native, inf, direction,
137 + return amd64_linux_siginfo_fixup_common (ptrace, inf, direction,
139 /* No fixup for native x32 GDB. */
140 else if (!is_elf64 && sizeof (void *) == 8)
141 - return amd64_linux_siginfo_fixup_common (native, inf, direction,
142 + return amd64_linux_siginfo_fixup_common (ptrace, inf, direction,
146 diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
147 index 72b3042..9f7df0c 100644
148 --- a/gdb/nat/amd64-linux-siginfo.c
149 +++ b/gdb/nat/amd64-linux-siginfo.c
151 #include "common-defs.h"
152 #include "amd64-linux-siginfo.h"
154 -/* The nat_* types below define the most complete kernel siginfo type
155 - known for the architecture, independent of the system/libc headers. */
156 +#define GDB_SI_SIZE 128
158 +/* The types below define the most complete kernel siginfo types known
159 + for the architecture, independent of the system/libc headers. They
160 + are named from a 64-bit kernel's perspective:
163 + |--------+----------------------|
164 + | 64-bit | nat_siginfo_t |
165 + | 32-bit | compat_siginfo_t |
166 + | x32 | compat_x32_siginfo_t |
171 typedef int nat_int_t;
172 -typedef void* nat_uptr_t;
173 +typedef unsigned long nat_uptr_t;
175 typedef int nat_time_t;
176 typedef int nat_timer_t;
178 -/* For native 64-bit, clock_t in _sigchld is 64bit aligned at 4 bytes. */
179 -typedef long __attribute__ ((__aligned__ (4))) nat_clock_t;
186 +/* For native 64-bit, clock_t in _sigchld is 64-bit. */
187 +typedef long nat_clock_t;
189 typedef union nat_sigval
191 @@ -106,11 +112,9 @@ typedef struct nat_siginfo
195 -} nat_siginfo_t __attribute__ ((__aligned__ (8)));
197 -/* Sanity check for the siginfo structure size. */
200 -gdb_static_assert (sizeof (nat_siginfo_t) == sizeof (siginfo_t));
201 +#endif /* __ILP32__ */
203 /* These types below (compat_*) define a siginfo type that is layout
204 compatible with the siginfo type exported by the 32-bit userspace
205 @@ -286,62 +290,71 @@ typedef struct compat_x32_siginfo
206 #define si_overrun si_timer2
209 +/* The type of the siginfo object the kernel returns in
210 + PTRACE_GETSIGINFO. If gdb is built as a x32 program, we get a x32
213 +typedef compat_x32_siginfo_t ptrace_siginfo_t;
215 +typedef nat_siginfo_t ptrace_siginfo_t;
218 /* Convert the system provided siginfo into compatible siginfo. */
221 -compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
222 +compat_siginfo_from_siginfo (compat_siginfo_t *to, const siginfo_t *from)
224 - nat_siginfo_t from_nat;
225 + ptrace_siginfo_t from_ptrace;
227 - memcpy (&from_nat, from, sizeof (from_nat));
228 + memcpy (&from_ptrace, from, sizeof (from_ptrace));
229 memset (to, 0, sizeof (*to));
231 - to->si_signo = from_nat.si_signo;
232 - to->si_errno = from_nat.si_errno;
233 - to->si_code = from_nat.si_code;
234 + to->si_signo = from_ptrace.si_signo;
235 + to->si_errno = from_ptrace.si_errno;
236 + to->si_code = from_ptrace.si_code;
238 if (to->si_code == SI_TIMER)
240 - to->cpt_si_timerid = from_nat.cpt_si_timerid;
241 - to->cpt_si_overrun = from_nat.cpt_si_overrun;
242 - to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
243 + to->cpt_si_timerid = from_ptrace.cpt_si_timerid;
244 + to->cpt_si_overrun = from_ptrace.cpt_si_overrun;
245 + to->cpt_si_ptr = from_ptrace.cpt_si_ptr;
247 else if (to->si_code == SI_USER)
249 - to->cpt_si_pid = from_nat.cpt_si_pid;
250 - to->cpt_si_uid = from_nat.cpt_si_uid;
251 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
252 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
254 else if (to->si_code < 0)
256 - to->cpt_si_pid = from_nat.cpt_si_pid;
257 - to->cpt_si_uid = from_nat.cpt_si_uid;
258 - to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
259 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
260 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
261 + to->cpt_si_ptr = from_ptrace.cpt_si_ptr;
265 switch (to->si_signo)
268 - to->cpt_si_pid = from_nat.cpt_si_pid;
269 - to->cpt_si_uid = from_nat.cpt_si_uid;
270 - to->cpt_si_status = from_nat.cpt_si_status;
271 - to->cpt_si_utime = from_nat.cpt_si_utime;
272 - to->cpt_si_stime = from_nat.cpt_si_stime;
273 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
274 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
275 + to->cpt_si_status = from_ptrace.cpt_si_status;
276 + to->cpt_si_utime = from_ptrace.cpt_si_utime;
277 + to->cpt_si_stime = from_ptrace.cpt_si_stime;
283 - to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
284 + to->cpt_si_addr = from_ptrace.cpt_si_addr;
287 - to->cpt_si_band = from_nat.cpt_si_band;
288 - to->cpt_si_fd = from_nat.cpt_si_fd;
289 + to->cpt_si_band = from_ptrace.cpt_si_band;
290 + to->cpt_si_fd = from_ptrace.cpt_si_fd;
293 - to->cpt_si_pid = from_nat.cpt_si_pid;
294 - to->cpt_si_uid = from_nat.cpt_si_uid;
295 - to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
296 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
297 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
298 + to->cpt_si_ptr = from_ptrace.cpt_si_ptr;
302 @@ -350,124 +363,124 @@ compat_siginfo_from_siginfo (compat_siginfo_t *to, siginfo_t *from)
303 /* Convert the compatible siginfo into system siginfo. */
306 -siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from)
307 +siginfo_from_compat_siginfo (siginfo_t *to, const compat_siginfo_t *from)
309 - nat_siginfo_t to_nat;
310 + ptrace_siginfo_t to_ptrace;
312 - memset (&to_nat, 0, sizeof (to_nat));
313 + memset (&to_ptrace, 0, sizeof (to_ptrace));
315 - to_nat.si_signo = from->si_signo;
316 - to_nat.si_errno = from->si_errno;
317 - to_nat.si_code = from->si_code;
318 + to_ptrace.si_signo = from->si_signo;
319 + to_ptrace.si_errno = from->si_errno;
320 + to_ptrace.si_code = from->si_code;
322 - if (to_nat.si_code == SI_TIMER)
323 + if (to_ptrace.si_code == SI_TIMER)
325 - to_nat.cpt_si_timerid = from->cpt_si_timerid;
326 - to_nat.cpt_si_overrun = from->cpt_si_overrun;
327 - to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
328 + to_ptrace.cpt_si_timerid = from->cpt_si_timerid;
329 + to_ptrace.cpt_si_overrun = from->cpt_si_overrun;
330 + to_ptrace.cpt_si_ptr = from->cpt_si_ptr;
332 - else if (to_nat.si_code == SI_USER)
333 + else if (to_ptrace.si_code == SI_USER)
335 - to_nat.cpt_si_pid = from->cpt_si_pid;
336 - to_nat.cpt_si_uid = from->cpt_si_uid;
337 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
338 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
340 - if (to_nat.si_code < 0)
341 + if (to_ptrace.si_code < 0)
343 - to_nat.cpt_si_pid = from->cpt_si_pid;
344 - to_nat.cpt_si_uid = from->cpt_si_uid;
345 - to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
346 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
347 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
348 + to_ptrace.cpt_si_ptr = from->cpt_si_ptr;
352 - switch (to_nat.si_signo)
353 + switch (to_ptrace.si_signo)
356 - to_nat.cpt_si_pid = from->cpt_si_pid;
357 - to_nat.cpt_si_uid = from->cpt_si_uid;
358 - to_nat.cpt_si_status = from->cpt_si_status;
359 - to_nat.cpt_si_utime = from->cpt_si_utime;
360 - to_nat.cpt_si_stime = from->cpt_si_stime;
361 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
362 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
363 + to_ptrace.cpt_si_status = from->cpt_si_status;
364 + to_ptrace.cpt_si_utime = from->cpt_si_utime;
365 + to_ptrace.cpt_si_stime = from->cpt_si_stime;
371 - to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
372 - to_nat.cpt_si_addr_lsb = (short) from->cpt_si_addr_lsb;
373 + to_ptrace.cpt_si_addr = from->cpt_si_addr;
374 + to_ptrace.cpt_si_addr_lsb = from->cpt_si_addr_lsb;
377 - to_nat.cpt_si_band = from->cpt_si_band;
378 - to_nat.cpt_si_fd = from->cpt_si_fd;
379 + to_ptrace.cpt_si_band = from->cpt_si_band;
380 + to_ptrace.cpt_si_fd = from->cpt_si_fd;
383 - to_nat.cpt_si_pid = from->cpt_si_pid;
384 - to_nat.cpt_si_uid = from->cpt_si_uid;
385 - to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
386 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
387 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
388 + to_ptrace.cpt_si_ptr = from->cpt_si_ptr;
392 - memcpy (to, &to_nat, sizeof (to_nat));
393 + memcpy (to, &to_ptrace, sizeof (to_ptrace));
396 /* Convert the system provided siginfo into compatible x32 siginfo. */
399 compat_x32_siginfo_from_siginfo (compat_x32_siginfo_t *to,
401 + const siginfo_t *from)
403 - nat_siginfo_t from_nat;
404 + ptrace_siginfo_t from_ptrace;
406 - memcpy (&from_nat, from, sizeof (from_nat));
407 + memcpy (&from_ptrace, from, sizeof (from_ptrace));
408 memset (to, 0, sizeof (*to));
410 - to->si_signo = from_nat.si_signo;
411 - to->si_errno = from_nat.si_errno;
412 - to->si_code = from_nat.si_code;
413 + to->si_signo = from_ptrace.si_signo;
414 + to->si_errno = from_ptrace.si_errno;
415 + to->si_code = from_ptrace.si_code;
417 if (to->si_code == SI_TIMER)
419 - to->cpt_si_timerid = from_nat.cpt_si_timerid;
420 - to->cpt_si_overrun = from_nat.cpt_si_overrun;
421 - to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
422 + to->cpt_si_timerid = from_ptrace.cpt_si_timerid;
423 + to->cpt_si_overrun = from_ptrace.cpt_si_overrun;
424 + to->cpt_si_ptr = from_ptrace.cpt_si_ptr;
426 else if (to->si_code == SI_USER)
428 - to->cpt_si_pid = from_nat.cpt_si_pid;
429 - to->cpt_si_uid = from_nat.cpt_si_uid;
430 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
431 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
433 else if (to->si_code < 0)
435 - to->cpt_si_pid = from_nat.cpt_si_pid;
436 - to->cpt_si_uid = from_nat.cpt_si_uid;
437 - to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
438 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
439 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
440 + to->cpt_si_ptr = from_ptrace.cpt_si_ptr;
444 switch (to->si_signo)
447 - to->cpt_si_pid = from_nat.cpt_si_pid;
448 - to->cpt_si_uid = from_nat.cpt_si_uid;
449 - to->cpt_si_status = from_nat.cpt_si_status;
450 - memcpy (&to->cpt_si_utime, &from_nat.cpt_si_utime,
451 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
452 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
453 + to->cpt_si_status = from_ptrace.cpt_si_status;
454 + memcpy (&to->cpt_si_utime, &from_ptrace.cpt_si_utime,
455 sizeof (to->cpt_si_utime));
456 - memcpy (&to->cpt_si_stime, &from_nat.cpt_si_stime,
457 + memcpy (&to->cpt_si_stime, &from_ptrace.cpt_si_stime,
458 sizeof (to->cpt_si_stime));
464 - to->cpt_si_addr = (intptr_t) from_nat.cpt_si_addr;
465 + to->cpt_si_addr = from_ptrace.cpt_si_addr;
468 - to->cpt_si_band = from_nat.cpt_si_band;
469 - to->cpt_si_fd = from_nat.cpt_si_fd;
470 + to->cpt_si_band = from_ptrace.cpt_si_band;
471 + to->cpt_si_fd = from_ptrace.cpt_si_fd;
474 - to->cpt_si_pid = from_nat.cpt_si_pid;
475 - to->cpt_si_uid = from_nat.cpt_si_uid;
476 - to->cpt_si_ptr = (intptr_t) from_nat.cpt_si_ptr;
477 + to->cpt_si_pid = from_ptrace.cpt_si_pid;
478 + to->cpt_si_uid = from_ptrace.cpt_si_uid;
479 + to->cpt_si_ptr = from_ptrace.cpt_si_ptr;
483 @@ -479,98 +492,105 @@ compat_x32_siginfo_from_siginfo (compat_x32_siginfo_t *to,
484 /* Convert the compatible x32 siginfo into system siginfo. */
486 siginfo_from_compat_x32_siginfo (siginfo_t *to,
487 - compat_x32_siginfo_t *from)
488 + const compat_x32_siginfo_t *from)
490 - nat_siginfo_t to_nat;
491 + ptrace_siginfo_t to_ptrace;
493 - memset (&to_nat, 0, sizeof (to_nat));
494 - to_nat.si_signo = from->si_signo;
495 - to_nat.si_errno = from->si_errno;
496 - to_nat.si_code = from->si_code;
497 + memset (&to_ptrace, 0, sizeof (to_ptrace));
498 + to_ptrace.si_signo = from->si_signo;
499 + to_ptrace.si_errno = from->si_errno;
500 + to_ptrace.si_code = from->si_code;
502 - if (to_nat.si_code == SI_TIMER)
503 + if (to_ptrace.si_code == SI_TIMER)
505 - to_nat.cpt_si_timerid = from->cpt_si_timerid;
506 - to_nat.cpt_si_overrun = from->cpt_si_overrun;
507 - to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
508 + to_ptrace.cpt_si_timerid = from->cpt_si_timerid;
509 + to_ptrace.cpt_si_overrun = from->cpt_si_overrun;
510 + to_ptrace.cpt_si_ptr = from->cpt_si_ptr;
512 - else if (to_nat.si_code == SI_USER)
513 + else if (to_ptrace.si_code == SI_USER)
515 - to_nat.cpt_si_pid = from->cpt_si_pid;
516 - to_nat.cpt_si_uid = from->cpt_si_uid;
517 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
518 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
520 - if (to_nat.si_code < 0)
521 + if (to_ptrace.si_code < 0)
523 - to_nat.cpt_si_pid = from->cpt_si_pid;
524 - to_nat.cpt_si_uid = from->cpt_si_uid;
525 - to_nat.cpt_si_ptr = (void *) (intptr_t) from->cpt_si_ptr;
526 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
527 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
528 + to_ptrace.cpt_si_ptr = from->cpt_si_ptr;
532 - switch (to_nat.si_signo)
533 + switch (to_ptrace.si_signo)
536 - to_nat.cpt_si_pid = from->cpt_si_pid;
537 - to_nat.cpt_si_uid = from->cpt_si_uid;
538 - to_nat.cpt_si_status = from->cpt_si_status;
539 - memcpy (&to_nat.cpt_si_utime, &from->cpt_si_utime,
540 - sizeof (to_nat.cpt_si_utime));
541 - memcpy (&to_nat.cpt_si_stime, &from->cpt_si_stime,
542 - sizeof (to_nat.cpt_si_stime));
543 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
544 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
545 + to_ptrace.cpt_si_status = from->cpt_si_status;
546 + memcpy (&to_ptrace.cpt_si_utime, &from->cpt_si_utime,
547 + sizeof (to_ptrace.cpt_si_utime));
548 + memcpy (&to_ptrace.cpt_si_stime, &from->cpt_si_stime,
549 + sizeof (to_ptrace.cpt_si_stime));
555 - to_nat.cpt_si_addr = (void *) (intptr_t) from->cpt_si_addr;
556 + to_ptrace.cpt_si_addr = from->cpt_si_addr;
559 - to_nat.cpt_si_band = from->cpt_si_band;
560 - to_nat.cpt_si_fd = from->cpt_si_fd;
561 + to_ptrace.cpt_si_band = from->cpt_si_band;
562 + to_ptrace.cpt_si_fd = from->cpt_si_fd;
565 - to_nat.cpt_si_pid = from->cpt_si_pid;
566 - to_nat.cpt_si_uid = from->cpt_si_uid;
567 - to_nat.cpt_si_ptr = (void* ) (intptr_t) from->cpt_si_ptr;
568 + to_ptrace.cpt_si_pid = from->cpt_si_pid;
569 + to_ptrace.cpt_si_uid = from->cpt_si_uid;
570 + to_ptrace.cpt_si_ptr = from->cpt_si_ptr;
574 - memcpy (to, &to_nat, sizeof (to_nat));
575 + memcpy (to, &to_ptrace, sizeof (to_ptrace));
578 -/* Convert a native/host siginfo object, into/from the siginfo in the
579 +/* Convert a ptrace siginfo object, into/from the siginfo in the
580 layout of the inferiors' architecture. Returns true if any
581 conversion was done; false otherwise. If DIRECTION is 1, then copy
582 - from INF to NATIVE. If DIRECTION is 0, then copy from NATIVE to INF. */
583 + from INF to PTRACE. If DIRECTION is 0, then copy from NATIVE to
587 -amd64_linux_siginfo_fixup_common (siginfo_t *native, gdb_byte *inf,
588 +amd64_linux_siginfo_fixup_common (siginfo_t *ptrace, gdb_byte *inf,
590 enum amd64_siginfo_fixup_mode mode)
592 if (mode == FIXUP_32)
594 - gdb_assert (sizeof (siginfo_t) == sizeof (compat_siginfo_t));
597 - compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native);
598 + compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, ptrace);
600 - siginfo_from_compat_siginfo (native, (struct compat_siginfo *) inf);
601 + siginfo_from_compat_siginfo (ptrace, (struct compat_siginfo *) inf);
605 else if (mode == FIXUP_X32)
607 - gdb_assert (sizeof (siginfo_t) == sizeof (compat_x32_siginfo_t));
610 compat_x32_siginfo_from_siginfo ((struct compat_x32_siginfo *) inf,
614 - siginfo_from_compat_x32_siginfo (native,
615 + siginfo_from_compat_x32_siginfo (ptrace,
616 (struct compat_x32_siginfo *) inf);
623 +/* Sanity check for the siginfo structure sizes. */
625 +gdb_static_assert (sizeof (siginfo_t) == GDB_SI_SIZE);
627 +gdb_static_assert (sizeof (nat_siginfo_t) == GDB_SI_SIZE);
629 +gdb_static_assert (sizeof (compat_x32_siginfo_t) == GDB_SI_SIZE);
630 +gdb_static_assert (sizeof (compat_siginfo_t) == GDB_SI_SIZE);
631 +gdb_static_assert (sizeof (ptrace_siginfo_t) == GDB_SI_SIZE);