| 1 | /* Variables that describe the inferior process running under GDB: |
| 2 | Where it is, why it stopped, and how to step it. |
| 3 | Copyright 1986, 1989, 1992 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GDB. |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 20 | |
| 21 | #if !defined (INFERIOR_H) |
| 22 | #define INFERIOR_H 1 |
| 23 | |
| 24 | /* For symtab_and_line */ |
| 25 | #include "symtab.h" |
| 26 | |
| 27 | /* For bpstat. */ |
| 28 | #include "breakpoint.h" |
| 29 | |
| 30 | /* For FRAME_ADDR. */ |
| 31 | #include "frame.h" |
| 32 | |
| 33 | /* |
| 34 | * Structure in which to save the status of the inferior. Save |
| 35 | * through "save_inferior_status", restore through |
| 36 | * "restore_inferior_status". |
| 37 | * This pair of routines should be called around any transfer of |
| 38 | * control to the inferior which you don't want showing up in your |
| 39 | * control variables. |
| 40 | */ |
| 41 | struct inferior_status { |
| 42 | int pc_changed; |
| 43 | int stop_signal; |
| 44 | int stop_pc; |
| 45 | FRAME_ADDR stop_frame_address; |
| 46 | bpstat stop_bpstat; |
| 47 | int stop_step; |
| 48 | int stop_stack_dummy; |
| 49 | int stopped_by_random_signal; |
| 50 | int trap_expected; |
| 51 | CORE_ADDR step_range_start; |
| 52 | CORE_ADDR step_range_end; |
| 53 | FRAME_ADDR step_frame_address; |
| 54 | int step_over_calls; |
| 55 | CORE_ADDR step_resume_break_address; |
| 56 | int stop_after_trap; |
| 57 | int stop_soon_quietly; |
| 58 | FRAME_ADDR selected_frame_address; |
| 59 | int selected_level; |
| 60 | char stop_registers[REGISTER_BYTES]; |
| 61 | int breakpoint_proceeded; |
| 62 | int restore_stack_info; |
| 63 | int proceed_to_finish; |
| 64 | }; |
| 65 | |
| 66 | extern void |
| 67 | save_inferior_status PARAMS ((struct inferior_status *, int)); |
| 68 | |
| 69 | extern void |
| 70 | restore_inferior_status PARAMS ((struct inferior_status *)); |
| 71 | |
| 72 | /* File name for default use for standard in/out in the inferior. */ |
| 73 | |
| 74 | extern char *inferior_io_terminal; |
| 75 | |
| 76 | /* Pid of our debugged inferior, or 0 if no inferior now. */ |
| 77 | |
| 78 | extern int inferior_pid; |
| 79 | |
| 80 | /* Character array containing an image of the inferior programs' registers. */ |
| 81 | |
| 82 | extern char registers[]; |
| 83 | |
| 84 | /* Array of validity bits (one per register). Nonzero at position XXX_REGNUM |
| 85 | means that `registers' contains a valid copy of inferior register XXX. */ |
| 86 | |
| 87 | extern char register_valid[NUM_REGS]; |
| 88 | |
| 89 | extern void |
| 90 | clear_proceed_status PARAMS ((void)); |
| 91 | |
| 92 | extern void |
| 93 | proceed PARAMS ((CORE_ADDR, int, int)); |
| 94 | |
| 95 | extern void |
| 96 | kill_inferior PARAMS ((void)); |
| 97 | |
| 98 | extern void |
| 99 | generic_mourn_inferior PARAMS ((void)); |
| 100 | |
| 101 | extern void |
| 102 | terminal_ours PARAMS ((void)); |
| 103 | |
| 104 | extern void |
| 105 | run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES])); |
| 106 | |
| 107 | extern CORE_ADDR |
| 108 | read_pc PARAMS ((void)); |
| 109 | |
| 110 | extern void |
| 111 | write_pc PARAMS ((CORE_ADDR)); |
| 112 | |
| 113 | extern void |
| 114 | wait_for_inferior PARAMS ((void)); |
| 115 | |
| 116 | extern void |
| 117 | init_wait_for_inferior PARAMS ((void)); |
| 118 | |
| 119 | extern void |
| 120 | close_exec_file PARAMS ((void)); |
| 121 | |
| 122 | extern void |
| 123 | reopen_exec_file PARAMS ((void)); |
| 124 | |
| 125 | /* The `resume' routine should only be called in special circumstances. |
| 126 | Normally, use `proceed', which handles a lot of bookkeeping. */ |
| 127 | extern void |
| 128 | resume PARAMS ((int, int)); |
| 129 | |
| 130 | /* From misc files */ |
| 131 | |
| 132 | extern void |
| 133 | store_inferior_registers PARAMS ((int)); |
| 134 | |
| 135 | extern void |
| 136 | fetch_inferior_registers PARAMS ((int)); |
| 137 | |
| 138 | extern void |
| 139 | solib_create_inferior_hook PARAMS ((void)); |
| 140 | |
| 141 | extern void |
| 142 | child_terminal_info PARAMS ((char *, int)); |
| 143 | |
| 144 | extern void |
| 145 | term_info PARAMS ((char *, int)); |
| 146 | |
| 147 | extern void |
| 148 | terminal_ours_for_output PARAMS ((void)); |
| 149 | |
| 150 | extern void |
| 151 | terminal_inferior PARAMS ((void)); |
| 152 | |
| 153 | extern void |
| 154 | terminal_init_inferior PARAMS ((void)); |
| 155 | |
| 156 | /* From infptrace.c */ |
| 157 | |
| 158 | extern int |
| 159 | attach PARAMS ((int)); |
| 160 | |
| 161 | void |
| 162 | detach PARAMS ((int)); |
| 163 | |
| 164 | extern void |
| 165 | child_resume PARAMS ((int, int)); |
| 166 | |
| 167 | #ifndef PTRACE_ARG3_TYPE |
| 168 | #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */ |
| 169 | #endif |
| 170 | |
| 171 | extern int |
| 172 | call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int)); |
| 173 | |
| 174 | /* From procfs.c */ |
| 175 | |
| 176 | extern int |
| 177 | proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR))); |
| 178 | |
| 179 | /* From fork-child.c */ |
| 180 | |
| 181 | extern void |
| 182 | fork_inferior PARAMS ((char *, char *, char **, |
| 183 | void (*) (void), |
| 184 | void (*) (int))); |
| 185 | |
| 186 | /* From inflow.c */ |
| 187 | |
| 188 | extern void |
| 189 | new_tty_prefork PARAMS ((char *)); |
| 190 | |
| 191 | /* From infrun.c */ |
| 192 | |
| 193 | extern void |
| 194 | start_remote PARAMS ((void)); |
| 195 | |
| 196 | extern void |
| 197 | normal_stop PARAMS ((void)); |
| 198 | |
| 199 | extern int |
| 200 | signal_stop_state PARAMS ((int)); |
| 201 | |
| 202 | extern int |
| 203 | signal_print_state PARAMS ((int)); |
| 204 | |
| 205 | extern int |
| 206 | signal_pass_state PARAMS ((int)); |
| 207 | |
| 208 | /* From infcmd.c */ |
| 209 | |
| 210 | extern void |
| 211 | tty_command PARAMS ((char *, int)); |
| 212 | |
| 213 | extern void |
| 214 | attach_command PARAMS ((char *, int)); |
| 215 | |
| 216 | /* Last signal that the inferior received (why it stopped). */ |
| 217 | |
| 218 | extern int stop_signal; |
| 219 | |
| 220 | /* Address at which inferior stopped. */ |
| 221 | |
| 222 | extern CORE_ADDR stop_pc; |
| 223 | |
| 224 | /* Stack frame when program stopped. */ |
| 225 | |
| 226 | extern FRAME_ADDR stop_frame_address; |
| 227 | |
| 228 | /* Chain containing status of breakpoint(s) that we have stopped at. */ |
| 229 | |
| 230 | extern bpstat stop_bpstat; |
| 231 | |
| 232 | /* Flag indicating that a command has proceeded the inferior past the |
| 233 | current breakpoint. */ |
| 234 | |
| 235 | extern int breakpoint_proceeded; |
| 236 | |
| 237 | /* Nonzero if stopped due to a step command. */ |
| 238 | |
| 239 | extern int stop_step; |
| 240 | |
| 241 | /* Nonzero if stopped due to completion of a stack dummy routine. */ |
| 242 | |
| 243 | extern int stop_stack_dummy; |
| 244 | |
| 245 | /* Nonzero if program stopped due to a random (unexpected) signal in |
| 246 | inferior process. */ |
| 247 | |
| 248 | extern int stopped_by_random_signal; |
| 249 | |
| 250 | /* Range to single step within. |
| 251 | If this is nonzero, respond to a single-step signal |
| 252 | by continuing to step if the pc is in this range. */ |
| 253 | |
| 254 | extern CORE_ADDR step_range_start; /* Inclusive */ |
| 255 | extern CORE_ADDR step_range_end; /* Exclusive */ |
| 256 | |
| 257 | /* Stack frame address as of when stepping command was issued. |
| 258 | This is how we know when we step into a subroutine call, |
| 259 | and how to set the frame for the breakpoint used to step out. */ |
| 260 | |
| 261 | extern FRAME_ADDR step_frame_address; |
| 262 | |
| 263 | /* 1 means step over all subroutine calls. |
| 264 | -1 means step over calls to undebuggable functions. */ |
| 265 | |
| 266 | extern int step_over_calls; |
| 267 | |
| 268 | /* If stepping, nonzero means step count is > 1 |
| 269 | so don't print frame next time inferior stops |
| 270 | if it stops due to stepping. */ |
| 271 | |
| 272 | extern int step_multi; |
| 273 | |
| 274 | /* Nonzero means expecting a trap and caller will handle it themselves. |
| 275 | It is used after attach, due to attaching to a process; |
| 276 | when running in the shell before the child program has been exec'd; |
| 277 | and when running some kinds of remote stuff (FIXME?). */ |
| 278 | |
| 279 | extern int stop_soon_quietly; |
| 280 | |
| 281 | /* Nonzero if proceed is being used for a "finish" command or a similar |
| 282 | situation when stop_registers should be saved. */ |
| 283 | |
| 284 | extern int proceed_to_finish; |
| 285 | |
| 286 | /* Save register contents here when about to pop a stack dummy frame, |
| 287 | if-and-only-if proceed_to_finish is set. |
| 288 | Thus this contains the return value from the called function (assuming |
| 289 | values are returned in a register). */ |
| 290 | |
| 291 | extern char stop_registers[REGISTER_BYTES]; |
| 292 | |
| 293 | /* Nonzero if pc has been changed by the debugger |
| 294 | since the inferior stopped. */ |
| 295 | |
| 296 | extern int pc_changed; |
| 297 | |
| 298 | /* Nonzero if the child process in inferior_pid was attached rather |
| 299 | than forked. */ |
| 300 | |
| 301 | extern int attach_flag; |
| 302 | \f |
| 303 | /* Possible values for CALL_DUMMY_LOCATION. */ |
| 304 | #define ON_STACK 1 |
| 305 | #define BEFORE_TEXT_END 2 |
| 306 | #define AFTER_TEXT_END 3 |
| 307 | |
| 308 | #if !defined (CALL_DUMMY_LOCATION) |
| 309 | #define CALL_DUMMY_LOCATION ON_STACK |
| 310 | #endif /* No CALL_DUMMY_LOCATION. */ |
| 311 | |
| 312 | /* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK |
| 313 | below is for infrun.c, which may give the macro a pc without that |
| 314 | subtracted out. */ |
| 315 | #if !defined (PC_IN_CALL_DUMMY) |
| 316 | #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END |
| 317 | extern CORE_ADDR text_end; |
| 318 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ |
| 319 | ((pc) >= text_end - CALL_DUMMY_LENGTH \ |
| 320 | && (pc) <= text_end + DECR_PC_AFTER_BREAK) |
| 321 | #else /* Not before text_end. */ |
| 322 | #if CALL_DUMMY_LOCATION == AFTER_TEXT_END |
| 323 | extern CORE_ADDR text_end; |
| 324 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ |
| 325 | ((pc) >= text_end \ |
| 326 | && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK) |
| 327 | #else /* On stack. */ |
| 328 | |
| 329 | /* This assumes that frame_address is the value of SP_REGNUM before |
| 330 | the dummy frame was pushed. The only known machine for which this |
| 331 | isn't true is the 29k, which doesn't use ON_STACK. Machines for |
| 332 | which it isn't true who want to put stack dummies on the stack |
| 333 | could provide their own PC_IN_CALL_DUMMY, or perhaps this macro |
| 334 | could be re-written to check for the end of the stack instead |
| 335 | (using the target_ops->sections). Are there user programs, libraries, |
| 336 | kernel routines, etc. which also execute on the stack? If so, the |
| 337 | latter would be a bad idea. */ |
| 338 | |
| 339 | #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ |
| 340 | ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address)) |
| 341 | #endif /* On stack. */ |
| 342 | #endif /* Not before text_end. */ |
| 343 | #endif /* No PC_IN_CALL_DUMMY. */ |
| 344 | |
| 345 | #endif /* !defined (INFERIOR_H) */ |