remove using_exec_ops global
Commit Message
This removes the using_exec_ops global from exec.c, in favor of
querying the target stack directly using target_is_pushed. This is
more in keeping with other code in gdb, and is also more future-proof
as it is more multi-target-ready.
Built and regtested on x86-64 Fedora 20.
2014-07-18 Tom Tromey <tromey@redhat.com>
* exec.c (using_exec_ops): Remove.
(exec_close_1): Update. Remove extraneous block, reindent.
(add_target_sections): Use target_is_pushed.
---
gdb/ChangeLog | 6 ++++++
gdb/exec.c | 32 +++++++++++---------------------
2 files changed, 17 insertions(+), 21 deletions(-)
Comments
On 07/18/2014 05:25 PM, Tom Tromey wrote:
> This removes the using_exec_ops global from exec.c, in favor of
> querying the target stack directly using target_is_pushed. This is
> more in keeping with other code in gdb, and is also more future-proof
> as it is more multi-target-ready.
>
> Built and regtested on x86-64 Fedora 20.
>
> 2014-07-18 Tom Tromey <tromey@redhat.com>
>
> * exec.c (using_exec_ops): Remove.
> (exec_close_1): Update. Remove extraneous block, reindent.
> (add_target_sections): Use target_is_pushed.
Looks good to me.
Thanks,
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> This removes the using_exec_ops global from exec.c, in favor of
Tom> querying the target stack directly using target_is_pushed. This is
Tom> more in keeping with other code in gdb, and is also more future-proof
Tom> as it is more multi-target-ready.
I'm checking this in.
Tom
@@ -63,9 +63,6 @@ void _initialize_exec (void);
static struct target_ops exec_ops;
-/* True if the exec target is pushed on the stack. */
-static int using_exec_ops;
-
/* Whether to open exec and core files read-only or read-write. */
int write_files = 0;
@@ -115,22 +112,18 @@ exec_close (void)
static void
exec_close_1 (struct target_ops *self)
{
- using_exec_ops = 0;
+ struct program_space *ss;
+ struct cleanup *old_chain;
+ old_chain = save_current_program_space ();
+ ALL_PSPACES (ss)
{
- struct program_space *ss;
- struct cleanup *old_chain;
-
- old_chain = save_current_program_space ();
- ALL_PSPACES (ss)
- {
- set_current_program_space (ss);
- clear_section_table (current_target_sections);
- exec_close ();
- }
-
- do_cleanups (old_chain);
+ set_current_program_space (ss);
+ clear_section_table (current_target_sections);
+ exec_close ();
}
+
+ do_cleanups (old_chain);
}
void
@@ -445,11 +438,8 @@ add_target_sections (void *owner,
/* If these are the first file sections we can provide memory
from, push the file_stratum target. */
- if (!using_exec_ops)
- {
- using_exec_ops = 1;
- push_target (&exec_ops);
- }
+ if (!target_is_pushed (&exec_ops))
+ push_target (&exec_ops);
}
}