This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/ob] Fix longjmp clober in sim-resume.c
- From: Andrew Cagney <ac131313 at ges dot redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 15 Jul 2002 12:12:52 -0400
- Subject: [patch/ob] Fix longjmp clober in sim-resume.c
Just FYI,
This fixes a potential (-Werror) long jump clober problem in sim-resume.
committed as ob,
Andrew
2002-07-15 Andrew Cagney <ac131313@redhat.com>
* sim-resume.c (sim_resume): Add local variable sig_to_deliver to
avoid possible longjmp problems with automatic variable siggnal.
Index: sim-resume.c
===================================================================
RCS file: /cvs/src/src/sim/common/sim-resume.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 sim-resume.c
--- sim-resume.c 12 Jul 1999 11:14:09 -0000 1.1.1.2
+++ sim-resume.c 15 Jul 2002 16:02:11 -0000
@@ -65,24 +65,29 @@
int last_cpu_nr = sim_engine_last_cpu_nr (sd);
int next_cpu_nr = sim_engine_next_cpu_nr (sd);
int nr_cpus = sim_engine_nr_cpus (sd);
+ int sig_to_deliver;
sim_events_preprocess (sd, last_cpu_nr >= nr_cpus, next_cpu_nr >= nr_cpus);
if (next_cpu_nr >= nr_cpus)
next_cpu_nr = 0;
- /* Only deliver the siggnal ]sic] the first time through - don't
- re-deliver any siggnal during a restart. */
- if (jmpval == sim_engine_restart_jmpval)
- siggnal = 0;
+ /* Only deliver the SIGGNAL [sic] the first time through - don't
+ re-deliver any SIGGNAL during a restart. NOTE: A new local
+ variable is used to avoid problems with the automatic
+ variable ``siggnal'' being trashed by a long jump. */
+ if (jmpval == sim_engine_start_jmpval)
+ sig_to_deliver = siggnal;
+ else
+ sig_to_deliver = 0;
#ifdef SIM_CPU_EXCEPTION_RESUME
{
sim_cpu* cpu = STATE_CPU (sd, next_cpu_nr);
- SIM_CPU_EXCEPTION_RESUME(sd, cpu, siggnal);
+ SIM_CPU_EXCEPTION_RESUME(sd, cpu, sig_to_deliver);
}
#endif
- sim_engine_run (sd, next_cpu_nr, nr_cpus, siggnal);
+ sim_engine_run (sd, next_cpu_nr, nr_cpus, sig_to_deliver);
}
engine->jmpbuf = NULL;