@@ -852,15 +852,9 @@ inf_validate_task_sc (struct inf *inf)
if (inf->task->cur_sc < suspend_count)
{
- int abort;
-
- target_terminal_ours (); /* Allow I/O. */
- abort = !query (_("Pid %d has an additional task suspend count of %d;"
- " clear it? "), inf->pid,
- suspend_count - inf->task->cur_sc);
- target_terminal_inferior (); /* Give it back to the child. */
-
- if (abort)
+ if (!query (_("Pid %d has an additional task suspend count of %d;"
+ " clear it? "), inf->pid,
+ suspend_count - inf->task->cur_sc))
error (_("Additional task suspend count left untouched."));
inf->task->cur_sc = suspend_count;
@@ -4914,17 +4914,12 @@ i386_record_lea_modrm (struct i386_record_s *irp)
{
if (record_full_memory_query)
{
- int q;
-
- target_terminal_ours ();
- q = yquery (_("\
+ if (yquery (_("\
Process record ignores the memory change of instruction at address %s\n\
because it can't get the value of the segment register.\n\
Do you want to stop the program?"),
- paddress (gdbarch, irp->orig_addr));
- target_terminal_inferior ();
- if (q)
- return -1;
+ paddress (gdbarch, irp->orig_addr)))
+ return -1;
}
return 0;
@@ -5805,16 +5800,11 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
{
if (record_full_memory_query)
{
- int q;
-
- target_terminal_ours ();
- q = yquery (_("\
+ if (yquery (_("\
Process record ignores the memory change of instruction at address %s\n\
because it can't get the value of the segment register.\n\
Do you want to stop the program?"),
- paddress (gdbarch, ir.orig_addr));
- target_terminal_inferior ();
- if (q)
+ paddress (gdbarch, ir.orig_addr)))
return -1;
}
}
@@ -6479,16 +6469,11 @@ Do you want to stop the program?"),
/* addr += ((uint32_t) read_register (I386_ES_REGNUM)) << 4; */
if (record_full_memory_query)
{
- int q;
-
- target_terminal_ours ();
- q = yquery (_("\
+ if (yquery (_("\
Process record ignores the memory change of instruction at address %s\n\
because it can't get the value of the segment register.\n\
Do you want to stop the program?"),
- paddress (gdbarch, ir.orig_addr));
- target_terminal_inferior ();
- if (q)
+ paddress (gdbarch, ir.orig_addr)))
return -1;
}
}
@@ -7034,17 +7019,12 @@ Do you want to stop the program?"),
{
if (record_full_memory_query)
{
- int q;
-
- target_terminal_ours ();
- q = yquery (_("\
+ if (yquery (_("\
Process record ignores the memory change of instruction at address %s\n\
because it can't get the value of the segment register.\n\
Do you want to stop the program?"),
- paddress (gdbarch, ir.orig_addr));
- target_terminal_inferior ();
- if (q)
- return -1;
+ paddress (gdbarch, ir.orig_addr)))
+ return -1;
}
}
else
@@ -7091,16 +7071,11 @@ Do you want to stop the program?"),
{
if (record_full_memory_query)
{
- int q;
-
- target_terminal_ours ();
- q = yquery (_("\
+ if (yquery (_("\
Process record ignores the memory change of instruction at address %s\n\
because it can't get the value of the segment register.\n\
Do you want to stop the program?"),
- paddress (gdbarch, ir.orig_addr));
- target_terminal_inferior ();
- if (q)
+ paddress (gdbarch, ir.orig_addr)))
return -1;
}
}
@@ -254,17 +254,10 @@ record_linux_system_call (enum gdb_syscall syscall,
break;
case gdb_sys_exit:
- {
- int q;
-
- target_terminal_ours ();
- q = yquery (_("The next instruction is syscall exit. "
- "It will make the program exit. "
- "Do you want to stop the program?"));
- target_terminal_inferior ();
- if (q)
- return 1;
- }
+ if (yquery (_("The next instruction is syscall exit. "
+ "It will make the program exit. "
+ "Do you want to stop the program?")))
+ return 1;
break;
case gdb_sys_fork:
@@ -663,17 +656,10 @@ record_linux_system_call (enum gdb_syscall syscall,
break;
case gdb_sys_reboot:
- {
- int q;
-
- target_terminal_ours ();
- q = yquery (_("The next instruction is syscall reboot. "
- "It will restart the computer. "
- "Do you want to stop the program?"));
- target_terminal_inferior ();
- if (q)
- return 1;
- }
+ if (yquery (_("The next instruction is syscall reboot. "
+ "It will restart the computer. "
+ "Do you want to stop the program?")))
+ return 1;
break;
case gdb_old_readdir:
@@ -693,17 +679,12 @@ record_linux_system_call (enum gdb_syscall syscall,
regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
if (record_full_memory_query)
{
- int q;
-
- target_terminal_ours ();
- q = yquery (_("\
+ if (yquery (_("\
The next instruction is syscall munmap.\n\
It will free the memory addr = 0x%s len = %u.\n\
It will make record target cannot record some memory change.\n\
Do you want to stop the program?"),
- OUTPUT_REG (tmpulongest, tdep->arg1), (int) len);
- target_terminal_inferior ();
- if (q)
+ OUTPUT_REG (tmpulongest, tdep->arg1), (int) len))
return 1;
}
}
@@ -1764,17 +1745,10 @@ Do you want to stop the program?"),
break;
case gdb_sys_exit_group:
- {
- int q;
-
- target_terminal_ours ();
- q = yquery (_("The next instruction is syscall exit_group. "
- "It will make the program exit. "
- "Do you want to stop the program?"));
- target_terminal_inferior ();
- if (q)
- return 1;
- }
+ if (yquery (_("The next instruction is syscall exit_group. "
+ "It will make the program exit. "
+ "Do you want to stop the program?")))
+ return 1;
break;
case gdb_sys_lookup_dcookie:
@@ -723,16 +723,12 @@ do_attach (ptid_t ptid)
static void
interrupt_query (void)
{
- target_terminal_ours ();
-
if (query (_("Interrupted while waiting for the program.\n\
Give up (and stop debugging it)? ")))
{
target_mourn_inferior ();
quit ();
}
-
- target_terminal_inferior ();
}
/* The user typed ^C twice. */
@@ -535,26 +535,18 @@ record_full_arch_list_add_end (void)
}
static void
-record_full_check_insn_num (int set_terminal)
+record_full_check_insn_num (void)
{
if (record_full_insn_num == record_full_insn_max_num)
{
/* Ask user what to do. */
if (record_full_stop_at_limit)
{
- int q;
-
- if (set_terminal)
- target_terminal_ours ();
- q = yquery (_("Do you want to auto delete previous execution "
+ if (!yquery (_("Do you want to auto delete previous execution "
"log entries when record/replay buffer becomes "
- "full (record full stop-at-limit)?"));
- if (set_terminal)
- target_terminal_inferior ();
- if (q)
- record_full_stop_at_limit = 0;
- else
+ "full (record full stop-at-limit)?")))
error (_("Process record: stopped by user."));
+ record_full_stop_at_limit = 0;
}
}
}
@@ -583,7 +575,7 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal)
record_full_arch_list_tail = NULL;
/* Check record_full_insn_num. */
- record_full_check_insn_num (1);
+ record_full_check_insn_num ();
/* If gdb sends a signal value to target_resume,
save it in the 'end' field of the previous instruction.
@@ -1420,7 +1412,7 @@ static void
record_full_registers_change (struct regcache *regcache, int regnum)
{
/* Check record_full_insn_num. */
- record_full_check_insn_num (0);
+ record_full_check_insn_num ();
record_full_arch_list_head = NULL;
record_full_arch_list_tail = NULL;
@@ -1546,7 +1538,7 @@ record_full_xfer_partial (struct target_ops *ops, enum target_object object,
}
/* Check record_full_insn_num */
- record_full_check_insn_num (0);
+ record_full_check_insn_num ();
/* Record registers change to list as an instruction. */
record_full_arch_list_head = NULL;
@@ -5900,10 +5900,6 @@ static void
interrupt_query (void)
{
struct remote_state *rs = get_remote_state ();
- struct cleanup *old_chain;
-
- old_chain = make_cleanup_restore_target_terminal ();
- target_terminal_ours ();
if (rs->waiting_for_stop_reply && rs->ctrlc_pending_p)
{
@@ -5920,8 +5916,6 @@ interrupt_query (void)
"Give up waiting? ")))
quit ();
}
-
- do_cleanups (old_chain);
}
/* Enable/disable target terminal ownership. Most targets can use
@@ -1245,12 +1245,15 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
if (!confirm || server_command)
return def_value;
+ old_chain = make_cleanup_restore_target_terminal ();
+
/* If input isn't coming from the user directly, just say what
question we're asking, and then answer the default automatically. This
way, important error messages don't get lost when talking to GDB
over a pipe. */
if (! input_from_terminal_p ())
{
+ target_terminal_ours_for_output ();
wrap_here ("");
vfprintf_filtered (gdb_stdout, ctlstr, args);
@@ -1259,15 +1262,18 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
y_string, n_string, def_answer);
gdb_flush (gdb_stdout);
+ do_cleanups (old_chain);
return def_value;
}
if (deprecated_query_hook)
{
- return deprecated_query_hook (ctlstr, args);
- }
+ int res;
- old_chain = make_cleanup (null_cleanup, NULL);
+ res = deprecated_query_hook (ctlstr, args);
+ do_cleanups (old_chain);
+ return res;
+ }
/* Format the question outside of the loop, to avoid reusing args. */
question = xstrvprintf (ctlstr, args);
@@ -1281,6 +1287,9 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
/* Used for calculating time spend waiting for user. */
gettimeofday (&prompt_started, NULL);
+ /* We'll need to handle input. */
+ target_terminal_ours ();
+
while (1)
{
char *response, answer;
@@ -1852,6 +1861,7 @@ prompt_for_continue (void)
reinitialize_more_filter ();
/* We'll need to handle input. */
+ make_cleanup_restore_target_terminal ();
target_terminal_ours ();
/* Call gdb_readline_wrapper, not readline, in order to keep an