1 /* Default child (native) target interface, for GDB when running under 2 Unix. 3 4 Copyright (C) 1988-1996, 1998-2002, 2004-2005, 2007-2012 Free 5 Software Foundation, Inc. 6 7 This file is part of GDB. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 21 22 #include "defs.h" 23 #include "regcache.h" 24 #include "memattr.h" 25 #include "symtab.h" 26 #include "target.h" 27 #include "inferior.h" 28 #include "gdb_string.h" 29 #include "inf-child.h" 30 31 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this 32 for all registers. */ 33 34 static void 35 inf_child_fetch_inferior_registers (struct target_ops *ops, 36 struct regcache *regcache, int regnum) 37 { 38 if (regnum == -1) 39 { 40 for (regnum = 0; 41 regnum < gdbarch_num_regs (get_regcache_arch (regcache)); 42 regnum++) 43 regcache_raw_supply (regcache, regnum, NULL); 44 } 45 else 46 regcache_raw_supply (regcache, regnum, NULL); 47 } 48 49 /* Store register REGNUM back into the inferior. If REGNUM is -1, do 50 this for all registers (including the floating point registers). */ 51 52 static void 53 inf_child_store_inferior_registers (struct target_ops *ops, 54 struct regcache *regcache, int regnum) 55 { 56 } 57 58 static void 59 inf_child_post_attach (int pid) 60 { 61 /* This version of Unix doesn't require a meaningful "post attach" 62 operation by a debugger. */ 63 } 64 65 /* Get ready to modify the registers array. On machines which store 66 individual registers, this doesn't need to do anything. On 67 machines which store all the registers in one fell swoop, this 68 makes sure that registers contains all the registers from the 69 program being debugged. */ 70 71 static void 72 inf_child_prepare_to_store (struct regcache *regcache) 73 { 74 } 75 76 static void 77 inf_child_open (char *arg, int from_tty) 78 { 79 error (_("Use the \"run\" command to start a Unix child process.")); 80 } 81 82 static void 83 inf_child_post_startup_inferior (ptid_t ptid) 84 { 85 /* This version of Unix doesn't require a meaningful "post startup 86 inferior" operation by a debugger. */ 87 } 88 89 static int 90 inf_child_follow_fork (struct target_ops *ops, int follow_child) 91 { 92 /* This version of Unix doesn't support following fork or vfork 93 events. */ 94 return 0; 95 } 96 97 static int 98 inf_child_can_run (void) 99 { 100 return 1; 101 } 102 103 static char * 104 inf_child_pid_to_exec_file (int pid) 105 { 106 /* This version of Unix doesn't support translation of a process ID 107 to the filename of the executable file. */ 108 return NULL; 109 } 110 111 struct target_ops * 112 inf_child_target (void) 113 { 114 struct target_ops *t = XZALLOC (struct target_ops); 115 116 t->to_shortname = "child"; 117 t->to_longname = "Unix child process"; 118 t->to_doc = "Unix child process (started by the \"run\" command)."; 119 t->to_open = inf_child_open; 120 t->to_post_attach = inf_child_post_attach; 121 t->to_fetch_registers = inf_child_fetch_inferior_registers; 122 t->to_store_registers = inf_child_store_inferior_registers; 123 t->to_prepare_to_store = inf_child_prepare_to_store; 124 t->to_insert_breakpoint = memory_insert_breakpoint; 125 t->to_remove_breakpoint = memory_remove_breakpoint; 126 t->to_terminal_init = terminal_init_inferior; 127 t->to_terminal_inferior = terminal_inferior; 128 t->to_terminal_ours_for_output = terminal_ours_for_output; 129 t->to_terminal_save_ours = terminal_save_ours; 130 t->to_terminal_ours = terminal_ours; 131 t->to_terminal_info = child_terminal_info; 132 t->to_post_startup_inferior = inf_child_post_startup_inferior; 133 t->to_follow_fork = inf_child_follow_fork; 134 t->to_can_run = inf_child_can_run; 135 t->to_pid_to_exec_file = inf_child_pid_to_exec_file; 136 t->to_stratum = process_stratum; 137 t->to_has_all_memory = default_child_has_all_memory; 138 t->to_has_memory = default_child_has_memory; 139 t->to_has_stack = default_child_has_stack; 140 t->to_has_registers = default_child_has_registers; 141 t->to_has_execution = default_child_has_execution; 142 t->to_magic = OPS_MAGIC; 143 return t; 144 } 145