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.
This commit is contained in:
parent
3201a343ca
commit
0b080f5982
4 changed files with 69 additions and 11 deletions
14
gdb/defs.h
14
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 **);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue