diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-03-23 09:50:35 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-03-23 09:50:35 -0400 |
commit | 02980c5645e355833b989e9551befddd54e75640 (patch) | |
tree | 9cdcf5e5ceb0fece771f1cc5084dc7343556e9fc /gdb | |
parent | fadf6add3028d477457c809f60f07643964d7fd2 (diff) | |
download | binutils-02980c5645e355833b989e9551befddd54e75640.zip binutils-02980c5645e355833b989e9551befddd54e75640.tar.gz binutils-02980c5645e355833b989e9551befddd54e75640.tar.bz2 |
gdb: remove push_target free functions
Same as the previous patch, but for the push_target functions.
The implementation of the move variant is moved to a new overload of
inferior::push_target.
gdb/ChangeLog:
* target.h (push_target): Remove, update callers to use
inferior::push_target.
* target.c (push_target): Remove.
* inferior.h (class inferior) <push_target>: New overload.
Change-Id: I5a95496666278b8f3965e5e8aecb76f54a97c185
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/aix-thread.c | 2 | ||||
-rw-r--r-- | gdb/bsd-kvm.c | 2 | ||||
-rw-r--r-- | gdb/bsd-uthread.c | 2 | ||||
-rw-r--r-- | gdb/corelow.c | 2 | ||||
-rw-r--r-- | gdb/darwin-nat.c | 2 | ||||
-rw-r--r-- | gdb/exec.c | 4 | ||||
-rw-r--r-- | gdb/gnu-nat.c | 6 | ||||
-rw-r--r-- | gdb/go32-nat.c | 2 | ||||
-rw-r--r-- | gdb/inf-child.c | 2 | ||||
-rw-r--r-- | gdb/inf-ptrace.c | 7 | ||||
-rw-r--r-- | gdb/inferior.c | 2 | ||||
-rw-r--r-- | gdb/inferior.h | 7 | ||||
-rw-r--r-- | gdb/infrun.c | 6 | ||||
-rw-r--r-- | gdb/linux-thread-db.c | 2 | ||||
-rw-r--r-- | gdb/nto-procfs.c | 4 | ||||
-rw-r--r-- | gdb/procfs.c | 4 | ||||
-rw-r--r-- | gdb/ravenscar-thread.c | 2 | ||||
-rw-r--r-- | gdb/record-btrace.c | 2 | ||||
-rw-r--r-- | gdb/record-full.c | 4 | ||||
-rw-r--r-- | gdb/regcache.c | 2 | ||||
-rw-r--r-- | gdb/remote-sim.c | 2 | ||||
-rw-r--r-- | gdb/remote.c | 4 | ||||
-rw-r--r-- | gdb/scoped-mock-context.h | 2 | ||||
-rw-r--r-- | gdb/sol-thread.c | 2 | ||||
-rw-r--r-- | gdb/target.c | 19 | ||||
-rw-r--r-- | gdb/target.h | 5 | ||||
-rw-r--r-- | gdb/tracectf.c | 2 | ||||
-rw-r--r-- | gdb/tracefile-tfile.c | 2 | ||||
-rw-r--r-- | gdb/windows-nat.c | 4 |
30 files changed, 54 insertions, 61 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7396237..274e157 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2021-03-23 Simon Marchi <simon.marchi@polymtl.ca> + * target.h (push_target): Remove, update callers to use + inferior::push_target. + * target.c (push_target): Remove. + * inferior.h (class inferior) <push_target>: New overload. + +2021-03-23 Simon Marchi <simon.marchi@polymtl.ca> + * target.h (unpush_target): Remove, update all callers to use `inferior::unpush_target` instead. (struct target_unpusher) <operator()>: Just declare. diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index a479d01..fc34210 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -974,7 +974,7 @@ pd_enable (void) return; /* Prepare for thread debugging. */ - push_target (&aix_thread_ops); + current_inferior ()->push_target (&aix_thread_ops); pd_able = 1; /* If we're debugging a core file or an attached inferior, the diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c index 17db2fe..89da40a 100644 --- a/gdb/bsd-kvm.c +++ b/gdb/bsd-kvm.c @@ -134,7 +134,7 @@ bsd_kvm_target_open (const char *arg, int from_tty) bsd_kvm_corefile = filename; current_inferior ()->unpush_target (&bsd_kvm_ops); core_kd = temp_kd; - push_target (&bsd_kvm_ops); + current_inferior ()->push_target (&bsd_kvm_ops); thread_info *thr = add_thread_silent (&bsd_kvm_ops, bsd_kvm_ptid); switch_to_thread (thr); diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 2ee47bf..3cb8f64 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -231,7 +231,7 @@ bsd_uthread_activate (struct objfile *objfile) bsd_uthread_thread_ctx_offset = bsd_uthread_lookup_offset ("_thread_ctx_offset", objfile); - push_target (&bsd_uthread_ops); + current_inferior ()->push_target (&bsd_uthread_ops); bsd_uthread_active = 1; return 1; } diff --git a/gdb/corelow.c b/gdb/corelow.c index a4c1f63..a1943ab 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -458,7 +458,7 @@ core_target_open (const char *arg, int from_tty) if (!current_program_space->exec_bfd ()) set_gdbarch_from_file (core_bfd); - push_target (std::move (target_holder)); + current_inferior ()->push_target (std::move (target_holder)); switch_to_no_thread (); diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index ca95d7b..f8e4443 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1659,7 +1659,7 @@ darwin_attach_pid (struct inferior *inf) target_ops *darwin_ops = get_native_target (); if (!target_is_pushed (darwin_ops)) - push_target (darwin_ops); + inf->push_target (darwin_ops); } /* Get the thread_info object corresponding to this darwin_thread_info. */ @@ -616,7 +616,7 @@ program_space::add_target_sections (void *owner, continue; switch_to_inferior_no_thread (inf); - push_target (&exec_ops); + inf->push_target (&exec_ops); } } } @@ -682,7 +682,7 @@ void exec_on_vfork () { if (!current_program_space->target_sections ().empty ()) - push_target (&exec_ops); + current_inferior ()->push_target (&exec_ops); } diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 409d141..9ea4c40 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2114,7 +2114,7 @@ gnu_nat_target::create_inferior (const char *exec_file, inf_debug (inf, "creating inferior"); if (!target_is_pushed (this)) - push_target (this); + current_inferior ()->push_target (this); pid = fork_inferior (exec_file, allargs, env, gnu_ptrace_me, NULL, NULL, NULL, NULL); @@ -2190,9 +2190,9 @@ gnu_nat_target::attach (const char *args, int from_tty) inf_attach (inf, pid); - push_target (this); - inferior = current_inferior (); + inferior->push_target (this); + inferior_appeared (inferior, pid); inferior->attach_flag = 1; diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index b18a62e..79c31fc 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -757,7 +757,7 @@ go32_nat_target::create_inferior (const char *exec_file, inferior_appeared (inf, SOME_PID); if (!target_is_pushed (this)) - push_target (this); + inf->push_target (this); thread_info *thr = add_thread_silent (ptid_t (SOME_PID)); switch_to_thread (thr); diff --git a/gdb/inf-child.c b/gdb/inf-child.c index b8bc2e2..0e68a40 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -166,7 +166,7 @@ inf_child_open_target (const char *arg, int from_tty) gdb_assert (dynamic_cast<inf_child_target *> (target) != NULL); target_preopen (from_tty); - push_target (target); + current_inferior ()->push_target (target); inf_child_explicitly_opened = 1; if (from_tty) printf_filtered ("Done. Use the \"run\" command to start a process.\n"); diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 7ca02df..e630ba44 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -82,7 +82,7 @@ inf_ptrace_target::create_inferior (const char *exec_file, if (! ops_already_pushed) { /* Clear possible core file with its process_stratum. */ - push_target (this); + current_inferior ()->push_target (this); unpusher.reset (this); } @@ -139,12 +139,14 @@ inf_ptrace_target::attach (const char *args, int from_tty) if (pid == getpid ()) /* Trying to masturbate? */ error (_("I refuse to debug myself!")); + inf = current_inferior (); + target_unpush_up unpusher; if (! ops_already_pushed) { /* target_pid_to_str already uses the target. Also clear possible core file with its process_stratum. */ - push_target (this); + inf->push_target (this); unpusher.reset (this); } @@ -169,7 +171,6 @@ inf_ptrace_target::attach (const char *args, int from_tty) error (_("This system does not support attaching to a process")); #endif - inf = current_inferior (); inferior_appeared (inf, pid); inf->attach_flag = 1; diff --git a/gdb/inferior.c b/gdb/inferior.c index 49f869a..69baee3 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -771,7 +771,7 @@ switch_to_inferior_and_push_target (inferior *new_inf, /* Reuse the target for new inferior. */ if (!no_connection && proc_target != NULL) { - push_target (proc_target); + new_inf->push_target (proc_target); if (proc_target->connection_string () != NULL) printf_filtered (_("Added inferior %d on connection %d (%s %s)\n"), new_inf->num, diff --git a/gdb/inferior.h b/gdb/inferior.h index b8d5ff9..66fc180 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -352,6 +352,13 @@ public: void push_target (struct target_ops *t) { m_target_stack.push (t); } + /* An overload that deletes the target on failure. */ + void push_target (target_ops_up &&t) + { + m_target_stack.push (t.get ()); + t.release (); + } + /* Unpush T from this inferior's target stack. */ int unpush_target (struct target_ops *t) { return m_target_stack.unpush (t); } diff --git a/gdb/infrun.c b/gdb/infrun.c index 3b65a6d..50340e6 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -477,7 +477,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ set_current_inferior (child_inf); switch_to_no_thread (); child_inf->symfile_flags = SYMFILE_NO_READ; - push_target (parent_inf->process_target ()); + child_inf->push_target (parent_inf->process_target ()); thread_info *child_thr = add_thread_silent (child_inf->process_target (), child_ptid); @@ -627,7 +627,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ informing the solib layer about this new process. */ set_current_inferior (child_inf); - push_target (target); + child_inf->push_target (target); } thread_info *child_thr = add_thread_silent (target, child_ptid); @@ -1183,7 +1183,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target) inferior *org_inferior = current_inferior (); switch_to_inferior_no_thread (inf); - push_target (org_inferior->process_target ()); + inf->push_target (org_inferior->process_target ()); thread_info *thr = add_thread (inf->process_target (), ptid); switch_to_thread (thr); } diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 3a3d3de..de8687e 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -944,7 +944,7 @@ try_thread_db_load_1 (struct thread_db_info *info) /* The thread library was detected. Activate the thread_db target for this process. */ - push_target (&the_thread_db_target); + current_inferior ()->push_target (&the_thread_db_target); return true; } diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 021230a..b74392f 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -718,7 +718,7 @@ nto_procfs_target::attach (const char *args, int from_tty) inf->attach_flag = 1; if (!target_is_pushed (ops)) - push_target (ops); + inf->push_target (ops); update_thread_list (); @@ -1319,7 +1319,7 @@ nto_procfs_target::create_inferior (const char *exec_file, errn, safe_strerror(errn) ); */ } if (!target_is_pushed (ops)) - push_target (ops); + inf->push_target (ops); target_terminal::init (); if (current_program_space->exec_bfd () != NULL diff --git a/gdb/procfs.c b/gdb/procfs.c index cab29c3..b376809 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1771,7 +1771,7 @@ procfs_target::attach (const char *args, int from_tty) target_unpush_up unpusher; if (!target_is_pushed (this)) { - push_target (this); + current_inferior ()->push_target (this); unpusher.reset (this); } @@ -2863,7 +2863,7 @@ procfs_target::create_inferior (const char *exec_file, } if (!target_is_pushed (this)) - push_target (this); + current_inferior ()->push_target (this); pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap, NULL, procfs_pre_trace, shell_file, NULL); diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index 63aa1d1..1398d1b 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -674,7 +674,7 @@ ravenscar_inferior_created (inferior *inf) } ravenscar_thread_target *rtarget = new ravenscar_thread_target (); - push_target (target_ops_up (rtarget)); + inf->push_target (target_ops_up (rtarget)); thread_info *thr = rtarget->add_active_thread (); if (thr != nullptr) switch_to_thread (thr); diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 1a0cac2..b7b3c91 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -337,7 +337,7 @@ record_btrace_push_target (void) record_btrace_auto_enable (); - push_target (&record_btrace_ops); + current_inferior ()->push_target (&record_btrace_ops); record_btrace_async_inferior_event_handler = create_async_event_handler (record_btrace_handle_async_inferior_event, diff --git a/gdb/record-full.c b/gdb/record-full.c index 59e4410..8310b7b 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -924,7 +924,7 @@ record_full_core_open_1 (const char *name, int from_tty) record_full_core_sections = build_section_table (core_bfd); - push_target (&record_full_core_ops); + current_inferior ()->push_target (&record_full_core_ops); record_full_restore (); } @@ -947,7 +947,7 @@ record_full_open_1 (const char *name, int from_tty) error (_("Process record: the current architecture doesn't support " "record function.")); - push_target (&record_full_ops); + current_inferior ()->push_target (&record_full_ops); } static void record_full_init_record_breakpoints (void); diff --git a/gdb/regcache.c b/gdb/regcache.c index 27c0ae5..a419a21 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1925,7 +1925,7 @@ cooked_write_test (struct gdbarch *gdbarch) /* Push the process_stratum target so we can mock accessing registers. */ - push_target (&mock_target); + current_inferior ()->push_target (&mock_target); /* Pop it again on exit (return/exception). */ struct on_exit diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index f72bbd2..1746b626 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -763,7 +763,7 @@ gdbsim_target_open (const char *args, int from_tty) sim_data->gdbsim_desc = gdbsim_desc; - push_target (&gdbsim_ops); + current_inferior ()->push_target (&gdbsim_ops); printf_filtered ("Connected to the simulator.\n"); /* There's nothing running after "target sim" or "load"; not until diff --git a/gdb/remote.c b/gdb/remote.c index ae15f41..a7f3539 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -2474,7 +2474,7 @@ remote_target::remote_add_inferior (bool fake_pid_p, int pid, int attached, inf = add_inferior_with_spaces (); } switch_to_inferior_no_thread (inf); - push_target (this); + inf->push_target (this); inferior_appeared (inf, pid); } @@ -5673,7 +5673,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p) } /* Switch to using the remote target now. */ - push_target (std::move (target_holder)); + current_inferior ()->push_target (std::move (target_holder)); /* Register extra event sources in the event loop. */ rs->remote_async_inferior_event_token diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h index 8332e46..8d295ba 100644 --- a/gdb/scoped-mock-context.h +++ b/gdb/scoped-mock-context.h @@ -64,7 +64,7 @@ struct scoped_mock_context /* Push the process_stratum target so we can mock accessing registers. */ gdb_assert (mock_target.stratum () == process_stratum); - push_target (&mock_target); + mock_inferior.push_target (&mock_target); /* Switch to the mock thread. */ switch_to_thread (&mock_thread); diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 1458185..825f691 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -641,7 +641,7 @@ check_for_thread_db (void) printf_unfiltered (_("[Thread debugging using libthread_db enabled]\n")); /* The thread library was detected. Activate the sol_thread target. */ - push_target (&sol_thread_ops); + current_inferior ()->push_target (&sol_thread_ops); sol_thread_active = 1; main_ph.ptid = inferior_ptid; /* Save for xfer_memory. */ diff --git a/gdb/target.c b/gdb/target.c index 236aded..fe97312 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -158,7 +158,7 @@ static void set_targetdebug (const char *args, int from_tty, struct cmd_list_element *c) { if (targetdebug) - push_target (the_debug_target); + current_inferior ()->push_target (the_debug_target); else current_inferior ()->unpush_target (the_debug_target); } @@ -572,23 +572,6 @@ target_stack::push (target_ops *t) /* See target.h. */ -void -push_target (struct target_ops *t) -{ - current_inferior ()->push_target (t); -} - -/* See target.h. */ - -void -push_target (target_ops_up &&t) -{ - current_inferior ()->push_target (t.get ()); - t.release (); -} - -/* See target.h. */ - bool target_stack::unpush (target_ops *t) { diff --git a/gdb/target.h b/gdb/target.h index 3a64094..1830d3a 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -2385,11 +2385,6 @@ extern void add_target (const target_info &info, extern void add_deprecated_target_alias (const target_info &info, const char *alias); -extern void push_target (struct target_ops *); - -/* An overload that deletes the target on failure. */ -extern void push_target (target_ops_up &&); - /* A unique_ptr helper to unpush a target. */ struct target_unpusher diff --git a/gdb/tracectf.c b/gdb/tracectf.c index 38c327d..4a245ee 100644 --- a/gdb/tracectf.c +++ b/gdb/tracectf.c @@ -1165,7 +1165,7 @@ ctf_target_open (const char *dirname, int from_tty) gdb_assert (start_pos->type == BT_SEEK_RESTORE); trace_dirname = xstrdup (dirname); - push_target (&ctf_ops); + current_inferior ()->push_target (&ctf_ops); inferior_appeared (current_inferior (), CTF_PID); diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index ea70364..d82cac8 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -498,7 +498,7 @@ tfile_target_open (const char *arg, int from_tty) && (startswith (header + 1, "TRACE0\n")))) error (_("File is not a valid trace file.")); - push_target (&tfile_ops); + current_inferior ()->push_target (&tfile_ops); trace_regblock_size = 0; ts = current_trace_status (); diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index c8275fc..5166289 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2027,8 +2027,9 @@ windows_nat_target::do_initial_windows_stuff (DWORD pid, bool attaching) #endif current_event.dwProcessId = pid; memset (¤t_event, 0, sizeof (current_event)); + inf = current_inferior (); if (!target_is_pushed (this)) - push_target (this); + inf->push_target (this); disable_breakpoints_in_shlibs (); windows_clear_solib (); clear_proceed_status (0); @@ -2049,7 +2050,6 @@ windows_nat_target::do_initial_windows_stuff (DWORD pid, bool attaching) windows_set_segment_register_p (i386_windows_segment_register_p); } - inf = current_inferior (); inferior_appeared (inf, pid); inf->attach_flag = attaching; |