X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Ftarget.c;h=a9744c4f67dc4334cb68a69d06897478ac6f4bc5;hb=21002a635bf3da33367592e3a3ab3cce24fe5299;hp=d7653c4126ff42b3f299cf4e1af22bcb1642c059;hpb=d7f3ff3ea7830389f458be7c5eadb5d4a4e0a90b;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/target.c b/gdb/target.c index d7653c4126..a9744c4f67 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1,6 +1,6 @@ /* Select target systems and architectures at runtime for GDB. - Copyright (C) 1990-2015 Free Software Foundation, Inc. + Copyright (C) 1990-2016 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -466,6 +466,14 @@ target_terminal_is_inferior (void) /* See target.h. */ +int +target_terminal_is_ours (void) +{ + return (terminal_state == terminal_is_ours); +} + +/* See target.h. */ + void target_terminal_inferior (void) { @@ -483,6 +491,11 @@ target_terminal_inferior (void) inferior's terminal modes. */ (*current_target.to_terminal_inferior) (¤t_target); terminal_state = terminal_is_inferior; + + /* If the user hit C-c before, pretend that it was hit right + here. */ + if (check_quit_flag ()) + target_pass_ctrlc (); } /* See target.h. */ @@ -746,21 +759,35 @@ unpush_target (struct target_ops *t) return 1; } +/* Unpush TARGET and assert that it worked. */ + +static void +unpush_target_and_assert (struct target_ops *target) +{ + if (!unpush_target (target)) + { + fprintf_unfiltered (gdb_stderr, + "pop_all_targets couldn't find target %s\n", + target->to_shortname); + internal_error (__FILE__, __LINE__, + _("failed internal consistency check")); + } +} + void pop_all_targets_above (enum strata above_stratum) { while ((int) (current_target.to_stratum) > (int) above_stratum) - { - if (!unpush_target (target_stack)) - { - fprintf_unfiltered (gdb_stderr, - "pop_all_targets couldn't find target %s\n", - target_stack->to_shortname); - internal_error (__FILE__, __LINE__, - _("failed internal consistency check")); - break; - } - } + unpush_target_and_assert (target_stack); +} + +/* See target.h. */ + +void +pop_all_targets_at_and_above (enum strata stratum) +{ + while ((int) (current_target.to_stratum) >= (int) stratum) + unpush_target_and_assert (target_stack); } void @@ -1380,7 +1407,7 @@ target_xfer_partial (struct target_ops *ops, /* Read LEN bytes of target memory at address MEMADDR, placing the results in GDB's memory at MYADDR. Returns either 0 for success or - TARGET_XFER_E_IO if any error occurs. + -1 if any error occurs. If an error occurs, no guarantee is made about the contents of the data at MYADDR. In particular, the caller should not depend upon partial reads @@ -1399,7 +1426,7 @@ target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) myaddr, memaddr, len) == len) return 0; else - return TARGET_XFER_E_IO; + return -1; } /* See target/target.h. */ @@ -1431,7 +1458,7 @@ target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) myaddr, memaddr, len) == len) return 0; else - return TARGET_XFER_E_IO; + return -1; } /* Like target_read_memory, but specify explicitly that this is a read from @@ -1446,7 +1473,7 @@ target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) myaddr, memaddr, len) == len) return 0; else - return TARGET_XFER_E_IO; + return -1; } /* Like target_read_memory, but specify explicitly that this is a read from @@ -1461,14 +1488,14 @@ target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) myaddr, memaddr, len) == len) return 0; else - return TARGET_XFER_E_IO; + return -1; } /* Write LEN bytes from MYADDR to target memory at address MEMADDR. - Returns either 0 for success or TARGET_XFER_E_IO if any - error occurs. If an error occurs, no guarantee is made about how - much data got written. Callers that can deal with partial writes - should call target_write. */ + Returns either 0 for success or -1 if any error occurs. If an + error occurs, no guarantee is made about how much data got written. + Callers that can deal with partial writes should call + target_write. */ int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) @@ -1479,14 +1506,14 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) myaddr, memaddr, len) == len) return 0; else - return TARGET_XFER_E_IO; + return -1; } /* Write LEN bytes from MYADDR to target raw memory at address - MEMADDR. Returns either 0 for success or TARGET_XFER_E_IO - if any error occurs. If an error occurs, no guarantee is made - about how much data got written. Callers that can deal with - partial writes should call target_write. */ + MEMADDR. Returns either 0 for success or -1 if any error occurs. + If an error occurs, no guarantee is made about how much data got + written. Callers that can deal with partial writes should call + target_write. */ int target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) @@ -1497,7 +1524,7 @@ target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) myaddr, memaddr, len) == len) return 0; else - return TARGET_XFER_E_IO; + return -1; } /* Fetch the target's memory map. */ @@ -1822,8 +1849,9 @@ read_memory_robust (struct target_ops *ops, /* Got an error reading full chunk. See if maybe we can read some subrange. */ xfree (buffer); - read_whatever_is_readable (ops, offset + xfered_total, unit_size, - offset + xfered_total + to_read, &result); + read_whatever_is_readable (ops, offset + xfered_total, + offset + xfered_total + to_read, + unit_size, &result); xfered_total += to_read; } else @@ -2142,6 +2170,8 @@ target_pre_inferior (int from_tty) the inferior was attached to. */ current_inferior ()->attach_flag = 0; + current_inferior ()->highest_thread_num = 0; + agent_capability_invalidate (); } @@ -2250,7 +2280,7 @@ target_pid_to_str (ptid_t ptid) return (*current_target.to_pid_to_str) (¤t_target, ptid); } -char * +const char * target_thread_name (struct thread_info *info) { return current_target.to_thread_name (¤t_target, info); @@ -3335,9 +3365,17 @@ target_interrupt (ptid_t ptid) /* See target.h. */ void -target_check_pending_interrupt (void) +target_pass_ctrlc (void) +{ + (*current_target.to_pass_ctrlc) (¤t_target); +} + +/* See target.h. */ + +void +default_target_pass_ctrlc (struct target_ops *ops) { - (*current_target.to_check_pending_interrupt) (¤t_target); + target_interrupt (inferior_ptid); } /* See target/target.h. */ @@ -3529,7 +3567,8 @@ target_verify_memory (const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size) target.h. */ int -target_insert_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask, int rw) +target_insert_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask, + enum target_hw_bp_type rw) { return current_target.to_insert_mask_watchpoint (¤t_target, addr, mask, rw); @@ -3539,7 +3578,8 @@ target_insert_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask, int rw) target.h. */ int -target_remove_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask, int rw) +target_remove_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask, + enum target_hw_bp_type rw) { return current_target.to_remove_mask_watchpoint (¤t_target, addr, mask, rw); @@ -3833,6 +3873,14 @@ target_async (int enable) current_target.to_async (¤t_target, enable); } +/* See target.h. */ + +void +target_thread_events (int enable) +{ + current_target.to_thread_events (¤t_target, enable); +} + /* Controls if targets can report that they can/are async. This is just for maintainers to use when debugging gdb. */ int target_async_permitted = 1;