1 /* Tracing functionality for remote targets in custom GDB protocol
2 Copyright 1997, 1998 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 #include "expression.h"
30 #include "gdb_string.h"
32 #include "tracepoint.h"
38 /* readline include files */
39 #include <readline/readline.h>
40 #include <readline/history.h>
42 /* readline defines this. */
49 /* maximum length of an agent aexpression.
50 this accounts for the fact that packets are limited to 400 bytes
51 (which includes everything -- including the checksum), and assumes
52 the worst case of maximum length for each of the pieces of a
55 NOTE: expressions get mem2hex'ed otherwise this would be twice as
56 large. (400 - 31)/2 == 184 */
57 #define MAX_AGENT_EXPR_LEN 184
60 extern int info_verbose;
61 extern void (*readline_begin_hook) PARAMS ((char *,...));
62 extern char *(*readline_hook) PARAMS ((char *));
63 extern void (*readline_end_hook) PARAMS ((void));
64 extern void x_command PARAMS ((char *, int));
65 extern int addressprint; /* Print machine addresses? */
67 /* GDB commands implemented in other modules:
70 extern void output_command PARAMS ((char *, int));
71 extern void registers_info PARAMS ((char *, int));
72 extern void args_info PARAMS ((char *, int));
73 extern void locals_info PARAMS ((char *, int));
76 /* If this definition isn't overridden by the header files, assume
77 that isatty and fileno exist on this system. */
79 #define ISATTY(FP) (isatty (fileno (FP)))
85 This module defines the following debugger commands:
86 trace : set a tracepoint on a function, line, or address.
87 info trace : list all debugger-defined tracepoints.
88 delete trace : delete one or more tracepoints.
89 enable trace : enable one or more tracepoints.
90 disable trace : disable one or more tracepoints.
91 actions : specify actions to be taken at a tracepoint.
92 passcount : specify a pass count for a tracepoint.
93 tstart : start a trace experiment.
94 tstop : stop a trace experiment.
95 tstatus : query the status of a trace experiment.
96 tfind : find a trace frame in the trace buffer.
97 tdump : print everything collected at the current tracepoint.
98 save-tracepoints : write tracepoint setup into a file.
100 This module defines the following user-visible debugger variables:
101 $trace_frame : sequence number of trace frame currently being debugged.
102 $trace_line : source line of trace frame currently being debugged.
103 $trace_file : source file of trace frame currently being debugged.
104 $tracepoint : tracepoint number of trace frame currently being debugged.
108 /* ======= Important global variables: ======= */
110 /* Chain of all tracepoints defined. */
111 struct tracepoint *tracepoint_chain;
113 /* Number of last tracepoint made. */
114 static int tracepoint_count;
116 /* Number of last traceframe collected. */
117 static int traceframe_number;
119 /* Tracepoint for last traceframe collected. */
120 static int tracepoint_number;
122 /* Symbol for function for last traceframe collected */
123 static struct symbol *traceframe_fun;
125 /* Symtab and line for last traceframe collected */
126 static struct symtab_and_line traceframe_sal;
128 /* Tracing command lists */
129 static struct cmd_list_element *tfindlist;
131 /* ======= Important command functions: ======= */
132 static void trace_command PARAMS ((char *, int));
133 static void tracepoints_info PARAMS ((char *, int));
134 static void delete_trace_command PARAMS ((char *, int));
135 static void enable_trace_command PARAMS ((char *, int));
136 static void disable_trace_command PARAMS ((char *, int));
137 static void trace_pass_command PARAMS ((char *, int));
138 static void trace_actions_command PARAMS ((char *, int));
139 static void trace_start_command PARAMS ((char *, int));
140 static void trace_stop_command PARAMS ((char *, int));
141 static void trace_status_command PARAMS ((char *, int));
142 static void trace_find_command PARAMS ((char *, int));
143 static void trace_find_pc_command PARAMS ((char *, int));
144 static void trace_find_tracepoint_command PARAMS ((char *, int));
145 static void trace_find_line_command PARAMS ((char *, int));
146 static void trace_find_range_command PARAMS ((char *, int));
147 static void trace_find_outside_command PARAMS ((char *, int));
148 static void tracepoint_save_command PARAMS ((char *, int));
149 static void trace_dump_command PARAMS ((char *, int));
151 /* support routines */
152 static void trace_mention PARAMS ((struct tracepoint *));
154 struct collection_list;
155 static void add_aexpr PARAMS ((struct collection_list *, struct agent_expr *));
156 static unsigned char *mem2hex (unsigned char *, unsigned char *, int);
157 static void add_register PARAMS ((struct collection_list * collection,
158 unsigned int regno));
159 static void free_actions_list PARAMS ((char **actions_list));
160 static void free_actions_list_cleanup_wrapper PARAMS ((void *));
162 extern void _initialize_tracepoint PARAMS ((void));
164 /* Utility: returns true if "target remote" */
168 if (current_target.to_shortname &&
169 strcmp (current_target.to_shortname, "remote") == 0)
175 /* Utility: generate error from an incoming stub packet. */
181 return; /* not an error msg */
184 case '1': /* malformed packet error */
185 if (*++buf == '0') /* general case: */
186 error ("tracepoint.c: error in outgoing packet.");
188 error ("tracepoint.c: error in outgoing packet at field #%d.",
189 strtol (buf, NULL, 16));
191 error ("trace API error 0x%s.", ++buf);
193 error ("Target returns error code '%s'.", buf);
197 /* Utility: wait for reply from stub, while accepting "O" packets */
199 remote_get_noisy_reply (char *buf,
202 do /* loop on reply from remote stub */
204 QUIT; /* allow user to bail out with ^C */
205 getpkt (buf, sizeof_buf, 0);
207 error ("Target does not support this command.");
208 else if (buf[0] == 'E')
210 else if (buf[0] == 'O' &&
212 remote_console_output (buf + 1); /* 'O' message from stub */
214 return buf; /* here's the actual reply */
219 /* Set tracepoint count to NUM. */
221 set_tracepoint_count (num)
224 tracepoint_count = num;
225 set_internalvar (lookup_internalvar ("tpnum"),
226 value_from_longest (builtin_type_int, (LONGEST) num));
229 /* Set traceframe number to NUM. */
231 set_traceframe_num (num)
234 traceframe_number = num;
235 set_internalvar (lookup_internalvar ("trace_frame"),
236 value_from_longest (builtin_type_int, (LONGEST) num));
239 /* Set tracepoint number to NUM. */
241 set_tracepoint_num (num)
244 tracepoint_number = num;
245 set_internalvar (lookup_internalvar ("tracepoint"),
246 value_from_longest (builtin_type_int, (LONGEST) num));
249 /* Set externally visible debug variables for querying/printing
250 the traceframe context (line, function, file) */
253 set_traceframe_context (trace_pc)
256 static struct type *func_string, *file_string;
257 static struct type *func_range, *file_range;
258 static value_ptr func_val, file_val;
259 static struct type *charstar;
262 if (charstar == (struct type *) NULL)
263 charstar = lookup_pointer_type (builtin_type_char);
265 if (trace_pc == -1) /* cease debugging any trace buffers */
268 traceframe_sal.pc = traceframe_sal.line = 0;
269 traceframe_sal.symtab = NULL;
270 set_internalvar (lookup_internalvar ("trace_func"),
271 value_from_pointer (charstar, (LONGEST) 0));
272 set_internalvar (lookup_internalvar ("trace_file"),
273 value_from_pointer (charstar, (LONGEST) 0));
274 set_internalvar (lookup_internalvar ("trace_line"),
275 value_from_pointer (builtin_type_int, (LONGEST) - 1));
279 /* save as globals for internal use */
280 traceframe_sal = find_pc_line (trace_pc, 0);
281 traceframe_fun = find_pc_function (trace_pc);
283 /* save linenumber as "$trace_line", a debugger variable visible to users */
284 set_internalvar (lookup_internalvar ("trace_line"),
285 value_from_longest (builtin_type_int,
286 (LONGEST) traceframe_sal.line));
288 /* save func name as "$trace_func", a debugger variable visible to users */
289 if (traceframe_fun == NULL ||
290 SYMBOL_NAME (traceframe_fun) == NULL)
291 set_internalvar (lookup_internalvar ("trace_func"),
292 value_from_pointer (charstar, (LONGEST) 0));
295 len = strlen (SYMBOL_NAME (traceframe_fun));
296 func_range = create_range_type (func_range,
297 builtin_type_int, 0, len - 1);
298 func_string = create_array_type (func_string,
299 builtin_type_char, func_range);
300 func_val = allocate_value (func_string);
301 VALUE_TYPE (func_val) = func_string;
302 memcpy (VALUE_CONTENTS_RAW (func_val),
303 SYMBOL_NAME (traceframe_fun),
305 func_val->modifiable = 0;
306 set_internalvar (lookup_internalvar ("trace_func"), func_val);
309 /* save file name as "$trace_file", a debugger variable visible to users */
310 if (traceframe_sal.symtab == NULL ||
311 traceframe_sal.symtab->filename == NULL)
312 set_internalvar (lookup_internalvar ("trace_file"),
313 value_from_pointer (charstar, (LONGEST) 0));
316 len = strlen (traceframe_sal.symtab->filename);
317 file_range = create_range_type (file_range,
318 builtin_type_int, 0, len - 1);
319 file_string = create_array_type (file_string,
320 builtin_type_char, file_range);
321 file_val = allocate_value (file_string);
322 VALUE_TYPE (file_val) = file_string;
323 memcpy (VALUE_CONTENTS_RAW (file_val),
324 traceframe_sal.symtab->filename,
326 file_val->modifiable = 0;
327 set_internalvar (lookup_internalvar ("trace_file"), file_val);
331 /* Low level routine to set a tracepoint.
332 Returns the tracepoint object so caller can set other things.
333 Does not set the tracepoint number!
334 Does not print anything.
336 ==> This routine should not be called if there is a chance of later
337 error(); otherwise it leaves a bogus tracepoint on the chain. Validate
338 your arguments BEFORE calling this routine! */
340 static struct tracepoint *
341 set_raw_tracepoint (sal)
342 struct symtab_and_line sal;
344 register struct tracepoint *t, *tc;
345 struct cleanup *old_chain;
347 t = (struct tracepoint *) xmalloc (sizeof (struct tracepoint));
348 old_chain = make_cleanup (free, t);
349 memset (t, 0, sizeof (*t));
351 if (sal.symtab == NULL)
352 t->source_file = NULL;
354 t->source_file = savestring (sal.symtab->filename,
355 strlen (sal.symtab->filename));
357 t->section = sal.section;
358 t->language = current_language->la_language;
359 t->input_radix = input_radix;
360 t->line_number = sal.line;
361 t->enabled = enabled;
365 t->addr_string = NULL;
367 /* Add this tracepoint to the end of the chain
368 so that a list of tracepoints will come out in order
369 of increasing numbers. */
371 tc = tracepoint_chain;
373 tracepoint_chain = t;
380 discard_cleanups (old_chain);
384 /* Set a tracepoint according to ARG (function, linenum or *address) */
386 trace_command (arg, from_tty)
390 char **canonical = (char **) NULL;
391 struct symtabs_and_lines sals;
392 struct symtab_and_line sal;
393 struct tracepoint *t;
394 char *addr_start = 0, *addr_end = 0;
398 error ("trace command requires an argument");
400 if (from_tty && info_verbose)
401 printf_filtered ("TRACE %s\n", arg);
404 sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical);
407 return; /* ??? Presumably decode_line_1 has already warned? */
409 /* Resolve all line numbers to PC's */
410 for (i = 0; i < sals.nelts; i++)
411 resolve_sal_pc (&sals.sals[i]);
413 /* Now set all the tracepoints. */
414 for (i = 0; i < sals.nelts; i++)
418 t = set_raw_tracepoint (sal);
419 set_tracepoint_count (tracepoint_count + 1);
420 t->number = tracepoint_count;
422 /* If a canonical line spec is needed use that instead of the
424 if (canonical != (char **) NULL && canonical[i] != NULL)
425 t->addr_string = canonical[i];
427 t->addr_string = savestring (addr_start, addr_end - addr_start);
431 /* Let the UI know of any additions */
432 if (create_tracepoint_hook)
433 create_tracepoint_hook (t);
438 printf_filtered ("Multiple tracepoints were set.\n");
439 printf_filtered ("Use 'delete trace' to delete unwanted tracepoints.\n");
443 /* Tell the user we have just set a tracepoint TP. */
447 struct tracepoint *tp;
449 printf_filtered ("Tracepoint %d", tp->number);
451 if (addressprint || (tp->source_file == NULL))
453 printf_filtered (" at ");
454 print_address_numeric (tp->address, 1, gdb_stdout);
457 printf_filtered (": file %s, line %d.",
458 tp->source_file, tp->line_number);
460 printf_filtered ("\n");
463 /* Print information on tracepoint number TPNUM_EXP, or all if omitted. */
466 tracepoints_info (tpnum_exp, from_tty)
470 struct tracepoint *t;
471 struct action_line *action;
472 int found_a_tracepoint = 0;
473 char wrap_indent[80];
478 tpnum = parse_and_eval_address (tpnum_exp);
481 if (tpnum == -1 || tpnum == t->number)
483 extern int addressprint; /* print machine addresses? */
485 if (!found_a_tracepoint++)
487 printf_filtered ("Num Enb ");
489 printf_filtered ("Address ");
490 printf_filtered ("PassC StepC What\n");
492 strcpy (wrap_indent, " ");
494 strcat (wrap_indent, " ");
496 printf_filtered ("%-3d %-3s ", t->number,
497 t->enabled == enabled ? "y" : "n");
499 printf_filtered ("%s ",
500 local_hex_string_custom ((unsigned long) t->address,
502 printf_filtered ("%-5d %-5ld ", t->pass_count, t->step_count);
506 sym = find_pc_sect_function (t->address, t->section);
509 fputs_filtered ("in ", gdb_stdout);
510 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
511 wrap_here (wrap_indent);
512 fputs_filtered (" at ", gdb_stdout);
514 fputs_filtered (t->source_file, gdb_stdout);
515 printf_filtered (":%d", t->line_number);
518 print_address_symbolic (t->address, gdb_stdout, demangle, " ");
520 printf_filtered ("\n");
523 printf_filtered (" Actions for tracepoint %d: \n", t->number);
524 for (action = t->actions; action; action = action->next)
526 printf_filtered ("\t%s\n", action->action);
530 if (!found_a_tracepoint)
533 printf_filtered ("No tracepoints.\n");
535 printf_filtered ("No tracepoint number %d.\n", tpnum);
539 /* Optimization: the code to parse an enable, disable, or delete TP command
540 is virtually identical except for whether it performs an enable, disable,
541 or delete. Therefore I've combined them into one function with an opcode.
543 enum tracepoint_opcode
550 /* This function implements enable, disable and delete commands. */
552 tracepoint_operation (t, from_tty, opcode)
553 struct tracepoint *t;
555 enum tracepoint_opcode opcode;
557 struct tracepoint *t2;
559 if (t == NULL) /* no tracepoint operand */
565 t->enabled = enabled;
566 if (modify_tracepoint_hook)
567 modify_tracepoint_hook (t);
570 t->enabled = disabled;
571 if (modify_tracepoint_hook)
572 modify_tracepoint_hook (t);
575 if (tracepoint_chain == t)
576 tracepoint_chain = t->next;
585 /* Let the UI know of any deletions */
586 if (delete_tracepoint_hook)
587 delete_tracepoint_hook (t);
590 free (t->addr_string);
592 free (t->source_file);
601 /* Utility: parse a tracepoint number and look it up in the list.
602 If MULTI_P is true, there might be a range of tracepoints in ARG.
603 if OPTIONAL_P is true, then if the argument is missing, the most
604 recent tracepoint (tracepoint_count) is returned. */
606 get_tracepoint_by_number (arg, multi_p, optional_p)
608 int multi_p, optional_p;
610 struct tracepoint *t;
612 char *instring = arg == NULL ? NULL : *arg;
614 if (arg == NULL || *arg == NULL || ! **arg)
617 tpnum = tracepoint_count;
619 error_no_arg ("tracepoint number");
622 tpnum = multi_p ? get_number_or_range (arg) : get_number (arg);
626 if (instring && *instring)
627 printf_filtered ("bad tracepoint number at or near '%s'\n", instring);
629 printf_filtered ("Tracepoint argument missing and no previous tracepoint\n");
634 if (t->number == tpnum)
639 /* FIXME: if we are in the middle of a range we don't want to give
640 a message. The current interface to get_number_or_range doesn't
641 allow us to discover this. */
642 printf_unfiltered ("No tracepoint number %d.\n", tpnum);
646 /* Utility: parse a list of tracepoint numbers, and call a func for each. */
648 map_args_over_tracepoints (args, from_tty, opcode)
651 enum tracepoint_opcode opcode;
653 struct tracepoint *t, *tmp;
655 if (args == 0 || *args == 0) /* do them all */
656 ALL_TRACEPOINTS_SAFE (t, tmp)
657 tracepoint_operation (t, from_tty, opcode);
661 QUIT; /* give user option to bail out with ^C */
662 t = get_tracepoint_by_number (&args, 1, 0);
663 tracepoint_operation (t, from_tty, opcode);
664 while (*args == ' ' || *args == '\t')
669 /* The 'enable trace' command enables tracepoints. Not supported by all targets. */
671 enable_trace_command (args, from_tty)
676 map_args_over_tracepoints (args, from_tty, enable_op);
679 /* The 'disable trace' command enables tracepoints. Not supported by all targets. */
681 disable_trace_command (args, from_tty)
686 map_args_over_tracepoints (args, from_tty, disable_op);
689 /* Remove a tracepoint (or all if no argument) */
691 delete_trace_command (args, from_tty)
696 if (!args || !*args) /* No args implies all tracepoints; */
697 if (from_tty) /* confirm only if from_tty... */
698 if (tracepoint_chain) /* and if there are tracepoints to delete! */
699 if (!query ("Delete all tracepoints? "))
702 map_args_over_tracepoints (args, from_tty, delete_op);
705 /* Set passcount for tracepoint.
707 First command argument is passcount, second is tracepoint number.
708 If tracepoint number omitted, apply to most recently defined.
709 Also accepts special argument "all". */
712 trace_pass_command (args, from_tty)
716 struct tracepoint *t1 = (struct tracepoint *) -1, *t2;
720 if (args == 0 || *args == 0)
721 error ("passcount command requires an argument (count + optional TP num)");
723 count = strtoul (args, &args, 10); /* count comes first, then TP num */
725 while (*args && isspace ((int) *args))
728 if (*args && strncasecmp (args, "all", 3) == 0)
730 args += 3; /* skip special argument "all" */
733 error ("Junk at end of arguments.");
736 t1 = get_tracepoint_by_number (&args, 1, 1);
743 if (t1 == (struct tracepoint *) -1 || t1 == t2)
745 t2->pass_count = count;
746 if (modify_tracepoint_hook)
747 modify_tracepoint_hook (t2);
749 printf_filtered ("Setting tracepoint %d's passcount to %d\n",
753 t1 = get_tracepoint_by_number (&args, 1, 0);
759 /* ACTIONS functions: */
761 /* Prototypes for action-parsing utility commands */
762 static void read_actions PARAMS ((struct tracepoint *));
764 /* The three functions:
765 collect_pseudocommand,
766 while_stepping_pseudocommand, and
767 end_actions_pseudocommand
768 are placeholders for "commands" that are actually ONLY to be used
769 within a tracepoint action list. If the actual function is ever called,
770 it means that somebody issued the "command" at the top level,
771 which is always an error. */
774 end_actions_pseudocommand (args, from_tty)
778 error ("This command cannot be used at the top level.");
782 while_stepping_pseudocommand (args, from_tty)
786 error ("This command can only be used in a tracepoint actions list.");
790 collect_pseudocommand (args, from_tty)
794 error ("This command can only be used in a tracepoint actions list.");
797 /* Enter a list of actions for a tracepoint. */
799 trace_actions_command (args, from_tty)
803 struct tracepoint *t;
805 char *end_msg = "End with a line saying just \"end\".";
807 t = get_tracepoint_by_number (&args, 0, 1);
810 sprintf (tmpbuf, "Enter actions for tracepoint %d, one per line.",
815 if (readline_begin_hook)
816 (*readline_begin_hook) ("%s %s\n", tmpbuf, end_msg);
817 else if (input_from_terminal_p ())
818 printf_filtered ("%s\n%s\n", tmpbuf, end_msg);
822 t->step_count = 0; /* read_actions may set this */
825 if (readline_end_hook)
826 (*readline_end_hook) ();
827 /* tracepoints_changed () */
829 /* else just return */
832 /* worker function */
835 struct tracepoint *t;
838 char *prompt1 = "> ", *prompt2 = " > ";
839 char *prompt = prompt1;
840 enum actionline_type linetype;
841 extern FILE *instream;
842 struct action_line *next = NULL, *temp;
843 struct cleanup *old_chain;
845 /* Control-C quits instantly if typed while in this loop
846 since it should not wait until the user types a newline. */
852 signal (STOP_SIGNAL, handle_stop_sig);
854 signal (STOP_SIGNAL, stop_sig);
857 old_chain = make_cleanup ((make_cleanup_func) free_actions, (void *) t);
860 /* Make sure that all output has been output. Some machines may let
861 you get away with leaving out some of the gdb_flush, but not all. */
863 gdb_flush (gdb_stdout);
864 gdb_flush (gdb_stderr);
866 if (readline_hook && instream == NULL)
867 line = (*readline_hook) (prompt);
868 else if (instream == stdin && ISATTY (instream))
870 line = readline (prompt);
871 if (line && *line) /* add it to command history */
875 line = gdb_readline (0);
877 linetype = validate_actionline (&line, t);
878 if (linetype == BADLINE)
879 continue; /* already warned -- collect another line */
881 temp = xmalloc (sizeof (struct action_line));
885 if (next == NULL) /* first action for this tracepoint? */
886 t->actions = next = temp;
893 if (linetype == STEPPING) /* begin "while-stepping" */
895 if (prompt == prompt2)
897 warning ("Already processing 'while-stepping'");
901 prompt = prompt2; /* change prompt for stepping actions */
903 else if (linetype == END)
905 if (prompt == prompt2)
907 prompt = prompt1; /* end of single-stepping actions */
910 { /* end of actions */
911 if (t->actions->next == NULL)
913 /* an "end" all by itself with no other actions means
914 this tracepoint has no actions. Discard empty list. */
923 signal (STOP_SIGNAL, SIG_DFL);
926 discard_cleanups (old_chain);
929 /* worker function */
931 validate_actionline (line, t)
933 struct tracepoint *t;
935 struct cmd_list_element *c;
936 struct expression *exp = NULL;
937 struct cleanup *old_chain = NULL;
940 for (p = *line; isspace ((int) *p);)
943 /* symbol lookup etc. */
944 if (*p == '\0') /* empty line: just prompt for another line. */
947 if (*p == '#') /* comment line */
950 c = lookup_cmd (&p, cmdlist, "", -1, 1);
953 warning ("'%s' is not an action that I know, or is ambiguous.", p);
957 if (c->function.cfunc == collect_pseudocommand)
959 struct agent_expr *aexpr;
960 struct agent_reqs areqs;
963 { /* repeat over a comma-separated list */
964 QUIT; /* allow user to bail out with ^C */
965 while (isspace ((int) *p))
968 if (*p == '$') /* look for special pseudo-symbols */
970 if ((0 == strncasecmp ("reg", p + 1, 3)) ||
971 (0 == strncasecmp ("arg", p + 1, 3)) ||
972 (0 == strncasecmp ("loc", p + 1, 3)))
977 /* else fall thru, treat p as an expression and parse it! */
979 exp = parse_exp_1 (&p, block_for_pc (t->address), 1);
980 old_chain = make_cleanup (free_current_contents, &exp);
982 if (exp->elts[0].opcode == OP_VAR_VALUE)
984 if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
986 warning ("constant %s (value %ld) will not be collected.",
987 SYMBOL_NAME (exp->elts[2].symbol),
988 SYMBOL_VALUE (exp->elts[2].symbol));
991 else if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_OPTIMIZED_OUT)
993 warning ("%s is optimized away and cannot be collected.",
994 SYMBOL_NAME (exp->elts[2].symbol));
999 /* we have something to collect, make sure that the expr to
1000 bytecode translator can handle it and that it's not too long */
1001 aexpr = gen_trace_for_expr (t->address, exp);
1002 (void) make_cleanup ((make_cleanup_func) free_agent_expr, aexpr);
1004 if (aexpr->len > MAX_AGENT_EXPR_LEN)
1005 error ("expression too complicated, try simplifying");
1007 ax_reqs (aexpr, &areqs);
1008 (void) make_cleanup (free, areqs.reg_mask);
1010 if (areqs.flaw != agent_flaw_none)
1011 error ("malformed expression");
1013 if (areqs.min_height < 0)
1014 error ("gdb: Internal error: expression has min height < 0");
1016 if (areqs.max_height > 20)
1017 error ("expression too complicated, try simplifying");
1019 do_cleanups (old_chain);
1021 while (p && *p++ == ',');
1024 else if (c->function.cfunc == while_stepping_pseudocommand)
1026 char *steparg; /* in case warning is necessary */
1028 while (isspace ((int) *p))
1033 (t->step_count = strtol (p, &p, 0)) == 0)
1035 warning ("'%s': bad step-count; command ignored.", *line);
1040 else if (c->function.cfunc == end_actions_pseudocommand)
1044 warning ("'%s' is not a supported tracepoint action.", *line);
1049 /* worker function */
1052 struct tracepoint *t;
1054 struct action_line *line, *next;
1056 for (line = t->actions; line; line = next)
1060 free (line->action);
1068 int type; /* 0 for absolute memory range, else basereg number */
1069 bfd_signed_vma start;
1073 struct collection_list
1075 unsigned char regs_mask[8]; /* room for up to 256 regs */
1078 struct memrange *list;
1079 long aexpr_listsize; /* size of array pointed to by expr_list elt */
1080 long next_aexpr_elt;
1081 struct agent_expr **aexpr_list;
1084 tracepoint_list, stepping_list;
1086 /* MEMRANGE functions: */
1088 static int memrange_cmp PARAMS ((const void *, const void *));
1090 /* compare memranges for qsort */
1092 memrange_cmp (va, vb)
1096 const struct memrange *a = va, *b = vb;
1098 if (a->type < b->type)
1100 if (a->type > b->type)
1104 if ((bfd_vma) a->start < (bfd_vma) b->start)
1106 if ((bfd_vma) a->start > (bfd_vma) b->start)
1111 if (a->start < b->start)
1113 if (a->start > b->start)
1119 /* Sort the memrange list using qsort, and merge adjacent memranges */
1121 memrange_sortmerge (memranges)
1122 struct collection_list *memranges;
1126 qsort (memranges->list, memranges->next_memrange,
1127 sizeof (struct memrange), memrange_cmp);
1128 if (memranges->next_memrange > 0)
1130 for (a = 0, b = 1; b < memranges->next_memrange; b++)
1132 if (memranges->list[a].type == memranges->list[b].type &&
1133 memranges->list[b].start - memranges->list[a].end <=
1134 MAX_REGISTER_VIRTUAL_SIZE)
1136 /* memrange b starts before memrange a ends; merge them. */
1137 if (memranges->list[b].end > memranges->list[a].end)
1138 memranges->list[a].end = memranges->list[b].end;
1139 continue; /* next b, same a */
1143 memcpy (&memranges->list[a], &memranges->list[b],
1144 sizeof (struct memrange));
1146 memranges->next_memrange = a + 1;
1150 /* Add a register to a collection list */
1152 add_register (collection, regno)
1153 struct collection_list *collection;
1157 printf_filtered ("collect register %d\n", regno);
1158 if (regno > (8 * sizeof (collection->regs_mask)))
1159 error ("Internal: register number %d too large for tracepoint",
1161 collection->regs_mask[regno / 8] |= 1 << (regno % 8);
1164 /* Add a memrange to a collection list */
1166 add_memrange (memranges, type, base, len)
1167 struct collection_list *memranges;
1169 bfd_signed_vma base;
1174 printf_filtered ("(%d,", type);
1176 printf_filtered (",%ld)\n", len);
1179 /* type: 0 == memory, n == basereg */
1180 memranges->list[memranges->next_memrange].type = type;
1181 /* base: addr if memory, offset if reg relative. */
1182 memranges->list[memranges->next_memrange].start = base;
1183 /* len: we actually save end (base + len) for convenience */
1184 memranges->list[memranges->next_memrange].end = base + len;
1185 memranges->next_memrange++;
1186 if (memranges->next_memrange >= memranges->listsize)
1188 memranges->listsize *= 2;
1189 memranges->list = xrealloc (memranges->list,
1190 memranges->listsize);
1193 if (type != -1) /* better collect the base register! */
1194 add_register (memranges, type);
1197 /* Add a symbol to a collection list */
1199 collect_symbol (collect, sym, frame_regno, frame_offset)
1200 struct collection_list *collect;
1207 bfd_signed_vma offset;
1209 len = TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym)));
1210 switch (SYMBOL_CLASS (sym))
1213 printf_filtered ("%s: don't know symbol class %d\n",
1214 SYMBOL_NAME (sym), SYMBOL_CLASS (sym));
1217 printf_filtered ("constant %s (value %ld) will not be collected.\n",
1218 SYMBOL_NAME (sym), SYMBOL_VALUE (sym));
1221 offset = SYMBOL_VALUE_ADDRESS (sym);
1226 sprintf_vma (tmp, offset);
1227 printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n",
1228 SYMBOL_NAME (sym), len, tmp /* address */);
1230 add_memrange (collect, -1, offset, len); /* 0 == memory */
1234 reg = SYMBOL_VALUE (sym);
1236 printf_filtered ("LOC_REG[parm] %s: ", SYMBOL_NAME (sym));
1237 add_register (collect, reg);
1238 /* check for doubles stored in two registers */
1239 /* FIXME: how about larger types stored in 3 or more regs? */
1240 if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT &&
1241 len > REGISTER_RAW_SIZE (reg))
1242 add_register (collect, reg + 1);
1245 printf_filtered ("Sorry, don't know how to do LOC_REF_ARG yet.\n");
1246 printf_filtered (" (will not collect %s)\n",
1251 offset = frame_offset + SYMBOL_VALUE (sym);
1254 printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
1255 SYMBOL_NAME (sym), len);
1256 printf_vma (offset);
1257 printf_filtered (" from frame ptr reg %d\n", reg);
1259 add_memrange (collect, reg, offset, len);
1261 case LOC_REGPARM_ADDR:
1262 reg = SYMBOL_VALUE (sym);
1266 printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset ",
1267 SYMBOL_NAME (sym), len);
1268 printf_vma (offset);
1269 printf_filtered (" from reg %d\n", reg);
1271 add_memrange (collect, reg, offset, len);
1276 offset = frame_offset + SYMBOL_VALUE (sym);
1279 printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
1280 SYMBOL_NAME (sym), len);
1281 printf_vma (offset);
1282 printf_filtered (" from frame ptr reg %d\n", reg);
1284 add_memrange (collect, reg, offset, len);
1287 case LOC_BASEREG_ARG:
1288 reg = SYMBOL_BASEREG (sym);
1289 offset = SYMBOL_VALUE (sym);
1292 printf_filtered ("LOC_BASEREG %s: collect %ld bytes at offset ",
1293 SYMBOL_NAME (sym), len);
1294 printf_vma (offset);
1295 printf_filtered (" from basereg %d\n", reg);
1297 add_memrange (collect, reg, offset, len);
1299 case LOC_UNRESOLVED:
1300 printf_filtered ("Don't know LOC_UNRESOLVED %s\n", SYMBOL_NAME (sym));
1302 case LOC_OPTIMIZED_OUT:
1303 printf_filtered ("%s has been optimized out of existance.\n",
1309 /* Add all locals (or args) symbols to collection list */
1311 add_local_symbols (collect, pc, frame_regno, frame_offset, type)
1312 struct collection_list *collect;
1319 struct block *block;
1320 int i, nsyms, count = 0;
1322 block = block_for_pc (pc);
1325 QUIT; /* allow user to bail out with ^C */
1326 nsyms = BLOCK_NSYMS (block);
1327 for (i = 0; i < nsyms; i++)
1329 sym = BLOCK_SYM (block, i);
1330 switch (SYMBOL_CLASS (sym))
1333 warning ("don't know how to trace local symbol %s",
1339 if (type == 'L') /* collecting Locals */
1342 collect_symbol (collect, sym, frame_regno, frame_offset);
1349 case LOC_REGPARM_ADDR:
1350 case LOC_BASEREG_ARG:
1351 if (type == 'A') /* collecting Arguments */
1354 collect_symbol (collect, sym, frame_regno, frame_offset);
1358 if (BLOCK_FUNCTION (block))
1361 block = BLOCK_SUPERBLOCK (block);
1364 warning ("No %s found in scope.", type == 'L' ? "locals" : "args");
1367 /* worker function */
1369 clear_collection_list (list)
1370 struct collection_list *list;
1374 list->next_memrange = 0;
1375 for (ndx = 0; ndx < list->next_aexpr_elt; ndx++)
1377 free_agent_expr (list->aexpr_list[ndx]);
1378 list->aexpr_list[ndx] = NULL;
1380 list->next_aexpr_elt = 0;
1381 memset (list->regs_mask, 0, sizeof (list->regs_mask));
1384 /* reduce a collection list to string form (for gdb protocol) */
1386 stringify_collection_list (list, string)
1387 struct collection_list *list;
1390 char temp_buf[2048];
1394 char *(*str_list)[];
1398 count = 1 + list->next_memrange + list->next_aexpr_elt + 1;
1399 str_list = (char *(*)[]) xmalloc (count * sizeof (char *));
1401 for (i = sizeof (list->regs_mask) - 1; i > 0; i--)
1402 if (list->regs_mask[i] != 0) /* skip leading zeroes in regs_mask */
1404 if (list->regs_mask[i] != 0) /* prepare to send regs_mask to the stub */
1407 printf_filtered ("\nCollecting registers (mask): 0x");
1412 QUIT; /* allow user to bail out with ^C */
1414 printf_filtered ("%02X", list->regs_mask[i]);
1415 sprintf (end, "%02X", list->regs_mask[i]);
1418 (*str_list)[ndx] = savestring (temp_buf, end - temp_buf);
1422 printf_filtered ("\n");
1423 if (list->next_memrange > 0 && info_verbose)
1424 printf_filtered ("Collecting memranges: \n");
1425 for (i = 0, count = 0, end = temp_buf; i < list->next_memrange; i++)
1427 QUIT; /* allow user to bail out with ^C */
1428 sprintf_vma (tmp2, list->list[i].start);
1431 printf_filtered ("(%d, %s, %ld)\n",
1434 (long) (list->list[i].end - list->list[i].start));
1436 if (count + 27 > MAX_AGENT_EXPR_LEN)
1438 (*str_list)[ndx] = savestring (temp_buf, count);
1444 sprintf (end, "M%X,%s,%lX",
1447 (long) (list->list[i].end - list->list[i].start));
1449 count += strlen (end);
1453 for (i = 0; i < list->next_aexpr_elt; i++)
1455 QUIT; /* allow user to bail out with ^C */
1456 if ((count + 10 + 2 * list->aexpr_list[i]->len) > MAX_AGENT_EXPR_LEN)
1458 (*str_list)[ndx] = savestring (temp_buf, count);
1463 sprintf (end, "X%08X,", list->aexpr_list[i]->len);
1464 end += 10; /* 'X' + 8 hex digits + ',' */
1467 end = mem2hex (list->aexpr_list[i]->buf, end, list->aexpr_list[i]->len);
1468 count += 2 * list->aexpr_list[i]->len;
1473 (*str_list)[ndx] = savestring (temp_buf, count);
1478 (*str_list)[ndx] = NULL;
1487 free_actions_list_cleanup_wrapper (al)
1490 free_actions_list (al);
1494 free_actions_list (actions_list)
1495 char **actions_list;
1499 if (actions_list == 0)
1502 for (ndx = 0; actions_list[ndx]; ndx++)
1503 free (actions_list[ndx]);
1505 free (actions_list);
1508 /* render all actions into gdb protocol */
1510 encode_actions (t, tdp_actions, stepping_actions)
1511 struct tracepoint *t;
1512 char ***tdp_actions;
1513 char ***stepping_actions;
1515 static char tdp_buff[2048], step_buff[2048];
1517 struct expression *exp = NULL;
1518 struct action_line *action;
1521 struct collection_list *collect;
1522 struct cmd_list_element *cmd;
1523 struct agent_expr *aexpr;
1524 long frame_reg, frame_offset;
1527 clear_collection_list (&tracepoint_list);
1528 clear_collection_list (&stepping_list);
1529 collect = &tracepoint_list;
1531 *tdp_actions = NULL;
1532 *stepping_actions = NULL;
1534 TARGET_VIRTUAL_FRAME_POINTER (t->address, &frame_reg, &frame_offset);
1536 for (action = t->actions; action; action = action->next)
1538 QUIT; /* allow user to bail out with ^C */
1539 action_exp = action->action;
1540 while (isspace ((int) *action_exp))
1543 if (*action_exp == '#') /* comment line */
1546 cmd = lookup_cmd (&action_exp, cmdlist, "", -1, 1);
1548 error ("Bad action list item: %s", action_exp);
1550 if (cmd->function.cfunc == collect_pseudocommand)
1553 { /* repeat over a comma-separated list */
1554 QUIT; /* allow user to bail out with ^C */
1555 while (isspace ((int) *action_exp))
1558 if (0 == strncasecmp ("$reg", action_exp, 4))
1560 for (i = 0; i < NUM_REGS; i++)
1561 add_register (collect, i);
1562 action_exp = strchr (action_exp, ','); /* more? */
1564 else if (0 == strncasecmp ("$arg", action_exp, 4))
1566 add_local_symbols (collect,
1571 action_exp = strchr (action_exp, ','); /* more? */
1573 else if (0 == strncasecmp ("$loc", action_exp, 4))
1575 add_local_symbols (collect,
1580 action_exp = strchr (action_exp, ','); /* more? */
1584 unsigned long addr, len;
1585 struct cleanup *old_chain = NULL;
1586 struct cleanup *old_chain1 = NULL;
1587 struct agent_reqs areqs;
1589 exp = parse_exp_1 (&action_exp, block_for_pc (t->address), 1);
1590 old_chain = make_cleanup ((make_cleanup_func)
1591 free_current_contents, &exp);
1593 switch (exp->elts[0].opcode)
1596 i = exp->elts[1].longconst;
1598 printf_filtered ("OP_REGISTER: ");
1599 add_register (collect, i);
1603 /* safe because we know it's a simple expression */
1604 tempval = evaluate_expression (exp);
1605 addr = VALUE_ADDRESS (tempval) + VALUE_OFFSET (tempval);
1606 len = TYPE_LENGTH (check_typedef (exp->elts[1].type));
1607 add_memrange (collect, -1, addr, len);
1611 collect_symbol (collect,
1612 exp->elts[2].symbol,
1617 default: /* full-fledged expression */
1618 aexpr = gen_trace_for_expr (t->address, exp);
1620 old_chain1 = make_cleanup ((make_cleanup_func)
1621 free_agent_expr, aexpr);
1623 ax_reqs (aexpr, &areqs);
1624 if (areqs.flaw != agent_flaw_none)
1625 error ("malformed expression");
1627 if (areqs.min_height < 0)
1628 error ("gdb: Internal error: expression has min height < 0");
1629 if (areqs.max_height > 20)
1630 error ("expression too complicated, try simplifying");
1632 discard_cleanups (old_chain1);
1633 add_aexpr (collect, aexpr);
1635 /* take care of the registers */
1636 if (areqs.reg_mask_len > 0)
1641 for (ndx1 = 0; ndx1 < areqs.reg_mask_len; ndx1++)
1643 QUIT; /* allow user to bail out with ^C */
1644 if (areqs.reg_mask[ndx1] != 0)
1646 /* assume chars have 8 bits */
1647 for (ndx2 = 0; ndx2 < 8; ndx2++)
1648 if (areqs.reg_mask[ndx1] & (1 << ndx2))
1649 /* it's used -- record it */
1650 add_register (collect, ndx1 * 8 + ndx2);
1656 do_cleanups (old_chain);
1659 while (action_exp && *action_exp++ == ',');
1661 else if (cmd->function.cfunc == while_stepping_pseudocommand)
1663 collect = &stepping_list;
1665 else if (cmd->function.cfunc == end_actions_pseudocommand)
1667 if (collect == &stepping_list) /* end stepping actions */
1668 collect = &tracepoint_list;
1670 break; /* end tracepoint actions */
1673 memrange_sortmerge (&tracepoint_list);
1674 memrange_sortmerge (&stepping_list);
1676 *tdp_actions = stringify_collection_list (&tracepoint_list, &tdp_buff);
1677 *stepping_actions = stringify_collection_list (&stepping_list, &step_buff);
1681 add_aexpr (collect, aexpr)
1682 struct collection_list *collect;
1683 struct agent_expr *aexpr;
1685 if (collect->next_aexpr_elt >= collect->aexpr_listsize)
1687 collect->aexpr_list =
1688 xrealloc (collect->aexpr_list,
1689 2 * collect->aexpr_listsize * sizeof (struct agent_expr *));
1690 collect->aexpr_listsize *= 2;
1692 collect->aexpr_list[collect->next_aexpr_elt] = aexpr;
1693 collect->next_aexpr_elt++;
1696 static char target_buf[2048];
1698 /* Set "transparent" memory ranges
1700 Allow trace mechanism to treat text-like sections
1701 (and perhaps all read-only sections) transparently,
1702 i.e. don't reject memory requests from these address ranges
1703 just because they haven't been collected. */
1706 remote_set_transparent_ranges (void)
1708 extern bfd *exec_bfd;
1715 return; /* no information to give. */
1717 strcpy (target_buf, "QTro");
1718 for (s = exec_bfd->sections; s; s = s->next)
1720 char tmp1[40], tmp2[40];
1722 if ((s->flags & SEC_LOAD) == 0 ||
1723 /* (s->flags & SEC_CODE) == 0 || */
1724 (s->flags & SEC_READONLY) == 0)
1729 size = bfd_get_section_size_before_reloc (s);
1730 sprintf_vma (tmp1, lma);
1731 sprintf_vma (tmp2, lma + size);
1732 sprintf (target_buf + strlen (target_buf),
1733 ":%s,%s", tmp1, tmp2);
1737 putpkt (target_buf);
1738 getpkt (target_buf, sizeof (target_buf), 0);
1744 Tell target to clear any previous trace experiment.
1745 Walk the list of tracepoints, and send them (and their actions)
1746 to the target. If no errors,
1747 Tell target to start a new trace experiment. */
1750 trace_start_command (args, from_tty)
1753 { /* STUB_COMM MOSTLY_IMPLEMENTED */
1754 struct tracepoint *t;
1757 char **stepping_actions;
1759 struct cleanup *old_chain = NULL;
1761 dont_repeat (); /* like "run", dangerous to repeat accidentally */
1763 if (target_is_remote ())
1766 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1767 if (strcmp (target_buf, "OK"))
1768 error ("Target does not support this command.");
1774 sprintf_vma (tmp, t->address);
1775 sprintf (buf, "QTDP:%x:%s:%c:%lx:%x", t->number, tmp, /* address */
1776 t->enabled == enabled ? 'E' : 'D',
1777 t->step_count, t->pass_count);
1782 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1783 if (strcmp (target_buf, "OK"))
1784 error ("Target does not support tracepoints.");
1788 encode_actions (t, &tdp_actions, &stepping_actions);
1789 old_chain = make_cleanup (free_actions_list_cleanup_wrapper,
1791 (void) make_cleanup (free_actions_list_cleanup_wrapper,
1794 /* do_single_steps (t); */
1797 for (ndx = 0; tdp_actions[ndx]; ndx++)
1799 QUIT; /* allow user to bail out with ^C */
1800 sprintf (buf, "QTDP:-%x:%s:%s%c",
1801 t->number, tmp, /* address */
1803 ((tdp_actions[ndx + 1] || stepping_actions)
1806 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1807 if (strcmp (target_buf, "OK"))
1808 error ("Error on target while setting tracepoints.");
1811 if (stepping_actions)
1813 for (ndx = 0; stepping_actions[ndx]; ndx++)
1815 QUIT; /* allow user to bail out with ^C */
1816 sprintf (buf, "QTDP:-%x:%s:%s%s%s",
1817 t->number, tmp, /* address */
1818 ((ndx == 0) ? "S" : ""),
1819 stepping_actions[ndx],
1820 (stepping_actions[ndx + 1] ? "-" : ""));
1822 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1823 if (strcmp (target_buf, "OK"))
1824 error ("Error on target while setting tracepoints.");
1828 do_cleanups (old_chain);
1831 /* Tell target to treat text-like sections as transparent */
1832 remote_set_transparent_ranges ();
1833 /* Now insert traps and begin collecting data */
1835 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1836 if (strcmp (target_buf, "OK"))
1837 error ("Bogus reply from target: %s", target_buf);
1838 set_traceframe_num (-1); /* all old traceframes invalidated */
1839 set_tracepoint_num (-1);
1840 set_traceframe_context (-1);
1841 trace_running_p = 1;
1842 if (trace_start_stop_hook)
1843 trace_start_stop_hook (1, from_tty);
1847 error ("Trace can only be run on remote targets.");
1852 trace_stop_command (args, from_tty)
1855 { /* STUB_COMM IS_IMPLEMENTED */
1856 if (target_is_remote ())
1859 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1860 if (strcmp (target_buf, "OK"))
1861 error ("Bogus reply from target: %s", target_buf);
1862 trace_running_p = 0;
1863 if (trace_start_stop_hook)
1864 trace_start_stop_hook (0, from_tty);
1867 error ("Trace can only be run on remote targets.");
1870 unsigned long trace_running_p;
1872 /* tstatus command */
1874 trace_status_command (args, from_tty)
1877 { /* STUB_COMM IS_IMPLEMENTED */
1878 if (target_is_remote ())
1880 putpkt ("qTStatus");
1881 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1883 if (target_buf[0] != 'T' ||
1884 (target_buf[1] != '0' && target_buf[1] != '1'))
1885 error ("Bogus reply from target: %s", target_buf);
1887 /* exported for use by the GUI */
1888 trace_running_p = (target_buf[1] == '1');
1891 error ("Trace can only be run on remote targets.");
1894 /* Worker function for the various flavors of the tfind command */
1896 finish_tfind_command (char *msg,
1900 int target_frameno = -1, target_tracept = -1;
1901 CORE_ADDR old_frame_addr;
1902 struct symbol *old_func;
1905 old_frame_addr = FRAME_FP (get_current_frame ());
1906 old_func = find_pc_function (read_pc ());
1909 reply = remote_get_noisy_reply (msg, sizeof_msg);
1911 while (reply && *reply)
1915 if ((target_frameno = (int) strtol (++reply, &reply, 16)) == -1)
1917 /* A request for a non-existant trace frame has failed.
1918 Our response will be different, depending on FROM_TTY:
1920 If FROM_TTY is true, meaning that this command was
1921 typed interactively by the user, then give an error
1922 and DO NOT change the state of traceframe_number etc.
1924 However if FROM_TTY is false, meaning that we're either
1925 in a script, a loop, or a user-defined command, then
1926 DON'T give an error, but DO change the state of
1927 traceframe_number etc. to invalid.
1929 The rationalle is that if you typed the command, you
1930 might just have committed a typo or something, and you'd
1931 like to NOT lose your current debugging state. However
1932 if you're in a user-defined command or especially in a
1933 loop, then you need a way to detect that the command
1934 failed WITHOUT aborting. This allows you to write
1935 scripts that search thru the trace buffer until the end,
1936 and then continue on to do something else. */
1939 error ("Target failed to find requested trace frame.");
1943 printf_filtered ("End of trace buffer.\n");
1944 /* The following will not recurse, since it's special-cased */
1945 trace_find_command ("-1", from_tty);
1946 reply = NULL; /* break out of loop,
1947 (avoid recursive nonsense) */
1952 if ((target_tracept = (int) strtol (++reply, &reply, 16)) == -1)
1953 error ("Target failed to find requested trace frame.");
1955 case 'O': /* "OK"? */
1956 if (reply[1] == 'K' && reply[2] == '\0')
1959 error ("Bogus reply from target: %s", reply);
1962 error ("Bogus reply from target: %s", reply);
1965 flush_cached_frames ();
1966 registers_changed ();
1967 select_frame (get_current_frame (), 0);
1968 set_traceframe_num (target_frameno);
1969 set_tracepoint_num (target_tracept);
1970 if (target_frameno == -1)
1971 set_traceframe_context (-1);
1973 set_traceframe_context (read_pc ());
1979 /* NOTE: in immitation of the step command, try to determine
1980 whether we have made a transition from one function to another.
1981 If so, we'll print the "stack frame" (ie. the new function and
1982 it's arguments) -- otherwise we'll just show the new source line.
1984 This determination is made by checking (1) whether the current
1985 function has changed, and (2) whether the current FP has changed.
1986 Hack: if the FP wasn't collected, either at the current or the
1987 previous frame, assume that the FP has NOT changed. */
1989 if (old_func == find_pc_function (read_pc ()) &&
1990 (old_frame_addr == 0 ||
1991 FRAME_FP (get_current_frame ()) == 0 ||
1992 old_frame_addr == FRAME_FP (get_current_frame ())))
1997 print_stack_frame (selected_frame, selected_frame_level, source_only);
2002 /* trace_find_command takes a trace frame number n,
2003 sends "QTFrame:<n>" to the target,
2004 and accepts a reply that may contain several optional pieces
2005 of information: a frame number, a tracepoint number, and an
2006 indication of whether this is a trap frame or a stepping frame.
2008 The minimal response is just "OK" (which indicates that the
2009 target does not give us a frame number or a tracepoint number).
2010 Instead of that, the target may send us a string containing
2012 F<hexnum> (gives the selected frame number)
2013 T<hexnum> (gives the selected tracepoint number)
2018 trace_find_command (args, from_tty)
2021 { /* STUB_COMM PART_IMPLEMENTED */
2022 /* this should only be called with a numeric argument */
2025 if (target_is_remote ())
2027 if (trace_find_hook)
2028 trace_find_hook (args, from_tty);
2030 if (args == 0 || *args == 0)
2031 { /* TFIND with no args means find NEXT trace frame. */
2032 if (traceframe_number == -1)
2033 frameno = 0; /* "next" is first one */
2035 frameno = traceframe_number + 1;
2037 else if (0 == strcmp (args, "-"))
2039 if (traceframe_number == -1)
2040 error ("not debugging trace buffer");
2041 else if (from_tty && traceframe_number == 0)
2042 error ("already at start of trace buffer");
2044 frameno = traceframe_number - 1;
2047 frameno = parse_and_eval_address (args);
2050 error ("invalid input (%d is less than zero)", frameno);
2052 sprintf (target_buf, "QTFrame:%x", frameno);
2053 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2056 error ("Trace can only be run on remote targets.");
2061 trace_find_end_command (args, from_tty)
2065 trace_find_command ("-1", from_tty);
2070 trace_find_none_command (args, from_tty)
2074 trace_find_command ("-1", from_tty);
2079 trace_find_start_command (args, from_tty)
2083 trace_find_command ("0", from_tty);
2086 /* tfind pc command */
2088 trace_find_pc_command (args, from_tty)
2091 { /* STUB_COMM PART_IMPLEMENTED */
2095 if (target_is_remote ())
2097 if (args == 0 || *args == 0)
2098 pc = read_pc (); /* default is current pc */
2100 pc = parse_and_eval_address (args);
2102 sprintf_vma (tmp, pc);
2103 sprintf (target_buf, "QTFrame:pc:%s", tmp);
2104 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2107 error ("Trace can only be run on remote targets.");
2110 /* tfind tracepoint command */
2112 trace_find_tracepoint_command (args, from_tty)
2115 { /* STUB_COMM PART_IMPLEMENTED */
2118 if (target_is_remote ())
2120 if (args == 0 || *args == 0)
2121 if (tracepoint_number == -1)
2122 error ("No current tracepoint -- please supply an argument.");
2124 tdp = tracepoint_number; /* default is current TDP */
2126 tdp = parse_and_eval_address (args);
2128 sprintf (target_buf, "QTFrame:tdp:%x", tdp);
2129 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2132 error ("Trace can only be run on remote targets.");
2135 /* TFIND LINE command:
2137 This command will take a sourceline for argument, just like BREAK
2138 or TRACE (ie. anything that "decode_line_1" can handle).
2140 With no argument, this command will find the next trace frame
2141 corresponding to a source line OTHER THAN THE CURRENT ONE. */
2144 trace_find_line_command (args, from_tty)
2147 { /* STUB_COMM PART_IMPLEMENTED */
2148 static CORE_ADDR start_pc, end_pc;
2149 struct symtabs_and_lines sals;
2150 struct symtab_and_line sal;
2151 struct cleanup *old_chain;
2152 char startpc_str[40], endpc_str[40];
2154 if (target_is_remote ())
2156 if (args == 0 || *args == 0)
2158 sal = find_pc_line ((get_current_frame ())->pc, 0);
2160 sals.sals = (struct symtab_and_line *)
2161 xmalloc (sizeof (struct symtab_and_line));
2166 sals = decode_line_spec (args, 1);
2170 old_chain = make_cleanup (free, sals.sals);
2171 if (sal.symtab == 0)
2173 printf_filtered ("TFIND: No line number information available");
2176 /* This is useful for "info line *0x7f34". If we can't tell the
2177 user about a source line, at least let them have the symbolic
2179 printf_filtered (" for address ");
2181 print_address (sal.pc, gdb_stdout);
2182 printf_filtered (";\n -- will attempt to find by PC. \n");
2186 printf_filtered (".\n");
2187 return; /* no line, no PC; what can we do? */
2190 else if (sal.line > 0
2191 && find_line_pc_range (sal, &start_pc, &end_pc))
2193 if (start_pc == end_pc)
2195 printf_filtered ("Line %d of \"%s\"",
2196 sal.line, sal.symtab->filename);
2198 printf_filtered (" is at address ");
2199 print_address (start_pc, gdb_stdout);
2201 printf_filtered (" but contains no code.\n");
2202 sal = find_pc_line (start_pc, 0);
2204 find_line_pc_range (sal, &start_pc, &end_pc) &&
2206 printf_filtered ("Attempting to find line %d instead.\n",
2209 error ("Cannot find a good line.");
2213 /* Is there any case in which we get here, and have an address
2214 which the user would want to see? If we have debugging symbols
2215 and no line numbers? */
2216 error ("Line number %d is out of range for \"%s\".\n",
2217 sal.line, sal.symtab->filename);
2219 sprintf_vma (startpc_str, start_pc);
2220 sprintf_vma (endpc_str, end_pc - 1);
2221 if (args && *args) /* find within range of stated line */
2222 sprintf (target_buf, "QTFrame:range:%s:%s", startpc_str, endpc_str);
2223 else /* find OUTSIDE OF range of CURRENT line */
2224 sprintf (target_buf, "QTFrame:outside:%s:%s", startpc_str, endpc_str);
2225 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2226 do_cleanups (old_chain);
2229 error ("Trace can only be run on remote targets.");
2232 /* tfind range command */
2234 trace_find_range_command (args, from_tty)
2238 static CORE_ADDR start, stop;
2239 char start_str[40], stop_str[40];
2242 if (target_is_remote ())
2244 if (args == 0 || *args == 0)
2245 { /* XXX FIXME: what should default behavior be? */
2246 printf_filtered ("Usage: tfind range <startaddr>,<endaddr>\n");
2250 if (0 != (tmp = strchr (args, ',')))
2252 *tmp++ = '\0'; /* terminate start address */
2253 while (isspace ((int) *tmp))
2255 start = parse_and_eval_address (args);
2256 stop = parse_and_eval_address (tmp);
2259 { /* no explicit end address? */
2260 start = parse_and_eval_address (args);
2261 stop = start + 1; /* ??? */
2264 sprintf_vma (start_str, start);
2265 sprintf_vma (stop_str, stop);
2266 sprintf (target_buf, "QTFrame:range:%s:%s", start_str, stop_str);
2267 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2270 error ("Trace can only be run on remote targets.");
2273 /* tfind outside command */
2275 trace_find_outside_command (args, from_tty)
2279 CORE_ADDR start, stop;
2280 char start_str[40], stop_str[40];
2283 if (target_is_remote ())
2285 if (args == 0 || *args == 0)
2286 { /* XXX FIXME: what should default behavior be? */
2287 printf_filtered ("Usage: tfind outside <startaddr>,<endaddr>\n");
2291 if (0 != (tmp = strchr (args, ',')))
2293 *tmp++ = '\0'; /* terminate start address */
2294 while (isspace ((int) *tmp))
2296 start = parse_and_eval_address (args);
2297 stop = parse_and_eval_address (tmp);
2300 { /* no explicit end address? */
2301 start = parse_and_eval_address (args);
2302 stop = start + 1; /* ??? */
2305 sprintf_vma (start_str, start);
2306 sprintf_vma (stop_str, stop);
2307 sprintf (target_buf, "QTFrame:outside:%s:%s", start_str, stop_str);
2308 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2311 error ("Trace can only be run on remote targets.");
2314 /* save-tracepoints command */
2316 tracepoint_save_command (args, from_tty)
2320 struct tracepoint *tp;
2321 struct action_line *line;
2323 char *i1 = " ", *i2 = " ";
2324 char *indent, *actionline;
2327 if (args == 0 || *args == 0)
2328 error ("Argument required (file name in which to save tracepoints");
2330 if (tracepoint_chain == 0)
2332 warning ("save-tracepoints: no tracepoints to save.\n");
2336 if (!(fp = fopen (args, "w")))
2337 error ("Unable to open file '%s' for saving tracepoints");
2339 ALL_TRACEPOINTS (tp)
2341 if (tp->addr_string)
2342 fprintf (fp, "trace %s\n", tp->addr_string);
2345 sprintf_vma (tmp, tp->address);
2346 fprintf (fp, "trace *0x%s\n", tmp);
2350 fprintf (fp, " passcount %d\n", tp->pass_count);
2354 fprintf (fp, " actions\n");
2356 for (line = tp->actions; line; line = line->next)
2358 struct cmd_list_element *cmd;
2360 QUIT; /* allow user to bail out with ^C */
2361 actionline = line->action;
2362 while (isspace ((int) *actionline))
2365 fprintf (fp, "%s%s\n", indent, actionline);
2366 if (*actionline != '#') /* skip for comment lines */
2368 cmd = lookup_cmd (&actionline, cmdlist, "", -1, 1);
2370 error ("Bad action list item: %s", actionline);
2371 if (cmd->function.cfunc == while_stepping_pseudocommand)
2373 else if (cmd->function.cfunc == end_actions_pseudocommand)
2381 printf_filtered ("Tracepoints saved to file '%s'.\n", args);
2385 /* info scope command: list the locals for a scope. */
2387 scope_info (args, from_tty)
2391 struct symtabs_and_lines sals;
2393 struct minimal_symbol *msym;
2394 struct block *block;
2395 char **canonical, *symname, *save_args = args;
2396 int i, j, nsyms, count = 0;
2398 if (args == 0 || *args == 0)
2399 error ("requires an argument (function, line or *addr) to define a scope");
2401 sals = decode_line_1 (&args, 1, NULL, 0, &canonical);
2402 if (sals.nelts == 0)
2403 return; /* presumably decode_line_1 has already warned */
2405 /* Resolve line numbers to PC */
2406 resolve_sal_pc (&sals.sals[0]);
2407 block = block_for_pc (sals.sals[0].pc);
2411 QUIT; /* allow user to bail out with ^C */
2412 nsyms = BLOCK_NSYMS (block);
2413 for (i = 0; i < nsyms; i++)
2415 QUIT; /* allow user to bail out with ^C */
2417 printf_filtered ("Scope for %s:\n", save_args);
2419 sym = BLOCK_SYM (block, i);
2420 symname = SYMBOL_NAME (sym);
2421 if (symname == NULL || *symname == '\0')
2422 continue; /* probably botched, certainly useless */
2424 printf_filtered ("Symbol %s is ", symname);
2425 switch (SYMBOL_CLASS (sym))
2428 case LOC_UNDEF: /* messed up symbol? */
2429 printf_filtered ("a bogus symbol, class %d.\n",
2430 SYMBOL_CLASS (sym));
2431 count--; /* don't count this one */
2434 printf_filtered ("a constant with value %ld (0x%lx)",
2435 SYMBOL_VALUE (sym), SYMBOL_VALUE (sym));
2437 case LOC_CONST_BYTES:
2438 printf_filtered ("constant bytes: ");
2439 if (SYMBOL_TYPE (sym))
2440 for (j = 0; j < TYPE_LENGTH (SYMBOL_TYPE (sym)); j++)
2441 fprintf_filtered (gdb_stdout, " %02x",
2442 (unsigned) SYMBOL_VALUE_BYTES (sym)[j]);
2445 printf_filtered ("in static storage at address ");
2446 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
2449 printf_filtered ("a local variable in register $%s",
2450 REGISTER_NAME (SYMBOL_VALUE (sym)));
2454 printf_filtered ("an argument at stack/frame offset %ld",
2455 SYMBOL_VALUE (sym));
2458 printf_filtered ("a local variable at frame offset %ld",
2459 SYMBOL_VALUE (sym));
2462 printf_filtered ("a reference argument at offset %ld",
2463 SYMBOL_VALUE (sym));
2466 printf_filtered ("an argument in register $%s",
2467 REGISTER_NAME (SYMBOL_VALUE (sym)));
2469 case LOC_REGPARM_ADDR:
2470 printf_filtered ("the address of an argument, in register $%s",
2471 REGISTER_NAME (SYMBOL_VALUE (sym)));
2474 printf_filtered ("a typedef.\n");
2477 printf_filtered ("a label at address ");
2478 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
2481 printf_filtered ("a function at address ");
2482 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), 1,
2486 printf_filtered ("a variable at offset %ld from register $%s",
2488 REGISTER_NAME (SYMBOL_BASEREG (sym)));
2490 case LOC_BASEREG_ARG:
2491 printf_filtered ("an argument at offset %ld from register $%s",
2493 REGISTER_NAME (SYMBOL_BASEREG (sym)));
2495 case LOC_UNRESOLVED:
2496 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, NULL);
2498 printf_filtered ("Unresolved Static");
2501 printf_filtered ("static storage at address ");
2502 print_address_numeric (SYMBOL_VALUE_ADDRESS (msym), 1,
2506 case LOC_OPTIMIZED_OUT:
2507 printf_filtered ("optimized out.\n");
2510 if (SYMBOL_TYPE (sym))
2511 printf_filtered (", length %d.\n",
2512 TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym))));
2514 if (BLOCK_FUNCTION (block))
2517 block = BLOCK_SUPERBLOCK (block);
2520 printf_filtered ("Scope for %s contains no locals or arguments.\n",
2524 /* worker function (cleanup) */
2526 replace_comma (comma)
2534 trace_dump_command (args, from_tty)
2538 struct tracepoint *t;
2539 struct action_line *action;
2540 char *action_exp, *next_comma;
2541 struct cleanup *old_cleanups;
2542 int stepping_actions = 0;
2543 int stepping_frame = 0;
2545 if (!target_is_remote ())
2547 error ("Trace can only be run on remote targets.");
2551 if (tracepoint_number == -1)
2553 warning ("No current trace frame.");
2558 if (t->number == tracepoint_number)
2562 error ("No known tracepoint matches 'current' tracepoint #%d.",
2565 old_cleanups = make_cleanup (null_cleanup, NULL);
2567 printf_filtered ("Data collected at tracepoint %d, trace frame %d:\n",
2568 tracepoint_number, traceframe_number);
2570 /* The current frame is a trap frame if the frame PC is equal
2571 to the tracepoint PC. If not, then the current frame was
2572 collected during single-stepping. */
2574 stepping_frame = (t->address != read_pc ());
2576 for (action = t->actions; action; action = action->next)
2578 struct cmd_list_element *cmd;
2580 QUIT; /* allow user to bail out with ^C */
2581 action_exp = action->action;
2582 while (isspace ((int) *action_exp))
2585 /* The collection actions to be done while stepping are
2586 bracketed by the commands "while-stepping" and "end". */
2588 if (*action_exp == '#') /* comment line */
2591 cmd = lookup_cmd (&action_exp, cmdlist, "", -1, 1);
2593 error ("Bad action list item: %s", action_exp);
2595 if (cmd->function.cfunc == while_stepping_pseudocommand)
2596 stepping_actions = 1;
2597 else if (cmd->function.cfunc == end_actions_pseudocommand)
2598 stepping_actions = 0;
2599 else if (cmd->function.cfunc == collect_pseudocommand)
2601 /* Display the collected data.
2602 For the trap frame, display only what was collected at the trap.
2603 Likewise for stepping frames, display only what was collected
2604 while stepping. This means that the two boolean variables,
2605 STEPPING_FRAME and STEPPING_ACTIONS should be equal. */
2606 if (stepping_frame == stepping_actions)
2609 { /* repeat over a comma-separated list */
2610 QUIT; /* allow user to bail out with ^C */
2611 if (*action_exp == ',')
2613 while (isspace ((int) *action_exp))
2616 next_comma = strchr (action_exp, ',');
2618 if (0 == strncasecmp (action_exp, "$reg", 4))
2619 registers_info (NULL, from_tty);
2620 else if (0 == strncasecmp (action_exp, "$loc", 4))
2621 locals_info (NULL, from_tty);
2622 else if (0 == strncasecmp (action_exp, "$arg", 4))
2623 args_info (NULL, from_tty);
2628 make_cleanup (replace_comma, next_comma);
2631 printf_filtered ("%s = ", action_exp);
2632 output_command (action_exp, from_tty);
2633 printf_filtered ("\n");
2637 action_exp = next_comma;
2639 while (action_exp && *action_exp == ',');
2643 discard_cleanups (old_cleanups);
2646 /* Convert the memory pointed to by mem into hex, placing result in buf.
2647 * Return a pointer to the last char put in buf (null)
2648 * "stolen" from sparc-stub.c
2651 static const char hexchars[] = "0123456789abcdef";
2653 static unsigned char *
2654 mem2hex (mem, buf, count)
2665 *buf++ = hexchars[ch >> 4];
2666 *buf++ = hexchars[ch & 0xf];
2675 get_traceframe_number ()
2677 return traceframe_number;
2681 /* module initialization */
2683 _initialize_tracepoint ()
2685 tracepoint_chain = 0;
2686 tracepoint_count = 0;
2687 traceframe_number = -1;
2688 tracepoint_number = -1;
2690 set_internalvar (lookup_internalvar ("tpnum"),
2691 value_from_longest (builtin_type_int, (LONGEST) 0));
2692 set_internalvar (lookup_internalvar ("trace_frame"),
2693 value_from_longest (builtin_type_int, (LONGEST) - 1));
2695 if (tracepoint_list.list == NULL)
2697 tracepoint_list.listsize = 128;
2698 tracepoint_list.list = xmalloc
2699 (tracepoint_list.listsize * sizeof (struct memrange));
2701 if (tracepoint_list.aexpr_list == NULL)
2703 tracepoint_list.aexpr_listsize = 128;
2704 tracepoint_list.aexpr_list = xmalloc
2705 (tracepoint_list.aexpr_listsize * sizeof (struct agent_expr *));
2708 if (stepping_list.list == NULL)
2710 stepping_list.listsize = 128;
2711 stepping_list.list = xmalloc
2712 (stepping_list.listsize * sizeof (struct memrange));
2715 if (stepping_list.aexpr_list == NULL)
2717 stepping_list.aexpr_listsize = 128;
2718 stepping_list.aexpr_list = xmalloc
2719 (stepping_list.aexpr_listsize * sizeof (struct agent_expr *));
2722 add_info ("scope", scope_info,
2723 "List the variables local to a scope");
2725 add_cmd ("tracepoints", class_trace, NO_FUNCTION,
2726 "Tracing of program execution without stopping the program.",
2729 add_info ("tracepoints", tracepoints_info,
2730 "Status of tracepoints, or tracepoint number NUMBER.\n\
2731 Convenience variable \"$tpnum\" contains the number of the\n\
2732 last tracepoint set.");
2734 add_info_alias ("tp", "tracepoints", 1);
2736 add_com ("save-tracepoints", class_trace, tracepoint_save_command,
2737 "Save current tracepoint definitions as a script.\n\
2738 Use the 'source' command in another debug session to restore them.");
2740 add_com ("tdump", class_trace, trace_dump_command,
2741 "Print everything collected at the current tracepoint.");
2743 add_prefix_cmd ("tfind", class_trace, trace_find_command,
2744 "Select a trace frame;\n\
2745 No argument means forward by one frame; '-' meand backward by one frame.",
2746 &tfindlist, "tfind ", 1, &cmdlist);
2748 add_cmd ("outside", class_trace, trace_find_outside_command,
2749 "Select a trace frame whose PC is outside the given \
2750 range.\nUsage: tfind outside addr1, addr2",
2753 add_cmd ("range", class_trace, trace_find_range_command,
2754 "Select a trace frame whose PC is in the given range.\n\
2755 Usage: tfind range addr1,addr2",
2758 add_cmd ("line", class_trace, trace_find_line_command,
2759 "Select a trace frame by source line.\n\
2760 Argument can be a line number (with optional source file), \n\
2761 a function name, or '*' followed by an address.\n\
2762 Default argument is 'the next source line that was traced'.",
2765 add_cmd ("tracepoint", class_trace, trace_find_tracepoint_command,
2766 "Select a trace frame by tracepoint number.\n\
2767 Default is the tracepoint for the current trace frame.",
2770 add_cmd ("pc", class_trace, trace_find_pc_command,
2771 "Select a trace frame by PC.\n\
2772 Default is the current PC, or the PC of the current trace frame.",
2775 add_cmd ("end", class_trace, trace_find_end_command,
2776 "Synonym for 'none'.\n\
2777 De-select any trace frame and resume 'live' debugging.",
2780 add_cmd ("none", class_trace, trace_find_none_command,
2781 "De-select any trace frame and resume 'live' debugging.",
2784 add_cmd ("start", class_trace, trace_find_start_command,
2785 "Select the first trace frame in the trace buffer.",
2788 add_com ("tstatus", class_trace, trace_status_command,
2789 "Display the status of the current trace data collection.");
2791 add_com ("tstop", class_trace, trace_stop_command,
2792 "Stop trace data collection.");
2794 add_com ("tstart", class_trace, trace_start_command,
2795 "Start trace data collection.");
2797 add_com ("passcount", class_trace, trace_pass_command,
2798 "Set the passcount for a tracepoint.\n\
2799 The trace will end when the tracepoint has been passed 'count' times.\n\
2800 Usage: passcount COUNT TPNUM, where TPNUM may also be \"all\";\n\
2801 if TPNUM is omitted, passcount refers to the last tracepoint defined.");
2803 add_com ("end", class_trace, end_actions_pseudocommand,
2804 "Ends a list of commands or actions.\n\
2805 Several GDB commands allow you to enter a list of commands or actions.\n\
2806 Entering \"end\" on a line by itself is the normal way to terminate\n\
2808 Note: the \"end\" command cannot be used at the gdb prompt.");
2810 add_com ("while-stepping", class_trace, while_stepping_pseudocommand,
2811 "Specify single-stepping behavior at a tracepoint.\n\
2812 Argument is number of instructions to trace in single-step mode\n\
2813 following the tracepoint. This command is normally followed by\n\
2814 one or more \"collect\" commands, to specify what to collect\n\
2815 while single-stepping.\n\n\
2816 Note: this command can only be used in a tracepoint \"actions\" list.");
2818 add_com_alias ("ws", "while-stepping", class_alias, 0);
2819 add_com_alias ("stepping", "while-stepping", class_alias, 0);
2821 add_com ("collect", class_trace, collect_pseudocommand,
2822 "Specify one or more data items to be collected at a tracepoint.\n\
2823 Accepts a comma-separated list of (one or more) expressions. GDB will\n\
2824 collect all data (variables, registers) referenced by that expression.\n\
2825 Also accepts the following special arguments:\n\
2826 $regs -- all registers.\n\
2827 $args -- all function arguments.\n\
2828 $locals -- all variables local to the block/function scope.\n\
2829 Note: this command can only be used in a tracepoint \"actions\" list.");
2831 add_com ("actions", class_trace, trace_actions_command,
2832 "Specify the actions to be taken at a tracepoint.\n\
2833 Tracepoint actions may include collecting of specified data, \n\
2834 single-stepping, or enabling/disabling other tracepoints, \n\
2835 depending on target's capabilities.");
2837 add_cmd ("tracepoints", class_trace, delete_trace_command,
2838 "Delete specified tracepoints.\n\
2839 Arguments are tracepoint numbers, separated by spaces.\n\
2840 No argument means delete all tracepoints.",
2843 add_cmd ("tracepoints", class_trace, disable_trace_command,
2844 "Disable specified tracepoints.\n\
2845 Arguments are tracepoint numbers, separated by spaces.\n\
2846 No argument means disable all tracepoints.",
2849 add_cmd ("tracepoints", class_trace, enable_trace_command,
2850 "Enable specified tracepoints.\n\
2851 Arguments are tracepoint numbers, separated by spaces.\n\
2852 No argument means enable all tracepoints.",
2855 add_com ("trace", class_trace, trace_command,
2856 "Set a tracepoint at a specified line or function or address.\n\
2857 Argument may be a line number, function name, or '*' plus an address.\n\
2858 For a line number or function, trace at the start of its code.\n\
2859 If an address is specified, trace at that exact address.\n\n\
2860 Do \"help tracepoints\" for info on other tracepoint commands.");
2862 add_com_alias ("tp", "trace", class_alias, 0);
2863 add_com_alias ("tr", "trace", class_alias, 1);
2864 add_com_alias ("tra", "trace", class_alias, 1);
2865 add_com_alias ("trac", "trace", class_alias, 1);