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) (char *, ...);
62 extern char *(*readline_hook) (char *);
63 extern void (*readline_end_hook) (void);
64 extern void x_command (char *, int);
65 extern int addressprint; /* Print machine addresses? */
67 /* GDB commands implemented in other modules:
70 extern void output_command (char *, int);
71 extern void registers_info (char *, int);
72 extern void args_info (char *, int);
73 extern void locals_info (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 (char *, int);
133 static void tracepoints_info (char *, int);
134 static void delete_trace_command (char *, int);
135 static void enable_trace_command (char *, int);
136 static void disable_trace_command (char *, int);
137 static void trace_pass_command (char *, int);
138 static void trace_actions_command (char *, int);
139 static void trace_start_command (char *, int);
140 static void trace_stop_command (char *, int);
141 static void trace_status_command (char *, int);
142 static void trace_find_command (char *, int);
143 static void trace_find_pc_command (char *, int);
144 static void trace_find_tracepoint_command (char *, int);
145 static void trace_find_line_command (char *, int);
146 static void trace_find_range_command (char *, int);
147 static void trace_find_outside_command (char *, int);
148 static void tracepoint_save_command (char *, int);
149 static void trace_dump_command (char *, int);
151 /* support routines */
152 static void trace_mention (struct tracepoint *);
154 struct collection_list;
155 static void add_aexpr (struct collection_list *, struct agent_expr *);
156 static unsigned char *mem2hex (unsigned char *, unsigned char *, int);
157 static void add_register (struct collection_list *collection,
159 static struct cleanup *make_cleanup_free_actions (struct tracepoint *t);
160 static void free_actions_list (char **actions_list);
161 static void free_actions_list_cleanup_wrapper (void *);
163 extern void _initialize_tracepoint (void);
165 /* Utility: returns true if "target remote" */
167 target_is_remote (void)
169 if (current_target.to_shortname &&
170 strcmp (current_target.to_shortname, "remote") == 0)
176 /* Utility: generate error from an incoming stub packet. */
178 trace_error (char *buf)
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 (int num)
223 tracepoint_count = num;
224 set_internalvar (lookup_internalvar ("tpnum"),
225 value_from_longest (builtin_type_int, (LONGEST) num));
228 /* Set traceframe number to NUM. */
230 set_traceframe_num (int num)
232 traceframe_number = num;
233 set_internalvar (lookup_internalvar ("trace_frame"),
234 value_from_longest (builtin_type_int, (LONGEST) num));
237 /* Set tracepoint number to NUM. */
239 set_tracepoint_num (int num)
241 tracepoint_number = num;
242 set_internalvar (lookup_internalvar ("tracepoint"),
243 value_from_longest (builtin_type_int, (LONGEST) num));
246 /* Set externally visible debug variables for querying/printing
247 the traceframe context (line, function, file) */
250 set_traceframe_context (CORE_ADDR trace_pc)
252 static struct type *func_string, *file_string;
253 static struct type *func_range, *file_range;
254 static value_ptr func_val, file_val;
255 static struct type *charstar;
258 if (charstar == (struct type *) NULL)
259 charstar = lookup_pointer_type (builtin_type_char);
261 if (trace_pc == -1) /* cease debugging any trace buffers */
264 traceframe_sal.pc = traceframe_sal.line = 0;
265 traceframe_sal.symtab = NULL;
266 set_internalvar (lookup_internalvar ("trace_func"),
267 value_from_pointer (charstar, (LONGEST) 0));
268 set_internalvar (lookup_internalvar ("trace_file"),
269 value_from_pointer (charstar, (LONGEST) 0));
270 set_internalvar (lookup_internalvar ("trace_line"),
271 value_from_pointer (builtin_type_int, (LONGEST) - 1));
275 /* save as globals for internal use */
276 traceframe_sal = find_pc_line (trace_pc, 0);
277 traceframe_fun = find_pc_function (trace_pc);
279 /* save linenumber as "$trace_line", a debugger variable visible to users */
280 set_internalvar (lookup_internalvar ("trace_line"),
281 value_from_longest (builtin_type_int,
282 (LONGEST) traceframe_sal.line));
284 /* save func name as "$trace_func", a debugger variable visible to users */
285 if (traceframe_fun == NULL ||
286 SYMBOL_NAME (traceframe_fun) == NULL)
287 set_internalvar (lookup_internalvar ("trace_func"),
288 value_from_pointer (charstar, (LONGEST) 0));
291 len = strlen (SYMBOL_NAME (traceframe_fun));
292 func_range = create_range_type (func_range,
293 builtin_type_int, 0, len - 1);
294 func_string = create_array_type (func_string,
295 builtin_type_char, func_range);
296 func_val = allocate_value (func_string);
297 VALUE_TYPE (func_val) = func_string;
298 memcpy (VALUE_CONTENTS_RAW (func_val),
299 SYMBOL_NAME (traceframe_fun),
301 func_val->modifiable = 0;
302 set_internalvar (lookup_internalvar ("trace_func"), func_val);
305 /* save file name as "$trace_file", a debugger variable visible to users */
306 if (traceframe_sal.symtab == NULL ||
307 traceframe_sal.symtab->filename == NULL)
308 set_internalvar (lookup_internalvar ("trace_file"),
309 value_from_pointer (charstar, (LONGEST) 0));
312 len = strlen (traceframe_sal.symtab->filename);
313 file_range = create_range_type (file_range,
314 builtin_type_int, 0, len - 1);
315 file_string = create_array_type (file_string,
316 builtin_type_char, file_range);
317 file_val = allocate_value (file_string);
318 VALUE_TYPE (file_val) = file_string;
319 memcpy (VALUE_CONTENTS_RAW (file_val),
320 traceframe_sal.symtab->filename,
322 file_val->modifiable = 0;
323 set_internalvar (lookup_internalvar ("trace_file"), file_val);
327 /* Low level routine to set a tracepoint.
328 Returns the tracepoint object so caller can set other things.
329 Does not set the tracepoint number!
330 Does not print anything.
332 ==> This routine should not be called if there is a chance of later
333 error(); otherwise it leaves a bogus tracepoint on the chain. Validate
334 your arguments BEFORE calling this routine! */
336 static struct tracepoint *
337 set_raw_tracepoint (struct symtab_and_line sal)
339 register struct tracepoint *t, *tc;
340 struct cleanup *old_chain;
342 t = (struct tracepoint *) xmalloc (sizeof (struct tracepoint));
343 old_chain = make_cleanup (free, t);
344 memset (t, 0, sizeof (*t));
346 if (sal.symtab == NULL)
347 t->source_file = NULL;
349 t->source_file = savestring (sal.symtab->filename,
350 strlen (sal.symtab->filename));
352 t->section = sal.section;
353 t->language = current_language->la_language;
354 t->input_radix = input_radix;
355 t->line_number = sal.line;
356 t->enabled = enabled;
360 t->addr_string = NULL;
362 /* Add this tracepoint to the end of the chain
363 so that a list of tracepoints will come out in order
364 of increasing numbers. */
366 tc = tracepoint_chain;
368 tracepoint_chain = t;
375 discard_cleanups (old_chain);
379 /* Set a tracepoint according to ARG (function, linenum or *address) */
381 trace_command (char *arg, int from_tty)
383 char **canonical = (char **) NULL;
384 struct symtabs_and_lines sals;
385 struct symtab_and_line sal;
386 struct tracepoint *t;
387 char *addr_start = 0, *addr_end = 0;
391 error ("trace command requires an argument");
393 if (from_tty && info_verbose)
394 printf_filtered ("TRACE %s\n", arg);
397 sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical);
400 return; /* ??? Presumably decode_line_1 has already warned? */
402 /* Resolve all line numbers to PC's */
403 for (i = 0; i < sals.nelts; i++)
404 resolve_sal_pc (&sals.sals[i]);
406 /* Now set all the tracepoints. */
407 for (i = 0; i < sals.nelts; i++)
411 t = set_raw_tracepoint (sal);
412 set_tracepoint_count (tracepoint_count + 1);
413 t->number = tracepoint_count;
415 /* If a canonical line spec is needed use that instead of the
417 if (canonical != (char **) NULL && canonical[i] != NULL)
418 t->addr_string = canonical[i];
420 t->addr_string = savestring (addr_start, addr_end - addr_start);
424 /* Let the UI know of any additions */
425 if (create_tracepoint_hook)
426 create_tracepoint_hook (t);
431 printf_filtered ("Multiple tracepoints were set.\n");
432 printf_filtered ("Use 'delete trace' to delete unwanted tracepoints.\n");
436 /* Tell the user we have just set a tracepoint TP. */
439 trace_mention (struct tracepoint *tp)
441 printf_filtered ("Tracepoint %d", tp->number);
443 if (addressprint || (tp->source_file == NULL))
445 printf_filtered (" at ");
446 print_address_numeric (tp->address, 1, gdb_stdout);
449 printf_filtered (": file %s, line %d.",
450 tp->source_file, tp->line_number);
452 printf_filtered ("\n");
455 /* Print information on tracepoint number TPNUM_EXP, or all if omitted. */
458 tracepoints_info (char *tpnum_exp, int from_tty)
460 struct tracepoint *t;
461 struct action_line *action;
462 int found_a_tracepoint = 0;
463 char wrap_indent[80];
468 tpnum = parse_and_eval_address (tpnum_exp);
471 if (tpnum == -1 || tpnum == t->number)
473 extern int addressprint; /* print machine addresses? */
475 if (!found_a_tracepoint++)
477 printf_filtered ("Num Enb ");
479 printf_filtered ("Address ");
480 printf_filtered ("PassC StepC What\n");
482 strcpy (wrap_indent, " ");
484 strcat (wrap_indent, " ");
486 printf_filtered ("%-3d %-3s ", t->number,
487 t->enabled == enabled ? "y" : "n");
489 printf_filtered ("%s ",
490 local_hex_string_custom ((unsigned long) t->address,
492 printf_filtered ("%-5d %-5ld ", t->pass_count, t->step_count);
496 sym = find_pc_sect_function (t->address, t->section);
499 fputs_filtered ("in ", gdb_stdout);
500 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
501 wrap_here (wrap_indent);
502 fputs_filtered (" at ", gdb_stdout);
504 fputs_filtered (t->source_file, gdb_stdout);
505 printf_filtered (":%d", t->line_number);
508 print_address_symbolic (t->address, gdb_stdout, demangle, " ");
510 printf_filtered ("\n");
513 printf_filtered (" Actions for tracepoint %d: \n", t->number);
514 for (action = t->actions; action; action = action->next)
516 printf_filtered ("\t%s\n", action->action);
520 if (!found_a_tracepoint)
523 printf_filtered ("No tracepoints.\n");
525 printf_filtered ("No tracepoint number %d.\n", tpnum);
529 /* Optimization: the code to parse an enable, disable, or delete TP command
530 is virtually identical except for whether it performs an enable, disable,
531 or delete. Therefore I've combined them into one function with an opcode.
533 enum tracepoint_opcode
540 /* This function implements enable, disable and delete commands. */
542 tracepoint_operation (struct tracepoint *t, int from_tty,
543 enum tracepoint_opcode opcode)
545 struct tracepoint *t2;
547 if (t == NULL) /* no tracepoint operand */
553 t->enabled = enabled;
554 if (modify_tracepoint_hook)
555 modify_tracepoint_hook (t);
558 t->enabled = disabled;
559 if (modify_tracepoint_hook)
560 modify_tracepoint_hook (t);
563 if (tracepoint_chain == t)
564 tracepoint_chain = t->next;
573 /* Let the UI know of any deletions */
574 if (delete_tracepoint_hook)
575 delete_tracepoint_hook (t);
578 free (t->addr_string);
580 free (t->source_file);
589 /* Utility: parse a tracepoint number and look it up in the list.
590 If MULTI_P is true, there might be a range of tracepoints in ARG.
591 if OPTIONAL_P is true, then if the argument is missing, the most
592 recent tracepoint (tracepoint_count) is returned. */
594 get_tracepoint_by_number (char **arg, int multi_p, int optional_p)
596 struct tracepoint *t;
598 char *instring = arg == NULL ? NULL : *arg;
600 if (arg == NULL || *arg == NULL || ! **arg)
603 tpnum = tracepoint_count;
605 error_no_arg ("tracepoint number");
608 tpnum = multi_p ? get_number_or_range (arg) : get_number (arg);
612 if (instring && *instring)
613 printf_filtered ("bad tracepoint number at or near '%s'\n", instring);
615 printf_filtered ("Tracepoint argument missing and no previous tracepoint\n");
620 if (t->number == tpnum)
625 /* FIXME: if we are in the middle of a range we don't want to give
626 a message. The current interface to get_number_or_range doesn't
627 allow us to discover this. */
628 printf_unfiltered ("No tracepoint number %d.\n", tpnum);
632 /* Utility: parse a list of tracepoint numbers, and call a func for each. */
634 map_args_over_tracepoints (char *args, int from_tty,
635 enum tracepoint_opcode opcode)
637 struct tracepoint *t, *tmp;
639 if (args == 0 || *args == 0) /* do them all */
640 ALL_TRACEPOINTS_SAFE (t, tmp)
641 tracepoint_operation (t, from_tty, opcode);
645 QUIT; /* give user option to bail out with ^C */
646 t = get_tracepoint_by_number (&args, 1, 0);
647 tracepoint_operation (t, from_tty, opcode);
648 while (*args == ' ' || *args == '\t')
653 /* The 'enable trace' command enables tracepoints. Not supported by all targets. */
655 enable_trace_command (char *args, int from_tty)
658 map_args_over_tracepoints (args, from_tty, enable_op);
661 /* The 'disable trace' command enables tracepoints. Not supported by all targets. */
663 disable_trace_command (char *args, int from_tty)
666 map_args_over_tracepoints (args, from_tty, disable_op);
669 /* Remove a tracepoint (or all if no argument) */
671 delete_trace_command (char *args, int from_tty)
674 if (!args || !*args) /* No args implies all tracepoints; */
675 if (from_tty) /* confirm only if from_tty... */
676 if (tracepoint_chain) /* and if there are tracepoints to delete! */
677 if (!query ("Delete all tracepoints? "))
680 map_args_over_tracepoints (args, from_tty, delete_op);
683 /* Set passcount for tracepoint.
685 First command argument is passcount, second is tracepoint number.
686 If tracepoint number omitted, apply to most recently defined.
687 Also accepts special argument "all". */
690 trace_pass_command (char *args, int from_tty)
692 struct tracepoint *t1 = (struct tracepoint *) -1, *t2;
696 if (args == 0 || *args == 0)
697 error ("passcount command requires an argument (count + optional TP num)");
699 count = strtoul (args, &args, 10); /* count comes first, then TP num */
701 while (*args && isspace ((int) *args))
704 if (*args && strncasecmp (args, "all", 3) == 0)
706 args += 3; /* skip special argument "all" */
709 error ("Junk at end of arguments.");
712 t1 = get_tracepoint_by_number (&args, 1, 1);
719 if (t1 == (struct tracepoint *) -1 || t1 == t2)
721 t2->pass_count = count;
722 if (modify_tracepoint_hook)
723 modify_tracepoint_hook (t2);
725 printf_filtered ("Setting tracepoint %d's passcount to %d\n",
729 t1 = get_tracepoint_by_number (&args, 1, 0);
735 /* ACTIONS functions: */
737 /* Prototypes for action-parsing utility commands */
738 static void read_actions (struct tracepoint *);
740 /* The three functions:
741 collect_pseudocommand,
742 while_stepping_pseudocommand, and
743 end_actions_pseudocommand
744 are placeholders for "commands" that are actually ONLY to be used
745 within a tracepoint action list. If the actual function is ever called,
746 it means that somebody issued the "command" at the top level,
747 which is always an error. */
750 end_actions_pseudocommand (char *args, int from_tty)
752 error ("This command cannot be used at the top level.");
756 while_stepping_pseudocommand (char *args, int from_tty)
758 error ("This command can only be used in a tracepoint actions list.");
762 collect_pseudocommand (char *args, int from_tty)
764 error ("This command can only be used in a tracepoint actions list.");
767 /* Enter a list of actions for a tracepoint. */
769 trace_actions_command (char *args, int from_tty)
771 struct tracepoint *t;
773 char *end_msg = "End with a line saying just \"end\".";
775 t = get_tracepoint_by_number (&args, 0, 1);
778 sprintf (tmpbuf, "Enter actions for tracepoint %d, one per line.",
783 if (readline_begin_hook)
784 (*readline_begin_hook) ("%s %s\n", tmpbuf, end_msg);
785 else if (input_from_terminal_p ())
786 printf_filtered ("%s\n%s\n", tmpbuf, end_msg);
790 t->step_count = 0; /* read_actions may set this */
793 if (readline_end_hook)
794 (*readline_end_hook) ();
795 /* tracepoints_changed () */
797 /* else just return */
800 /* worker function */
802 read_actions (struct tracepoint *t)
805 char *prompt1 = "> ", *prompt2 = " > ";
806 char *prompt = prompt1;
807 enum actionline_type linetype;
808 extern FILE *instream;
809 struct action_line *next = NULL, *temp;
810 struct cleanup *old_chain;
812 /* Control-C quits instantly if typed while in this loop
813 since it should not wait until the user types a newline. */
819 signal (STOP_SIGNAL, handle_stop_sig);
821 signal (STOP_SIGNAL, stop_sig);
824 old_chain = make_cleanup_free_actions (t);
827 /* Make sure that all output has been output. Some machines may let
828 you get away with leaving out some of the gdb_flush, but not all. */
830 gdb_flush (gdb_stdout);
831 gdb_flush (gdb_stderr);
833 if (readline_hook && instream == NULL)
834 line = (*readline_hook) (prompt);
835 else if (instream == stdin && ISATTY (instream))
837 line = readline (prompt);
838 if (line && *line) /* add it to command history */
842 line = gdb_readline (0);
844 linetype = validate_actionline (&line, t);
845 if (linetype == BADLINE)
846 continue; /* already warned -- collect another line */
848 temp = xmalloc (sizeof (struct action_line));
852 if (next == NULL) /* first action for this tracepoint? */
853 t->actions = next = temp;
860 if (linetype == STEPPING) /* begin "while-stepping" */
862 if (prompt == prompt2)
864 warning ("Already processing 'while-stepping'");
868 prompt = prompt2; /* change prompt for stepping actions */
870 else if (linetype == END)
872 if (prompt == prompt2)
874 prompt = prompt1; /* end of single-stepping actions */
877 { /* end of actions */
878 if (t->actions->next == NULL)
880 /* an "end" all by itself with no other actions means
881 this tracepoint has no actions. Discard empty list. */
890 signal (STOP_SIGNAL, SIG_DFL);
893 discard_cleanups (old_chain);
896 /* worker function */
898 validate_actionline (char **line, struct tracepoint *t)
900 struct cmd_list_element *c;
901 struct expression *exp = NULL;
902 struct cleanup *old_chain = NULL;
905 for (p = *line; isspace ((int) *p);)
908 /* symbol lookup etc. */
909 if (*p == '\0') /* empty line: just prompt for another line. */
912 if (*p == '#') /* comment line */
915 c = lookup_cmd (&p, cmdlist, "", -1, 1);
918 warning ("'%s' is not an action that I know, or is ambiguous.", p);
922 if (c->function.cfunc == collect_pseudocommand)
924 struct agent_expr *aexpr;
925 struct agent_reqs areqs;
928 { /* repeat over a comma-separated list */
929 QUIT; /* allow user to bail out with ^C */
930 while (isspace ((int) *p))
933 if (*p == '$') /* look for special pseudo-symbols */
935 if ((0 == strncasecmp ("reg", p + 1, 3)) ||
936 (0 == strncasecmp ("arg", p + 1, 3)) ||
937 (0 == strncasecmp ("loc", p + 1, 3)))
942 /* else fall thru, treat p as an expression and parse it! */
944 exp = parse_exp_1 (&p, block_for_pc (t->address), 1);
945 old_chain = make_cleanup (free_current_contents, &exp);
947 if (exp->elts[0].opcode == OP_VAR_VALUE)
949 if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
951 warning ("constant %s (value %ld) will not be collected.",
952 SYMBOL_NAME (exp->elts[2].symbol),
953 SYMBOL_VALUE (exp->elts[2].symbol));
956 else if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_OPTIMIZED_OUT)
958 warning ("%s is optimized away and cannot be collected.",
959 SYMBOL_NAME (exp->elts[2].symbol));
964 /* we have something to collect, make sure that the expr to
965 bytecode translator can handle it and that it's not too long */
966 aexpr = gen_trace_for_expr (t->address, exp);
967 make_cleanup_free_agent_expr (aexpr);
969 if (aexpr->len > MAX_AGENT_EXPR_LEN)
970 error ("expression too complicated, try simplifying");
972 ax_reqs (aexpr, &areqs);
973 (void) make_cleanup (free, areqs.reg_mask);
975 if (areqs.flaw != agent_flaw_none)
976 error ("malformed expression");
978 if (areqs.min_height < 0)
979 error ("gdb: Internal error: expression has min height < 0");
981 if (areqs.max_height > 20)
982 error ("expression too complicated, try simplifying");
984 do_cleanups (old_chain);
986 while (p && *p++ == ',');
989 else if (c->function.cfunc == while_stepping_pseudocommand)
991 char *steparg; /* in case warning is necessary */
993 while (isspace ((int) *p))
998 (t->step_count = strtol (p, &p, 0)) == 0)
1000 warning ("'%s': bad step-count; command ignored.", *line);
1005 else if (c->function.cfunc == end_actions_pseudocommand)
1009 warning ("'%s' is not a supported tracepoint action.", *line);
1014 /* worker function */
1016 free_actions (struct tracepoint *t)
1018 struct action_line *line, *next;
1020 for (line = t->actions; line; line = next)
1024 free (line->action);
1031 do_free_actions_cleanup (void *t)
1036 static struct cleanup *
1037 make_cleanup_free_actions (struct tracepoint *t)
1039 return make_cleanup (do_free_actions_cleanup, t);
1044 int type; /* 0 for absolute memory range, else basereg number */
1045 bfd_signed_vma start;
1049 struct collection_list
1051 unsigned char regs_mask[8]; /* room for up to 256 regs */
1054 struct memrange *list;
1055 long aexpr_listsize; /* size of array pointed to by expr_list elt */
1056 long next_aexpr_elt;
1057 struct agent_expr **aexpr_list;
1060 tracepoint_list, stepping_list;
1062 /* MEMRANGE functions: */
1064 static int memrange_cmp (const void *, const void *);
1066 /* compare memranges for qsort */
1068 memrange_cmp (const void *va, const void *vb)
1070 const struct memrange *a = va, *b = vb;
1072 if (a->type < b->type)
1074 if (a->type > b->type)
1078 if ((bfd_vma) a->start < (bfd_vma) b->start)
1080 if ((bfd_vma) a->start > (bfd_vma) b->start)
1085 if (a->start < b->start)
1087 if (a->start > b->start)
1093 /* Sort the memrange list using qsort, and merge adjacent memranges */
1095 memrange_sortmerge (struct collection_list *memranges)
1099 qsort (memranges->list, memranges->next_memrange,
1100 sizeof (struct memrange), memrange_cmp);
1101 if (memranges->next_memrange > 0)
1103 for (a = 0, b = 1; b < memranges->next_memrange; b++)
1105 if (memranges->list[a].type == memranges->list[b].type &&
1106 memranges->list[b].start - memranges->list[a].end <=
1107 MAX_REGISTER_VIRTUAL_SIZE)
1109 /* memrange b starts before memrange a ends; merge them. */
1110 if (memranges->list[b].end > memranges->list[a].end)
1111 memranges->list[a].end = memranges->list[b].end;
1112 continue; /* next b, same a */
1116 memcpy (&memranges->list[a], &memranges->list[b],
1117 sizeof (struct memrange));
1119 memranges->next_memrange = a + 1;
1123 /* Add a register to a collection list */
1125 add_register (struct collection_list *collection, unsigned int regno)
1128 printf_filtered ("collect register %d\n", regno);
1129 if (regno > (8 * sizeof (collection->regs_mask)))
1130 error ("Internal: register number %d too large for tracepoint",
1132 collection->regs_mask[regno / 8] |= 1 << (regno % 8);
1135 /* Add a memrange to a collection list */
1137 add_memrange (struct collection_list *memranges, int type, bfd_signed_vma base,
1142 printf_filtered ("(%d,", type);
1144 printf_filtered (",%ld)\n", len);
1147 /* type: 0 == memory, n == basereg */
1148 memranges->list[memranges->next_memrange].type = type;
1149 /* base: addr if memory, offset if reg relative. */
1150 memranges->list[memranges->next_memrange].start = base;
1151 /* len: we actually save end (base + len) for convenience */
1152 memranges->list[memranges->next_memrange].end = base + len;
1153 memranges->next_memrange++;
1154 if (memranges->next_memrange >= memranges->listsize)
1156 memranges->listsize *= 2;
1157 memranges->list = xrealloc (memranges->list,
1158 memranges->listsize);
1161 if (type != -1) /* better collect the base register! */
1162 add_register (memranges, type);
1165 /* Add a symbol to a collection list */
1167 collect_symbol (struct collection_list *collect, struct symbol *sym,
1168 long frame_regno, long frame_offset)
1172 bfd_signed_vma offset;
1174 len = TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym)));
1175 switch (SYMBOL_CLASS (sym))
1178 printf_filtered ("%s: don't know symbol class %d\n",
1179 SYMBOL_NAME (sym), SYMBOL_CLASS (sym));
1182 printf_filtered ("constant %s (value %ld) will not be collected.\n",
1183 SYMBOL_NAME (sym), SYMBOL_VALUE (sym));
1186 offset = SYMBOL_VALUE_ADDRESS (sym);
1191 sprintf_vma (tmp, offset);
1192 printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n",
1193 SYMBOL_NAME (sym), len, tmp /* address */);
1195 add_memrange (collect, -1, offset, len); /* 0 == memory */
1199 reg = SYMBOL_VALUE (sym);
1201 printf_filtered ("LOC_REG[parm] %s: ", SYMBOL_NAME (sym));
1202 add_register (collect, reg);
1203 /* check for doubles stored in two registers */
1204 /* FIXME: how about larger types stored in 3 or more regs? */
1205 if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT &&
1206 len > REGISTER_RAW_SIZE (reg))
1207 add_register (collect, reg + 1);
1210 printf_filtered ("Sorry, don't know how to do LOC_REF_ARG yet.\n");
1211 printf_filtered (" (will not collect %s)\n",
1216 offset = frame_offset + SYMBOL_VALUE (sym);
1219 printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
1220 SYMBOL_NAME (sym), len);
1221 printf_vma (offset);
1222 printf_filtered (" from frame ptr reg %d\n", reg);
1224 add_memrange (collect, reg, offset, len);
1226 case LOC_REGPARM_ADDR:
1227 reg = SYMBOL_VALUE (sym);
1231 printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset ",
1232 SYMBOL_NAME (sym), len);
1233 printf_vma (offset);
1234 printf_filtered (" from reg %d\n", reg);
1236 add_memrange (collect, reg, offset, len);
1241 offset = frame_offset + SYMBOL_VALUE (sym);
1244 printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
1245 SYMBOL_NAME (sym), len);
1246 printf_vma (offset);
1247 printf_filtered (" from frame ptr reg %d\n", reg);
1249 add_memrange (collect, reg, offset, len);
1252 case LOC_BASEREG_ARG:
1253 reg = SYMBOL_BASEREG (sym);
1254 offset = SYMBOL_VALUE (sym);
1257 printf_filtered ("LOC_BASEREG %s: collect %ld bytes at offset ",
1258 SYMBOL_NAME (sym), len);
1259 printf_vma (offset);
1260 printf_filtered (" from basereg %d\n", reg);
1262 add_memrange (collect, reg, offset, len);
1264 case LOC_UNRESOLVED:
1265 printf_filtered ("Don't know LOC_UNRESOLVED %s\n", SYMBOL_NAME (sym));
1267 case LOC_OPTIMIZED_OUT:
1268 printf_filtered ("%s has been optimized out of existance.\n",
1274 /* Add all locals (or args) symbols to collection list */
1276 add_local_symbols (struct collection_list *collect, CORE_ADDR pc,
1277 long frame_regno, long frame_offset, int type)
1280 struct block *block;
1281 int i, nsyms, count = 0;
1283 block = block_for_pc (pc);
1286 QUIT; /* allow user to bail out with ^C */
1287 nsyms = BLOCK_NSYMS (block);
1288 for (i = 0; i < nsyms; i++)
1290 sym = BLOCK_SYM (block, i);
1291 switch (SYMBOL_CLASS (sym))
1294 warning ("don't know how to trace local symbol %s",
1300 if (type == 'L') /* collecting Locals */
1303 collect_symbol (collect, sym, frame_regno, frame_offset);
1310 case LOC_REGPARM_ADDR:
1311 case LOC_BASEREG_ARG:
1312 if (type == 'A') /* collecting Arguments */
1315 collect_symbol (collect, sym, frame_regno, frame_offset);
1319 if (BLOCK_FUNCTION (block))
1322 block = BLOCK_SUPERBLOCK (block);
1325 warning ("No %s found in scope.", type == 'L' ? "locals" : "args");
1328 /* worker function */
1330 clear_collection_list (struct collection_list *list)
1334 list->next_memrange = 0;
1335 for (ndx = 0; ndx < list->next_aexpr_elt; ndx++)
1337 free_agent_expr (list->aexpr_list[ndx]);
1338 list->aexpr_list[ndx] = NULL;
1340 list->next_aexpr_elt = 0;
1341 memset (list->regs_mask, 0, sizeof (list->regs_mask));
1344 /* reduce a collection list to string form (for gdb protocol) */
1346 stringify_collection_list (struct collection_list *list, char *string)
1348 char temp_buf[2048];
1352 char *(*str_list)[];
1356 count = 1 + list->next_memrange + list->next_aexpr_elt + 1;
1357 str_list = (char *(*)[]) xmalloc (count * sizeof (char *));
1359 for (i = sizeof (list->regs_mask) - 1; i > 0; i--)
1360 if (list->regs_mask[i] != 0) /* skip leading zeroes in regs_mask */
1362 if (list->regs_mask[i] != 0) /* prepare to send regs_mask to the stub */
1365 printf_filtered ("\nCollecting registers (mask): 0x");
1370 QUIT; /* allow user to bail out with ^C */
1372 printf_filtered ("%02X", list->regs_mask[i]);
1373 sprintf (end, "%02X", list->regs_mask[i]);
1376 (*str_list)[ndx] = savestring (temp_buf, end - temp_buf);
1380 printf_filtered ("\n");
1381 if (list->next_memrange > 0 && info_verbose)
1382 printf_filtered ("Collecting memranges: \n");
1383 for (i = 0, count = 0, end = temp_buf; i < list->next_memrange; i++)
1385 QUIT; /* allow user to bail out with ^C */
1386 sprintf_vma (tmp2, list->list[i].start);
1389 printf_filtered ("(%d, %s, %ld)\n",
1392 (long) (list->list[i].end - list->list[i].start));
1394 if (count + 27 > MAX_AGENT_EXPR_LEN)
1396 (*str_list)[ndx] = savestring (temp_buf, count);
1402 sprintf (end, "M%X,%s,%lX",
1405 (long) (list->list[i].end - list->list[i].start));
1407 count += strlen (end);
1411 for (i = 0; i < list->next_aexpr_elt; i++)
1413 QUIT; /* allow user to bail out with ^C */
1414 if ((count + 10 + 2 * list->aexpr_list[i]->len) > MAX_AGENT_EXPR_LEN)
1416 (*str_list)[ndx] = savestring (temp_buf, count);
1421 sprintf (end, "X%08X,", list->aexpr_list[i]->len);
1422 end += 10; /* 'X' + 8 hex digits + ',' */
1425 end = mem2hex (list->aexpr_list[i]->buf, end, list->aexpr_list[i]->len);
1426 count += 2 * list->aexpr_list[i]->len;
1431 (*str_list)[ndx] = savestring (temp_buf, count);
1436 (*str_list)[ndx] = NULL;
1445 free_actions_list_cleanup_wrapper (void *al)
1447 free_actions_list (al);
1451 free_actions_list (char **actions_list)
1455 if (actions_list == 0)
1458 for (ndx = 0; actions_list[ndx]; ndx++)
1459 free (actions_list[ndx]);
1461 free (actions_list);
1464 /* render all actions into gdb protocol */
1466 encode_actions (struct tracepoint *t, char ***tdp_actions,
1467 char ***stepping_actions)
1469 static char tdp_buff[2048], step_buff[2048];
1471 struct expression *exp = NULL;
1472 struct action_line *action;
1475 struct collection_list *collect;
1476 struct cmd_list_element *cmd;
1477 struct agent_expr *aexpr;
1478 long frame_reg, frame_offset;
1481 clear_collection_list (&tracepoint_list);
1482 clear_collection_list (&stepping_list);
1483 collect = &tracepoint_list;
1485 *tdp_actions = NULL;
1486 *stepping_actions = NULL;
1488 TARGET_VIRTUAL_FRAME_POINTER (t->address, &frame_reg, &frame_offset);
1490 for (action = t->actions; action; action = action->next)
1492 QUIT; /* allow user to bail out with ^C */
1493 action_exp = action->action;
1494 while (isspace ((int) *action_exp))
1497 if (*action_exp == '#') /* comment line */
1500 cmd = lookup_cmd (&action_exp, cmdlist, "", -1, 1);
1502 error ("Bad action list item: %s", action_exp);
1504 if (cmd->function.cfunc == collect_pseudocommand)
1507 { /* repeat over a comma-separated list */
1508 QUIT; /* allow user to bail out with ^C */
1509 while (isspace ((int) *action_exp))
1512 if (0 == strncasecmp ("$reg", action_exp, 4))
1514 for (i = 0; i < NUM_REGS; i++)
1515 add_register (collect, i);
1516 action_exp = strchr (action_exp, ','); /* more? */
1518 else if (0 == strncasecmp ("$arg", action_exp, 4))
1520 add_local_symbols (collect,
1525 action_exp = strchr (action_exp, ','); /* more? */
1527 else if (0 == strncasecmp ("$loc", action_exp, 4))
1529 add_local_symbols (collect,
1534 action_exp = strchr (action_exp, ','); /* more? */
1538 unsigned long addr, len;
1539 struct cleanup *old_chain = NULL;
1540 struct cleanup *old_chain1 = NULL;
1541 struct agent_reqs areqs;
1543 exp = parse_exp_1 (&action_exp, block_for_pc (t->address), 1);
1544 old_chain = make_cleanup (free_current_contents, &exp);
1546 switch (exp->elts[0].opcode)
1549 i = exp->elts[1].longconst;
1551 printf_filtered ("OP_REGISTER: ");
1552 add_register (collect, i);
1556 /* safe because we know it's a simple expression */
1557 tempval = evaluate_expression (exp);
1558 addr = VALUE_ADDRESS (tempval) + VALUE_OFFSET (tempval);
1559 len = TYPE_LENGTH (check_typedef (exp->elts[1].type));
1560 add_memrange (collect, -1, addr, len);
1564 collect_symbol (collect,
1565 exp->elts[2].symbol,
1570 default: /* full-fledged expression */
1571 aexpr = gen_trace_for_expr (t->address, exp);
1573 old_chain1 = make_cleanup_free_agent_expr (aexpr);
1575 ax_reqs (aexpr, &areqs);
1576 if (areqs.flaw != agent_flaw_none)
1577 error ("malformed expression");
1579 if (areqs.min_height < 0)
1580 error ("gdb: Internal error: expression has min height < 0");
1581 if (areqs.max_height > 20)
1582 error ("expression too complicated, try simplifying");
1584 discard_cleanups (old_chain1);
1585 add_aexpr (collect, aexpr);
1587 /* take care of the registers */
1588 if (areqs.reg_mask_len > 0)
1593 for (ndx1 = 0; ndx1 < areqs.reg_mask_len; ndx1++)
1595 QUIT; /* allow user to bail out with ^C */
1596 if (areqs.reg_mask[ndx1] != 0)
1598 /* assume chars have 8 bits */
1599 for (ndx2 = 0; ndx2 < 8; ndx2++)
1600 if (areqs.reg_mask[ndx1] & (1 << ndx2))
1601 /* it's used -- record it */
1602 add_register (collect, ndx1 * 8 + ndx2);
1608 do_cleanups (old_chain);
1611 while (action_exp && *action_exp++ == ',');
1613 else if (cmd->function.cfunc == while_stepping_pseudocommand)
1615 collect = &stepping_list;
1617 else if (cmd->function.cfunc == end_actions_pseudocommand)
1619 if (collect == &stepping_list) /* end stepping actions */
1620 collect = &tracepoint_list;
1622 break; /* end tracepoint actions */
1625 memrange_sortmerge (&tracepoint_list);
1626 memrange_sortmerge (&stepping_list);
1628 *tdp_actions = stringify_collection_list (&tracepoint_list, tdp_buff);
1629 *stepping_actions = stringify_collection_list (&stepping_list, step_buff);
1633 add_aexpr (struct collection_list *collect, struct agent_expr *aexpr)
1635 if (collect->next_aexpr_elt >= collect->aexpr_listsize)
1637 collect->aexpr_list =
1638 xrealloc (collect->aexpr_list,
1639 2 * collect->aexpr_listsize * sizeof (struct agent_expr *));
1640 collect->aexpr_listsize *= 2;
1642 collect->aexpr_list[collect->next_aexpr_elt] = aexpr;
1643 collect->next_aexpr_elt++;
1646 static char target_buf[2048];
1648 /* Set "transparent" memory ranges
1650 Allow trace mechanism to treat text-like sections
1651 (and perhaps all read-only sections) transparently,
1652 i.e. don't reject memory requests from these address ranges
1653 just because they haven't been collected. */
1656 remote_set_transparent_ranges (void)
1658 extern bfd *exec_bfd;
1665 return; /* no information to give. */
1667 strcpy (target_buf, "QTro");
1668 for (s = exec_bfd->sections; s; s = s->next)
1670 char tmp1[40], tmp2[40];
1672 if ((s->flags & SEC_LOAD) == 0 ||
1673 /* (s->flags & SEC_CODE) == 0 || */
1674 (s->flags & SEC_READONLY) == 0)
1679 size = bfd_get_section_size_before_reloc (s);
1680 sprintf_vma (tmp1, lma);
1681 sprintf_vma (tmp2, lma + size);
1682 sprintf (target_buf + strlen (target_buf),
1683 ":%s,%s", tmp1, tmp2);
1687 putpkt (target_buf);
1688 getpkt (target_buf, sizeof (target_buf), 0);
1694 Tell target to clear any previous trace experiment.
1695 Walk the list of tracepoints, and send them (and their actions)
1696 to the target. If no errors,
1697 Tell target to start a new trace experiment. */
1700 trace_start_command (char *args, int from_tty)
1701 { /* STUB_COMM MOSTLY_IMPLEMENTED */
1702 struct tracepoint *t;
1705 char **stepping_actions;
1707 struct cleanup *old_chain = NULL;
1709 dont_repeat (); /* like "run", dangerous to repeat accidentally */
1711 if (target_is_remote ())
1714 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1715 if (strcmp (target_buf, "OK"))
1716 error ("Target does not support this command.");
1722 sprintf_vma (tmp, t->address);
1723 sprintf (buf, "QTDP:%x:%s:%c:%lx:%x", t->number, tmp, /* address */
1724 t->enabled == enabled ? 'E' : 'D',
1725 t->step_count, t->pass_count);
1730 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1731 if (strcmp (target_buf, "OK"))
1732 error ("Target does not support tracepoints.");
1736 encode_actions (t, &tdp_actions, &stepping_actions);
1737 old_chain = make_cleanup (free_actions_list_cleanup_wrapper,
1739 (void) make_cleanup (free_actions_list_cleanup_wrapper,
1742 /* do_single_steps (t); */
1745 for (ndx = 0; tdp_actions[ndx]; ndx++)
1747 QUIT; /* allow user to bail out with ^C */
1748 sprintf (buf, "QTDP:-%x:%s:%s%c",
1749 t->number, tmp, /* address */
1751 ((tdp_actions[ndx + 1] || stepping_actions)
1754 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1755 if (strcmp (target_buf, "OK"))
1756 error ("Error on target while setting tracepoints.");
1759 if (stepping_actions)
1761 for (ndx = 0; stepping_actions[ndx]; ndx++)
1763 QUIT; /* allow user to bail out with ^C */
1764 sprintf (buf, "QTDP:-%x:%s:%s%s%s",
1765 t->number, tmp, /* address */
1766 ((ndx == 0) ? "S" : ""),
1767 stepping_actions[ndx],
1768 (stepping_actions[ndx + 1] ? "-" : ""));
1770 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1771 if (strcmp (target_buf, "OK"))
1772 error ("Error on target while setting tracepoints.");
1776 do_cleanups (old_chain);
1779 /* Tell target to treat text-like sections as transparent */
1780 remote_set_transparent_ranges ();
1781 /* Now insert traps and begin collecting data */
1783 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1784 if (strcmp (target_buf, "OK"))
1785 error ("Bogus reply from target: %s", target_buf);
1786 set_traceframe_num (-1); /* all old traceframes invalidated */
1787 set_tracepoint_num (-1);
1788 set_traceframe_context (-1);
1789 trace_running_p = 1;
1790 if (trace_start_stop_hook)
1791 trace_start_stop_hook (1, from_tty);
1795 error ("Trace can only be run on remote targets.");
1800 trace_stop_command (char *args, int from_tty)
1801 { /* STUB_COMM IS_IMPLEMENTED */
1802 if (target_is_remote ())
1805 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1806 if (strcmp (target_buf, "OK"))
1807 error ("Bogus reply from target: %s", target_buf);
1808 trace_running_p = 0;
1809 if (trace_start_stop_hook)
1810 trace_start_stop_hook (0, from_tty);
1813 error ("Trace can only be run on remote targets.");
1816 unsigned long trace_running_p;
1818 /* tstatus command */
1820 trace_status_command (char *args, int from_tty)
1821 { /* STUB_COMM IS_IMPLEMENTED */
1822 if (target_is_remote ())
1824 putpkt ("qTStatus");
1825 remote_get_noisy_reply (target_buf, sizeof (target_buf));
1827 if (target_buf[0] != 'T' ||
1828 (target_buf[1] != '0' && target_buf[1] != '1'))
1829 error ("Bogus reply from target: %s", target_buf);
1831 /* exported for use by the GUI */
1832 trace_running_p = (target_buf[1] == '1');
1835 error ("Trace can only be run on remote targets.");
1838 /* Worker function for the various flavors of the tfind command */
1840 finish_tfind_command (char *msg,
1844 int target_frameno = -1, target_tracept = -1;
1845 CORE_ADDR old_frame_addr;
1846 struct symbol *old_func;
1849 old_frame_addr = FRAME_FP (get_current_frame ());
1850 old_func = find_pc_function (read_pc ());
1853 reply = remote_get_noisy_reply (msg, sizeof_msg);
1855 while (reply && *reply)
1859 if ((target_frameno = (int) strtol (++reply, &reply, 16)) == -1)
1861 /* A request for a non-existant trace frame has failed.
1862 Our response will be different, depending on FROM_TTY:
1864 If FROM_TTY is true, meaning that this command was
1865 typed interactively by the user, then give an error
1866 and DO NOT change the state of traceframe_number etc.
1868 However if FROM_TTY is false, meaning that we're either
1869 in a script, a loop, or a user-defined command, then
1870 DON'T give an error, but DO change the state of
1871 traceframe_number etc. to invalid.
1873 The rationalle is that if you typed the command, you
1874 might just have committed a typo or something, and you'd
1875 like to NOT lose your current debugging state. However
1876 if you're in a user-defined command or especially in a
1877 loop, then you need a way to detect that the command
1878 failed WITHOUT aborting. This allows you to write
1879 scripts that search thru the trace buffer until the end,
1880 and then continue on to do something else. */
1883 error ("Target failed to find requested trace frame.");
1887 printf_filtered ("End of trace buffer.\n");
1888 /* The following will not recurse, since it's special-cased */
1889 trace_find_command ("-1", from_tty);
1890 reply = NULL; /* break out of loop,
1891 (avoid recursive nonsense) */
1896 if ((target_tracept = (int) strtol (++reply, &reply, 16)) == -1)
1897 error ("Target failed to find requested trace frame.");
1899 case 'O': /* "OK"? */
1900 if (reply[1] == 'K' && reply[2] == '\0')
1903 error ("Bogus reply from target: %s", reply);
1906 error ("Bogus reply from target: %s", reply);
1909 flush_cached_frames ();
1910 registers_changed ();
1911 select_frame (get_current_frame (), 0);
1912 set_traceframe_num (target_frameno);
1913 set_tracepoint_num (target_tracept);
1914 if (target_frameno == -1)
1915 set_traceframe_context (-1);
1917 set_traceframe_context (read_pc ());
1923 /* NOTE: in immitation of the step command, try to determine
1924 whether we have made a transition from one function to another.
1925 If so, we'll print the "stack frame" (ie. the new function and
1926 it's arguments) -- otherwise we'll just show the new source line.
1928 This determination is made by checking (1) whether the current
1929 function has changed, and (2) whether the current FP has changed.
1930 Hack: if the FP wasn't collected, either at the current or the
1931 previous frame, assume that the FP has NOT changed. */
1933 if (old_func == find_pc_function (read_pc ()) &&
1934 (old_frame_addr == 0 ||
1935 FRAME_FP (get_current_frame ()) == 0 ||
1936 old_frame_addr == FRAME_FP (get_current_frame ())))
1941 print_stack_frame (selected_frame, selected_frame_level, source_only);
1946 /* trace_find_command takes a trace frame number n,
1947 sends "QTFrame:<n>" to the target,
1948 and accepts a reply that may contain several optional pieces
1949 of information: a frame number, a tracepoint number, and an
1950 indication of whether this is a trap frame or a stepping frame.
1952 The minimal response is just "OK" (which indicates that the
1953 target does not give us a frame number or a tracepoint number).
1954 Instead of that, the target may send us a string containing
1956 F<hexnum> (gives the selected frame number)
1957 T<hexnum> (gives the selected tracepoint number)
1962 trace_find_command (char *args, int from_tty)
1963 { /* STUB_COMM PART_IMPLEMENTED */
1964 /* this should only be called with a numeric argument */
1967 if (target_is_remote ())
1969 if (trace_find_hook)
1970 trace_find_hook (args, from_tty);
1972 if (args == 0 || *args == 0)
1973 { /* TFIND with no args means find NEXT trace frame. */
1974 if (traceframe_number == -1)
1975 frameno = 0; /* "next" is first one */
1977 frameno = traceframe_number + 1;
1979 else if (0 == strcmp (args, "-"))
1981 if (traceframe_number == -1)
1982 error ("not debugging trace buffer");
1983 else if (from_tty && traceframe_number == 0)
1984 error ("already at start of trace buffer");
1986 frameno = traceframe_number - 1;
1989 frameno = parse_and_eval_address (args);
1992 error ("invalid input (%d is less than zero)", frameno);
1994 sprintf (target_buf, "QTFrame:%x", frameno);
1995 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
1998 error ("Trace can only be run on remote targets.");
2003 trace_find_end_command (char *args, int from_tty)
2005 trace_find_command ("-1", from_tty);
2010 trace_find_none_command (char *args, int from_tty)
2012 trace_find_command ("-1", from_tty);
2017 trace_find_start_command (char *args, int from_tty)
2019 trace_find_command ("0", from_tty);
2022 /* tfind pc command */
2024 trace_find_pc_command (char *args, int from_tty)
2025 { /* STUB_COMM PART_IMPLEMENTED */
2029 if (target_is_remote ())
2031 if (args == 0 || *args == 0)
2032 pc = read_pc (); /* default is current pc */
2034 pc = parse_and_eval_address (args);
2036 sprintf_vma (tmp, pc);
2037 sprintf (target_buf, "QTFrame:pc:%s", tmp);
2038 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2041 error ("Trace can only be run on remote targets.");
2044 /* tfind tracepoint command */
2046 trace_find_tracepoint_command (char *args, int from_tty)
2047 { /* STUB_COMM PART_IMPLEMENTED */
2050 if (target_is_remote ())
2052 if (args == 0 || *args == 0)
2053 if (tracepoint_number == -1)
2054 error ("No current tracepoint -- please supply an argument.");
2056 tdp = tracepoint_number; /* default is current TDP */
2058 tdp = parse_and_eval_address (args);
2060 sprintf (target_buf, "QTFrame:tdp:%x", tdp);
2061 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2064 error ("Trace can only be run on remote targets.");
2067 /* TFIND LINE command:
2069 This command will take a sourceline for argument, just like BREAK
2070 or TRACE (ie. anything that "decode_line_1" can handle).
2072 With no argument, this command will find the next trace frame
2073 corresponding to a source line OTHER THAN THE CURRENT ONE. */
2076 trace_find_line_command (char *args, int from_tty)
2077 { /* STUB_COMM PART_IMPLEMENTED */
2078 static CORE_ADDR start_pc, end_pc;
2079 struct symtabs_and_lines sals;
2080 struct symtab_and_line sal;
2081 struct cleanup *old_chain;
2082 char startpc_str[40], endpc_str[40];
2084 if (target_is_remote ())
2086 if (args == 0 || *args == 0)
2088 sal = find_pc_line ((get_current_frame ())->pc, 0);
2090 sals.sals = (struct symtab_and_line *)
2091 xmalloc (sizeof (struct symtab_and_line));
2096 sals = decode_line_spec (args, 1);
2100 old_chain = make_cleanup (free, sals.sals);
2101 if (sal.symtab == 0)
2103 printf_filtered ("TFIND: No line number information available");
2106 /* This is useful for "info line *0x7f34". If we can't tell the
2107 user about a source line, at least let them have the symbolic
2109 printf_filtered (" for address ");
2111 print_address (sal.pc, gdb_stdout);
2112 printf_filtered (";\n -- will attempt to find by PC. \n");
2116 printf_filtered (".\n");
2117 return; /* no line, no PC; what can we do? */
2120 else if (sal.line > 0
2121 && find_line_pc_range (sal, &start_pc, &end_pc))
2123 if (start_pc == end_pc)
2125 printf_filtered ("Line %d of \"%s\"",
2126 sal.line, sal.symtab->filename);
2128 printf_filtered (" is at address ");
2129 print_address (start_pc, gdb_stdout);
2131 printf_filtered (" but contains no code.\n");
2132 sal = find_pc_line (start_pc, 0);
2134 find_line_pc_range (sal, &start_pc, &end_pc) &&
2136 printf_filtered ("Attempting to find line %d instead.\n",
2139 error ("Cannot find a good line.");
2143 /* Is there any case in which we get here, and have an address
2144 which the user would want to see? If we have debugging symbols
2145 and no line numbers? */
2146 error ("Line number %d is out of range for \"%s\".\n",
2147 sal.line, sal.symtab->filename);
2149 sprintf_vma (startpc_str, start_pc);
2150 sprintf_vma (endpc_str, end_pc - 1);
2151 if (args && *args) /* find within range of stated line */
2152 sprintf (target_buf, "QTFrame:range:%s:%s", startpc_str, endpc_str);
2153 else /* find OUTSIDE OF range of CURRENT line */
2154 sprintf (target_buf, "QTFrame:outside:%s:%s", startpc_str, endpc_str);
2155 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2156 do_cleanups (old_chain);
2159 error ("Trace can only be run on remote targets.");
2162 /* tfind range command */
2164 trace_find_range_command (char *args, int from_tty)
2166 static CORE_ADDR start, stop;
2167 char start_str[40], stop_str[40];
2170 if (target_is_remote ())
2172 if (args == 0 || *args == 0)
2173 { /* XXX FIXME: what should default behavior be? */
2174 printf_filtered ("Usage: tfind range <startaddr>,<endaddr>\n");
2178 if (0 != (tmp = strchr (args, ',')))
2180 *tmp++ = '\0'; /* terminate start address */
2181 while (isspace ((int) *tmp))
2183 start = parse_and_eval_address (args);
2184 stop = parse_and_eval_address (tmp);
2187 { /* no explicit end address? */
2188 start = parse_and_eval_address (args);
2189 stop = start + 1; /* ??? */
2192 sprintf_vma (start_str, start);
2193 sprintf_vma (stop_str, stop);
2194 sprintf (target_buf, "QTFrame:range:%s:%s", start_str, stop_str);
2195 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2198 error ("Trace can only be run on remote targets.");
2201 /* tfind outside command */
2203 trace_find_outside_command (char *args, int from_tty)
2205 CORE_ADDR start, stop;
2206 char start_str[40], stop_str[40];
2209 if (target_is_remote ())
2211 if (args == 0 || *args == 0)
2212 { /* XXX FIXME: what should default behavior be? */
2213 printf_filtered ("Usage: tfind outside <startaddr>,<endaddr>\n");
2217 if (0 != (tmp = strchr (args, ',')))
2219 *tmp++ = '\0'; /* terminate start address */
2220 while (isspace ((int) *tmp))
2222 start = parse_and_eval_address (args);
2223 stop = parse_and_eval_address (tmp);
2226 { /* no explicit end address? */
2227 start = parse_and_eval_address (args);
2228 stop = start + 1; /* ??? */
2231 sprintf_vma (start_str, start);
2232 sprintf_vma (stop_str, stop);
2233 sprintf (target_buf, "QTFrame:outside:%s:%s", start_str, stop_str);
2234 finish_tfind_command (target_buf, sizeof (target_buf), from_tty);
2237 error ("Trace can only be run on remote targets.");
2240 /* save-tracepoints command */
2242 tracepoint_save_command (char *args, int from_tty)
2244 struct tracepoint *tp;
2245 struct action_line *line;
2247 char *i1 = " ", *i2 = " ";
2248 char *indent, *actionline;
2251 if (args == 0 || *args == 0)
2252 error ("Argument required (file name in which to save tracepoints");
2254 if (tracepoint_chain == 0)
2256 warning ("save-tracepoints: no tracepoints to save.\n");
2260 if (!(fp = fopen (args, "w")))
2261 error ("Unable to open file '%s' for saving tracepoints");
2263 ALL_TRACEPOINTS (tp)
2265 if (tp->addr_string)
2266 fprintf (fp, "trace %s\n", tp->addr_string);
2269 sprintf_vma (tmp, tp->address);
2270 fprintf (fp, "trace *0x%s\n", tmp);
2274 fprintf (fp, " passcount %d\n", tp->pass_count);
2278 fprintf (fp, " actions\n");
2280 for (line = tp->actions; line; line = line->next)
2282 struct cmd_list_element *cmd;
2284 QUIT; /* allow user to bail out with ^C */
2285 actionline = line->action;
2286 while (isspace ((int) *actionline))
2289 fprintf (fp, "%s%s\n", indent, actionline);
2290 if (*actionline != '#') /* skip for comment lines */
2292 cmd = lookup_cmd (&actionline, cmdlist, "", -1, 1);
2294 error ("Bad action list item: %s", actionline);
2295 if (cmd->function.cfunc == while_stepping_pseudocommand)
2297 else if (cmd->function.cfunc == end_actions_pseudocommand)
2305 printf_filtered ("Tracepoints saved to file '%s'.\n", args);
2309 /* info scope command: list the locals for a scope. */
2311 scope_info (char *args, int from_tty)
2313 struct symtabs_and_lines sals;
2315 struct minimal_symbol *msym;
2316 struct block *block;
2317 char **canonical, *symname, *save_args = args;
2318 int i, j, nsyms, count = 0;
2320 if (args == 0 || *args == 0)
2321 error ("requires an argument (function, line or *addr) to define a scope");
2323 sals = decode_line_1 (&args, 1, NULL, 0, &canonical);
2324 if (sals.nelts == 0)
2325 return; /* presumably decode_line_1 has already warned */
2327 /* Resolve line numbers to PC */
2328 resolve_sal_pc (&sals.sals[0]);
2329 block = block_for_pc (sals.sals[0].pc);
2333 QUIT; /* allow user to bail out with ^C */
2334 nsyms = BLOCK_NSYMS (block);
2335 for (i = 0; i < nsyms; i++)
2337 QUIT; /* allow user to bail out with ^C */
2339 printf_filtered ("Scope for %s:\n", save_args);
2341 sym = BLOCK_SYM (block, i);
2342 symname = SYMBOL_NAME (sym);
2343 if (symname == NULL || *symname == '\0')
2344 continue; /* probably botched, certainly useless */
2346 printf_filtered ("Symbol %s is ", symname);
2347 switch (SYMBOL_CLASS (sym))
2350 case LOC_UNDEF: /* messed up symbol? */
2351 printf_filtered ("a bogus symbol, class %d.\n",
2352 SYMBOL_CLASS (sym));
2353 count--; /* don't count this one */
2356 printf_filtered ("a constant with value %ld (0x%lx)",
2357 SYMBOL_VALUE (sym), SYMBOL_VALUE (sym));
2359 case LOC_CONST_BYTES:
2360 printf_filtered ("constant bytes: ");
2361 if (SYMBOL_TYPE (sym))
2362 for (j = 0; j < TYPE_LENGTH (SYMBOL_TYPE (sym)); j++)
2363 fprintf_filtered (gdb_stdout, " %02x",
2364 (unsigned) SYMBOL_VALUE_BYTES (sym)[j]);
2367 printf_filtered ("in static storage at address ");
2368 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
2371 printf_filtered ("a local variable in register $%s",
2372 REGISTER_NAME (SYMBOL_VALUE (sym)));
2376 printf_filtered ("an argument at stack/frame offset %ld",
2377 SYMBOL_VALUE (sym));
2380 printf_filtered ("a local variable at frame offset %ld",
2381 SYMBOL_VALUE (sym));
2384 printf_filtered ("a reference argument at offset %ld",
2385 SYMBOL_VALUE (sym));
2388 printf_filtered ("an argument in register $%s",
2389 REGISTER_NAME (SYMBOL_VALUE (sym)));
2391 case LOC_REGPARM_ADDR:
2392 printf_filtered ("the address of an argument, in register $%s",
2393 REGISTER_NAME (SYMBOL_VALUE (sym)));
2396 printf_filtered ("a typedef.\n");
2399 printf_filtered ("a label at address ");
2400 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, gdb_stdout);
2403 printf_filtered ("a function at address ");
2404 print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), 1,
2408 printf_filtered ("a variable at offset %ld from register $%s",
2410 REGISTER_NAME (SYMBOL_BASEREG (sym)));
2412 case LOC_BASEREG_ARG:
2413 printf_filtered ("an argument at offset %ld from register $%s",
2415 REGISTER_NAME (SYMBOL_BASEREG (sym)));
2417 case LOC_UNRESOLVED:
2418 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, NULL);
2420 printf_filtered ("Unresolved Static");
2423 printf_filtered ("static storage at address ");
2424 print_address_numeric (SYMBOL_VALUE_ADDRESS (msym), 1,
2428 case LOC_OPTIMIZED_OUT:
2429 printf_filtered ("optimized out.\n");
2432 if (SYMBOL_TYPE (sym))
2433 printf_filtered (", length %d.\n",
2434 TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym))));
2436 if (BLOCK_FUNCTION (block))
2439 block = BLOCK_SUPERBLOCK (block);
2442 printf_filtered ("Scope for %s contains no locals or arguments.\n",
2446 /* worker function (cleanup) */
2448 replace_comma (void *data)
2456 trace_dump_command (char *args, int from_tty)
2458 struct tracepoint *t;
2459 struct action_line *action;
2460 char *action_exp, *next_comma;
2461 struct cleanup *old_cleanups;
2462 int stepping_actions = 0;
2463 int stepping_frame = 0;
2465 if (!target_is_remote ())
2467 error ("Trace can only be run on remote targets.");
2471 if (tracepoint_number == -1)
2473 warning ("No current trace frame.");
2478 if (t->number == tracepoint_number)
2482 error ("No known tracepoint matches 'current' tracepoint #%d.",
2485 old_cleanups = make_cleanup (null_cleanup, NULL);
2487 printf_filtered ("Data collected at tracepoint %d, trace frame %d:\n",
2488 tracepoint_number, traceframe_number);
2490 /* The current frame is a trap frame if the frame PC is equal
2491 to the tracepoint PC. If not, then the current frame was
2492 collected during single-stepping. */
2494 stepping_frame = (t->address != read_pc ());
2496 for (action = t->actions; action; action = action->next)
2498 struct cmd_list_element *cmd;
2500 QUIT; /* allow user to bail out with ^C */
2501 action_exp = action->action;
2502 while (isspace ((int) *action_exp))
2505 /* The collection actions to be done while stepping are
2506 bracketed by the commands "while-stepping" and "end". */
2508 if (*action_exp == '#') /* comment line */
2511 cmd = lookup_cmd (&action_exp, cmdlist, "", -1, 1);
2513 error ("Bad action list item: %s", action_exp);
2515 if (cmd->function.cfunc == while_stepping_pseudocommand)
2516 stepping_actions = 1;
2517 else if (cmd->function.cfunc == end_actions_pseudocommand)
2518 stepping_actions = 0;
2519 else if (cmd->function.cfunc == collect_pseudocommand)
2521 /* Display the collected data.
2522 For the trap frame, display only what was collected at the trap.
2523 Likewise for stepping frames, display only what was collected
2524 while stepping. This means that the two boolean variables,
2525 STEPPING_FRAME and STEPPING_ACTIONS should be equal. */
2526 if (stepping_frame == stepping_actions)
2529 { /* repeat over a comma-separated list */
2530 QUIT; /* allow user to bail out with ^C */
2531 if (*action_exp == ',')
2533 while (isspace ((int) *action_exp))
2536 next_comma = strchr (action_exp, ',');
2538 if (0 == strncasecmp (action_exp, "$reg", 4))
2539 registers_info (NULL, from_tty);
2540 else if (0 == strncasecmp (action_exp, "$loc", 4))
2541 locals_info (NULL, from_tty);
2542 else if (0 == strncasecmp (action_exp, "$arg", 4))
2543 args_info (NULL, from_tty);
2548 make_cleanup (replace_comma, next_comma);
2551 printf_filtered ("%s = ", action_exp);
2552 output_command (action_exp, from_tty);
2553 printf_filtered ("\n");
2557 action_exp = next_comma;
2559 while (action_exp && *action_exp == ',');
2563 discard_cleanups (old_cleanups);
2566 /* Convert the memory pointed to by mem into hex, placing result in buf.
2567 * Return a pointer to the last char put in buf (null)
2568 * "stolen" from sparc-stub.c
2571 static const char hexchars[] = "0123456789abcdef";
2573 static unsigned char *
2574 mem2hex (unsigned char *mem, unsigned char *buf, int count)
2582 *buf++ = hexchars[ch >> 4];
2583 *buf++ = hexchars[ch & 0xf];
2592 get_traceframe_number (void)
2594 return traceframe_number;
2598 /* module initialization */
2600 _initialize_tracepoint (void)
2602 tracepoint_chain = 0;
2603 tracepoint_count = 0;
2604 traceframe_number = -1;
2605 tracepoint_number = -1;
2607 set_internalvar (lookup_internalvar ("tpnum"),
2608 value_from_longest (builtin_type_int, (LONGEST) 0));
2609 set_internalvar (lookup_internalvar ("trace_frame"),
2610 value_from_longest (builtin_type_int, (LONGEST) - 1));
2612 if (tracepoint_list.list == NULL)
2614 tracepoint_list.listsize = 128;
2615 tracepoint_list.list = xmalloc
2616 (tracepoint_list.listsize * sizeof (struct memrange));
2618 if (tracepoint_list.aexpr_list == NULL)
2620 tracepoint_list.aexpr_listsize = 128;
2621 tracepoint_list.aexpr_list = xmalloc
2622 (tracepoint_list.aexpr_listsize * sizeof (struct agent_expr *));
2625 if (stepping_list.list == NULL)
2627 stepping_list.listsize = 128;
2628 stepping_list.list = xmalloc
2629 (stepping_list.listsize * sizeof (struct memrange));
2632 if (stepping_list.aexpr_list == NULL)
2634 stepping_list.aexpr_listsize = 128;
2635 stepping_list.aexpr_list = xmalloc
2636 (stepping_list.aexpr_listsize * sizeof (struct agent_expr *));
2639 add_info ("scope", scope_info,
2640 "List the variables local to a scope");
2642 add_cmd ("tracepoints", class_trace, NO_FUNCTION,
2643 "Tracing of program execution without stopping the program.",
2646 add_info ("tracepoints", tracepoints_info,
2647 "Status of tracepoints, or tracepoint number NUMBER.\n\
2648 Convenience variable \"$tpnum\" contains the number of the\n\
2649 last tracepoint set.");
2651 add_info_alias ("tp", "tracepoints", 1);
2653 add_com ("save-tracepoints", class_trace, tracepoint_save_command,
2654 "Save current tracepoint definitions as a script.\n\
2655 Use the 'source' command in another debug session to restore them.");
2657 add_com ("tdump", class_trace, trace_dump_command,
2658 "Print everything collected at the current tracepoint.");
2660 add_prefix_cmd ("tfind", class_trace, trace_find_command,
2661 "Select a trace frame;\n\
2662 No argument means forward by one frame; '-' meand backward by one frame.",
2663 &tfindlist, "tfind ", 1, &cmdlist);
2665 add_cmd ("outside", class_trace, trace_find_outside_command,
2666 "Select a trace frame whose PC is outside the given \
2667 range.\nUsage: tfind outside addr1, addr2",
2670 add_cmd ("range", class_trace, trace_find_range_command,
2671 "Select a trace frame whose PC is in the given range.\n\
2672 Usage: tfind range addr1,addr2",
2675 add_cmd ("line", class_trace, trace_find_line_command,
2676 "Select a trace frame by source line.\n\
2677 Argument can be a line number (with optional source file), \n\
2678 a function name, or '*' followed by an address.\n\
2679 Default argument is 'the next source line that was traced'.",
2682 add_cmd ("tracepoint", class_trace, trace_find_tracepoint_command,
2683 "Select a trace frame by tracepoint number.\n\
2684 Default is the tracepoint for the current trace frame.",
2687 add_cmd ("pc", class_trace, trace_find_pc_command,
2688 "Select a trace frame by PC.\n\
2689 Default is the current PC, or the PC of the current trace frame.",
2692 add_cmd ("end", class_trace, trace_find_end_command,
2693 "Synonym for 'none'.\n\
2694 De-select any trace frame and resume 'live' debugging.",
2697 add_cmd ("none", class_trace, trace_find_none_command,
2698 "De-select any trace frame and resume 'live' debugging.",
2701 add_cmd ("start", class_trace, trace_find_start_command,
2702 "Select the first trace frame in the trace buffer.",
2705 add_com ("tstatus", class_trace, trace_status_command,
2706 "Display the status of the current trace data collection.");
2708 add_com ("tstop", class_trace, trace_stop_command,
2709 "Stop trace data collection.");
2711 add_com ("tstart", class_trace, trace_start_command,
2712 "Start trace data collection.");
2714 add_com ("passcount", class_trace, trace_pass_command,
2715 "Set the passcount for a tracepoint.\n\
2716 The trace will end when the tracepoint has been passed 'count' times.\n\
2717 Usage: passcount COUNT TPNUM, where TPNUM may also be \"all\";\n\
2718 if TPNUM is omitted, passcount refers to the last tracepoint defined.");
2720 add_com ("end", class_trace, end_actions_pseudocommand,
2721 "Ends a list of commands or actions.\n\
2722 Several GDB commands allow you to enter a list of commands or actions.\n\
2723 Entering \"end\" on a line by itself is the normal way to terminate\n\
2725 Note: the \"end\" command cannot be used at the gdb prompt.");
2727 add_com ("while-stepping", class_trace, while_stepping_pseudocommand,
2728 "Specify single-stepping behavior at a tracepoint.\n\
2729 Argument is number of instructions to trace in single-step mode\n\
2730 following the tracepoint. This command is normally followed by\n\
2731 one or more \"collect\" commands, to specify what to collect\n\
2732 while single-stepping.\n\n\
2733 Note: this command can only be used in a tracepoint \"actions\" list.");
2735 add_com_alias ("ws", "while-stepping", class_alias, 0);
2736 add_com_alias ("stepping", "while-stepping", class_alias, 0);
2738 add_com ("collect", class_trace, collect_pseudocommand,
2739 "Specify one or more data items to be collected at a tracepoint.\n\
2740 Accepts a comma-separated list of (one or more) expressions. GDB will\n\
2741 collect all data (variables, registers) referenced by that expression.\n\
2742 Also accepts the following special arguments:\n\
2743 $regs -- all registers.\n\
2744 $args -- all function arguments.\n\
2745 $locals -- all variables local to the block/function scope.\n\
2746 Note: this command can only be used in a tracepoint \"actions\" list.");
2748 add_com ("actions", class_trace, trace_actions_command,
2749 "Specify the actions to be taken at a tracepoint.\n\
2750 Tracepoint actions may include collecting of specified data, \n\
2751 single-stepping, or enabling/disabling other tracepoints, \n\
2752 depending on target's capabilities.");
2754 add_cmd ("tracepoints", class_trace, delete_trace_command,
2755 "Delete specified tracepoints.\n\
2756 Arguments are tracepoint numbers, separated by spaces.\n\
2757 No argument means delete all tracepoints.",
2760 add_cmd ("tracepoints", class_trace, disable_trace_command,
2761 "Disable specified tracepoints.\n\
2762 Arguments are tracepoint numbers, separated by spaces.\n\
2763 No argument means disable all tracepoints.",
2766 add_cmd ("tracepoints", class_trace, enable_trace_command,
2767 "Enable specified tracepoints.\n\
2768 Arguments are tracepoint numbers, separated by spaces.\n\
2769 No argument means enable all tracepoints.",
2772 add_com ("trace", class_trace, trace_command,
2773 "Set a tracepoint at a specified line or function or address.\n\
2774 Argument may be a line number, function name, or '*' plus an address.\n\
2775 For a line number or function, trace at the start of its code.\n\
2776 If an address is specified, trace at that exact address.\n\n\
2777 Do \"help tracepoints\" for info on other tracepoint commands.");
2779 add_com_alias ("tp", "trace", class_alias, 0);
2780 add_com_alias ("tr", "trace", class_alias, 1);
2781 add_com_alias ("tra", "trace", class_alias, 1);
2782 add_com_alias ("trac", "trace", class_alias, 1);