* [PATCH 0/3] Make all native targets inherit inf-child.c.
@ 2014-03-07 15:14 Pedro Alves
2014-03-07 15:14 ` [PATCH 2/3] Make the windows-nat.c target " Pedro Alves
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-07 15:14 UTC (permalink / raw)
To: gdb-patches
This series makes the remaining native targets that don't inherit
inf-child.c do that.
This is so that all native targets inherit a single "superclass".
With that, it's easier to install new default target methods that
should only apply to the native target.
For convenience if you'd like to test, I've also put this at:
git@github.com:palves/gdb.git inf_child_everywhere
Pedro Alves (3):
Make the go32-nat.c target inherit inf-child.c.
Make the windows-nat.c target inherit inf-child.c.
Make the nto-procfs.c target inherit inf-child.c.
gdb/go32-nat.c | 146 +++++++++++++++++++++---------------------------------
gdb/nto-procfs.c | 119 +++++++++++++++++---------------------------
gdb/windows-nat.c | 124 +++++++++++++++++-----------------------------
3 files changed, 149 insertions(+), 240 deletions(-)
--
1.7.11.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] Make the windows-nat.c target inherit inf-child.c.
2014-03-07 15:14 [PATCH 0/3] Make all native targets inherit inf-child.c Pedro Alves
@ 2014-03-07 15:14 ` Pedro Alves
2014-03-11 16:42 ` Pedro Alves
2014-03-07 15:15 ` [PATCH 3/3] Make the nto-procfs.c " Pedro Alves
2014-03-07 15:15 ` [PATCH 1/3] Make the go32-nat.c " Pedro Alves
2 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2014-03-07 15:14 UTC (permalink / raw)
To: gdb-patches
So that all native targets inherit a single "superclass".
Target methods that are set to or do the same as inf-child.c's are
removed.
Tested by cross building on Fedora 17, and then confirming that
./gdb.exe ./gdb.exe -ex "set pagination off" -ex "start"
under Wine still works.
gdb/
2014-03-07 Pedro Alves <palves@redhat.com>
* windows-nat.c: Include inf-child.h.
(windows_ops): Delete global.
(windows_open, windows_prepare_to_store, windows_can_run): Delete
methods.
(init_windows_ops): Delete function.
(windows_target): New function, based on init_windows_ops, but
inherit inf_child_target.
(_initialize_windows_nat): Use windows_target. Install x86
specific target methods here.
---
gdb/windows-nat.c | 124 ++++++++++++++++++++----------------------------------
1 file changed, 46 insertions(+), 78 deletions(-)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 6c45d0a..6e62dfe 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -66,6 +66,7 @@
#include "windows-nat.h"
#include "i386-nat.h"
#include "complaints.h"
+#include "inf-child.h"
#define AdjustTokenPrivileges dyn_AdjustTokenPrivileges
#define DebugActiveProcessStop dyn_DebugActiveProcessStop
@@ -93,8 +94,6 @@ static BOOL WINAPI (*GetCurrentConsoleFont) (HANDLE, BOOL,
CONSOLE_FONT_INFO *);
static COORD WINAPI (*GetConsoleFontSize) (HANDLE, DWORD);
-static struct target_ops windows_ops;
-
#undef STARTUPINFO
#undef CreateProcess
#undef GetModuleFileNameEx
@@ -1993,12 +1992,6 @@ windows_files_info (struct target_ops *ignore)
target_pid_to_str (inferior_ptid));
}
-static void
-windows_open (char *arg, int from_tty)
-{
- error (_("Use the \"run\" command to start a Unix child process."));
-}
-
/* Modify CreateProcess parameters for use of a new separate console.
Parameters are:
*FLAGS: DWORD parameter for general process creation flags.
@@ -2431,18 +2424,6 @@ windows_kill_inferior (struct target_ops *ops)
}
static void
-windows_prepare_to_store (struct target_ops *self, struct regcache *regcache)
-{
- /* Do nothing, since we can store individual regs. */
-}
-
-static int
-windows_can_run (struct target_ops *self)
-{
- return 1;
-}
-
-static void
windows_close (struct target_ops *self)
{
DEBUG_EVENTS (("gdb: windows_close, inferior_ptid=%d\n",
@@ -2553,62 +2534,35 @@ windows_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
return ptid_build (ptid_get_pid (inferior_ptid), 0, lwp);
}
-static void
-init_windows_ops (void)
-{
- windows_ops.to_shortname = "child";
- windows_ops.to_longname = "Win32 child process";
- windows_ops.to_doc = "Win32 child process (started by the \"run\" command).";
- windows_ops.to_open = windows_open;
- windows_ops.to_close = windows_close;
- windows_ops.to_attach = windows_attach;
- windows_ops.to_attach_no_wait = 1;
- windows_ops.to_detach = windows_detach;
- windows_ops.to_resume = windows_resume;
- windows_ops.to_wait = windows_wait;
- windows_ops.to_fetch_registers = windows_fetch_inferior_registers;
- windows_ops.to_store_registers = windows_store_inferior_registers;
- windows_ops.to_prepare_to_store = windows_prepare_to_store;
- windows_ops.to_xfer_partial = windows_xfer_partial;
- windows_ops.to_files_info = windows_files_info;
- windows_ops.to_insert_breakpoint = memory_insert_breakpoint;
- windows_ops.to_remove_breakpoint = memory_remove_breakpoint;
- windows_ops.to_terminal_init = terminal_init_inferior;
- windows_ops.to_terminal_inferior = terminal_inferior;
- windows_ops.to_terminal_ours_for_output = terminal_ours_for_output;
- windows_ops.to_terminal_ours = terminal_ours;
- windows_ops.to_terminal_save_ours = terminal_save_ours;
- windows_ops.to_terminal_info = child_terminal_info;
- windows_ops.to_kill = windows_kill_inferior;
- windows_ops.to_create_inferior = windows_create_inferior;
- windows_ops.to_mourn_inferior = windows_mourn_inferior;
- windows_ops.to_can_run = windows_can_run;
- windows_ops.to_thread_alive = windows_thread_alive;
- windows_ops.to_pid_to_str = windows_pid_to_str;
- windows_ops.to_stop = windows_stop;
- windows_ops.to_stratum = process_stratum;
- windows_ops.to_has_all_memory = default_child_has_all_memory;
- windows_ops.to_has_memory = default_child_has_memory;
- windows_ops.to_has_stack = default_child_has_stack;
- windows_ops.to_has_registers = default_child_has_registers;
- windows_ops.to_has_execution = default_child_has_execution;
- windows_ops.to_pid_to_exec_file = windows_pid_to_exec_file;
- windows_ops.to_get_ada_task_ptid = windows_get_ada_task_ptid;
- windows_ops.to_get_tib_address = windows_get_tib_address;
-
- i386_use_watchpoints (&windows_ops);
-
- i386_dr_low.set_control = cygwin_set_dr7;
- i386_dr_low.set_addr = cygwin_set_dr;
- i386_dr_low.get_addr = cygwin_get_dr;
- i386_dr_low.get_status = cygwin_get_dr6;
- i386_dr_low.get_control = cygwin_get_dr7;
-
- /* i386_dr_low.debug_register_length field is set by
- calling i386_set_debug_register_length function
- in processor windows specific native file. */
-
- windows_ops.to_magic = OPS_MAGIC;
+static struct target_ops *
+windows_target (void)
+{
+ struct target_ops *t = inf_child_target ();
+
+ t->to_shortname = "child";
+ t->to_longname = "Win32 child process";
+ t->to_doc = "Win32 child process (started by the \"run\" command).";
+ t->to_close = windows_close;
+ t->to_attach = windows_attach;
+ t->to_attach_no_wait = 1;
+ t->to_detach = windows_detach;
+ t->to_resume = windows_resume;
+ t->to_wait = windows_wait;
+ t->to_fetch_registers = windows_fetch_inferior_registers;
+ t->to_store_registers = windows_store_inferior_registers;
+ t->to_xfer_partial = windows_xfer_partial;
+ t->to_files_info = windows_files_info;
+ t->to_kill = windows_kill_inferior;
+ t->to_create_inferior = windows_create_inferior;
+ t->to_mourn_inferior = windows_mourn_inferior;
+ t->to_thread_alive = windows_thread_alive;
+ t->to_pid_to_str = windows_pid_to_str;
+ t->to_stop = windows_stop;
+ t->to_pid_to_exec_file = windows_pid_to_exec_file;
+ t->to_get_ada_task_ptid = windows_get_ada_task_ptid;
+ t->to_get_tib_address = windows_get_tib_address;
+
+ return t;
}
static void
@@ -2624,8 +2578,23 @@ void
_initialize_windows_nat (void)
{
struct cmd_list_element *c;
+ struct target_ops *t;
+
+ t = windows_target ();
+
+ i386_use_watchpoints (t);
+
+ i386_dr_low.set_control = cygwin_set_dr7;
+ i386_dr_low.set_addr = cygwin_set_dr;
+ i386_dr_low.get_addr = cygwin_get_dr;
+ i386_dr_low.get_status = cygwin_get_dr6;
+ i386_dr_low.get_control = cygwin_get_dr7;
+
+ /* i386_dr_low.debug_register_length field is set by
+ calling i386_set_debug_register_length function
+ in processor windows specific native file. */
- init_windows_ops ();
+ add_target (t);
#ifdef __CYGWIN__
cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);
@@ -2711,7 +2680,6 @@ Show whether to display kernel exceptions in child process."), NULL,
add_cmd ("selector", class_info, display_selectors,
_("Display selectors infos."),
&info_w32_cmdlist);
- add_target (&windows_ops);
deprecated_init_ui_hook = set_windows_aliases;
}
--
1.7.11.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] Make the nto-procfs.c target inherit inf-child.c.
2014-03-07 15:14 [PATCH 0/3] Make all native targets inherit inf-child.c Pedro Alves
2014-03-07 15:14 ` [PATCH 2/3] Make the windows-nat.c target " Pedro Alves
@ 2014-03-07 15:15 ` Pedro Alves
2014-03-07 15:15 ` [PATCH 1/3] Make the go32-nat.c " Pedro Alves
2 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-07 15:15 UTC (permalink / raw)
To: gdb-patches
So that all native targets inherit a single "superclass".
Target methods that are set to or do the same as inf-child.c's are
removed.
Not tested.
gdb/
2014-03-07 Pedro Alves <palves@redhat.com>
* nto-procfs.c: Include inf-child.h.
(procfs_ops): Delete global.
(procfs_can_run): Delete method.
(procfs_detach, procfs_mourn_inferior): Unpush the passed in
target pointer instead of referencing procfs_ops.
(procfs_prepare_to_store): Delete.
(init_procfs_ops): Delete function.
(procfs_target): New function, based on init_procfs_ops, but
inherit inf_child_target.
(_initialize_procfs): Use procfs_target.
---
gdb/nto-procfs.c | 119 +++++++++++++++++++++----------------------------------
1 file changed, 46 insertions(+), 73 deletions(-)
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index bdda7ce..c552a8e 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -42,13 +42,12 @@
#include "command.h"
#include "regcache.h"
#include "solib.h"
+#include "inf-child.h"
#define NULL_PID 0
#define _DEBUG_FLAG_TRACE (_DEBUG_FLAG_TRACE_EXEC|_DEBUG_FLAG_TRACE_RD|\
_DEBUG_FLAG_TRACE_WR|_DEBUG_FLAG_TRACE_MODIFY)
-static struct target_ops procfs_ops;
-
int ctl_fd;
static void (*ofunc) ();
@@ -57,10 +56,6 @@ static procfs_run run;
static void procfs_open (char *, int);
-static int procfs_can_run (struct target_ops *self);
-
-static void init_procfs_ops (void);
-
static ptid_t do_attach (ptid_t ptid);
static int procfs_can_use_hw_breakpoint (struct target_ops *self,
@@ -602,14 +597,6 @@ procfs_files_info (struct target_ops *ignore)
target_pid_to_str (inferior_ptid), nto_procfs_path);
}
-/* Mark our target-struct as eligible for stray "run" and "attach"
- commands. */
-static int
-procfs_can_run (struct target_ops *self)
-{
- return 1;
-}
-
/* Attach to process PID, then initialize for debugging it. */
static void
procfs_attach (struct target_ops *ops, char *args, int from_tty)
@@ -917,7 +904,7 @@ procfs_detach (struct target_ops *ops, const char *args, int from_tty)
inferior_ptid = null_ptid;
detach_inferior (pid);
init_thread_list ();
- unpush_target (&procfs_ops); /* Pop out of handling an inferior. */
+ unpush_target (ops); /* Pop out of handling an inferior. */
}
static int
@@ -1036,7 +1023,7 @@ procfs_mourn_inferior (struct target_ops *ops)
}
inferior_ptid = null_ptid;
init_thread_list ();
- unpush_target (&procfs_ops);
+ unpush_target (ops);
generic_mourn_inferior ();
}
@@ -1240,13 +1227,6 @@ procfs_kill_inferior (struct target_ops *ops)
target_mourn_inferior ();
}
-/* Store register REGNO, or all registers if REGNO == -1, from the contents
- of REGISTERS. */
-static void
-procfs_prepare_to_store (struct target_ops *self, struct regcache *regcache)
-{
-}
-
/* Fill buf with regset and return devctl cmd to do the setting. Return
-1 if we fail to get the regset. Store size of regset in regsize. */
static int
@@ -1390,56 +1370,48 @@ procfs_pid_to_str (struct target_ops *ops, ptid_t ptid)
return buf;
}
-static void
-init_procfs_ops (void)
+/* Create a nto-procfs target. */
+
+static struct target_ops *
+procfs_target (void)
{
- procfs_ops.to_shortname = "procfs";
- procfs_ops.to_longname = "QNX Neutrino procfs child process";
- procfs_ops.to_doc =
- "QNX Neutrino procfs child process (started by the \"run\" command).\n\
+ struct target_ops *t = inf_child_target ();
+
+ t->to_shortname = "procfs";
+ t->to_longname = "QNX Neutrino procfs child process";
+ t->to_doc
+ = "QNX Neutrino procfs child process (started by the \"run\" command).\n\
target procfs <node>";
- procfs_ops.to_open = procfs_open;
- procfs_ops.to_attach = procfs_attach;
- procfs_ops.to_post_attach = procfs_post_attach;
- procfs_ops.to_detach = procfs_detach;
- procfs_ops.to_resume = procfs_resume;
- procfs_ops.to_wait = procfs_wait;
- procfs_ops.to_fetch_registers = procfs_fetch_registers;
- procfs_ops.to_store_registers = procfs_store_registers;
- procfs_ops.to_prepare_to_store = procfs_prepare_to_store;
- procfs_ops.to_xfer_partial = procfs_xfer_partial;
- procfs_ops.to_files_info = procfs_files_info;
- procfs_ops.to_insert_breakpoint = procfs_insert_breakpoint;
- procfs_ops.to_remove_breakpoint = procfs_remove_breakpoint;
- procfs_ops.to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
- procfs_ops.to_insert_hw_breakpoint = procfs_insert_hw_breakpoint;
- procfs_ops.to_remove_hw_breakpoint = procfs_remove_hw_breakpoint;
- procfs_ops.to_insert_watchpoint = procfs_insert_hw_watchpoint;
- procfs_ops.to_remove_watchpoint = procfs_remove_hw_watchpoint;
- procfs_ops.to_stopped_by_watchpoint = procfs_stopped_by_watchpoint;
- procfs_ops.to_terminal_init = terminal_init_inferior;
- procfs_ops.to_terminal_inferior = terminal_inferior;
- procfs_ops.to_terminal_ours_for_output = terminal_ours_for_output;
- procfs_ops.to_terminal_ours = terminal_ours;
- procfs_ops.to_terminal_info = child_terminal_info;
- procfs_ops.to_kill = procfs_kill_inferior;
- procfs_ops.to_create_inferior = procfs_create_inferior;
- procfs_ops.to_mourn_inferior = procfs_mourn_inferior;
- procfs_ops.to_can_run = procfs_can_run;
- procfs_ops.to_pass_signals = procfs_pass_signals;
- procfs_ops.to_thread_alive = procfs_thread_alive;
- procfs_ops.to_find_new_threads = procfs_find_new_threads;
- procfs_ops.to_pid_to_str = procfs_pid_to_str;
- procfs_ops.to_stop = procfs_stop;
- procfs_ops.to_stratum = process_stratum;
- procfs_ops.to_has_all_memory = default_child_has_all_memory;
- procfs_ops.to_has_memory = default_child_has_memory;
- procfs_ops.to_has_stack = default_child_has_stack;
- procfs_ops.to_has_registers = default_child_has_registers;
- procfs_ops.to_has_execution = default_child_has_execution;
- procfs_ops.to_magic = OPS_MAGIC;
- procfs_ops.to_have_continuable_watchpoint = 1;
- procfs_ops.to_extra_thread_info = nto_extra_thread_info;
+ t->to_open = procfs_open;
+ t->to_attach = procfs_attach;
+ t->to_post_attach = procfs_post_attach;
+ t->to_detach = procfs_detach;
+ t->to_resume = procfs_resume;
+ t->to_wait = procfs_wait;
+ t->to_fetch_registers = procfs_fetch_registers;
+ t->to_store_registers = procfs_store_registers;
+ t->to_xfer_partial = procfs_xfer_partial;
+ t->to_files_info = procfs_files_info;
+ t->to_insert_breakpoint = procfs_insert_breakpoint;
+ t->to_remove_breakpoint = procfs_remove_breakpoint;
+ t->to_can_use_hw_breakpoint = procfs_can_use_hw_breakpoint;
+ t->to_insert_hw_breakpoint = procfs_insert_hw_breakpoint;
+ t->to_remove_hw_breakpoint = procfs_remove_hw_breakpoint;
+ t->to_insert_watchpoint = procfs_insert_hw_watchpoint;
+ t->to_remove_watchpoint = procfs_remove_hw_watchpoint;
+ t->to_stopped_by_watchpoint = procfs_stopped_by_watchpoint;
+ t->to_kill = procfs_kill_inferior;
+ t->to_create_inferior = procfs_create_inferior;
+ t->to_mourn_inferior = procfs_mourn_inferior;
+ t->to_pass_signals = procfs_pass_signals;
+ t->to_thread_alive = procfs_thread_alive;
+ t->to_find_new_threads = procfs_find_new_threads;
+ t->to_pid_to_str = procfs_pid_to_str;
+ t->to_stop = procfs_stop;
+ t->to_have_continuable_watchpoint = 1;
+ t->to_extra_thread_info = nto_extra_thread_info;
+
+ return t;
}
#define OSTYPE_NTO 1
@@ -1448,9 +1420,10 @@ void
_initialize_procfs (void)
{
sigset_t set;
+ struct target_ops *t;
- init_procfs_ops ();
- add_target (&procfs_ops);
+ t = procfs_target ();
+ add_target (t);
/* We use SIGUSR1 to gain control after we block waiting for a process.
We use sigwaitevent to wait. */
--
1.7.11.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] Make the go32-nat.c target inherit inf-child.c.
2014-03-07 15:14 [PATCH 0/3] Make all native targets inherit inf-child.c Pedro Alves
2014-03-07 15:14 ` [PATCH 2/3] Make the windows-nat.c target " Pedro Alves
2014-03-07 15:15 ` [PATCH 3/3] Make the nto-procfs.c " Pedro Alves
@ 2014-03-07 15:15 ` Pedro Alves
2014-03-07 15:32 ` Eli Zaretskii
2 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2014-03-07 15:15 UTC (permalink / raw)
To: gdb-patches
So that all native targets inherit a single "superclass".
Target methods that are set to or do the same as inf-child.c's are
removed.
Tested by cross building on Fedora 17.
gdb/
2014-03-07 Pedro Alves <palves@redhat.com>
* go32-nat.c: Include inf-child.h.
(go32_ops): Delete global.
(go32_close, go32_detach, go32_prepare_to_store, go32_can_run):
Delete methods.
(go32_create_inferior): Push the passed in target pointer instead
of referencing go32_ops.
(init_go32_ops): Delete function. Moved parts to _initialize_go32_nat.
(go32_target): New function, based on init_go32_ops, but inherit
inf_child_target.
(_initialize_go32_nat): Use go32_target. Move parts of
init_go32_ops here.
---
gdb/go32-nat.c | 146 ++++++++++++++++++++++-----------------------------------
1 file changed, 57 insertions(+), 89 deletions(-)
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 20ebee7..08d803c 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -102,6 +102,7 @@
#include <string.h>
#include "top.h"
#include "cli/cli-utils.h"
+#include "inf-child.h"
#include <stdio.h> /* might be required for __DJGPP_MINOR__ */
#include <stdlib.h>
@@ -236,8 +237,6 @@ static int dr_ref_count[4];
static int prog_has_started = 0;
static void go32_mourn_inferior (struct target_ops *ops);
-static struct target_ops go32_ops;
-
#define r_ofs(x) (offsetof(TSS,x))
static struct
@@ -346,11 +345,6 @@ go32_open (char *name, int from_tty)
}
static void
-go32_close (struct target_ops *self)
-{
-}
-
-static void
go32_attach (struct target_ops *ops, char *args, int from_tty)
{
error (_("\
@@ -358,11 +352,6 @@ You cannot attach to a running program on this platform.\n\
Use the `run' command to run DJGPP programs."));
}
-static void
-go32_detach (struct target_ops *ops, const char *args, int from_tty)
-{
-}
-
static int resume_is_step;
static int resume_signal = -1;
@@ -572,12 +561,6 @@ go32_store_registers (struct target_ops *ops,
}
}
-static void
-go32_prepare_to_store (struct target_ops *self, struct regcache *regcache)
-{
-}
-
-
/* Const-correct version of DJGPP's write_child, which unfortunately
takes a non-const buffer pointer. */
@@ -733,7 +716,7 @@ go32_create_inferior (struct target_ops *ops, char *exec_file,
inf = current_inferior ();
inferior_appeared (inf, SOME_PID);
- push_target (&go32_ops);
+ push_target (ops);
add_thread_silent (inferior_ptid);
@@ -771,12 +754,6 @@ go32_mourn_inferior (struct target_ops *ops)
generic_mourn_inferior ();
}
-static int
-go32_can_run (struct target_ops *self)
-{
- return 1;
-}
-
/* Hardware watchpoint support. */
#define D_REGS edi.dr
@@ -976,68 +953,37 @@ go32_pid_to_str (struct target_ops *ops, ptid_t ptid)
return normal_pid_to_str (ptid);
}
-static void
-init_go32_ops (void)
-{
- go32_ops.to_shortname = "djgpp";
- go32_ops.to_longname = "djgpp target process";
- go32_ops.to_doc =
- "Program loaded by djgpp, when gdb is used as an external debugger";
- go32_ops.to_open = go32_open;
- go32_ops.to_close = go32_close;
- go32_ops.to_attach = go32_attach;
- go32_ops.to_detach = go32_detach;
- go32_ops.to_resume = go32_resume;
- go32_ops.to_wait = go32_wait;
- go32_ops.to_fetch_registers = go32_fetch_registers;
- go32_ops.to_store_registers = go32_store_registers;
- go32_ops.to_prepare_to_store = go32_prepare_to_store;
- go32_ops.to_xfer_partial = go32_xfer_partial;
- go32_ops.to_files_info = go32_files_info;
- go32_ops.to_insert_breakpoint = memory_insert_breakpoint;
- go32_ops.to_remove_breakpoint = memory_remove_breakpoint;
- go32_ops.to_terminal_init = go32_terminal_init;
- go32_ops.to_terminal_inferior = go32_terminal_inferior;
- go32_ops.to_terminal_ours_for_output = go32_terminal_ours;
- go32_ops.to_terminal_ours = go32_terminal_ours;
- go32_ops.to_terminal_info = go32_terminal_info;
- go32_ops.to_kill = go32_kill_inferior;
- go32_ops.to_create_inferior = go32_create_inferior;
- go32_ops.to_mourn_inferior = go32_mourn_inferior;
- go32_ops.to_can_run = go32_can_run;
- go32_ops.to_thread_alive = go32_thread_alive;
- go32_ops.to_pid_to_str = go32_pid_to_str;
- go32_ops.to_stratum = process_stratum;
- go32_ops.to_has_all_memory = default_child_has_all_memory;
- go32_ops.to_has_memory = default_child_has_memory;
- go32_ops.to_has_stack = default_child_has_stack;
- go32_ops.to_has_registers = default_child_has_registers;
- go32_ops.to_has_execution = default_child_has_execution;
-
- i386_use_watchpoints (&go32_ops);
-
-
- i386_dr_low.set_control = go32_set_dr7;
- i386_dr_low.set_addr = go32_set_dr;
- i386_dr_low.get_status = go32_get_dr6;
- i386_dr_low.get_control = go32_get_dr7;
- i386_dr_low.get_addr = go32_get_dr;
- i386_set_debug_register_length (4);
-
- go32_ops.to_magic = OPS_MAGIC;
-
- /* Initialize child's cwd as empty to be initialized when starting
- the child. */
- *child_cwd = 0;
-
- /* Initialize child's command line storage. */
- if (redir_debug_init (&child_cmd) == -1)
- internal_error (__FILE__, __LINE__,
- _("Cannot allocate redirection storage: "
- "not enough memory.\n"));
-
- /* We are always processing GCC-compiled programs. */
- processing_gcc_compilation = 2;
+/* Create a go32 target. */
+
+static struct target_ops *
+go32_target (void)
+{
+ struct target_ops *t = inf_child_target ();
+
+ t->to_shortname = "djgpp";
+ t->to_longname = "djgpp target process";
+ t->to_doc
+ = "Program loaded by djgpp, when gdb is used as an external debugger";
+ t->to_open = go32_open;
+ t->to_attach = go32_attach;
+ t->to_resume = go32_resume;
+ t->to_wait = go32_wait;
+ t->to_fetch_registers = go32_fetch_registers;
+ t->to_store_registers = go32_store_registers;
+ t->to_xfer_partial = go32_xfer_partial;
+ t->to_files_info = go32_files_info;
+ t->to_terminal_init = go32_terminal_init;
+ t->to_terminal_inferior = go32_terminal_inferior;
+ t->to_terminal_ours_for_output = go32_terminal_ours;
+ t->to_terminal_ours = go32_terminal_ours;
+ t->to_terminal_info = go32_terminal_info;
+ t->to_kill = go32_kill_inferior;
+ t->to_create_inferior = go32_create_inferior;
+ t->to_mourn_inferior = go32_mourn_inferior;
+ t->to_thread_alive = go32_thread_alive;
+ t->to_pid_to_str = go32_pid_to_str;
+
+ return t;
}
/* Return the current DOS codepage number. */
@@ -2127,8 +2073,30 @@ extern initialize_file_ftype _initialize_go32_nat;
void
_initialize_go32_nat (void)
{
- init_go32_ops ();
- add_target (&go32_ops);
+ struct target_ops *t = go32_target ();
+
+ i386_dr_low.set_control = go32_set_dr7;
+ i386_dr_low.set_addr = go32_set_dr;
+ i386_dr_low.get_status = go32_get_dr6;
+ i386_dr_low.get_control = go32_get_dr7;
+ i386_dr_low.get_addr = go32_get_dr;
+ i386_set_debug_register_length (4);
+
+ i386_use_watchpoints (t);
+ add_target (t);
+
+ /* Initialize child's cwd as empty to be initialized when starting
+ the child. */
+ *child_cwd = 0;
+
+ /* Initialize child's command line storage. */
+ if (redir_debug_init (&child_cmd) == -1)
+ internal_error (__FILE__, __LINE__,
+ _("Cannot allocate redirection storage: "
+ "not enough memory.\n"));
+
+ /* We are always processing GCC-compiled programs. */
+ processing_gcc_compilation = 2;
add_prefix_cmd ("dos", class_info, go32_info_dos_command, _("\
Print information specific to DJGPP (aka MS-DOS) debugging."),
--
1.7.11.7
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] Make the go32-nat.c target inherit inf-child.c.
2014-03-07 15:15 ` [PATCH 1/3] Make the go32-nat.c " Pedro Alves
@ 2014-03-07 15:32 ` Eli Zaretskii
2014-03-07 15:38 ` Pedro Alves
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2014-03-07 15:32 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> From: Pedro Alves <palves@redhat.com>
> Date: Fri, 7 Mar 2014 15:14:50 +0000
>
> So that all native targets inherit a single "superclass".
>
> Target methods that are set to or do the same as inf-child.c's are
> removed.
>
> Tested by cross building on Fedora 17.
>
> gdb/
> 2014-03-07 Pedro Alves <palves@redhat.com>
>
> * go32-nat.c: Include inf-child.h.
> (go32_ops): Delete global.
> (go32_close, go32_detach, go32_prepare_to_store, go32_can_run):
> Delete methods.
> (go32_create_inferior): Push the passed in target pointer instead
> of referencing go32_ops.
> (init_go32_ops): Delete function. Moved parts to _initialize_go32_nat.
> (go32_target): New function, based on init_go32_ops, but inherit
> inf_child_target.
> (_initialize_go32_nat): Use go32_target. Move parts of
> init_go32_ops here.
This is OK, thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] Make the go32-nat.c target inherit inf-child.c.
2014-03-07 15:32 ` Eli Zaretskii
@ 2014-03-07 15:38 ` Pedro Alves
0 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-07 15:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On 03/07/2014 03:32 PM, Eli Zaretskii wrote:
>> gdb/
>> 2014-03-07 Pedro Alves <palves@redhat.com>
>>
>> * go32-nat.c: Include inf-child.h.
>> (go32_ops): Delete global.
>> (go32_close, go32_detach, go32_prepare_to_store, go32_can_run):
>> Delete methods.
>> (go32_create_inferior): Push the passed in target pointer instead
>> of referencing go32_ops.
>> (init_go32_ops): Delete function. Moved parts to _initialize_go32_nat.
>> (go32_target): New function, based on init_go32_ops, but inherit
>> inf_child_target.
>> (_initialize_go32_nat): Use go32_target. Move parts of
>> init_go32_ops here.
>
> This is OK, thanks.
Thanks, pushed.
--
Pedro Alves
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] Make the windows-nat.c target inherit inf-child.c.
2014-03-07 15:14 ` [PATCH 2/3] Make the windows-nat.c target " Pedro Alves
@ 2014-03-11 16:42 ` Pedro Alves
2014-03-12 9:07 ` Joel Brobecker
0 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2014-03-11 16:42 UTC (permalink / raw)
Cc: gdb-patches
Hi!
I wonder whether anyone with easier Windows than me wants
to run this through the test suite? Otherwise, with the
little Wine test I did, I'm pretty sure I didn't break
things too much. :-)
Thanks,
--
Pedro Alves
On 03/07/2014 03:14 PM, Pedro Alves wrote:
> So that all native targets inherit a single "superclass".
>
> Target methods that are set to or do the same as inf-child.c's are
> removed.
>
> Tested by cross building on Fedora 17, and then confirming that
>
> ./gdb.exe ./gdb.exe -ex "set pagination off" -ex "start"
>
> under Wine still works.
>
> gdb/
> 2014-03-07 Pedro Alves <palves@redhat.com>
>
> * windows-nat.c: Include inf-child.h.
> (windows_ops): Delete global.
> (windows_open, windows_prepare_to_store, windows_can_run): Delete
> methods.
> (init_windows_ops): Delete function.
> (windows_target): New function, based on init_windows_ops, but
> inherit inf_child_target.
> (_initialize_windows_nat): Use windows_target. Install x86
> specific target methods here.
> ---
> gdb/windows-nat.c | 124 ++++++++++++++++++++----------------------------------
> 1 file changed, 46 insertions(+), 78 deletions(-)
>
> diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
> index 6c45d0a..6e62dfe 100644
> --- a/gdb/windows-nat.c
> +++ b/gdb/windows-nat.c
> @@ -66,6 +66,7 @@
> #include "windows-nat.h"
> #include "i386-nat.h"
> #include "complaints.h"
> +#include "inf-child.h"
>
> #define AdjustTokenPrivileges dyn_AdjustTokenPrivileges
> #define DebugActiveProcessStop dyn_DebugActiveProcessStop
> @@ -93,8 +94,6 @@ static BOOL WINAPI (*GetCurrentConsoleFont) (HANDLE, BOOL,
> CONSOLE_FONT_INFO *);
> static COORD WINAPI (*GetConsoleFontSize) (HANDLE, DWORD);
>
> -static struct target_ops windows_ops;
> -
> #undef STARTUPINFO
> #undef CreateProcess
> #undef GetModuleFileNameEx
> @@ -1993,12 +1992,6 @@ windows_files_info (struct target_ops *ignore)
> target_pid_to_str (inferior_ptid));
> }
>
> -static void
> -windows_open (char *arg, int from_tty)
> -{
> - error (_("Use the \"run\" command to start a Unix child process."));
> -}
> -
> /* Modify CreateProcess parameters for use of a new separate console.
> Parameters are:
> *FLAGS: DWORD parameter for general process creation flags.
> @@ -2431,18 +2424,6 @@ windows_kill_inferior (struct target_ops *ops)
> }
>
> static void
> -windows_prepare_to_store (struct target_ops *self, struct regcache *regcache)
> -{
> - /* Do nothing, since we can store individual regs. */
> -}
> -
> -static int
> -windows_can_run (struct target_ops *self)
> -{
> - return 1;
> -}
> -
> -static void
> windows_close (struct target_ops *self)
> {
> DEBUG_EVENTS (("gdb: windows_close, inferior_ptid=%d\n",
> @@ -2553,62 +2534,35 @@ windows_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
> return ptid_build (ptid_get_pid (inferior_ptid), 0, lwp);
> }
>
> -static void
> -init_windows_ops (void)
> -{
> - windows_ops.to_shortname = "child";
> - windows_ops.to_longname = "Win32 child process";
> - windows_ops.to_doc = "Win32 child process (started by the \"run\" command).";
> - windows_ops.to_open = windows_open;
> - windows_ops.to_close = windows_close;
> - windows_ops.to_attach = windows_attach;
> - windows_ops.to_attach_no_wait = 1;
> - windows_ops.to_detach = windows_detach;
> - windows_ops.to_resume = windows_resume;
> - windows_ops.to_wait = windows_wait;
> - windows_ops.to_fetch_registers = windows_fetch_inferior_registers;
> - windows_ops.to_store_registers = windows_store_inferior_registers;
> - windows_ops.to_prepare_to_store = windows_prepare_to_store;
> - windows_ops.to_xfer_partial = windows_xfer_partial;
> - windows_ops.to_files_info = windows_files_info;
> - windows_ops.to_insert_breakpoint = memory_insert_breakpoint;
> - windows_ops.to_remove_breakpoint = memory_remove_breakpoint;
> - windows_ops.to_terminal_init = terminal_init_inferior;
> - windows_ops.to_terminal_inferior = terminal_inferior;
> - windows_ops.to_terminal_ours_for_output = terminal_ours_for_output;
> - windows_ops.to_terminal_ours = terminal_ours;
> - windows_ops.to_terminal_save_ours = terminal_save_ours;
> - windows_ops.to_terminal_info = child_terminal_info;
> - windows_ops.to_kill = windows_kill_inferior;
> - windows_ops.to_create_inferior = windows_create_inferior;
> - windows_ops.to_mourn_inferior = windows_mourn_inferior;
> - windows_ops.to_can_run = windows_can_run;
> - windows_ops.to_thread_alive = windows_thread_alive;
> - windows_ops.to_pid_to_str = windows_pid_to_str;
> - windows_ops.to_stop = windows_stop;
> - windows_ops.to_stratum = process_stratum;
> - windows_ops.to_has_all_memory = default_child_has_all_memory;
> - windows_ops.to_has_memory = default_child_has_memory;
> - windows_ops.to_has_stack = default_child_has_stack;
> - windows_ops.to_has_registers = default_child_has_registers;
> - windows_ops.to_has_execution = default_child_has_execution;
> - windows_ops.to_pid_to_exec_file = windows_pid_to_exec_file;
> - windows_ops.to_get_ada_task_ptid = windows_get_ada_task_ptid;
> - windows_ops.to_get_tib_address = windows_get_tib_address;
> -
> - i386_use_watchpoints (&windows_ops);
> -
> - i386_dr_low.set_control = cygwin_set_dr7;
> - i386_dr_low.set_addr = cygwin_set_dr;
> - i386_dr_low.get_addr = cygwin_get_dr;
> - i386_dr_low.get_status = cygwin_get_dr6;
> - i386_dr_low.get_control = cygwin_get_dr7;
> -
> - /* i386_dr_low.debug_register_length field is set by
> - calling i386_set_debug_register_length function
> - in processor windows specific native file. */
> -
> - windows_ops.to_magic = OPS_MAGIC;
> +static struct target_ops *
> +windows_target (void)
> +{
> + struct target_ops *t = inf_child_target ();
> +
> + t->to_shortname = "child";
> + t->to_longname = "Win32 child process";
> + t->to_doc = "Win32 child process (started by the \"run\" command).";
> + t->to_close = windows_close;
> + t->to_attach = windows_attach;
> + t->to_attach_no_wait = 1;
> + t->to_detach = windows_detach;
> + t->to_resume = windows_resume;
> + t->to_wait = windows_wait;
> + t->to_fetch_registers = windows_fetch_inferior_registers;
> + t->to_store_registers = windows_store_inferior_registers;
> + t->to_xfer_partial = windows_xfer_partial;
> + t->to_files_info = windows_files_info;
> + t->to_kill = windows_kill_inferior;
> + t->to_create_inferior = windows_create_inferior;
> + t->to_mourn_inferior = windows_mourn_inferior;
> + t->to_thread_alive = windows_thread_alive;
> + t->to_pid_to_str = windows_pid_to_str;
> + t->to_stop = windows_stop;
> + t->to_pid_to_exec_file = windows_pid_to_exec_file;
> + t->to_get_ada_task_ptid = windows_get_ada_task_ptid;
> + t->to_get_tib_address = windows_get_tib_address;
> +
> + return t;
> }
>
> static void
> @@ -2624,8 +2578,23 @@ void
> _initialize_windows_nat (void)
> {
> struct cmd_list_element *c;
> + struct target_ops *t;
> +
> + t = windows_target ();
> +
> + i386_use_watchpoints (t);
> +
> + i386_dr_low.set_control = cygwin_set_dr7;
> + i386_dr_low.set_addr = cygwin_set_dr;
> + i386_dr_low.get_addr = cygwin_get_dr;
> + i386_dr_low.get_status = cygwin_get_dr6;
> + i386_dr_low.get_control = cygwin_get_dr7;
> +
> + /* i386_dr_low.debug_register_length field is set by
> + calling i386_set_debug_register_length function
> + in processor windows specific native file. */
>
> - init_windows_ops ();
> + add_target (t);
>
> #ifdef __CYGWIN__
> cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);
> @@ -2711,7 +2680,6 @@ Show whether to display kernel exceptions in child process."), NULL,
> add_cmd ("selector", class_info, display_selectors,
> _("Display selectors infos."),
> &info_w32_cmdlist);
> - add_target (&windows_ops);
> deprecated_init_ui_hook = set_windows_aliases;
> }
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] Make the windows-nat.c target inherit inf-child.c.
2014-03-11 16:42 ` Pedro Alves
@ 2014-03-12 9:07 ` Joel Brobecker
2014-03-12 11:29 ` Pedro Alves
0 siblings, 1 reply; 9+ messages in thread
From: Joel Brobecker @ 2014-03-12 9:07 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Hi Pedro,
> I wonder whether anyone with easier Windows than me wants
> to run this through the test suite? Otherwise, with the
> little Wine test I did, I'm pretty sure I didn't break
> things too much. :-)
I ran this patch against our testsuite on Windows, and found
no regression. I think it's good :-)...
--
Joel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] Make the windows-nat.c target inherit inf-child.c.
2014-03-12 9:07 ` Joel Brobecker
@ 2014-03-12 11:29 ` Pedro Alves
0 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-12 11:29 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On 03/12/2014 09:06 AM, Joel Brobecker wrote:
> Hi Pedro,
>
>> I wonder whether anyone with easier Windows than me wants
>> to run this through the test suite? Otherwise, with the
>> little Wine test I did, I'm pretty sure I didn't break
>> things too much. :-)
>
> I ran this patch against our testsuite on Windows, and found
> no regression. I think it's good :-)...
Thank you! This series is now all in.
--
Pedro Alves
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-03-12 11:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 15:14 [PATCH 0/3] Make all native targets inherit inf-child.c Pedro Alves
2014-03-07 15:14 ` [PATCH 2/3] Make the windows-nat.c target " Pedro Alves
2014-03-11 16:42 ` Pedro Alves
2014-03-12 9:07 ` Joel Brobecker
2014-03-12 11:29 ` Pedro Alves
2014-03-07 15:15 ` [PATCH 3/3] Make the nto-procfs.c " Pedro Alves
2014-03-07 15:15 ` [PATCH 1/3] Make the go32-nat.c " Pedro Alves
2014-03-07 15:32 ` Eli Zaretskii
2014-03-07 15:38 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox