From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17781 invoked by alias); 7 Mar 2014 15:14:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 17609 invoked by uid 89); 7 Mar 2014 15:14:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD,UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Mar 2014 15:14:57 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s27FEtB2030466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Mar 2014 10:14:56 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s27FEqVG026442 for ; Fri, 7 Mar 2014 10:14:55 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/3] Make the windows-nat.c target inherit inf-child.c. Date: Fri, 07 Mar 2014 15:14:00 -0000 Message-Id: <1394205292-19784-3-git-send-email-palves@redhat.com> In-Reply-To: <1394205292-19784-1-git-send-email-palves@redhat.com> References: <1394205292-19784-1-git-send-email-palves@redhat.com> X-SW-Source: 2014-03/txt/msg00190.txt.bz2 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 * 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