[6/9] Don't change current program space in exec_target::close

Message ID 20200722033444.18522-7-tom@tromey.com
State New
Headers show
Series
  • Remove some macros from exec.h and progspace.h
Related show

Commit Message

Tom Tromey July 22, 2020, 3:34 a.m.
Now that we've removed the macros and changed exec_close to be a
method, it's clear that exec_target::close can operate on program
spaces without changing the current program space.

gdb/ChangeLog
2020-07-21  Tom Tromey  <tom@tromey.com>

	* exec.c (exec_target::close): Don't change current program
	space.
---
 gdb/ChangeLog | 5 +++++
 gdb/exec.c    | 3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.17.2

Comments

Simon Marchi July 22, 2020, 12:22 p.m. | #1
On 2020-07-21 11:34 p.m., Tom Tromey wrote:
> Now that we've removed the macros and changed exec_close to be a

> method, it's clear that exec_target::close can operate on program

> spaces without changing the current program space.

> 

> gdb/ChangeLog

> 2020-07-21  Tom Tromey  <tom@tromey.com>

> 

> 	* exec.c (exec_target::close): Don't change current program

> 	space.

> ---

>  gdb/ChangeLog | 5 +++++

>  gdb/exec.c    | 3 ---

>  2 files changed, 5 insertions(+), 3 deletions(-)

> 

> diff --git a/gdb/exec.c b/gdb/exec.c

> index e2a0cae787c..b2c7a58b27f 100644

> --- a/gdb/exec.c

> +++ b/gdb/exec.c

> @@ -154,11 +154,8 @@ exec_target_open (const char *args, int from_tty)

>  void

>  exec_target::close ()

>  {

> -  scoped_restore_current_program_space restore_pspace;

> -

>    for (struct program_space *ss : program_spaces)

>      {

> -      set_current_program_space (ss);

>        clear_section_table (&ss->target_sections);

>        ss->exec_close ();

>      }


Ah, forget my comment on last patch.

So yeah, ss->exec_close calls remove_target_sections, which uses current_program_space.

I think that would need to be changed first, but there doesn't seem to be any blocker
for that.

Simon

Patch

diff --git a/gdb/exec.c b/gdb/exec.c
index e2a0cae787c..b2c7a58b27f 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -154,11 +154,8 @@  exec_target_open (const char *args, int from_tty)
 void
 exec_target::close ()
 {
-  scoped_restore_current_program_space restore_pspace;
-
   for (struct program_space *ss : program_spaces)
     {
-      set_current_program_space (ss);
       clear_section_table (&ss->target_sections);
       ss->exec_close ();
     }