• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisión41d955439ed303ea6a8a0f0b8867ab67920cbe97 (tree)
Tiempo2005-06-04 11:18:29
AutorMichael Snyder <msnyder@vmwa...>
CommiterMichael Snyder

Log Message

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.

Cambiar Resumen

Diferencia incremental

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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>
29
310 * tracepoint.c (emit_checkpoint_method4): Add PC to ckpt record.
411 * target.c (target_read_memory_trusted): New function.
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -58,6 +58,8 @@
5858
5959 #include "remote-fileio.h"
6060
61+#include "tracepoint.h"
62+
6163 /* Prototypes for local functions. */
6264 static void cleanup_sigint_signal_handler (void *dummy);
6365 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)
53665368 return 0;
53675369 }
53685370
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+
53695406 static void
53705407 init_remote_ops (void)
53715408 {
@@ -5413,6 +5450,9 @@ Specify the serial device it is connected to\n\
54135450 remote_ops.to_has_registers = 1;
54145451 remote_ops.to_has_execution = 1;
54155452 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;
54165456 remote_ops.to_magic = OPS_MAGIC;
54175457 }
54185458
@@ -5542,6 +5582,9 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
55425582 remote_async_ops.to_is_async_p = remote_is_async_p;
55435583 remote_async_ops.to_async = remote_async;
55445584 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;
55455588 remote_async_ops.to_magic = OPS_MAGIC;
55465589 }
55475590
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -38,6 +38,7 @@
3838 #include "regcache.h"
3939 #include "gdb_assert.h"
4040 #include "gdbcore.h"
41+#include "tracepoint.h"
4142
4243 static void target_info (char *, int);
4344
@@ -456,6 +457,10 @@ update_current_target (void)
456457 INHERIT (to_find_memory_regions, t);
457458 INHERIT (to_make_corefile_notes, t);
458459 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+
459464 INHERIT (to_magic, t);
460465 }
461466 #undef INHERIT
@@ -636,6 +641,16 @@ update_current_target (void)
636641 de_fault (to_async,
637642 (void (*) (void (*) (enum inferior_event_type, void*), void*))
638643 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+
639654 #undef de_fault
640655
641656 /* Finally, position the target-stack beneath the squashed
@@ -1847,6 +1862,36 @@ static char * dummy_make_corefile_notes (bfd *ignore1, int *ignore2)
18471862 return NULL;
18481863 }
18491864
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+
18501895 /* Set up the handful of non-empty slots needed by the dummy target
18511896 vector. */
18521897
@@ -1863,6 +1908,9 @@ init_dummy_target (void)
18631908 dummy_target.to_find_memory_regions = dummy_find_memory_regions;
18641909 dummy_target.to_make_corefile_notes = dummy_make_corefile_notes;
18651910 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;
18661914 dummy_target.to_magic = OPS_MAGIC;
18671915 }
18681916
@@ -2530,6 +2578,36 @@ debug_to_pid_to_exec_file (int pid)
25302578 return exec_file;
25312579 }
25322580
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+
25332611 static void
25342612 setup_target_debug (void)
25352613 {
@@ -2590,6 +2668,10 @@ setup_target_debug (void)
25902668 current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
25912669 current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
25922670
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+
25932675 }
25942676
25952677
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -422,6 +422,13 @@ struct target_ops
422422 gdb_byte *readbuf, const gdb_byte *writebuf,
423423 ULONGEST offset, LONGEST len);
424424
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+
425432 int to_magic;
426433 /* Need sub-structure for target machine related rather than comm related?
427434 */
@@ -1067,6 +1074,14 @@ extern int target_stopped_data_address_p (struct target_ops *);
10671074 #define target_stopped_data_address_p(CURRENT_TARGET) (1)
10681075 #endif
10691076
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+
10701085 /* This will only be defined by a target that supports catching vfork events,
10711086 such as HP-UX.
10721087
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1787,6 +1787,9 @@ remote_set_transparent_ranges (void)
17871787 }
17881788 }
17891789
1790+unsigned long trace_running_p;
1791+static FILE *checkpoint_file;
1792+
17901793 /* tstart command:
17911794
17921795 Tell target to clear any previous trace experiment.
@@ -1794,9 +1797,44 @@ remote_set_transparent_ranges (void)
17941797 to the target. If no errors,
17951798 Tell target to start a new trace experiment. */
17961799
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+
17971821 static void
17981822 trace_start_command (char *args, int from_tty)
17991823 {
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
18001838 struct tracepoint *t;
18011839 char buf[2048];
18021840 char **tdp_actions;
@@ -1903,12 +1941,47 @@ trace_start_command (char *args, int from_tty)
19031941 trace_running_p = 1;
19041942 if (deprecated_trace_start_stop_hook)
19051943 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. */
19061966 }
19071967
1908-/* tstop command */
19091968 static void
19101969 trace_stop_command (char *args, int from_tty)
19111970 {
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
19121985 if (default_trace_method)
19131986 {
19141987 /* Default implementation. */
@@ -1931,14 +2004,47 @@ trace_stop_command (char *args, int from_tty)
19312004 trace_running_p = 0;
19322005 if (deprecated_trace_start_stop_hook)
19332006 deprecated_trace_start_stop_hook (0, from_tty);
2007+#endif
19342008 }
19352009
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+}
19372030
1938-/* tstatus command */
19392031 static void
19402032 trace_status_command (char *args, int from_tty)
19412033 {
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
19422048 if (default_trace_method)
19432049 {
19442050 printf_filtered ("Trace is %s.\n", trace_running_p ? "on" : "off");
@@ -1959,6 +2065,7 @@ trace_status_command (char *args, int from_tty)
19592065 {
19602066 error (_("Target does not implement this command (tstatus)."));
19612067 }
2068+#endif
19622069 }
19632070
19642071 /* Worker function for the various flavors of the tfind command. */
@@ -2754,7 +2861,6 @@ get_traceframe_number (void)
27542861 return traceframe_number;
27552862 }
27562863
2757-static FILE *checkpoint_file;
27582864 static int tracepoint_method;
27592865
27602866 static void
@@ -3122,14 +3228,14 @@ static void
31223228 checkpoint_open (char *args, int from_tty)
31233229 {
31243230 if (args == NULL || *args == '\0')
3125- error ("Argument required: checkpoint file name.");
3231+ error ("Argument required: filename for tracepoint/checkpoint data.");
31263232
31273233 if ((checkpoint_file = fopen (args, "w")) == NULL)
31283234 error ("Could not open checkpoint file %s for output.", args);
31293235
31303236 fprintf (checkpoint_file, "CHECKPOINT FILE\n");
31313237 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",
31333239 args);
31343240 }
31353241
@@ -3212,6 +3318,11 @@ Open output file for checkpoints.\n\
32123318 Argument is filename.");
32133319 set_cmd_completer (c, filename_completer);
32143320
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+
32153326 c = add_com ("close-checkpoint", class_trace, checkpoint_close, "\
32163327 Close checkpoint file.\n\
32173328 No arguments, since only one checkpoint file may be open at a time.");
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -25,6 +25,10 @@
2525
2626 extern int default_trace_method;
2727 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;
2832
2933 /* Most of what follows is not meant for export.
3034 They're just forward declarations for internal use in tracepoint.c. */
@@ -119,8 +123,6 @@ enum actionline_type
119123
120124 extern struct tracepoint *tracepoint_chain;
121125
122-extern unsigned long trace_running_p;
123-
124126 /* A hook used to notify the UI of tracepoint operations. */
125127
126128 void (*deprecated_create_tracepoint_hook) (struct tracepoint *);