diff options
author | Tom Tromey <tom@tromey.com> | 2020-12-11 09:21:53 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-12-11 09:21:53 -0700 |
commit | 51107df53aeb2f6a5a03a1af29eec773b3aca463 (patch) | |
tree | 64ea015b1da68226155c02e7fb9af6b71ee7448b | |
parent | 15f4dddd8a29d064a634140a5fcb830715681889 (diff) | |
download | gdb-51107df53aeb2f6a5a03a1af29eec773b3aca463.zip gdb-51107df53aeb2f6a5a03a1af29eec773b3aca463.tar.gz gdb-51107df53aeb2f6a5a03a1af29eec773b3aca463.tar.bz2 |
Change current_inferior_ to be a inferior_ref
This changes current_inferior_ to be an inferior_ref, removing some
manual reference counting.
gdb/ChangeLog
2020-12-11 Tom Tromey <tom@tromey.com>
* inferior.c (current_inferior_): Change type.
(current_inferior, set_current_inferior, initialize_inferiors):
Update.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/inferior.c | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 732a1cf..3d97380 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2020-12-11 Tom Tromey <tom@tromey.com> + * inferior.c (current_inferior_): Change type. + (current_inferior, set_current_inferior, initialize_inferiors): + Update. + +2020-12-11 Tom Tromey <tom@tromey.com> + * gdbthread.h (class enable_thread_stack_temporaries) <m_thr>: Change type. diff --git a/gdb/inferior.c b/gdb/inferior.c index d4a783b..a6652b6 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -51,12 +51,12 @@ bool print_inferior_events = true; /* The Current Inferior. This is a strong reference. I.e., whenever an inferior is the current inferior, its refcount is incremented. */ -static struct inferior *current_inferior_ = NULL; +static inferior_ref current_inferior_; struct inferior* current_inferior (void) { - return current_inferior_; + return current_inferior_.get (); } void @@ -65,9 +65,7 @@ set_current_inferior (struct inferior *inf) /* There's always an inferior. */ gdb_assert (inf != NULL); - inf->incref (); - current_inferior_->decref (); - current_inferior_ = inf; + current_inferior_ = inferior_ref::new_reference (inf); } private_inferior::~private_inferior () = default; @@ -962,8 +960,7 @@ initialize_inferiors (void) can only allocate an inferior when all those modules have done that. Do this after initialize_progspace, due to the current_program_space reference. */ - current_inferior_ = add_inferior_silent (0); - current_inferior_->incref (); + set_current_inferior (add_inferior_silent (0)); current_inferior_->pspace = current_program_space; current_inferior_->aspace = current_program_space->aspace; /* The architecture will be initialized shortly, by |