This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [3/7] infrun cleanup: ecs->random_signal
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 7 Dec 2008 01:18:16 +0100 (CET)
- Subject: [rfc] [3/7] infrun cleanup: ecs->random_signal
Hello,
this removes the ecs->random_signal member, together with the nowhere-used
init_execution_control_state routine that resets it.
Except for this rotuine, ecs->random_signal is only used in
handle_inferior_event, to make local decisions and to set the global
stopped_by_random_signal variable in the end. Some assignments to
ecs->random_signal are actually dead, as they are always overwritten
later on. Likewise the related assignment to sw_single_step_trap_p
is dead; that variable is never used.
By removing the dead assignments, it is easy to simply set the
global stopped_by_random_signal directly as appropriate; no further
"random_signal" variable is actually required.
Bye,
Ulrich
ChangeLog:
* infrun.c (struct execution_control_state): Remove random_signal.
(init_execution_control_state): Remove function.
(handle_inferior_event): Remove dead variable sw_single_step_trap_p.
Remove some dead assignments to ecs->random_signal. Simplify
setting stopped_by_random_signal global variable.
Index: gdb-head/gdb/infrun.c
===================================================================
--- gdb-head.orig/gdb/infrun.c
+++ gdb-head/gdb/infrun.c
@@ -1571,7 +1571,6 @@ struct execution_control_state
struct thread_info *event_thread;
struct target_waitstatus ws;
- int random_signal;
CORE_ADDR stop_func_start;
CORE_ADDR stop_func_end;
char *stop_func_name;
@@ -1579,8 +1578,6 @@ struct execution_control_state
int wait_some_more;
};
-void init_execution_control_state (struct execution_control_state *ecs);
-
static void handle_inferior_event (struct execution_control_state *ecs);
static void handle_step_into_function (struct execution_control_state *ecs);
@@ -1874,15 +1871,6 @@ fetch_inferior_event (void *client_data)
display_gdb_prompt (0);
}
-/* Prepare an execution control state for looping through a
- wait_for_inferior-type loop. */
-
-void
-init_execution_control_state (struct execution_control_state *ecs)
-{
- ecs->random_signal = 0;
-}
-
/* Clear context switchable stepping state. */
void
@@ -2074,7 +2062,6 @@ ensure_not_running (void)
static void
handle_inferior_event (struct execution_control_state *ecs)
{
- int sw_single_step_trap_p = 0;
int stopped_by_watchpoint;
int stepped_after_stopped_by_watchpoint = 0;
struct symtab_and_line stop_pc_sal;
@@ -2097,6 +2084,7 @@ handle_inferior_event (struct execution_
/* Always clear state belonging to the previous time we stopped. */
stop_stack_dummy = 0;
+ stopped_by_random_signal = 0;
/* If it's a new process, add it to the thread database */
@@ -2304,10 +2292,8 @@ handle_inferior_event (struct execution_
ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
- ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
-
/* If no catchpoint triggered for this, then keep going. */
- if (ecs->random_signal)
+ if (!bpstat_explains_signal (ecs->event_thread->stop_bpstat))
{
ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
keep_going (ecs);
@@ -2338,10 +2324,9 @@ handle_inferior_event (struct execution_
xfree (pending_follow.execd_pathname);
ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
- ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
/* If no catchpoint triggered for this, then keep going. */
- if (ecs->random_signal)
+ if (!bpstat_explains_signal (ecs->event_thread->stop_bpstat))
{
ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
keep_going (ecs);
@@ -2477,8 +2462,6 @@ targets should add new threads to the th
remove_single_step_breakpoints ();
singlestep_breakpoints_inserted_p = 0;
- ecs->random_signal = 0;
-
context_switch (saved_singlestep_ptid);
if (deprecated_context_hook)
deprecated_context_hook (pid_to_thread_id (ecs->ptid));
@@ -2537,7 +2520,6 @@ targets should add new threads to the th
not see this breakpoint hit when stepping onto breakpoints. */
if (regular_breakpoint_inserted_here_p (stop_pc))
{
- ecs->random_signal = 0;
if (!breakpoint_thread_match (stop_pc, ecs->ptid))
thread_hop_needed = 1;
}
@@ -2551,7 +2533,6 @@ targets should add new threads to the th
"trap for %s\n",
target_pid_to_str (ecs->ptid));
- ecs->random_signal = 0;
/* The call to in_thread_list is necessary because PTIDs sometimes
change when we go from single-threaded to multi-threaded. If
the singlestep_ptid is still in the list, assume that it is
@@ -2661,14 +2642,7 @@ targets should add new threads to the th
return;
}
}
- else if (singlestep_breakpoints_inserted_p)
- {
- sw_single_step_trap_p = 1;
- ecs->random_signal = 0;
- }
}
- else
- ecs->random_signal = 1;
/* See if something interesting happened to the non-current thread. If
so, then switch to that thread. */
@@ -2747,8 +2721,6 @@ targets should add new threads to the th
bpstat_clear (&ecs->event_thread->stop_bpstat);
ecs->event_thread->stop_step = 0;
stop_print_frame = 1;
- ecs->random_signal = 0;
- stopped_by_random_signal = 0;
if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP
&& ecs->event_thread->trap_expected
@@ -2790,7 +2762,7 @@ targets should add new threads to the th
1) stop_stepping and return; to really stop and return to the debugger,
2) keep_going and return to start up again
(set ecs->event_thread->stepping_over_breakpoint to 1 to single step once)
- 3) set ecs->random_signal to 1, and the decision between 1 and 2
+ 3) set stopped_by_random_signal to 1, and the decision between 1 and 2
will be made according to the signal handling tables. */
/* First, distinguish signals caused by the debugger from signals
@@ -2893,15 +2865,17 @@ targets should add new threads to the th
SPARC. */
if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP)
- ecs->random_signal
+ stopped_by_random_signal
= !(bpstat_explains_signal (ecs->event_thread->stop_bpstat)
|| ecs->event_thread->trap_expected
|| (ecs->event_thread->step_range_end
&& ecs->event_thread->step_resume_breakpoint == NULL));
else
{
- ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
- if (!ecs->random_signal)
+ stopped_by_random_signal
+ = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
+
+ if (!stopped_by_random_signal)
ecs->event_thread->stop_signal = TARGET_SIGNAL_TRAP;
}
}
@@ -2911,13 +2885,13 @@ targets should add new threads to the th
(unexpected) signal. */
else
- ecs->random_signal = 1;
+ stopped_by_random_signal = 1;
process_event_stop_test:
/* For the program's own signals, act according to
the signal handling tables. */
- if (ecs->random_signal)
+ if (stopped_by_random_signal)
{
/* Signal not for debugging purposes. */
int printed = 0;
@@ -2926,8 +2900,6 @@ process_event_stop_test:
fprintf_unfiltered (gdb_stdlog, "infrun: random signal %d\n",
ecs->event_thread->stop_signal);
- stopped_by_random_signal = 1;
-
if (signal_print[ecs->event_thread->stop_signal])
{
printed = 1;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com