mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 18:14:13 +08:00
Pull out common parts of _initialize_{i386,amd64}_linux_nat
This commit adds two new helpers, x86_linux_create_target and x86_linux_add_target, to hold the parts of _initialize_i386_linux_nat and _initialize_amd64_linux_nat which are common. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * amd64-linux-nat.c (x86_linux_create_target): New function. (x86_linux_add_target): Likewise. (_initialize_amd64_linux_nat): Delegate to the above new functions. * i386-linux-nat.c (x86_linux_create_target): New function. (x86_linux_add_target): Likewise. (_initialize_i386_linux_nat): Delegate to the above new functions.
This commit is contained in:
parent
8c420b8d59
commit
c1e246a060
@ -1,3 +1,12 @@
|
||||
2014-07-11 Gary Benson <gbenson@redhat.com>
|
||||
|
||||
* amd64-linux-nat.c (x86_linux_create_target): New function.
|
||||
(x86_linux_add_target): Likewise.
|
||||
(_initialize_amd64_linux_nat): Delegate to the above new functions.
|
||||
* i386-linux-nat.c (x86_linux_create_target): New function.
|
||||
(x86_linux_add_target): Likewise.
|
||||
(_initialize_i386_linux_nat): Delegate to the above new functions.
|
||||
|
||||
2014-07-11 Gary Benson <gbenson@redhat.com>
|
||||
|
||||
* amd64-linux-nat.c (x86_linux_get_thread_area): New function.
|
||||
|
@ -1269,6 +1269,52 @@ x86_linux_read_btrace (struct target_ops *self,
|
||||
return linux_read_btrace (data, btinfo, type);
|
||||
}
|
||||
|
||||
/* Create an x86 GNU/Linux target. */
|
||||
|
||||
static struct target_ops *
|
||||
x86_linux_create_target (void)
|
||||
{
|
||||
/* Fill in the generic GNU/Linux methods. */
|
||||
struct target_ops *t = linux_target ();
|
||||
|
||||
/* Initialize the debug register function vectors. */
|
||||
i386_use_watchpoints (t);
|
||||
i386_dr_low.set_control = x86_linux_dr_set_control;
|
||||
i386_dr_low.set_addr = x86_linux_dr_set_addr;
|
||||
i386_dr_low.get_addr = x86_linux_dr_get_addr;
|
||||
i386_dr_low.get_status = x86_linux_dr_get_status;
|
||||
i386_dr_low.get_control = x86_linux_dr_get_control;
|
||||
i386_set_debug_register_length (sizeof (void *));
|
||||
|
||||
/* Override the GNU/Linux inferior startup hook. */
|
||||
super_post_startup_inferior = t->to_post_startup_inferior;
|
||||
t->to_post_startup_inferior = x86_linux_child_post_startup_inferior;
|
||||
|
||||
/* Add the description reader. */
|
||||
t->to_read_description = x86_linux_read_description;
|
||||
|
||||
/* Add btrace methods. */
|
||||
t->to_supports_btrace = linux_supports_btrace;
|
||||
t->to_enable_btrace = x86_linux_enable_btrace;
|
||||
t->to_disable_btrace = x86_linux_disable_btrace;
|
||||
t->to_teardown_btrace = x86_linux_teardown_btrace;
|
||||
t->to_read_btrace = x86_linux_read_btrace;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Add an x86 GNU/Linux target. */
|
||||
|
||||
static void
|
||||
x86_linux_add_target (struct target_ops *t)
|
||||
{
|
||||
linux_nat_add_target (t);
|
||||
linux_nat_set_new_thread (t, x86_linux_new_thread);
|
||||
linux_nat_set_new_fork (t, x86_linux_new_fork);
|
||||
linux_nat_set_forget_process (t, i386_forget_process);
|
||||
linux_nat_set_prepare_to_resume (t, x86_linux_prepare_to_resume);
|
||||
}
|
||||
|
||||
/* Provide a prototype to silence -Wmissing-prototypes. */
|
||||
void _initialize_amd64_linux_nat (void);
|
||||
|
||||
@ -1285,40 +1331,16 @@ _initialize_amd64_linux_nat (void)
|
||||
gdb_assert (ARRAY_SIZE (amd64_linux_gregset32_reg_offset)
|
||||
== amd64_native_gregset32_num_regs);
|
||||
|
||||
/* Fill in the generic GNU/Linux methods. */
|
||||
t = linux_target ();
|
||||
|
||||
i386_use_watchpoints (t);
|
||||
|
||||
i386_dr_low.set_control = x86_linux_dr_set_control;
|
||||
i386_dr_low.set_addr = x86_linux_dr_set_addr;
|
||||
i386_dr_low.get_addr = x86_linux_dr_get_addr;
|
||||
i386_dr_low.get_status = x86_linux_dr_get_status;
|
||||
i386_dr_low.get_control = x86_linux_dr_get_control;
|
||||
i386_set_debug_register_length (8);
|
||||
|
||||
/* Override the GNU/Linux inferior startup hook. */
|
||||
super_post_startup_inferior = t->to_post_startup_inferior;
|
||||
t->to_post_startup_inferior = x86_linux_child_post_startup_inferior;
|
||||
/* Create a generic x86 GNU/Linux target. */
|
||||
t = x86_linux_create_target ();
|
||||
|
||||
/* Add our register access methods. */
|
||||
t->to_fetch_registers = amd64_linux_fetch_inferior_registers;
|
||||
t->to_store_registers = amd64_linux_store_inferior_registers;
|
||||
|
||||
t->to_read_description = x86_linux_read_description;
|
||||
/* Add the target. */
|
||||
x86_linux_add_target (t);
|
||||
|
||||
/* Add btrace methods. */
|
||||
t->to_supports_btrace = linux_supports_btrace;
|
||||
t->to_enable_btrace = x86_linux_enable_btrace;
|
||||
t->to_disable_btrace = x86_linux_disable_btrace;
|
||||
t->to_teardown_btrace = x86_linux_teardown_btrace;
|
||||
t->to_read_btrace = x86_linux_read_btrace;
|
||||
|
||||
/* Register the target. */
|
||||
linux_nat_add_target (t);
|
||||
linux_nat_set_new_thread (t, x86_linux_new_thread);
|
||||
linux_nat_set_new_fork (t, x86_linux_new_fork);
|
||||
linux_nat_set_forget_process (t, i386_forget_process);
|
||||
/* Add our siginfo layout converter. */
|
||||
linux_nat_set_siginfo_fixup (t, amd64_linux_siginfo_fixup);
|
||||
linux_nat_set_prepare_to_resume (t, x86_linux_prepare_to_resume);
|
||||
}
|
||||
|
@ -1217,37 +1217,28 @@ x86_linux_read_btrace (struct target_ops *self,
|
||||
return linux_read_btrace (data, btinfo, type);
|
||||
}
|
||||
|
||||
/* -Wmissing-prototypes */
|
||||
extern initialize_file_ftype _initialize_i386_linux_nat;
|
||||
/* Create an x86 GNU/Linux target. */
|
||||
|
||||
void
|
||||
_initialize_i386_linux_nat (void)
|
||||
static struct target_ops *
|
||||
x86_linux_create_target (void)
|
||||
{
|
||||
struct target_ops *t;
|
||||
|
||||
/* Fill in the generic GNU/Linux methods. */
|
||||
t = linux_target ();
|
||||
struct target_ops *t = linux_target ();
|
||||
|
||||
/* Initialize the debug register function vectors. */
|
||||
i386_use_watchpoints (t);
|
||||
|
||||
i386_dr_low.set_control = x86_linux_dr_set_control;
|
||||
i386_dr_low.set_addr = x86_linux_dr_set_addr;
|
||||
i386_dr_low.get_addr = x86_linux_dr_get_addr;
|
||||
i386_dr_low.get_status = x86_linux_dr_get_status;
|
||||
i386_dr_low.get_control = x86_linux_dr_get_control;
|
||||
i386_set_debug_register_length (4);
|
||||
|
||||
/* Override the default ptrace resume method. */
|
||||
t->to_resume = i386_linux_resume;
|
||||
i386_set_debug_register_length (sizeof (void *));
|
||||
|
||||
/* Override the GNU/Linux inferior startup hook. */
|
||||
super_post_startup_inferior = t->to_post_startup_inferior;
|
||||
t->to_post_startup_inferior = x86_linux_child_post_startup_inferior;
|
||||
|
||||
/* Add our register access methods. */
|
||||
t->to_fetch_registers = i386_linux_fetch_inferior_registers;
|
||||
t->to_store_registers = i386_linux_store_inferior_registers;
|
||||
|
||||
/* Add the description reader. */
|
||||
t->to_read_description = x86_linux_read_description;
|
||||
|
||||
/* Add btrace methods. */
|
||||
@ -1257,10 +1248,37 @@ _initialize_i386_linux_nat (void)
|
||||
t->to_teardown_btrace = x86_linux_teardown_btrace;
|
||||
t->to_read_btrace = x86_linux_read_btrace;
|
||||
|
||||
/* Register the target. */
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Add an x86 GNU/Linux target. */
|
||||
|
||||
static void
|
||||
x86_linux_add_target (struct target_ops *t)
|
||||
{
|
||||
linux_nat_add_target (t);
|
||||
linux_nat_set_new_thread (t, x86_linux_new_thread);
|
||||
linux_nat_set_new_fork (t, x86_linux_new_fork);
|
||||
linux_nat_set_forget_process (t, i386_forget_process);
|
||||
linux_nat_set_prepare_to_resume (t, x86_linux_prepare_to_resume);
|
||||
}
|
||||
|
||||
/* -Wmissing-prototypes */
|
||||
extern initialize_file_ftype _initialize_i386_linux_nat;
|
||||
|
||||
void
|
||||
_initialize_i386_linux_nat (void)
|
||||
{
|
||||
/* Create a generic x86 GNU/Linux target. */
|
||||
struct target_ops *t = x86_linux_create_target ();
|
||||
|
||||
/* Override the default ptrace resume method. */
|
||||
t->to_resume = i386_linux_resume;
|
||||
|
||||
/* Add our register access methods. */
|
||||
t->to_fetch_registers = i386_linux_fetch_inferior_registers;
|
||||
t->to_store_registers = i386_linux_store_inferior_registers;
|
||||
|
||||
/* Add the target. */
|
||||
x86_linux_add_target (t);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user