1 http://sourceware.org/ml/gdb-patches/2010-09/msg00438.html
2 http://sourceware.org/ml/gdb-cvs/2010-09/msg00156.html
4 ### src/gdb/ChangeLog 2010/09/24 16:11:44 1.12203
5 ### src/gdb/ChangeLog 2010/09/24 18:35:20 1.12204
7 +2010-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
9 + Fix lost siginfo_t for inferior calls.
11 + (struct inferior_thread_state) <siginfo_gdbarch, siginfo_data>: New.
12 + (save_inferior_thread_state): New variables regcache, gdbarch and
13 + siginfo_data. Initialize SIGINFO_DATA if gdbarch_get_siginfo_type_p.
14 + Move INF_STATE allocation later, pre-clear it. Initialize REGISTERS
16 + (restore_inferior_thread_state): New variables regcache and gdbarch.
17 + Restore SIGINFO_DATA for matching GDBARCH. Restore REGISTERS using
18 + REGCACHE. Free also SIGINFO_DATA.
20 2010-09-24 Tom Tromey <tromey@redhat.com>
22 * dwarf2read.c (dw2_expand_symtabs_matching): Add missing
23 --- src/gdb/infrun.c 2010/09/06 14:22:07 1.450
24 +++ src/gdb/infrun.c 2010/09/24 18:35:27 1.451
25 @@ -6037,18 +6037,57 @@
26 enum target_signal stop_signal;
28 struct regcache *registers;
30 + /* Format of SIGINFO or NULL if it is not present. */
31 + struct gdbarch *siginfo_gdbarch;
33 + /* The inferior format depends on SIGINFO_GDBARCH and it has a length of
34 + TYPE_LENGTH (gdbarch_get_siginfo_type ()). For different gdbarch the
35 + content would be invalid. */
36 + gdb_byte *siginfo_data;
39 struct inferior_thread_state *
40 save_inferior_thread_state (void)
42 - struct inferior_thread_state *inf_state = XMALLOC (struct inferior_thread_state);
43 + struct inferior_thread_state *inf_state;
44 struct thread_info *tp = inferior_thread ();
45 + struct regcache *regcache = get_current_regcache ();
46 + struct gdbarch *gdbarch = get_regcache_arch (regcache);
47 + gdb_byte *siginfo_data = NULL;
49 + if (gdbarch_get_siginfo_type_p (gdbarch))
51 + struct type *type = gdbarch_get_siginfo_type (gdbarch);
52 + size_t len = TYPE_LENGTH (type);
53 + struct cleanup *back_to;
55 + siginfo_data = xmalloc (len);
56 + back_to = make_cleanup (xfree, siginfo_data);
58 + if (target_read (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL,
59 + siginfo_data, 0, len) == len)
60 + discard_cleanups (back_to);
63 + /* Errors ignored. */
64 + do_cleanups (back_to);
65 + siginfo_data = NULL;
69 + inf_state = XZALLOC (struct inferior_thread_state);
73 + inf_state->siginfo_gdbarch = gdbarch;
74 + inf_state->siginfo_data = siginfo_data;
77 inf_state->stop_signal = tp->stop_signal;
78 inf_state->stop_pc = stop_pc;
80 - inf_state->registers = regcache_dup (get_current_regcache ());
81 + inf_state->registers = regcache_dup (regcache);
85 @@ -6059,16 +6098,29 @@
86 restore_inferior_thread_state (struct inferior_thread_state *inf_state)
88 struct thread_info *tp = inferior_thread ();
89 + struct regcache *regcache = get_current_regcache ();
90 + struct gdbarch *gdbarch = get_regcache_arch (regcache);
92 tp->stop_signal = inf_state->stop_signal;
93 stop_pc = inf_state->stop_pc;
95 + if (inf_state->siginfo_gdbarch == gdbarch)
97 + struct type *type = gdbarch_get_siginfo_type (gdbarch);
98 + size_t len = TYPE_LENGTH (type);
100 + /* Errors ignored. */
101 + target_write (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL,
102 + inf_state->siginfo_data, 0, len);
105 /* The inferior can be gone if the user types "print exit(0)"
106 (and perhaps other times). */
107 if (target_has_execution)
108 /* NB: The register write goes through to the target. */
109 - regcache_cpy (get_current_regcache (), inf_state->registers);
110 + regcache_cpy (regcache, inf_state->registers);
111 regcache_xfree (inf_state->registers);
112 + xfree (inf_state->siginfo_data);
116 ### src/gdb/testsuite/ChangeLog 2010/09/22 20:08:04 1.2456
117 ### src/gdb/testsuite/ChangeLog 2010/09/24 18:35:28 1.2457
119 +2010-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
121 + Fix lost siginfo_t for inferior calls.
122 + * gdb.base/siginfo-infcall.exp: New file.
123 + * gdb.base/siginfo-infcall.c: New file.
125 2010-09-22 Joel Brobecker <brobecker@adacore.com>
127 * gdb.dwarf2/dw2-const.S: Minor (space) reformatting.
128 --- src/gdb/testsuite/gdb.base/siginfo-infcall.c
129 +++ src/gdb/testsuite/gdb.base/siginfo-infcall.c 2010-09-25 13:25:25.007169000 +0000
131 +/* This testcase is part of GDB, the GNU debugger.
133 + Copyright 2010 Free Software Foundation, Inc.
135 + This program is free software; you can redistribute it and/or modify
136 + it under the terms of the GNU General Public License as published by
137 + the Free Software Foundation; either version 3 of the License, or
138 + (at your option) any later version.
140 + This program is distributed in the hope that it will be useful,
141 + but WITHOUT ANY WARRANTY; without even the implied warranty of
142 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
143 + GNU General Public License for more details.
145 + You should have received a copy of the GNU General Public License
146 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
154 +# error "SA_SIGINFO is required for this test"
176 +handler (int sig, siginfo_t *siginfo, void *context)
178 + assert (sig == SIGUSR1);
179 + assert (siginfo->si_signo == SIGUSR1);
180 + if (siginfo->si_pid == getpid ())
189 + struct sigaction sa;
194 + memset (&sa, 0, sizeof (sa));
195 + sa.sa_sigaction = handler;
196 + sa.sa_flags = SA_SIGINFO;
198 + i = sigemptyset (&sa.sa_mask);
201 + i = sigaction (SIGUSR1, &sa, NULL);
204 + i = raise (SIGUSR1);
210 --- src/gdb/testsuite/gdb.base/siginfo-infcall.exp
211 +++ src/gdb/testsuite/gdb.base/siginfo-infcall.exp 2010-09-25 13:25:25.357724000 +0000
213 +# Copyright 2010 Free Software Foundation, Inc.
215 +# This program is free software; you can redistribute it and/or modify
216 +# it under the terms of the GNU General Public License as published by
217 +# the Free Software Foundation; either version 3 of the License, or
218 +# (at your option) any later version.
220 +# This program is distributed in the hope that it will be useful,
221 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
222 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223 +# GNU General Public License for more details.
225 +# You should have received a copy of the GNU General Public License
226 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
228 +if [target_info exists gdb,nosignals] {
229 + verbose "Skipping siginfo-infcall.exp because of nosignals."
233 +set testfile siginfo-infcall
234 +set srcfile ${testfile}.c
235 +set executable ${testfile}
236 +if { [prepare_for_testing ${testfile}.exp $executable] } {
244 +gdb_breakpoint "pass"
245 +gdb_breakpoint "fail"
247 +gdb_test "continue" "Program received signal SIGUSR1, .*" "continue to SIGUSR1"
249 +gdb_test "p callme ()" " = 42"
251 +set test "continue to the handler"
252 +gdb_test_multiple "continue" $test {
253 + -re "Breakpoint \[0-9\]+,\[^\r\n\]* pass .*\r\n$gdb_prompt $" {
256 + -re "Breakpoint \[0-9\]+,\[^\r\n\]* fail .*\r\n$gdb_prompt $" {