forked from Imagelibrary/binutils-gdb
gcore, target: allow target to prepare/cleanup for/after core file generation
Add new target functions to_prepare_to_generate_core and to_done_generating_core that are called before and after generating a core file, respectively. This allows targets to prepare for core file generation and to clean up afterwards. gdb/ * target.h (target_ops) <to_prepare_to_generate_core> <to_done_generating_core>: New. (target_prepare_to_generate_core, target_done_generating_core): New. * target.c (target_prepare_to_generate_core) (target_done_generating_core): New. * target-delegates.c: Regenerate. * gcore.c: (write_gcore_file): Rename to ... (write_gcore_file_1): ...this. (write_gcore_file): Call target_prepare_to_generate_core and target_done_generating_core.
This commit is contained in:
@@ -1,3 +1,16 @@
|
|||||||
|
2014-06-25 Markus Metzger <markus.t.metzger@intel.com>
|
||||||
|
|
||||||
|
* target.h (target_ops) <to_prepare_to_generate_core>
|
||||||
|
<to_done_generating_core>: New.
|
||||||
|
(target_prepare_to_generate_core, target_done_generating_core): New.
|
||||||
|
* target.c (target_prepare_to_generate_core)
|
||||||
|
(target_done_generating_core): New.
|
||||||
|
* target-delegates.c: Regenerate.
|
||||||
|
* gcore.c: (write_gcore_file): Rename to ...
|
||||||
|
(write_gcore_file_1): ...this.
|
||||||
|
(write_gcore_file): Call target_prepare_to_generate_core
|
||||||
|
and target_done_generating_core.
|
||||||
|
|
||||||
2014-06-25 Markus Metzger <markus.t.metzger@intel.com>
|
2014-06-25 Markus Metzger <markus.t.metzger@intel.com>
|
||||||
|
|
||||||
* fbsd-nat.c (fbsd_make_corefile_notes): Remove make_cleanup call.
|
* fbsd-nat.c (fbsd_make_corefile_notes): Remove make_cleanup call.
|
||||||
|
|||||||
27
gdb/gcore.c
27
gdb/gcore.c
@@ -61,12 +61,10 @@ create_gcore_bfd (const char *filename)
|
|||||||
return obfd;
|
return obfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write_gcore_file -- helper for gcore_command (exported).
|
/* write_gcore_file_1 -- do the actual work of write_gcore_file. */
|
||||||
Compose and write the corefile data to the core file. */
|
|
||||||
|
|
||||||
|
static void
|
||||||
void
|
write_gcore_file_1 (bfd *obfd)
|
||||||
write_gcore_file (bfd *obfd)
|
|
||||||
{
|
{
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
void *note_data = NULL;
|
void *note_data = NULL;
|
||||||
@@ -111,6 +109,25 @@ write_gcore_file (bfd *obfd)
|
|||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* write_gcore_file -- helper for gcore_command (exported).
|
||||||
|
Compose and write the corefile data to the core file. */
|
||||||
|
|
||||||
|
void
|
||||||
|
write_gcore_file (bfd *obfd)
|
||||||
|
{
|
||||||
|
volatile struct gdb_exception except;
|
||||||
|
|
||||||
|
target_prepare_to_generate_core ();
|
||||||
|
|
||||||
|
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||||
|
write_gcore_file_1 (obfd);
|
||||||
|
|
||||||
|
target_done_generating_core ();
|
||||||
|
|
||||||
|
if (except.reason < 0)
|
||||||
|
throw_exception (except);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_bfd_delete_cleanup (void *arg)
|
do_bfd_delete_cleanup (void *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1624,6 +1624,30 @@ delegate_decr_pc_after_break (struct target_ops *self, struct gdbarch *arg1)
|
|||||||
return self->to_decr_pc_after_break (self, arg1);
|
return self->to_decr_pc_after_break (self, arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delegate_prepare_to_generate_core (struct target_ops *self)
|
||||||
|
{
|
||||||
|
self = self->beneath;
|
||||||
|
self->to_prepare_to_generate_core (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tdefault_prepare_to_generate_core (struct target_ops *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delegate_done_generating_core (struct target_ops *self)
|
||||||
|
{
|
||||||
|
self = self->beneath;
|
||||||
|
self->to_done_generating_core (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tdefault_done_generating_core (struct target_ops *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
install_delegators (struct target_ops *ops)
|
install_delegators (struct target_ops *ops)
|
||||||
{
|
{
|
||||||
@@ -1897,6 +1921,10 @@ install_delegators (struct target_ops *ops)
|
|||||||
ops->to_get_tailcall_unwinder = delegate_get_tailcall_unwinder;
|
ops->to_get_tailcall_unwinder = delegate_get_tailcall_unwinder;
|
||||||
if (ops->to_decr_pc_after_break == NULL)
|
if (ops->to_decr_pc_after_break == NULL)
|
||||||
ops->to_decr_pc_after_break = delegate_decr_pc_after_break;
|
ops->to_decr_pc_after_break = delegate_decr_pc_after_break;
|
||||||
|
if (ops->to_prepare_to_generate_core == NULL)
|
||||||
|
ops->to_prepare_to_generate_core = delegate_prepare_to_generate_core;
|
||||||
|
if (ops->to_done_generating_core == NULL)
|
||||||
|
ops->to_done_generating_core = delegate_done_generating_core;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2037,4 +2065,6 @@ install_dummy_methods (struct target_ops *ops)
|
|||||||
ops->to_get_unwinder = tdefault_get_unwinder;
|
ops->to_get_unwinder = tdefault_get_unwinder;
|
||||||
ops->to_get_tailcall_unwinder = tdefault_get_tailcall_unwinder;
|
ops->to_get_tailcall_unwinder = tdefault_get_tailcall_unwinder;
|
||||||
ops->to_decr_pc_after_break = default_target_decr_pc_after_break;
|
ops->to_decr_pc_after_break = default_target_decr_pc_after_break;
|
||||||
|
ops->to_prepare_to_generate_core = tdefault_prepare_to_generate_core;
|
||||||
|
ops->to_done_generating_core = tdefault_done_generating_core;
|
||||||
}
|
}
|
||||||
|
|||||||
16
gdb/target.c
16
gdb/target.c
@@ -3606,6 +3606,22 @@ target_decr_pc_after_break (struct gdbarch *gdbarch)
|
|||||||
return current_target.to_decr_pc_after_break (¤t_target, gdbarch);
|
return current_target.to_decr_pc_after_break (¤t_target, gdbarch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See target.h. */
|
||||||
|
|
||||||
|
void
|
||||||
|
target_prepare_to_generate_core (void)
|
||||||
|
{
|
||||||
|
current_target.to_prepare_to_generate_core (¤t_target);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See target.h. */
|
||||||
|
|
||||||
|
void
|
||||||
|
target_done_generating_core (void)
|
||||||
|
{
|
||||||
|
current_target.to_done_generating_core (¤t_target);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debug_to_files_info (struct target_ops *target)
|
debug_to_files_info (struct target_ops *target)
|
||||||
{
|
{
|
||||||
|
|||||||
14
gdb/target.h
14
gdb/target.h
@@ -1109,6 +1109,14 @@ struct target_ops
|
|||||||
struct gdbarch *gdbarch)
|
struct gdbarch *gdbarch)
|
||||||
TARGET_DEFAULT_FUNC (default_target_decr_pc_after_break);
|
TARGET_DEFAULT_FUNC (default_target_decr_pc_after_break);
|
||||||
|
|
||||||
|
/* Prepare to generate a core file. */
|
||||||
|
void (*to_prepare_to_generate_core) (struct target_ops *)
|
||||||
|
TARGET_DEFAULT_IGNORE ();
|
||||||
|
|
||||||
|
/* Cleanup after generating a core file. */
|
||||||
|
void (*to_done_generating_core) (struct target_ops *)
|
||||||
|
TARGET_DEFAULT_IGNORE ();
|
||||||
|
|
||||||
int to_magic;
|
int to_magic;
|
||||||
/* Need sub-structure for target machine related rather than comm related?
|
/* Need sub-structure for target machine related rather than comm related?
|
||||||
*/
|
*/
|
||||||
@@ -2261,4 +2269,10 @@ extern CORE_ADDR forward_target_decr_pc_after_break (struct target_ops *ops,
|
|||||||
/* See to_decr_pc_after_break. */
|
/* See to_decr_pc_after_break. */
|
||||||
extern CORE_ADDR target_decr_pc_after_break (struct gdbarch *gdbarch);
|
extern CORE_ADDR target_decr_pc_after_break (struct gdbarch *gdbarch);
|
||||||
|
|
||||||
|
/* See to_prepare_to_generate_core. */
|
||||||
|
extern void target_prepare_to_generate_core (void);
|
||||||
|
|
||||||
|
/* See to_done_generating_core. */
|
||||||
|
extern void target_done_generating_core (void);
|
||||||
|
|
||||||
#endif /* !defined (TARGET_H) */
|
#endif /* !defined (TARGET_H) */
|
||||||
|
|||||||
Reference in New Issue
Block a user