aboutsummaryrefslogtreecommitdiff
path: root/gdb/defs.h
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-06-10 09:29:15 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-06-10 09:29:15 +0000
commit0b080f5982d636d473d4fb9e62ef1ee00b28fdbc (patch)
tree1bcc2168a81286fcb2ed029576c282e77c3c8736 /gdb/defs.h
parent3201a343ca2a328894f3d0384082eed9b757cf03 (diff)
downloadgdb-0b080f5982d636d473d4fb9e62ef1ee00b28fdbc.zip
gdb-0b080f5982d636d473d4fb9e62ef1ee00b28fdbc.tar.gz
gdb-0b080f5982d636d473d4fb9e62ef1ee00b28fdbc.tar.bz2
Introduce common cleanup for restoring integers.
* defs.h (make_cleanup_restore_integer): New declaration. (struct cleanup): New field free_arg. (make_my_cleanup_2): New. * utils.c (restore_integer_closure, restore_integer) (make_cleanup_restore_integer): New. (make_my_cleanup): Initialize the free_arg field and renamed to make_my_cleanup_2. (do_my_cleanups): Call free_arg. (discard_cleanups): Call free_arg. * breakpoint.c (restore_always_inserted_mode): Remove. (update_breakpoints_after_exec): Use make_cleanup_restore_integer.
Diffstat (limited to 'gdb/defs.h')
-rw-r--r--gdb/defs.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/gdb/defs.h b/gdb/defs.h
index 9069156..ca3fad8 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -230,12 +230,18 @@ enum return_value_convention
Use make_cleanup to add an element to the cleanup chain.
Use do_cleanups to do all cleanup actions back to a given
point in the chain. Use discard_cleanups to remove cleanups
- from the chain back to a given point, not doing them. */
+ from the chain back to a given point, not doing them.
+
+ If the argument is pointer to allocated memory, then you need to
+ to additionally set the 'free_arg' member to a function that will
+ free that memory. This function will be called both when the cleanup
+ is executed and when it's discarded. */
struct cleanup
{
struct cleanup *next;
void (*function) (void *);
+ void (*free_arg) (void *);
void *arg;
};
@@ -339,11 +345,17 @@ extern struct cleanup *make_cleanup_close (int fd);
extern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
+extern struct cleanup *make_cleanup_restore_integer (int *variable);
+
extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
extern struct cleanup *make_my_cleanup (struct cleanup **,
make_cleanup_ftype *, void *);
+extern struct cleanup *make_my_cleanup2 (struct cleanup **,
+ make_cleanup_ftype *, void *,
+ void (*free_arg) (void *));
+
extern struct cleanup *save_cleanups (void);
extern struct cleanup *save_final_cleanups (void);
extern struct cleanup *save_my_cleanups (struct cleanup **);