X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Finflow.c;h=6d645d291a7ef056966b324c5b011a9de29c1cc4;hb=e3ec872f8012377e50f0c9c888d2bc3163a356b2;hp=b71511308b3930ed1b89973c91897872c551096e;hpb=0747795c085d3b2a35da6bb474f32c58ce1b70c8;p=external%2Fbinutils.git diff --git a/gdb/inflow.c b/gdb/inflow.c index b715113..6d645d2 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -34,7 +34,7 @@ #ifdef HAVE_TERMIOS_H #include #endif -#include "common/job-control.h" +#include "gdbsupport/job-control.h" #ifdef HAVE_SYS_IOCTL_H #include @@ -58,13 +58,18 @@ static struct serial *stdin_serial; the inferior is resumed in the foreground. */ struct terminal_info { + terminal_info () = default; + ~terminal_info (); + + terminal_info &operator= (const terminal_info &) = default; + /* The name of the tty (from the `tty' command) that we gave to the inferior when it was started. */ - char *run_terminal; + char *run_terminal = nullptr; /* TTY state. We save it whenever the inferior stops, and restore it when it resumes in the foreground. */ - serial_ttystate ttystate; + serial_ttystate ttystate {}; #ifdef HAVE_TERMIOS_H /* The terminal's foreground process group. Saved whenever the @@ -80,11 +85,11 @@ struct terminal_info inf2's pgrp in the foreground instead of inf1's (which would be problematic since it would be left stopped: Ctrl-C wouldn't work, for example). */ - pid_t process_group; + pid_t process_group = 0; #endif /* fcntl flags. Saved and restored just like ttystate. */ - int tflags; + int tflags = 0; }; /* Our own tty state, which we restore every time we need to deal with @@ -103,35 +108,6 @@ static serial_ttystate initial_gdb_ttystate; static struct terminal_info *get_inflow_inferior_data (struct inferior *); -/* RAII class used to ignore SIGTTOU in a scope. */ - -class scoped_ignore_sigttou -{ -public: - scoped_ignore_sigttou () - { -#ifdef SIGTTOU - if (job_control) - m_osigttou = signal (SIGTTOU, SIG_IGN); -#endif - } - - ~scoped_ignore_sigttou () - { -#ifdef SIGTTOU - if (job_control) - signal (SIGTTOU, m_osigttou); -#endif - } - - DISABLE_COPY_AND_ASSIGN (scoped_ignore_sigttou); - -private: -#ifdef SIGTTOU - sighandler_t m_osigttou = NULL; -#endif -}; - /* While the inferior is running, we want SIGINT and SIGQUIT to go to the inferior only. If we have job control, that takes care of it. If not, we save our handlers in these two variables and set SIGINT and SIGQUIT @@ -623,16 +599,12 @@ child_pass_ctrlc (struct target_ops *self) } /* Per-inferior data key. */ -static const struct inferior_data *inflow_inferior_data; +static const struct inferior_key inflow_inferior_data; -static void -inflow_inferior_data_cleanup (struct inferior *inf, void *arg) +terminal_info::~terminal_info () { - struct terminal_info *info = (struct terminal_info *) arg; - - xfree (info->run_terminal); - xfree (info->ttystate); - xfree (info); + xfree (run_terminal); + xfree (ttystate); } /* Get the current svr4 data. If none is found yet, add it now. This @@ -643,12 +615,9 @@ get_inflow_inferior_data (struct inferior *inf) { struct terminal_info *info; - info = (struct terminal_info *) inferior_data (inf, inflow_inferior_data); + info = inflow_inferior_data.get (inf); if (info == NULL) - { - info = XCNEW (struct terminal_info); - set_inferior_data (inf, inflow_inferior_data, info); - } + info = inflow_inferior_data.emplace (inf); return info; } @@ -662,18 +631,8 @@ get_inflow_inferior_data (struct inferior *inf) static void inflow_inferior_exit (struct inferior *inf) { - struct terminal_info *info; - inf->terminal_state = target_terminal_state::is_ours; - - info = (struct terminal_info *) inferior_data (inf, inflow_inferior_data); - if (info != NULL) - { - xfree (info->run_terminal); - xfree (info->ttystate); - xfree (info); - set_inferior_data (inf, inflow_inferior_data, NULL); - } + inflow_inferior_data.clear (inf); } void @@ -705,13 +664,11 @@ copy_terminal_info (struct inferior *to, struct inferior *from) void swap_terminal_info (inferior *a, inferior *b) { - terminal_info *info_a - = (terminal_info *) inferior_data (a, inflow_inferior_data); - terminal_info *info_b - = (terminal_info *) inferior_data (a, inflow_inferior_data); + terminal_info *info_a = inflow_inferior_data.get (a); + terminal_info *info_b = inflow_inferior_data.get (b); - set_inferior_data (a, inflow_inferior_data, info_b); - set_inferior_data (b, inflow_inferior_data, info_a); + inflow_inferior_data.set (a, info_b); + inflow_inferior_data.set (b, info_a); std::swap (a->terminal_state, b->terminal_state); } @@ -1006,7 +963,4 @@ _initialize_inflow (void) have_job_control (); gdb::observers::inferior_exit.attach (inflow_inferior_exit); - - inflow_inferior_data - = register_inferior_data_with_cleanup (NULL, inflow_inferior_data_cleanup); }