GNU Binutils with patches for OS216
リビジョン | 41d955439ed303ea6a8a0f0b8867ab67920cbe97 (tree) |
---|---|
日時 | 2005-06-04 11:18:29 |
作者 | Michael Snyder <msnyder@vmwa...> |
コミッター | Michael Snyder |
2005-06-03 Michael Snyder <msnyder@redhat.com>
* tracepoint.c, remote.c, target.c, target.h, etc.:
Begin moving tracepoint methods into the target vector,
and migrating some of the remote protocol stuff from
tracepoint.c into remote.c.
@@ -1,4 +1,11 @@ | ||
1 | -2005-05-12 Michael Snyder <msnyder@redhat.com> | |
1 | +2005-06-03 Michael Snyder <msnyder@redhat.com> | |
2 | + | |
3 | + * tracepoint.c, remote.c, target.c, target.h, etc.: | |
4 | + Begin moving tracepoint methods into the target vector, | |
5 | + and migrating some of the remote protocol stuff from | |
6 | + tracepoint.c into remote.c. | |
7 | + | |
8 | +2005-06-03 Michael Snyder <msnyder@redhat.com> | |
2 | 9 | |
3 | 10 | * tracepoint.c (emit_checkpoint_method4): Add PC to ckpt record. |
4 | 11 | * target.c (target_read_memory_trusted): New function. |
@@ -58,6 +58,8 @@ | ||
58 | 58 | |
59 | 59 | #include "remote-fileio.h" |
60 | 60 | |
61 | +#include "tracepoint.h" | |
62 | + | |
61 | 63 | /* Prototypes for local functions. */ |
62 | 64 | static void cleanup_sigint_signal_handler (void *dummy); |
63 | 65 | static void initialize_sigint_signal_handler (void); |
@@ -5366,6 +5368,41 @@ remote_get_thread_local_address (ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset) | ||
5366 | 5368 | return 0; |
5367 | 5369 | } |
5368 | 5370 | |
5371 | +static int | |
5372 | +remote_start_tracepoints (char *args, int from_tty) | |
5373 | +{ | |
5374 | + fprintf_unfiltered (gdb_stdout, "remote to_start_tracepoints\n"); | |
5375 | + return 0; | |
5376 | +} | |
5377 | + | |
5378 | +static int | |
5379 | +remote_stop_tracepoints (char *args, int from_tty) | |
5380 | +{ | |
5381 | + fprintf_unfiltered (gdb_stdout, "remote to_stop_tracepoints\n"); | |
5382 | + return 0; | |
5383 | +} | |
5384 | + | |
5385 | +static int | |
5386 | +remote_tracepoint_status (char *args, int from_tty) | |
5387 | +{ | |
5388 | + struct remote_state *rs = get_remote_state (); | |
5389 | + char *buf = alloca (rs->remote_packet_size); | |
5390 | + | |
5391 | + if (from_tty && info_verbose) | |
5392 | + fprintf_unfiltered (gdb_stdout, "remote to_tracepoint_status\n"); | |
5393 | + putpkt ("qTStatus"); | |
5394 | + /* FIXME: How about async? See tracepoint.c, get_noisy_reply. */ | |
5395 | + getpkt (buf, rs->remote_packet_size, 0); | |
5396 | + | |
5397 | + if (buf[0] != 'T' || | |
5398 | + (buf[1] != '0' && buf[1] != '1')) | |
5399 | + return 0; /* Target does not support. */ | |
5400 | + | |
5401 | + /* Exported for use by the GUI. */ | |
5402 | + trace_running_p = (buf[1] == '1'); | |
5403 | + return 1; | |
5404 | +} | |
5405 | + | |
5369 | 5406 | static void |
5370 | 5407 | init_remote_ops (void) |
5371 | 5408 | { |
@@ -5413,6 +5450,9 @@ Specify the serial device it is connected to\n\ | ||
5413 | 5450 | remote_ops.to_has_registers = 1; |
5414 | 5451 | remote_ops.to_has_execution = 1; |
5415 | 5452 | remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */ |
5453 | + remote_ops.to_start_tracepoints = remote_start_tracepoints; | |
5454 | + remote_ops.to_stop_tracepoints = remote_stop_tracepoints; | |
5455 | + remote_ops.to_tracepoint_status = remote_tracepoint_status; | |
5416 | 5456 | remote_ops.to_magic = OPS_MAGIC; |
5417 | 5457 | } |
5418 | 5458 |
@@ -5542,6 +5582,9 @@ Specify the serial device it is connected to (e.g. /dev/ttya)."; | ||
5542 | 5582 | remote_async_ops.to_is_async_p = remote_is_async_p; |
5543 | 5583 | remote_async_ops.to_async = remote_async; |
5544 | 5584 | remote_async_ops.to_async_mask_value = 1; |
5585 | + remote_async_ops.to_start_tracepoints = remote_start_tracepoints; | |
5586 | + remote_async_ops.to_stop_tracepoints = remote_stop_tracepoints; | |
5587 | + remote_async_ops.to_tracepoint_status = remote_tracepoint_status; | |
5545 | 5588 | remote_async_ops.to_magic = OPS_MAGIC; |
5546 | 5589 | } |
5547 | 5590 |
@@ -38,6 +38,7 @@ | ||
38 | 38 | #include "regcache.h" |
39 | 39 | #include "gdb_assert.h" |
40 | 40 | #include "gdbcore.h" |
41 | +#include "tracepoint.h" | |
41 | 42 | |
42 | 43 | static void target_info (char *, int); |
43 | 44 |
@@ -456,6 +457,10 @@ update_current_target (void) | ||
456 | 457 | INHERIT (to_find_memory_regions, t); |
457 | 458 | INHERIT (to_make_corefile_notes, t); |
458 | 459 | INHERIT (to_get_thread_local_address, t); |
460 | + INHERIT (to_start_tracepoints, t); | |
461 | + INHERIT (to_stop_tracepoints, t); | |
462 | + INHERIT (to_tracepoint_status, t); | |
463 | + | |
459 | 464 | INHERIT (to_magic, t); |
460 | 465 | } |
461 | 466 | #undef INHERIT |
@@ -636,6 +641,16 @@ update_current_target (void) | ||
636 | 641 | de_fault (to_async, |
637 | 642 | (void (*) (void (*) (enum inferior_event_type, void*), void*)) |
638 | 643 | tcomplain); |
644 | + de_fault (to_start_tracepoints, | |
645 | + (int (*) (char *, int)) | |
646 | + return_zero); | |
647 | + de_fault (to_stop_tracepoints, | |
648 | + (int (*) (char *, int)) | |
649 | + return_zero); | |
650 | + de_fault (to_tracepoint_status, | |
651 | + (int (*) (char *, int)) | |
652 | + return_zero); | |
653 | + | |
639 | 654 | #undef de_fault |
640 | 655 | |
641 | 656 | /* Finally, position the target-stack beneath the squashed |
@@ -1847,6 +1862,36 @@ static char * dummy_make_corefile_notes (bfd *ignore1, int *ignore2) | ||
1847 | 1862 | return NULL; |
1848 | 1863 | } |
1849 | 1864 | |
1865 | +/* Generic fallback method for tracepoints: start tracepoint experiment. */ | |
1866 | +static int | |
1867 | +default_start_tracepoints (char *args, int from_tty) | |
1868 | +{ | |
1869 | + if (info_verbose) | |
1870 | + fprintf_unfiltered (gdb_stdout, "default to_start_tracepoints\n"); | |
1871 | + | |
1872 | + return trace_default_start (args, from_tty); | |
1873 | +} | |
1874 | + | |
1875 | +/* Generic fallback method for tracepoints: stop tracepoint experiment. */ | |
1876 | +static int | |
1877 | +default_stop_tracepoints (char *args, int from_tty) | |
1878 | +{ | |
1879 | + if (info_verbose) | |
1880 | + fprintf_unfiltered (gdb_stdout, "default to_stop_tracepoints\n"); | |
1881 | + | |
1882 | + return trace_default_stop (args, from_tty); | |
1883 | +} | |
1884 | + | |
1885 | +/* Generic fallback method for tracepoints: tracepoint experiment status. */ | |
1886 | +static int | |
1887 | +default_tracepoint_status (char *args, int from_tty) | |
1888 | +{ | |
1889 | + if (info_verbose) | |
1890 | + fprintf_unfiltered (gdb_stdout, "default to_tracepoint_status\n"); | |
1891 | + | |
1892 | + return trace_default_status (args, from_tty); | |
1893 | +} | |
1894 | + | |
1850 | 1895 | /* Set up the handful of non-empty slots needed by the dummy target |
1851 | 1896 | vector. */ |
1852 | 1897 |
@@ -1863,6 +1908,9 @@ init_dummy_target (void) | ||
1863 | 1908 | dummy_target.to_find_memory_regions = dummy_find_memory_regions; |
1864 | 1909 | dummy_target.to_make_corefile_notes = dummy_make_corefile_notes; |
1865 | 1910 | dummy_target.to_xfer_partial = default_xfer_partial; |
1911 | + dummy_target.to_start_tracepoints = default_start_tracepoints; | |
1912 | + dummy_target.to_stop_tracepoints = default_stop_tracepoints; | |
1913 | + dummy_target.to_tracepoint_status = default_tracepoint_status; | |
1866 | 1914 | dummy_target.to_magic = OPS_MAGIC; |
1867 | 1915 | } |
1868 | 1916 |
@@ -2530,6 +2578,36 @@ debug_to_pid_to_exec_file (int pid) | ||
2530 | 2578 | return exec_file; |
2531 | 2579 | } |
2532 | 2580 | |
2581 | +static int | |
2582 | +debug_to_start_tracepoints (char *args, int from_tty) | |
2583 | +{ | |
2584 | + int ret = debug_target.to_start_tracepoints (args, from_tty); | |
2585 | + | |
2586 | + fprintf_unfiltered (gdb_stdout, | |
2587 | + "target to_start_tracepoints returns %d\n", ret); | |
2588 | + return ret; | |
2589 | +} | |
2590 | + | |
2591 | +static int | |
2592 | +debug_to_stop_tracepoints (char *args, int from_tty) | |
2593 | +{ | |
2594 | + int ret = debug_target.to_stop_tracepoints (args, from_tty); | |
2595 | + | |
2596 | + fprintf_unfiltered (gdb_stdout, | |
2597 | + "target to_stop_tracepoints returns %d\n", ret); | |
2598 | + return ret; | |
2599 | +} | |
2600 | + | |
2601 | +static int | |
2602 | +debug_to_tracepoint_status (char *args, int from_tty) | |
2603 | +{ | |
2604 | + int ret = debug_target.to_tracepoint_status (args, from_tty); | |
2605 | + | |
2606 | + fprintf_unfiltered (gdb_stdout, | |
2607 | + "target to_tracepoint_status returns %d\n", ret); | |
2608 | + return ret; | |
2609 | +} | |
2610 | + | |
2533 | 2611 | static void |
2534 | 2612 | setup_target_debug (void) |
2535 | 2613 | { |
@@ -2590,6 +2668,10 @@ setup_target_debug (void) | ||
2590 | 2668 | current_target.to_get_current_exception_event = debug_to_get_current_exception_event; |
2591 | 2669 | current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file; |
2592 | 2670 | |
2671 | + current_target.to_start_tracepoints = debug_to_start_tracepoints; | |
2672 | + current_target.to_stop_tracepoints = debug_to_stop_tracepoints; | |
2673 | + current_target.to_tracepoint_status = debug_to_tracepoint_status; | |
2674 | + | |
2593 | 2675 | } |
2594 | 2676 | |
2595 | 2677 |
@@ -422,6 +422,13 @@ struct target_ops | ||
422 | 422 | gdb_byte *readbuf, const gdb_byte *writebuf, |
423 | 423 | ULONGEST offset, LONGEST len); |
424 | 424 | |
425 | + /* Tracepoint start. */ | |
426 | + int (*to_start_tracepoints) (char *, int); | |
427 | + /* Tracepoint stop. */ | |
428 | + int (*to_stop_tracepoints) (char *, int); | |
429 | + /* Tracepoint status. */ | |
430 | + int (*to_tracepoint_status) (char *, int); | |
431 | + | |
425 | 432 | int to_magic; |
426 | 433 | /* Need sub-structure for target machine related rather than comm related? |
427 | 434 | */ |
@@ -1067,6 +1074,14 @@ extern int target_stopped_data_address_p (struct target_ops *); | ||
1067 | 1074 | #define target_stopped_data_address_p(CURRENT_TARGET) (1) |
1068 | 1075 | #endif |
1069 | 1076 | |
1077 | +#define target_start_tracepoints(ARGS, FROM_TTY) \ | |
1078 | + (*current_target.to_start_tracepoints) (ARGS, FROM_TTY) | |
1079 | +#define target_stop_tracepoints(ARGS, FROM_TTY) \ | |
1080 | + (*current_target.to_stop_tracepoints) (ARGS, FROM_TTY) | |
1081 | +#define target_tracepoint_status(ARGS, FROM_TTY) \ | |
1082 | + (*current_target.to_tracepoint_status) (ARGS, FROM_TTY) | |
1083 | + | |
1084 | + | |
1070 | 1085 | /* This will only be defined by a target that supports catching vfork events, |
1071 | 1086 | such as HP-UX. |
1072 | 1087 |
@@ -1787,6 +1787,9 @@ remote_set_transparent_ranges (void) | ||
1787 | 1787 | } |
1788 | 1788 | } |
1789 | 1789 | |
1790 | +unsigned long trace_running_p; | |
1791 | +static FILE *checkpoint_file; | |
1792 | + | |
1790 | 1793 | /* tstart command: |
1791 | 1794 | |
1792 | 1795 | Tell target to clear any previous trace experiment. |
@@ -1794,9 +1797,44 @@ remote_set_transparent_ranges (void) | ||
1794 | 1797 | to the target. If no errors, |
1795 | 1798 | Tell target to start a new trace experiment. */ |
1796 | 1799 | |
1800 | +extern int | |
1801 | +trace_default_start (char *args, int from_tty) | |
1802 | +{ | |
1803 | + if (checkpoint_file == NULL) | |
1804 | + error (_("\ | |
1805 | +You must open a tracepoint file to use the default tracepoint\n\ | |
1806 | +method. This will enable gdb to save trace data into a file.\n\n\ | |
1807 | +See 'help open-tracepoint-file'.")); | |
1808 | + | |
1809 | + if (from_tty && info_verbose) | |
1810 | + fprintf_filtered (gdb_stdout, "default trace start\n"); | |
1811 | + set_traceframe_num (-1); /* All old traceframes invalidated. */ | |
1812 | + set_tracepoint_num (-1); | |
1813 | + set_traceframe_context (-1); | |
1814 | + trace_running_p = 1; | |
1815 | + if (deprecated_trace_start_stop_hook) | |
1816 | + deprecated_trace_start_stop_hook (1, from_tty); | |
1817 | + | |
1818 | + return 1; /* Handled. */ | |
1819 | +} | |
1820 | + | |
1797 | 1821 | static void |
1798 | 1822 | trace_start_command (char *args, int from_tty) |
1799 | 1823 | { |
1824 | +#if 1 | |
1825 | + if (!target_start_tracepoints (args, from_tty)) | |
1826 | + { | |
1827 | + if (!default_trace_method) | |
1828 | + if (query (_("Target tracepoint support not active. Use default method? "))) | |
1829 | + default_trace_method++; | |
1830 | + | |
1831 | + if (default_trace_method) | |
1832 | + trace_default_start (args, from_tty); | |
1833 | + else if (from_tty) | |
1834 | + fprintf_filtered (gdb_stdout, "Cancelled.\n"); | |
1835 | + } | |
1836 | + return; | |
1837 | +#else | |
1800 | 1838 | struct tracepoint *t; |
1801 | 1839 | char buf[2048]; |
1802 | 1840 | char **tdp_actions; |
@@ -1903,12 +1941,47 @@ trace_start_command (char *args, int from_tty) | ||
1903 | 1941 | trace_running_p = 1; |
1904 | 1942 | if (deprecated_trace_start_stop_hook) |
1905 | 1943 | deprecated_trace_start_stop_hook (1, from_tty); |
1944 | +#endif | |
1945 | +} | |
1946 | + | |
1947 | +/* tstop command: | |
1948 | + Tell the target to stop collecting trace data. */ | |
1949 | + | |
1950 | +extern int | |
1951 | +trace_default_stop (char *args, int from_tty) | |
1952 | +{ | |
1953 | + if (checkpoint_file == NULL) | |
1954 | + error (_("\ | |
1955 | +You must open a tracepoint file to use the default tracepoint\n\ | |
1956 | +method. This will enable gdb to save trace data into a file.\n\n\ | |
1957 | +See 'help open-tracepoint-file'.")); | |
1958 | + | |
1959 | + if (from_tty && info_verbose) | |
1960 | + fprintf_filtered (gdb_stdout, "default trace stop\n"); | |
1961 | + trace_running_p = 0; | |
1962 | + if (deprecated_trace_start_stop_hook) | |
1963 | + deprecated_trace_start_stop_hook (0, from_tty); | |
1964 | + | |
1965 | + return 1; /* Handled. */ | |
1906 | 1966 | } |
1907 | 1967 | |
1908 | -/* tstop command */ | |
1909 | 1968 | static void |
1910 | 1969 | trace_stop_command (char *args, int from_tty) |
1911 | 1970 | { |
1971 | +#if 1 | |
1972 | + if (!target_stop_tracepoints (args, from_tty)) | |
1973 | + { | |
1974 | + if (!default_trace_method) | |
1975 | + if (query (_("Target tracepoint support not active. Use default method? "))) | |
1976 | + default_trace_method++; | |
1977 | + | |
1978 | + if (default_trace_method) | |
1979 | + trace_default_stop (args, from_tty); | |
1980 | + else | |
1981 | + fprintf_filtered (gdb_stdout, "Cancelled.\n"); | |
1982 | + } | |
1983 | + return; | |
1984 | +#else | |
1912 | 1985 | if (default_trace_method) |
1913 | 1986 | { |
1914 | 1987 | /* Default implementation. */ |
@@ -1931,14 +2004,47 @@ trace_stop_command (char *args, int from_tty) | ||
1931 | 2004 | trace_running_p = 0; |
1932 | 2005 | if (deprecated_trace_start_stop_hook) |
1933 | 2006 | deprecated_trace_start_stop_hook (0, from_tty); |
2007 | +#endif | |
1934 | 2008 | } |
1935 | 2009 | |
1936 | -unsigned long trace_running_p; | |
2010 | +/* tstatus command: | |
2011 | + Report whether trace is running. */ | |
2012 | + | |
2013 | +extern int | |
2014 | +trace_default_status (char *args, int from_tty) | |
2015 | +{ | |
2016 | + if (checkpoint_file == NULL) | |
2017 | + error (_("\ | |
2018 | +You must open a tracepoint file to use the default tracepoint\n\ | |
2019 | +method. This will enable gdb to save trace data into a file.\n\n\ | |
2020 | +See 'help open-tracepoint-file'.")); | |
2021 | + | |
2022 | + if (from_tty && info_verbose) | |
2023 | + fprintf_filtered (gdb_stdout, "default trace status\n"); | |
2024 | + | |
2025 | + fprintf_filtered (gdb_stdout, "Trace is %s.\n", | |
2026 | + trace_running_p ? "on" : "off"); | |
2027 | + | |
2028 | + return 1; /* Handled. */ | |
2029 | +} | |
1937 | 2030 | |
1938 | -/* tstatus command */ | |
1939 | 2031 | static void |
1940 | 2032 | trace_status_command (char *args, int from_tty) |
1941 | 2033 | { |
2034 | +#if 1 | |
2035 | + if (!target_tracepoint_status (args, from_tty)) | |
2036 | + { | |
2037 | + if (!default_trace_method) | |
2038 | + if (query (_("Target tracepoint support not active. Use default method? "))) | |
2039 | + default_trace_method++; | |
2040 | + | |
2041 | + if (default_trace_method) | |
2042 | + trace_default_status (args, from_tty); | |
2043 | + else | |
2044 | + fprintf_filtered (gdb_stdout, "Cancelled.\n"); | |
2045 | + } | |
2046 | + return; | |
2047 | +#else | |
1942 | 2048 | if (default_trace_method) |
1943 | 2049 | { |
1944 | 2050 | printf_filtered ("Trace is %s.\n", trace_running_p ? "on" : "off"); |
@@ -1959,6 +2065,7 @@ trace_status_command (char *args, int from_tty) | ||
1959 | 2065 | { |
1960 | 2066 | error (_("Target does not implement this command (tstatus).")); |
1961 | 2067 | } |
2068 | +#endif | |
1962 | 2069 | } |
1963 | 2070 | |
1964 | 2071 | /* Worker function for the various flavors of the tfind command. */ |
@@ -2754,7 +2861,6 @@ get_traceframe_number (void) | ||
2754 | 2861 | return traceframe_number; |
2755 | 2862 | } |
2756 | 2863 | |
2757 | -static FILE *checkpoint_file; | |
2758 | 2864 | static int tracepoint_method; |
2759 | 2865 | |
2760 | 2866 | static void |
@@ -3122,14 +3228,14 @@ static void | ||
3122 | 3228 | checkpoint_open (char *args, int from_tty) |
3123 | 3229 | { |
3124 | 3230 | if (args == NULL || *args == '\0') |
3125 | - error ("Argument required: checkpoint file name."); | |
3231 | + error ("Argument required: filename for tracepoint/checkpoint data."); | |
3126 | 3232 | |
3127 | 3233 | if ((checkpoint_file = fopen (args, "w")) == NULL) |
3128 | 3234 | error ("Could not open checkpoint file %s for output.", args); |
3129 | 3235 | |
3130 | 3236 | fprintf (checkpoint_file, "CHECKPOINT FILE\n"); |
3131 | 3237 | if (from_tty) |
3132 | - fprintf_filtered (gdb_stdout, "File '%s' open for checkpoints.\n", | |
3238 | + fprintf_filtered (gdb_stdout, "File '%s' open for trace/checkpoints.\n", | |
3133 | 3239 | args); |
3134 | 3240 | } |
3135 | 3241 |
@@ -3212,6 +3318,11 @@ Open output file for checkpoints.\n\ | ||
3212 | 3318 | Argument is filename."); |
3213 | 3319 | set_cmd_completer (c, filename_completer); |
3214 | 3320 | |
3321 | + c = add_com ("open-tracepoint", class_trace, checkpoint_open, "\ | |
3322 | +Open output file for tracepoints.\n\ | |
3323 | +Argument is filename."); | |
3324 | + set_cmd_completer (c, filename_completer); | |
3325 | + | |
3215 | 3326 | c = add_com ("close-checkpoint", class_trace, checkpoint_close, "\ |
3216 | 3327 | Close checkpoint file.\n\ |
3217 | 3328 | No arguments, since only one checkpoint file may be open at a time."); |
@@ -25,6 +25,10 @@ | ||
25 | 25 | |
26 | 26 | extern int default_trace_method; |
27 | 27 | extern int tracepoint_event_p (void); |
28 | +extern int trace_default_start (char *, int); | |
29 | +extern int trace_default_stop (char *, int); | |
30 | +extern int trace_default_status (char *, int); | |
31 | +extern unsigned long trace_running_p; | |
28 | 32 | |
29 | 33 | /* Most of what follows is not meant for export. |
30 | 34 | They're just forward declarations for internal use in tracepoint.c. */ |
@@ -119,8 +123,6 @@ enum actionline_type | ||
119 | 123 | |
120 | 124 | extern struct tracepoint *tracepoint_chain; |
121 | 125 | |
122 | -extern unsigned long trace_running_p; | |
123 | - | |
124 | 126 | /* A hook used to notify the UI of tracepoint operations. */ |
125 | 127 | |
126 | 128 | void (*deprecated_create_tracepoint_hook) (struct tracepoint *); |