OLD | NEW |
1 /* Select target systems and architectures at runtime for GDB. | 1 /* Select target systems and architectures at runtime for GDB. |
2 | 2 |
3 Copyright (C) 1990-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1990-2012 Free Software Foundation, Inc. |
4 | 4 |
5 Contributed by Cygnus Support. | 5 Contributed by Cygnus Support. |
6 | 6 |
7 This file is part of GDB. | 7 This file is part of GDB. |
8 | 8 |
9 This program is free software; you can redistribute it and/or modify | 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 | 10 it under the terms of the GNU General Public License as published by |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "defs.h" | 22 #include "defs.h" |
23 #include <errno.h> | 23 #include <errno.h> |
24 #include "gdb_string.h" | 24 #include "gdb_string.h" |
25 #include "target.h" | 25 #include "target.h" |
26 #include "gdbcmd.h" | 26 #include "gdbcmd.h" |
27 #include "symtab.h" | 27 #include "symtab.h" |
28 #include "inferior.h" | 28 #include "inferior.h" |
29 #include "bfd.h" | 29 #include "bfd.h" |
30 #include "symfile.h" | 30 #include "symfile.h" |
31 #include "objfiles.h" | 31 #include "objfiles.h" |
32 #include "gdb_wait.h" | |
33 #include "dcache.h" | 32 #include "dcache.h" |
34 #include <signal.h> | 33 #include <signal.h> |
35 #include "regcache.h" | 34 #include "regcache.h" |
36 #include "gdb_assert.h" | 35 #include "gdb_assert.h" |
37 #include "gdbcore.h" | 36 #include "gdbcore.h" |
38 #include "exceptions.h" | 37 #include "exceptions.h" |
39 #include "target-descriptions.h" | 38 #include "target-descriptions.h" |
40 #include "gdbthread.h" | 39 #include "gdbthread.h" |
41 #include "solib.h" | 40 #include "solib.h" |
42 #include "exec.h" | 41 #include "exec.h" |
43 #include "inline-frame.h" | 42 #include "inline-frame.h" |
44 #include "tracepoint.h" | 43 #include "tracepoint.h" |
| 44 #include "gdb/fileio.h" |
| 45 #include "agent.h" |
45 | 46 |
46 static void target_info (char *, int); | 47 static void target_info (char *, int); |
47 | 48 |
48 static void default_terminal_info (char *, int); | 49 static void default_terminal_info (char *, int); |
49 | 50 |
50 static int default_watchpoint_addr_within_range (struct target_ops *, | 51 static int default_watchpoint_addr_within_range (struct target_ops *, |
51 CORE_ADDR, CORE_ADDR, int); | 52 CORE_ADDR, CORE_ADDR, int); |
52 | 53 |
53 static int default_region_ok_for_hw_watchpoint (CORE_ADDR, int); | 54 static int default_region_ok_for_hw_watchpoint (CORE_ADDR, int); |
54 | 55 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 INHERIT (to_insert_vfork_catchpoint, t); | 631 INHERIT (to_insert_vfork_catchpoint, t); |
631 INHERIT (to_remove_vfork_catchpoint, t); | 632 INHERIT (to_remove_vfork_catchpoint, t); |
632 /* Do not inherit to_follow_fork. */ | 633 /* Do not inherit to_follow_fork. */ |
633 INHERIT (to_insert_exec_catchpoint, t); | 634 INHERIT (to_insert_exec_catchpoint, t); |
634 INHERIT (to_remove_exec_catchpoint, t); | 635 INHERIT (to_remove_exec_catchpoint, t); |
635 INHERIT (to_set_syscall_catchpoint, t); | 636 INHERIT (to_set_syscall_catchpoint, t); |
636 INHERIT (to_has_exited, t); | 637 INHERIT (to_has_exited, t); |
637 /* Do not inherit to_mourn_inferior. */ | 638 /* Do not inherit to_mourn_inferior. */ |
638 INHERIT (to_can_run, t); | 639 INHERIT (to_can_run, t); |
639 /* Do not inherit to_pass_signals. */ | 640 /* Do not inherit to_pass_signals. */ |
| 641 /* Do not inherit to_program_signals. */ |
640 /* Do not inherit to_thread_alive. */ | 642 /* Do not inherit to_thread_alive. */ |
641 /* Do not inherit to_find_new_threads. */ | 643 /* Do not inherit to_find_new_threads. */ |
642 /* Do not inherit to_pid_to_str. */ | 644 /* Do not inherit to_pid_to_str. */ |
643 INHERIT (to_extra_thread_info, t); | 645 INHERIT (to_extra_thread_info, t); |
644 INHERIT (to_thread_name, t); | 646 INHERIT (to_thread_name, t); |
645 INHERIT (to_stop, t); | 647 INHERIT (to_stop, t); |
646 /* Do not inherit to_xfer_partial. */ | 648 /* Do not inherit to_xfer_partial. */ |
647 INHERIT (to_rcmd, t); | 649 INHERIT (to_rcmd, t); |
648 INHERIT (to_pid_to_exec_file, t); | 650 INHERIT (to_pid_to_exec_file, t); |
649 INHERIT (to_log_command, t); | 651 INHERIT (to_log_command, t); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 INHERIT (to_get_raw_trace_data, t); | 692 INHERIT (to_get_raw_trace_data, t); |
691 INHERIT (to_get_min_fast_tracepoint_insn_len, t); | 693 INHERIT (to_get_min_fast_tracepoint_insn_len, t); |
692 INHERIT (to_set_disconnected_tracing, t); | 694 INHERIT (to_set_disconnected_tracing, t); |
693 INHERIT (to_set_circular_trace_buffer, t); | 695 INHERIT (to_set_circular_trace_buffer, t); |
694 INHERIT (to_set_trace_notes, t); | 696 INHERIT (to_set_trace_notes, t); |
695 INHERIT (to_get_tib_address, t); | 697 INHERIT (to_get_tib_address, t); |
696 INHERIT (to_set_permissions, t); | 698 INHERIT (to_set_permissions, t); |
697 INHERIT (to_static_tracepoint_marker_at, t); | 699 INHERIT (to_static_tracepoint_marker_at, t); |
698 INHERIT (to_static_tracepoint_markers_by_strid, t); | 700 INHERIT (to_static_tracepoint_markers_by_strid, t); |
699 INHERIT (to_traceframe_info, t); | 701 INHERIT (to_traceframe_info, t); |
| 702 INHERIT (to_use_agent, t); |
| 703 INHERIT (to_can_use_agent, t); |
700 INHERIT (to_magic, t); | 704 INHERIT (to_magic, t); |
| 705 INHERIT (to_supports_evaluation_of_breakpoint_conditions, t); |
| 706 INHERIT (to_can_run_breakpoint_commands, t); |
701 /* Do not inherit to_memory_map. */ | 707 /* Do not inherit to_memory_map. */ |
702 /* Do not inherit to_flash_erase. */ | 708 /* Do not inherit to_flash_erase. */ |
703 /* Do not inherit to_flash_done. */ | 709 /* Do not inherit to_flash_done. */ |
704 } | 710 } |
705 #undef INHERIT | 711 #undef INHERIT |
706 | 712 |
707 /* Clean up a target struct so it no longer has any zero pointers in | 713 /* Clean up a target struct so it no longer has any zero pointers in |
708 it. Some entries are defaulted to a method that print an error, | 714 it. Some entries are defaulted to a method that print an error, |
709 others are hard-wired to a standard recursive default. */ | 715 others are hard-wired to a standard recursive default. */ |
710 | 716 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 target_ignore); | 923 target_ignore); |
918 de_fault (to_static_tracepoint_marker_at, | 924 de_fault (to_static_tracepoint_marker_at, |
919 (int (*) (CORE_ADDR, struct static_tracepoint_marker *)) | 925 (int (*) (CORE_ADDR, struct static_tracepoint_marker *)) |
920 return_zero); | 926 return_zero); |
921 de_fault (to_static_tracepoint_markers_by_strid, | 927 de_fault (to_static_tracepoint_markers_by_strid, |
922 (VEC(static_tracepoint_marker_p) * (*) (const char *)) | 928 (VEC(static_tracepoint_marker_p) * (*) (const char *)) |
923 tcomplain); | 929 tcomplain); |
924 de_fault (to_traceframe_info, | 930 de_fault (to_traceframe_info, |
925 (struct traceframe_info * (*) (void)) | 931 (struct traceframe_info * (*) (void)) |
926 tcomplain); | 932 tcomplain); |
| 933 de_fault (to_supports_evaluation_of_breakpoint_conditions, |
| 934 (int (*) (void)) |
| 935 return_zero); |
| 936 de_fault (to_can_run_breakpoint_commands, |
| 937 (int (*) (void)) |
| 938 return_zero); |
| 939 de_fault (to_use_agent, |
| 940 (int (*) (int)) |
| 941 tcomplain); |
| 942 de_fault (to_can_use_agent, |
| 943 (int (*) (void)) |
| 944 return_zero); |
927 de_fault (to_execution_direction, default_execution_direction); | 945 de_fault (to_execution_direction, default_execution_direction); |
928 | 946 |
929 #undef de_fault | 947 #undef de_fault |
930 | 948 |
931 /* Finally, position the target-stack beneath the squashed | 949 /* Finally, position the target-stack beneath the squashed |
932 "current_target". That way code looking for a non-inherited | 950 "current_target". That way code looking for a non-inherited |
933 target method can quickly and simply find it. */ | 951 target method can quickly and simply find it. */ |
934 current_target.beneath = target_stack; | 952 current_target.beneath = target_stack; |
935 | 953 |
936 if (targetdebug) | 954 if (targetdebug) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 | 1021 |
1004 /* Look for the specified target. Note that we assume that a target | 1022 /* Look for the specified target. Note that we assume that a target |
1005 can only occur once in the target stack. */ | 1023 can only occur once in the target stack. */ |
1006 | 1024 |
1007 for (cur = &target_stack; (*cur) != NULL; cur = &(*cur)->beneath) | 1025 for (cur = &target_stack; (*cur) != NULL; cur = &(*cur)->beneath) |
1008 { | 1026 { |
1009 if ((*cur) == t) | 1027 if ((*cur) == t) |
1010 break; | 1028 break; |
1011 } | 1029 } |
1012 | 1030 |
| 1031 /* If we don't find target_ops, quit. Only open targets should be |
| 1032 closed. */ |
1013 if ((*cur) == NULL) | 1033 if ((*cur) == NULL) |
1014 return 0;» » » /* Didn't find target_ops, quit now. */ | 1034 return 0;» » » |
1015 | |
1016 /* NOTE: cagney/2003-12-06: In '94 the close call was made | |
1017 unconditional by moving it to before the above check that the | |
1018 target was in the target stack (something about "Change the way | |
1019 pushing and popping of targets work to support target overlays | |
1020 and inheritance"). This doesn't make much sense - only open | |
1021 targets should be closed. */ | |
1022 target_close (t, 0); | |
1023 | 1035 |
1024 /* Unchain the target. */ | 1036 /* Unchain the target. */ |
1025 tmp = (*cur); | 1037 tmp = (*cur); |
1026 (*cur) = (*cur)->beneath; | 1038 (*cur) = (*cur)->beneath; |
1027 tmp->beneath = NULL; | 1039 tmp->beneath = NULL; |
1028 | 1040 |
1029 update_current_target (); | 1041 update_current_target (); |
1030 | 1042 |
| 1043 /* Finally close the target. Note we do this after unchaining, so |
| 1044 any target method calls from within the target_close |
| 1045 implementation don't end up in T anymore. */ |
| 1046 target_close (t, 0); |
| 1047 |
1031 return 1; | 1048 return 1; |
1032 } | 1049 } |
1033 | 1050 |
1034 void | 1051 void |
1035 pop_target (void) | 1052 pop_target (void) |
1036 { | 1053 { |
1037 target_close (target_stack, 0); /* Let it clean up. */ | 1054 target_close (target_stack, 0); /* Let it clean up. */ |
1038 if (unpush_target (target_stack) == 1) | 1055 if (unpush_target (target_stack) == 1) |
1039 return; | 1056 return; |
1040 | 1057 |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 if any error occurs. | 1753 if any error occurs. |
1737 | 1754 |
1738 If an error occurs, no guarantee is made about the contents of the data at | 1755 If an error occurs, no guarantee is made about the contents of the data at |
1739 MYADDR. In particular, the caller should not depend upon partial reads | 1756 MYADDR. In particular, the caller should not depend upon partial reads |
1740 filling the buffer with good data. There is no way for the caller to know | 1757 filling the buffer with good data. There is no way for the caller to know |
1741 how much good data might have been transfered anyway. Callers that can | 1758 how much good data might have been transfered anyway. Callers that can |
1742 deal with partial reads should call target_read (which will retry until | 1759 deal with partial reads should call target_read (which will retry until |
1743 it makes no progress, and then return how much was transferred). */ | 1760 it makes no progress, and then return how much was transferred). */ |
1744 | 1761 |
1745 int | 1762 int |
1746 target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len) | 1763 target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) |
1747 { | 1764 { |
1748 /* Dispatch to the topmost target, not the flattened current_target. | 1765 /* Dispatch to the topmost target, not the flattened current_target. |
1749 Memory accesses check target->to_has_(all_)memory, and the | 1766 Memory accesses check target->to_has_(all_)memory, and the |
1750 flattened target doesn't inherit those. */ | 1767 flattened target doesn't inherit those. */ |
1751 if (target_read (current_target.beneath, TARGET_OBJECT_MEMORY, NULL, | 1768 if (target_read (current_target.beneath, TARGET_OBJECT_MEMORY, NULL, |
1752 myaddr, memaddr, len) == len) | 1769 myaddr, memaddr, len) == len) |
1753 return 0; | 1770 return 0; |
1754 else | 1771 else |
1755 return EIO; | 1772 return EIO; |
1756 } | 1773 } |
1757 | 1774 |
1758 /* Like target_read_memory, but specify explicitly that this is a read from | 1775 /* Like target_read_memory, but specify explicitly that this is a read from |
1759 the target's stack. This may trigger different cache behavior. */ | 1776 the target's stack. This may trigger different cache behavior. */ |
1760 | 1777 |
1761 int | 1778 int |
1762 target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, int len) | 1779 target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) |
1763 { | 1780 { |
1764 /* Dispatch to the topmost target, not the flattened current_target. | 1781 /* Dispatch to the topmost target, not the flattened current_target. |
1765 Memory accesses check target->to_has_(all_)memory, and the | 1782 Memory accesses check target->to_has_(all_)memory, and the |
1766 flattened target doesn't inherit those. */ | 1783 flattened target doesn't inherit those. */ |
1767 | 1784 |
1768 if (target_read (current_target.beneath, TARGET_OBJECT_STACK_MEMORY, NULL, | 1785 if (target_read (current_target.beneath, TARGET_OBJECT_STACK_MEMORY, NULL, |
1769 myaddr, memaddr, len) == len) | 1786 myaddr, memaddr, len) == len) |
1770 return 0; | 1787 return 0; |
1771 else | 1788 else |
1772 return EIO; | 1789 return EIO; |
1773 } | 1790 } |
1774 | 1791 |
1775 /* Write LEN bytes from MYADDR to target memory at address MEMADDR. | 1792 /* Write LEN bytes from MYADDR to target memory at address MEMADDR. |
1776 Returns either 0 for success or an errno value if any error occurs. | 1793 Returns either 0 for success or an errno value if any error occurs. |
1777 If an error occurs, no guarantee is made about how much data got written. | 1794 If an error occurs, no guarantee is made about how much data got written. |
1778 Callers that can deal with partial writes should call target_write. */ | 1795 Callers that can deal with partial writes should call target_write. */ |
1779 | 1796 |
1780 int | 1797 int |
1781 target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) | 1798 target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) |
1782 { | 1799 { |
1783 /* Dispatch to the topmost target, not the flattened current_target. | 1800 /* Dispatch to the topmost target, not the flattened current_target. |
1784 Memory accesses check target->to_has_(all_)memory, and the | 1801 Memory accesses check target->to_has_(all_)memory, and the |
1785 flattened target doesn't inherit those. */ | 1802 flattened target doesn't inherit those. */ |
1786 if (target_write (current_target.beneath, TARGET_OBJECT_MEMORY, NULL, | 1803 if (target_write (current_target.beneath, TARGET_OBJECT_MEMORY, NULL, |
1787 myaddr, memaddr, len) == len) | 1804 myaddr, memaddr, len) == len) |
1788 return 0; | 1805 return 0; |
1789 else | 1806 else |
1790 return EIO; | 1807 return EIO; |
1791 } | 1808 } |
1792 | 1809 |
1793 /* Write LEN bytes from MYADDR to target raw memory at address | 1810 /* Write LEN bytes from MYADDR to target raw memory at address |
1794 MEMADDR. Returns either 0 for success or an errno value if any | 1811 MEMADDR. Returns either 0 for success or an errno value if any |
1795 error occurs. If an error occurs, no guarantee is made about how | 1812 error occurs. If an error occurs, no guarantee is made about how |
1796 much data got written. Callers that can deal with partial writes | 1813 much data got written. Callers that can deal with partial writes |
1797 should call target_write. */ | 1814 should call target_write. */ |
1798 | 1815 |
1799 int | 1816 int |
1800 target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) | 1817 target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len) |
1801 { | 1818 { |
1802 /* Dispatch to the topmost target, not the flattened current_target. | 1819 /* Dispatch to the topmost target, not the flattened current_target. |
1803 Memory accesses check target->to_has_(all_)memory, and the | 1820 Memory accesses check target->to_has_(all_)memory, and the |
1804 flattened target doesn't inherit those. */ | 1821 flattened target doesn't inherit those. */ |
1805 if (target_write (current_target.beneath, TARGET_OBJECT_RAW_MEMORY, NULL, | 1822 if (target_write (current_target.beneath, TARGET_OBJECT_RAW_MEMORY, NULL, |
1806 myaddr, memaddr, len) == len) | 1823 myaddr, memaddr, len) == len) |
1807 return 0; | 1824 return 0; |
1808 else | 1825 else |
1809 return EIO; | 1826 return EIO; |
1810 } | 1827 } |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2338 returned as a string, allocated using xmalloc. If an error occurs | 2355 returned as a string, allocated using xmalloc. If an error occurs |
2339 or the transfer is unsupported, NULL is returned. Empty objects | 2356 or the transfer is unsupported, NULL is returned. Empty objects |
2340 are returned as allocated but empty strings. A warning is issued | 2357 are returned as allocated but empty strings. A warning is issued |
2341 if the result contains any embedded NUL bytes. */ | 2358 if the result contains any embedded NUL bytes. */ |
2342 | 2359 |
2343 char * | 2360 char * |
2344 target_read_stralloc (struct target_ops *ops, enum target_object object, | 2361 target_read_stralloc (struct target_ops *ops, enum target_object object, |
2345 const char *annex) | 2362 const char *annex) |
2346 { | 2363 { |
2347 gdb_byte *buffer; | 2364 gdb_byte *buffer; |
2348 LONGEST transferred; | 2365 LONGEST i, transferred; |
2349 | 2366 |
2350 transferred = target_read_alloc_1 (ops, object, annex, &buffer, 1); | 2367 transferred = target_read_alloc_1 (ops, object, annex, &buffer, 1); |
2351 | 2368 |
2352 if (transferred < 0) | 2369 if (transferred < 0) |
2353 return NULL; | 2370 return NULL; |
2354 | 2371 |
2355 if (transferred == 0) | 2372 if (transferred == 0) |
2356 return xstrdup (""); | 2373 return xstrdup (""); |
2357 | 2374 |
2358 buffer[transferred] = 0; | 2375 buffer[transferred] = 0; |
2359 if (strlen (buffer) < transferred) | 2376 |
2360 warning (_("target object %d, annex %s, " | 2377 /* Check for embedded NUL bytes; but allow trailing NULs. */ |
2361 » "contained unexpected null characters"), | 2378 for (i = strlen (buffer); i < transferred; i++) |
2362 » (int) object, annex ? annex : "(none)"); | 2379 if (buffer[i] != 0) |
| 2380 { |
| 2381 » warning (_("target object %d, annex %s, " |
| 2382 » » "contained unexpected null characters"), |
| 2383 » » (int) object, annex ? annex : "(none)"); |
| 2384 » break; |
| 2385 } |
2363 | 2386 |
2364 return (char *) buffer; | 2387 return (char *) buffer; |
2365 } | 2388 } |
2366 | 2389 |
2367 /* Memory transfer methods. */ | 2390 /* Memory transfer methods. */ |
2368 | 2391 |
2369 void | 2392 void |
2370 get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf, | 2393 get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf, |
2371 LONGEST len) | 2394 LONGEST len) |
2372 { | 2395 { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2475 across inferiors. If code is shared between processes, so are | 2498 across inferiors. If code is shared between processes, so are |
2476 memory regions and features. */ | 2499 memory regions and features. */ |
2477 if (!gdbarch_has_global_solist (target_gdbarch)) | 2500 if (!gdbarch_has_global_solist (target_gdbarch)) |
2478 { | 2501 { |
2479 no_shared_libraries (NULL, from_tty); | 2502 no_shared_libraries (NULL, from_tty); |
2480 | 2503 |
2481 invalidate_target_mem_regions (); | 2504 invalidate_target_mem_regions (); |
2482 | 2505 |
2483 target_clear_description (); | 2506 target_clear_description (); |
2484 } | 2507 } |
| 2508 |
| 2509 agent_capability_invalidate (); |
2485 } | 2510 } |
2486 | 2511 |
2487 /* Callback for iterate_over_inferiors. Gets rid of the given | 2512 /* Callback for iterate_over_inferiors. Gets rid of the given |
2488 inferior. */ | 2513 inferior. */ |
2489 | 2514 |
2490 static int | 2515 static int |
2491 dispose_inferior (struct inferior *inf, void *args) | 2516 dispose_inferior (struct inferior *inf, void *args) |
2492 { | 2517 { |
2493 struct thread_info *thread; | 2518 struct thread_info *thread; |
2494 | 2519 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2642 for (t = current_target.beneath; t != NULL; t = t->beneath) | 2667 for (t = current_target.beneath; t != NULL; t = t->beneath) |
2643 { | 2668 { |
2644 if (t->to_thread_name != NULL) | 2669 if (t->to_thread_name != NULL) |
2645 return (*t->to_thread_name) (info); | 2670 return (*t->to_thread_name) (info); |
2646 } | 2671 } |
2647 | 2672 |
2648 return NULL; | 2673 return NULL; |
2649 } | 2674 } |
2650 | 2675 |
2651 void | 2676 void |
2652 target_resume (ptid_t ptid, int step, enum target_signal signal) | 2677 target_resume (ptid_t ptid, int step, enum gdb_signal signal) |
2653 { | 2678 { |
2654 struct target_ops *t; | 2679 struct target_ops *t; |
2655 | 2680 |
2656 target_dcache_invalidate (); | 2681 target_dcache_invalidate (); |
2657 | 2682 |
2658 for (t = current_target.beneath; t != NULL; t = t->beneath) | 2683 for (t = current_target.beneath; t != NULL; t = t->beneath) |
2659 { | 2684 { |
2660 if (t->to_resume != NULL) | 2685 if (t->to_resume != NULL) |
2661 { | 2686 { |
2662 t->to_resume (t, ptid, step, signal); | 2687 t->to_resume (t, ptid, step, signal); |
2663 if (targetdebug) | 2688 if (targetdebug) |
2664 fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", | 2689 fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", |
2665 PIDGET (ptid), | 2690 PIDGET (ptid), |
2666 step ? "step" : "continue", | 2691 step ? "step" : "continue", |
2667 » » » » target_signal_to_name (signal)); | 2692 » » » » gdb_signal_to_name (signal)); |
2668 | 2693 |
2669 registers_changed_ptid (ptid); | 2694 registers_changed_ptid (ptid); |
2670 set_executing (ptid, 1); | 2695 set_executing (ptid, 1); |
2671 set_running (ptid, 1); | 2696 set_running (ptid, 1); |
2672 clear_inline_frame_state (ptid); | 2697 clear_inline_frame_state (ptid); |
2673 return; | 2698 return; |
2674 } | 2699 } |
2675 } | 2700 } |
2676 | 2701 |
2677 noprocess (); | 2702 noprocess (); |
(...skipping 11 matching lines...) Expand all Loading... |
2689 if (targetdebug) | 2714 if (targetdebug) |
2690 { | 2715 { |
2691 int i; | 2716 int i; |
2692 | 2717 |
2693 fprintf_unfiltered (gdb_stdlog, "target_pass_signals (%d, {", | 2718 fprintf_unfiltered (gdb_stdlog, "target_pass_signals (%d, {", |
2694 numsigs); | 2719 numsigs); |
2695 | 2720 |
2696 for (i = 0; i < numsigs; i++) | 2721 for (i = 0; i < numsigs; i++) |
2697 if (pass_signals[i]) | 2722 if (pass_signals[i]) |
2698 fprintf_unfiltered (gdb_stdlog, " %s", | 2723 fprintf_unfiltered (gdb_stdlog, " %s", |
2699 » » » » target_signal_to_name (i)); | 2724 » » » » gdb_signal_to_name (i)); |
2700 | 2725 |
2701 fprintf_unfiltered (gdb_stdlog, " })\n"); | 2726 fprintf_unfiltered (gdb_stdlog, " })\n"); |
2702 } | 2727 } |
2703 | 2728 |
2704 (*t->to_pass_signals) (numsigs, pass_signals); | 2729 (*t->to_pass_signals) (numsigs, pass_signals); |
2705 return; | 2730 return; |
2706 } | 2731 } |
2707 } | 2732 } |
2708 } | 2733 } |
2709 | 2734 |
| 2735 void |
| 2736 target_program_signals (int numsigs, unsigned char *program_signals) |
| 2737 { |
| 2738 struct target_ops *t; |
| 2739 |
| 2740 for (t = current_target.beneath; t != NULL; t = t->beneath) |
| 2741 { |
| 2742 if (t->to_program_signals != NULL) |
| 2743 { |
| 2744 if (targetdebug) |
| 2745 { |
| 2746 int i; |
| 2747 |
| 2748 fprintf_unfiltered (gdb_stdlog, "target_program_signals (%d, {", |
| 2749 numsigs); |
| 2750 |
| 2751 for (i = 0; i < numsigs; i++) |
| 2752 if (program_signals[i]) |
| 2753 fprintf_unfiltered (gdb_stdlog, " %s", |
| 2754 gdb_signal_to_name (i)); |
| 2755 |
| 2756 fprintf_unfiltered (gdb_stdlog, " })\n"); |
| 2757 } |
| 2758 |
| 2759 (*t->to_program_signals) (numsigs, program_signals); |
| 2760 return; |
| 2761 } |
| 2762 } |
| 2763 } |
| 2764 |
2710 /* Look through the list of possible targets for a target that can | 2765 /* Look through the list of possible targets for a target that can |
2711 follow forks. */ | 2766 follow forks. */ |
2712 | 2767 |
2713 int | 2768 int |
2714 target_follow_fork (int follow_child) | 2769 target_follow_fork (int follow_child) |
2715 { | 2770 { |
2716 struct target_ops *t; | 2771 struct target_ops *t; |
2717 | 2772 |
2718 for (t = current_target.beneath; t != NULL; t = t->beneath) | 2773 for (t = current_target.beneath; t != NULL; t = t->beneath) |
2719 { | 2774 { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 { | 3129 { |
3075 struct target_ops *t; | 3130 struct target_ops *t; |
3076 | 3131 |
3077 for (t = ¤t_target; t != NULL; t = t->beneath) | 3132 for (t = ¤t_target; t != NULL; t = t->beneath) |
3078 if (t->to_supports_non_stop) | 3133 if (t->to_supports_non_stop) |
3079 return t->to_supports_non_stop (); | 3134 return t->to_supports_non_stop (); |
3080 | 3135 |
3081 return 0; | 3136 return 0; |
3082 } | 3137 } |
3083 | 3138 |
| 3139 /* Implement the "info proc" command. */ |
| 3140 |
| 3141 void |
| 3142 target_info_proc (char *args, enum info_proc_what what) |
| 3143 { |
| 3144 struct target_ops *t; |
| 3145 |
| 3146 /* If we're already connected to something that can get us OS |
| 3147 related data, use it. Otherwise, try using the native |
| 3148 target. */ |
| 3149 if (current_target.to_stratum >= process_stratum) |
| 3150 t = current_target.beneath; |
| 3151 else |
| 3152 t = find_default_run_target (NULL); |
| 3153 |
| 3154 for (; t != NULL; t = t->beneath) |
| 3155 { |
| 3156 if (t->to_info_proc != NULL) |
| 3157 { |
| 3158 t->to_info_proc (t, args, what); |
| 3159 |
| 3160 if (targetdebug) |
| 3161 fprintf_unfiltered (gdb_stdlog, |
| 3162 "target_info_proc (\"%s\", %d)\n", args, what); |
| 3163 |
| 3164 return; |
| 3165 } |
| 3166 } |
| 3167 |
| 3168 error (_("Not supported on this target.")); |
| 3169 } |
| 3170 |
3084 static int | 3171 static int |
3085 find_default_supports_disable_randomization (void) | 3172 find_default_supports_disable_randomization (void) |
3086 { | 3173 { |
3087 struct target_ops *t; | 3174 struct target_ops *t; |
3088 | 3175 |
3089 t = find_default_run_target (NULL); | 3176 t = find_default_run_target (NULL); |
3090 if (t && t->to_supports_disable_randomization) | 3177 if (t && t->to_supports_disable_randomization) |
3091 return (t->to_supports_disable_randomization) (); | 3178 return (t->to_supports_disable_randomization) (); |
3092 return 0; | 3179 return 0; |
3093 } | 3180 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 | 3240 |
3154 if (inf == NULL || inf->aspace == NULL) | 3241 if (inf == NULL || inf->aspace == NULL) |
3155 internal_error (__FILE__, __LINE__, | 3242 internal_error (__FILE__, __LINE__, |
3156 _("Can't determine the current " | 3243 _("Can't determine the current " |
3157 "address space of thread %s\n"), | 3244 "address space of thread %s\n"), |
3158 target_pid_to_str (ptid)); | 3245 target_pid_to_str (ptid)); |
3159 | 3246 |
3160 return inf->aspace; | 3247 return inf->aspace; |
3161 } | 3248 } |
3162 | 3249 |
| 3250 |
| 3251 /* Target file operations. */ |
| 3252 |
| 3253 static struct target_ops * |
| 3254 default_fileio_target (void) |
| 3255 { |
| 3256 /* If we're already connected to something that can perform |
| 3257 file I/O, use it. Otherwise, try using the native target. */ |
| 3258 if (current_target.to_stratum >= process_stratum) |
| 3259 return current_target.beneath; |
| 3260 else |
| 3261 return find_default_run_target ("file I/O"); |
| 3262 } |
| 3263 |
| 3264 /* Open FILENAME on the target, using FLAGS and MODE. Return a |
| 3265 target file descriptor, or -1 if an error occurs (and set |
| 3266 *TARGET_ERRNO). */ |
| 3267 int |
| 3268 target_fileio_open (const char *filename, int flags, int mode, |
| 3269 int *target_errno) |
| 3270 { |
| 3271 struct target_ops *t; |
| 3272 |
| 3273 for (t = default_fileio_target (); t != NULL; t = t->beneath) |
| 3274 { |
| 3275 if (t->to_fileio_open != NULL) |
| 3276 { |
| 3277 int fd = t->to_fileio_open (filename, flags, mode, target_errno); |
| 3278 |
| 3279 if (targetdebug) |
| 3280 fprintf_unfiltered (gdb_stdlog, |
| 3281 "target_fileio_open (%s,0x%x,0%o) = %d (%d)\n", |
| 3282 filename, flags, mode, |
| 3283 fd, fd != -1 ? 0 : *target_errno); |
| 3284 return fd; |
| 3285 } |
| 3286 } |
| 3287 |
| 3288 *target_errno = FILEIO_ENOSYS; |
| 3289 return -1; |
| 3290 } |
| 3291 |
| 3292 /* Write up to LEN bytes from WRITE_BUF to FD on the target. |
| 3293 Return the number of bytes written, or -1 if an error occurs |
| 3294 (and set *TARGET_ERRNO). */ |
| 3295 int |
| 3296 target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len, |
| 3297 ULONGEST offset, int *target_errno) |
| 3298 { |
| 3299 struct target_ops *t; |
| 3300 |
| 3301 for (t = default_fileio_target (); t != NULL; t = t->beneath) |
| 3302 { |
| 3303 if (t->to_fileio_pwrite != NULL) |
| 3304 { |
| 3305 int ret = t->to_fileio_pwrite (fd, write_buf, len, offset, |
| 3306 target_errno); |
| 3307 |
| 3308 if (targetdebug) |
| 3309 fprintf_unfiltered (gdb_stdlog, |
| 3310 "target_fileio_pwrite (%d,...,%d,%s) " |
| 3311 "= %d (%d)\n", |
| 3312 fd, len, pulongest (offset), |
| 3313 ret, ret != -1 ? 0 : *target_errno); |
| 3314 return ret; |
| 3315 } |
| 3316 } |
| 3317 |
| 3318 *target_errno = FILEIO_ENOSYS; |
| 3319 return -1; |
| 3320 } |
| 3321 |
| 3322 /* Read up to LEN bytes FD on the target into READ_BUF. |
| 3323 Return the number of bytes read, or -1 if an error occurs |
| 3324 (and set *TARGET_ERRNO). */ |
| 3325 int |
| 3326 target_fileio_pread (int fd, gdb_byte *read_buf, int len, |
| 3327 ULONGEST offset, int *target_errno) |
| 3328 { |
| 3329 struct target_ops *t; |
| 3330 |
| 3331 for (t = default_fileio_target (); t != NULL; t = t->beneath) |
| 3332 { |
| 3333 if (t->to_fileio_pread != NULL) |
| 3334 { |
| 3335 int ret = t->to_fileio_pread (fd, read_buf, len, offset, |
| 3336 target_errno); |
| 3337 |
| 3338 if (targetdebug) |
| 3339 fprintf_unfiltered (gdb_stdlog, |
| 3340 "target_fileio_pread (%d,...,%d,%s) " |
| 3341 "= %d (%d)\n", |
| 3342 fd, len, pulongest (offset), |
| 3343 ret, ret != -1 ? 0 : *target_errno); |
| 3344 return ret; |
| 3345 } |
| 3346 } |
| 3347 |
| 3348 *target_errno = FILEIO_ENOSYS; |
| 3349 return -1; |
| 3350 } |
| 3351 |
| 3352 /* Close FD on the target. Return 0, or -1 if an error occurs |
| 3353 (and set *TARGET_ERRNO). */ |
| 3354 int |
| 3355 target_fileio_close (int fd, int *target_errno) |
| 3356 { |
| 3357 struct target_ops *t; |
| 3358 |
| 3359 for (t = default_fileio_target (); t != NULL; t = t->beneath) |
| 3360 { |
| 3361 if (t->to_fileio_close != NULL) |
| 3362 { |
| 3363 int ret = t->to_fileio_close (fd, target_errno); |
| 3364 |
| 3365 if (targetdebug) |
| 3366 fprintf_unfiltered (gdb_stdlog, |
| 3367 "target_fileio_close (%d) = %d (%d)\n", |
| 3368 fd, ret, ret != -1 ? 0 : *target_errno); |
| 3369 return ret; |
| 3370 } |
| 3371 } |
| 3372 |
| 3373 *target_errno = FILEIO_ENOSYS; |
| 3374 return -1; |
| 3375 } |
| 3376 |
| 3377 /* Unlink FILENAME on the target. Return 0, or -1 if an error |
| 3378 occurs (and set *TARGET_ERRNO). */ |
| 3379 int |
| 3380 target_fileio_unlink (const char *filename, int *target_errno) |
| 3381 { |
| 3382 struct target_ops *t; |
| 3383 |
| 3384 for (t = default_fileio_target (); t != NULL; t = t->beneath) |
| 3385 { |
| 3386 if (t->to_fileio_unlink != NULL) |
| 3387 { |
| 3388 int ret = t->to_fileio_unlink (filename, target_errno); |
| 3389 |
| 3390 if (targetdebug) |
| 3391 fprintf_unfiltered (gdb_stdlog, |
| 3392 "target_fileio_unlink (%s) = %d (%d)\n", |
| 3393 filename, ret, ret != -1 ? 0 : *target_errno); |
| 3394 return ret; |
| 3395 } |
| 3396 } |
| 3397 |
| 3398 *target_errno = FILEIO_ENOSYS; |
| 3399 return -1; |
| 3400 } |
| 3401 |
| 3402 /* Read value of symbolic link FILENAME on the target. Return a |
| 3403 null-terminated string allocated via xmalloc, or NULL if an error |
| 3404 occurs (and set *TARGET_ERRNO). */ |
| 3405 char * |
| 3406 target_fileio_readlink (const char *filename, int *target_errno) |
| 3407 { |
| 3408 struct target_ops *t; |
| 3409 |
| 3410 for (t = default_fileio_target (); t != NULL; t = t->beneath) |
| 3411 { |
| 3412 if (t->to_fileio_readlink != NULL) |
| 3413 { |
| 3414 char *ret = t->to_fileio_readlink (filename, target_errno); |
| 3415 |
| 3416 if (targetdebug) |
| 3417 fprintf_unfiltered (gdb_stdlog, |
| 3418 "target_fileio_readlink (%s) = %s (%d)\n", |
| 3419 filename, ret? ret : "(nil)", |
| 3420 ret? 0 : *target_errno); |
| 3421 return ret; |
| 3422 } |
| 3423 } |
| 3424 |
| 3425 *target_errno = FILEIO_ENOSYS; |
| 3426 return NULL; |
| 3427 } |
| 3428 |
| 3429 static void |
| 3430 target_fileio_close_cleanup (void *opaque) |
| 3431 { |
| 3432 int fd = *(int *) opaque; |
| 3433 int target_errno; |
| 3434 |
| 3435 target_fileio_close (fd, &target_errno); |
| 3436 } |
| 3437 |
| 3438 /* Read target file FILENAME. Store the result in *BUF_P and |
| 3439 return the size of the transferred data. PADDING additional bytes are |
| 3440 available in *BUF_P. This is a helper function for |
| 3441 target_fileio_read_alloc; see the declaration of that function for more |
| 3442 information. */ |
| 3443 |
| 3444 static LONGEST |
| 3445 target_fileio_read_alloc_1 (const char *filename, |
| 3446 gdb_byte **buf_p, int padding) |
| 3447 { |
| 3448 struct cleanup *close_cleanup; |
| 3449 size_t buf_alloc, buf_pos; |
| 3450 gdb_byte *buf; |
| 3451 LONGEST n; |
| 3452 int fd; |
| 3453 int target_errno; |
| 3454 |
| 3455 fd = target_fileio_open (filename, FILEIO_O_RDONLY, 0700, &target_errno); |
| 3456 if (fd == -1) |
| 3457 return -1; |
| 3458 |
| 3459 close_cleanup = make_cleanup (target_fileio_close_cleanup, &fd); |
| 3460 |
| 3461 /* Start by reading up to 4K at a time. The target will throttle |
| 3462 this number down if necessary. */ |
| 3463 buf_alloc = 4096; |
| 3464 buf = xmalloc (buf_alloc); |
| 3465 buf_pos = 0; |
| 3466 while (1) |
| 3467 { |
| 3468 n = target_fileio_pread (fd, &buf[buf_pos], |
| 3469 buf_alloc - buf_pos - padding, buf_pos, |
| 3470 &target_errno); |
| 3471 if (n < 0) |
| 3472 { |
| 3473 /* An error occurred. */ |
| 3474 do_cleanups (close_cleanup); |
| 3475 xfree (buf); |
| 3476 return -1; |
| 3477 } |
| 3478 else if (n == 0) |
| 3479 { |
| 3480 /* Read all there was. */ |
| 3481 do_cleanups (close_cleanup); |
| 3482 if (buf_pos == 0) |
| 3483 xfree (buf); |
| 3484 else |
| 3485 *buf_p = buf; |
| 3486 return buf_pos; |
| 3487 } |
| 3488 |
| 3489 buf_pos += n; |
| 3490 |
| 3491 /* If the buffer is filling up, expand it. */ |
| 3492 if (buf_alloc < buf_pos * 2) |
| 3493 { |
| 3494 buf_alloc *= 2; |
| 3495 buf = xrealloc (buf, buf_alloc); |
| 3496 } |
| 3497 |
| 3498 QUIT; |
| 3499 } |
| 3500 } |
| 3501 |
| 3502 /* Read target file FILENAME. Store the result in *BUF_P and return |
| 3503 the size of the transferred data. See the declaration in "target.h" |
| 3504 function for more information about the return value. */ |
| 3505 |
| 3506 LONGEST |
| 3507 target_fileio_read_alloc (const char *filename, gdb_byte **buf_p) |
| 3508 { |
| 3509 return target_fileio_read_alloc_1 (filename, buf_p, 0); |
| 3510 } |
| 3511 |
| 3512 /* Read target file FILENAME. The result is NUL-terminated and |
| 3513 returned as a string, allocated using xmalloc. If an error occurs |
| 3514 or the transfer is unsupported, NULL is returned. Empty objects |
| 3515 are returned as allocated but empty strings. A warning is issued |
| 3516 if the result contains any embedded NUL bytes. */ |
| 3517 |
| 3518 char * |
| 3519 target_fileio_read_stralloc (const char *filename) |
| 3520 { |
| 3521 gdb_byte *buffer; |
| 3522 LONGEST i, transferred; |
| 3523 |
| 3524 transferred = target_fileio_read_alloc_1 (filename, &buffer, 1); |
| 3525 |
| 3526 if (transferred < 0) |
| 3527 return NULL; |
| 3528 |
| 3529 if (transferred == 0) |
| 3530 return xstrdup (""); |
| 3531 |
| 3532 buffer[transferred] = 0; |
| 3533 |
| 3534 /* Check for embedded NUL bytes; but allow trailing NULs. */ |
| 3535 for (i = strlen (buffer); i < transferred; i++) |
| 3536 if (buffer[i] != 0) |
| 3537 { |
| 3538 warning (_("target file %s " |
| 3539 "contained unexpected null characters"), |
| 3540 filename); |
| 3541 break; |
| 3542 } |
| 3543 |
| 3544 return (char *) buffer; |
| 3545 } |
| 3546 |
| 3547 |
3163 static int | 3548 static int |
3164 default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) | 3549 default_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) |
3165 { | 3550 { |
3166 return (len <= gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT); | 3551 return (len <= gdbarch_ptr_bit (target_gdbarch) / TARGET_CHAR_BIT); |
3167 } | 3552 } |
3168 | 3553 |
3169 static int | 3554 static int |
3170 default_watchpoint_addr_within_range (struct target_ops *target, | 3555 default_watchpoint_addr_within_range (struct target_ops *target, |
3171 CORE_ADDR addr, | 3556 CORE_ADDR addr, |
3172 CORE_ADDR start, int length) | 3557 CORE_ADDR start, int length) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3233 } | 3618 } |
3234 | 3619 |
3235 | 3620 |
3236 | 3621 |
3237 /* The inferior process has died. Long live the inferior! */ | 3622 /* The inferior process has died. Long live the inferior! */ |
3238 | 3623 |
3239 void | 3624 void |
3240 generic_mourn_inferior (void) | 3625 generic_mourn_inferior (void) |
3241 { | 3626 { |
3242 ptid_t ptid; | 3627 ptid_t ptid; |
error: old chunk mismatch |
None
OLD | NEW |