aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-10-22 21:39:09 +0000
committerAndrew Cagney <cagney@redhat.com>2003-10-22 21:39:09 +0000
commitf1c07ab0ca71fdadc64f2838f87f39784aee5b63 (patch)
tree669beaa649a52386e7e6431a687d5a74e7d3fbbe
parentc9ac89782df8198d0c48219364b15d3af5efa0dd (diff)
downloadgdb-f1c07ab0ca71fdadc64f2838f87f39784aee5b63.zip
gdb-f1c07ab0ca71fdadc64f2838f87f39784aee5b63.tar.gz
gdb-f1c07ab0ca71fdadc64f2838f87f39784aee5b63.tar.bz2
2003-10-22 Andrew Cagney <cagney@redhat.com>
* target.c (target_close): New function. (debug_to_close): Use "target_close". (push_target): Use "target_close". (unpush_target): Use "target_close". (pop_target): Use "target_close". * target.h (struct target_ops): Add "to_xclose". (target_open): Delete macro. Move comment to "to_open". (target_close): Replace macro with function that takes a target. * top.c (quit_target): Pass "current_target" to "target_close".
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/target.c20
-rw-r--r--gdb/target.h36
-rw-r--r--gdb/top.c2
4 files changed, 43 insertions, 27 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fd9b257..26114e7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2003-10-22 Andrew Cagney <cagney@redhat.com>
+
+ * target.c (target_close): New function.
+ (debug_to_close): Use "target_close".
+ (push_target): Use "target_close".
+ (unpush_target): Use "target_close".
+ (pop_target): Use "target_close".
+ * target.h (struct target_ops): Add "to_xclose".
+ (target_open): Delete macro. Move comment to "to_open".
+ (target_close): Replace macro with function that takes a target.
+ * top.c (quit_target): Pass "current_target" to "target_close".
+
2003-10-21 Elena Zannoni <ezannoni@redhat.com>
* minsyms.c (lookup_minimal_symbol_text): Remove unused parameter.
diff --git a/gdb/target.c b/gdb/target.c
index b7d398b..2677fb3 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -672,8 +672,7 @@ push_target (struct target_ops *t)
struct target_ops *tmp = (*cur);
(*cur) = (*cur)->beneath;
tmp->beneath = NULL;
- if (tmp->to_close)
- (tmp->to_close) (0);
+ target_close (tmp, 0);
}
/* We have removed all targets in our stratum, now add the new one. */
@@ -698,8 +697,7 @@ unpush_target (struct target_ops *t)
struct target_ops **cur;
struct target_ops *tmp;
- if (t->to_close)
- t->to_close (0); /* Let it clean up */
+ target_close (t, 0);
/* Look for the specified target. Note that we assume that a target
can only occur once in the target stack. */
@@ -726,7 +724,7 @@ unpush_target (struct target_ops *t)
void
pop_target (void)
{
- (current_target.to_close) (0); /* Let it clean up */
+ target_close (&current_target, 0); /* Let it clean up */
if (unpush_target (target_stack) == 1)
return;
@@ -1600,11 +1598,19 @@ debug_to_open (char *args, int from_tty)
static void
debug_to_close (int quitting)
{
- debug_target.to_close (quitting);
-
+ target_close (&debug_target, quitting);
fprintf_unfiltered (gdb_stdlog, "target_close (%d)\n", quitting);
}
+void
+target_close (struct target_ops *targ, int quitting)
+{
+ if (targ->to_xclose != NULL)
+ targ->to_xclose (targ, quitting);
+ else if (targ->to_close != NULL)
+ targ->to_close (quitting);
+}
+
static void
debug_to_attach (char *args, int from_tty)
{
diff --git a/gdb/target.h b/gdb/target.h
index 7bee270..b11647a 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -266,7 +266,15 @@ struct target_ops
char *to_doc; /* Documentation. Does not include trailing
newline, and starts with a one-line descrip-
tion (probably similar to to_longname). */
+ /* The open routine takes the rest of the parameters from the
+ command, and (if successful) pushes a new target onto the
+ stack. Targets should supply this routine, if only to provide
+ an error message. */
void (*to_open) (char *, int);
+ /* Old targets with a static target vector provide "to_close".
+ New re-entrant targets provide "to_xclose" and that is expected
+ to xfree everything (including the "struct target_ops"). */
+ void (*to_xclose) (struct target_ops *targ, int quitting);
void (*to_close) (int);
void (*to_attach) (char *, int);
void (*to_post_attach) (int);
@@ -413,26 +421,16 @@ extern struct target_ops current_target;
#define target_shortname (current_target.to_shortname)
#define target_longname (current_target.to_longname)
-/* The open routine takes the rest of the parameters from the command,
- and (if successful) pushes a new target onto the stack.
- Targets should supply this routine, if only to provide an error message. */
+/* Does whatever cleanup is required for a target that we are no
+ longer going to be calling. QUITTING indicates that GDB is exiting
+ and should not get hung on an error (otherwise it is important to
+ perform clean termination, even if it takes a while). This routine
+ is automatically always called when popping the target off the
+ target stack (to_beneath is undefined). Closing file descriptors
+ and freeing all memory allocated memory are typical things it
+ should do. */
-#define target_open(name, from_tty) \
- do { \
- dcache_invalidate (target_dcache); \
- (*current_target.to_open) (name, from_tty); \
- } while (0)
-
-/* Does whatever cleanup is required for a target that we are no longer
- going to be calling. Argument says whether we are quitting gdb and
- should not get hung in case of errors, or whether we want a clean
- termination even if it takes a while. This routine is automatically
- always called just before a routine is popped off the target stack.
- Closing file descriptors and freeing memory are typical things it should
- do. */
-
-#define target_close(quitting) \
- (*current_target.to_close) (quitting)
+void target_close (struct target_ops *targ, int quitting);
/* Attaches to a process on the target side. Arguments are as passed
to the `attach' command by the user. This routine can be called
diff --git a/gdb/top.c b/gdb/top.c
index 1e3399d..46e323b0 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1461,7 +1461,7 @@ quit_target (void *arg)
}
/* UDI wants this, to kill the TIP. */
- target_close (1);
+ target_close (&current_target, 1);
/* Save the history information if it is appropriate to do so. */
if (write_history_p && history_filename)