GDB (xrefs)

/tmp/gdb-8.1/gdb/tracepoint.c
Go to the documentation of this file.
1 /* Tracing functionality for remote targets in custom GDB protocol
2
3 Copyright (C) 1997-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "arch-utils.h"
22 #include "symtab.h"
23 #include "frame.h"
24 #include "gdbtypes.h"
25 #include "expression.h"
26 #include "gdbcmd.h"
27 #include "value.h"
28 #include "target.h"
29 #include "target-dcache.h"
30 #include "language.h"
31 #include "inferior.h"
32 #include "breakpoint.h"
33 #include "tracepoint.h"
34 #include "linespec.h"
35 #include "regcache.h"
36 #include "completer.h"
37 #include "block.h"
38 #include "dictionary.h"
39 #include "observer.h"
40 #include "user-regs.h"
41 #include "valprint.h"
42 #include "gdbcore.h"
43 #include "objfiles.h"
44 #include "filenames.h"
45 #include "gdbthread.h"
46 #include "stack.h"
47 #include "remote.h"
48 #include "source.h"
49 #include "ax.h"
50 #include "ax-gdb.h"
51 #include "memrange.h"
52 #include "cli/cli-utils.h"
53 #include "probe.h"
54 #include "ctf.h"
55 #include "filestuff.h"
56 #include "rsp-low.h"
57 #include "tracefile.h"
58 #include "location.h"
59 #include <algorithm>
60
61 /* readline include files */
62 #include "readline/readline.h"
63 #include "readline/history.h"
64
65 /* readline defines this. */
66 #undef savestring
67
68 #include <unistd.h>
69
70 /* Maximum length of an agent aexpression.
71 This accounts for the fact that packets are limited to 400 bytes
72 (which includes everything -- including the checksum), and assumes
73 the worst case of maximum length for each of the pieces of a
74 continuation packet.
75
76 NOTE: expressions get mem2hex'ed otherwise this would be twice as
77 large. (400 - 31)/2 == 184 */
78 #define MAX_AGENT_EXPR_LEN 184
79
80 /* A hook used to notify the UI of tracepoint operations. */
81
82 void (*deprecated_trace_find_hook) (char *arg, int from_tty);
83 void (*deprecated_trace_start_stop_hook) (int start, int from_tty);
84
85 /*
86 Tracepoint.c:
87
88 This module defines the following debugger commands:
89 trace : set a tracepoint on a function, line, or address.
90 info trace : list all debugger-defined tracepoints.
91 delete trace : delete one or more tracepoints.
92 enable trace : enable one or more tracepoints.
93 disable trace : disable one or more tracepoints.
94 actions : specify actions to be taken at a tracepoint.
95 passcount : specify a pass count for a tracepoint.
96 tstart : start a trace experiment.
97 tstop : stop a trace experiment.
98 tstatus : query the status of a trace experiment.
99 tfind : find a trace frame in the trace buffer.
100 tdump : print everything collected at the current tracepoint.
101 save-tracepoints : write tracepoint setup into a file.
102
103 This module defines the following user-visible debugger variables:
104 $trace_frame : sequence number of trace frame currently being debugged.
105 $trace_line : source line of trace frame currently being debugged.
106 $trace_file : source file of trace frame currently being debugged.
107 $tracepoint : tracepoint number of trace frame currently being debugged.
108 */
109
110
111 /* ======= Important global variables: ======= */
112
113 /* The list of all trace state variables. We don't retain pointers to
114 any of these for any reason - API is by name or number only - so it
115 works to have a vector of objects. */
116
117 typedef struct trace_state_variable tsv_s;
118 DEF_VEC_O(tsv_s);
119
120 static VEC(tsv_s) *tvariables;
121
122 /* The next integer to assign to a variable. */
123
124 static int next_tsv_number = 1;
125
126 /* Number of last traceframe collected. */
127 static int traceframe_number;
128
129 /* Tracepoint for last traceframe collected. */
130 static int tracepoint_number;
131
132 /* The traceframe info of the current traceframe. NULL if we haven't
133 yet attempted to fetch it, or if the target does not support
134 fetching this object, or if we're not inspecting a traceframe
135 presently. */
136 static traceframe_info_up current_traceframe_info;
137
138 /* Tracing command lists. */
139 static struct cmd_list_element *tfindlist;
140
141 /* List of expressions to collect by default at each tracepoint hit. */
142 char *default_collect;
143
144 static int disconnected_tracing;
145
146 /* This variable controls whether we ask the target for a linear or
147 circular trace buffer. */
148
149 static int circular_trace_buffer;
150
151 /* This variable is the requested trace buffer size, or -1 to indicate
152 that we don't care and leave it up to the target to set a size. */
153
154 static int trace_buffer_size = -1;
155
156 /* Textual notes applying to the current and/or future trace runs. */
157
158 char *trace_user = NULL;
159
160 /* Textual notes applying to the current and/or future trace runs. */
161
162 char *trace_notes = NULL;
163
164 /* Textual notes applying to the stopping of a trace. */
165
166 char *trace_stop_notes = NULL;
167
168 /* support routines */
169
170 struct collection_list;
171 static char *mem2hex (gdb_byte *, char *, int);
172
173 static struct command_line *
174 all_tracepoint_actions_and_cleanup (struct breakpoint *t);
175
176 static struct trace_status trace_status;
177
178 const char *stop_reason_names[] = {
179 "tunknown",
180 "tnotrun",
181 "tstop",
182 "tfull",
183 "tdisconnected",
184 "tpasscount",
185 "terror"
186 };
187
188 struct trace_status *
189 current_trace_status (void)
190 {
191 return &trace_status;
192 }
193
194 /* Free and clear the traceframe info cache of the current
195 traceframe. */
196
197 static void
198 clear_traceframe_info (void)
199 {
200 current_traceframe_info = NULL;
201 }
202
203 /* Set traceframe number to NUM. */
204 static void
205 set_traceframe_num (int num)
206 {
207 traceframe_number = num;
208 set_internalvar_integer (lookup_internalvar ("trace_frame"), num);
209 }
210
211 /* Set tracepoint number to NUM. */
212 static void
213 set_tracepoint_num (int num)
214 {
215 tracepoint_number = num;
216 set_internalvar_integer (lookup_internalvar ("tracepoint"), num);
217 }
218
219 /* Set externally visible debug variables for querying/printing
220 the traceframe context (line, function, file). */
221
222 static void
223 set_traceframe_context (struct frame_info *trace_frame)
224 {
225 CORE_ADDR trace_pc;
226 struct symbol *traceframe_fun;
227 symtab_and_line traceframe_sal;
228
229 /* Save as globals for internal use. */
230 if (trace_frame != NULL
231 && get_frame_pc_if_available (trace_frame, &trace_pc))
232 {
233 traceframe_sal = find_pc_line (trace_pc, 0);
234 traceframe_fun = find_pc_function (trace_pc);
235
236 /* Save linenumber as "$trace_line", a debugger variable visible to
237 users. */
238 set_internalvar_integer (lookup_internalvar ("trace_line"),
239 traceframe_sal.line);
240 }
241 else
242 {
243 traceframe_fun = NULL;
244 set_internalvar_integer (lookup_internalvar ("trace_line"), -1);
245 }
246
247 /* Save func name as "$trace_func", a debugger variable visible to
248 users. */
249 if (traceframe_fun == NULL
250 || SYMBOL_LINKAGE_NAME (traceframe_fun) == NULL)
251 clear_internalvar (lookup_internalvar ("trace_func"));
252 else
253 set_internalvar_string (lookup_internalvar ("trace_func"),
254 SYMBOL_LINKAGE_NAME (traceframe_fun));
255
256 /* Save file name as "$trace_file", a debugger variable visible to
257 users. */
258 if (traceframe_sal.symtab == NULL)
259 clear_internalvar (lookup_internalvar ("trace_file"));
260 else
261 set_internalvar_string (lookup_internalvar ("trace_file"),
262 symtab_to_filename_for_display (traceframe_sal.symtab));
263 }
264
265 /* Create a new trace state variable with the given name. */
266
267 struct trace_state_variable *
268 create_trace_state_variable (const char *name)
269 {
270 struct trace_state_variable tsv;
271
272 memset (&tsv, 0, sizeof (tsv));
273 tsv.name = xstrdup (name);
274 tsv.number = next_tsv_number++;
275 return VEC_safe_push (tsv_s, tvariables, &tsv);
276 }
277
278 /* Look for a trace state variable of the given name. */
279
280 struct trace_state_variable *
281 find_trace_state_variable (const char *name)
282 {
283 struct trace_state_variable *tsv;
284 int ix;
285
286 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
287 if (strcmp (name, tsv->name) == 0)
288 return tsv;
289
290 return NULL;
291 }
292
293 /* Look for a trace state variable of the given number. Return NULL if
294 not found. */
295
296 struct trace_state_variable *
297 find_trace_state_variable_by_number (int number)
298 {
299 struct trace_state_variable *tsv;
300 int ix;
301
302 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
303 if (tsv->number == number)
304 return tsv;
305
306 return NULL;
307 }
308
309 static void
310 delete_trace_state_variable (const char *name)
311 {
312 struct trace_state_variable *tsv;
313 int ix;
314
315 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
316 if (strcmp (name, tsv->name) == 0)
317 {
318 observer_notify_tsv_deleted (tsv);
319
320 xfree ((void *)tsv->name);
321 VEC_unordered_remove (tsv_s, tvariables, ix);
322
323 return;
324 }
325
326 warning (_("No trace variable named \"$%s\", not deleting"), name);
327 }
328
329 /* Throws an error if NAME is not valid syntax for a trace state
330 variable's name. */
331
332 void
333 validate_trace_state_variable_name (const char *name)
334 {
335 const char *p;
336
337 if (*name == '\0')
338 error (_("Must supply a non-empty variable name"));
339
340 /* All digits in the name is reserved for value history
341 references. */
342 for (p = name; isdigit (*p); p++)
343 ;
344 if (*p == '\0')
345 error (_("$%s is not a valid trace state variable name"), name);
346
347 for (p = name; isalnum (*p) || *p == '_'; p++)
348 ;
349 if (*p != '\0')
350 error (_("$%s is not a valid trace state variable name"), name);
351 }
352
353 /* The 'tvariable' command collects a name and optional expression to
354 evaluate into an initial value. */
355
356 static void
357 trace_variable_command (const char *args, int from_tty)
358 {
359 LONGEST initval = 0;
360 struct trace_state_variable *tsv;
361 const char *name_start, *p;
362
363 if (!args || !*args)
364 error_no_arg (_("Syntax is $NAME [ = EXPR ]"));
365
366 /* Only allow two syntaxes; "$name" and "$name=value". */
367 p = skip_spaces (args);
368
369 if (*p++ != '$')
370 error (_("Name of trace variable should start with '$'"));
371
372 name_start = p;
373 while (isalnum (*p) || *p == '_')
374 p++;
375 std::string name (name_start, p - name_start);
376
377 p = skip_spaces (p);
378 if (*p != '=' && *p != '\0')
379 error (_("Syntax must be $NAME [ = EXPR ]"));
380
381 validate_trace_state_variable_name (name.c_str ());
382
383 if (*p == '=')
384 initval = value_as_long (parse_and_eval (++p));
385
386 /* If the variable already exists, just change its initial value. */
387 tsv = find_trace_state_variable (name.c_str ());
388 if (tsv)
389 {
390 if (tsv->initial_value != initval)
391 {
392 tsv->initial_value = initval;
393 observer_notify_tsv_modified (tsv);
394 }
395 printf_filtered (_("Trace state variable $%s "
396 "now has initial value %s.\n"),
397 tsv->name, plongest (tsv->initial_value));
398 return;
399 }
400
401 /* Create a new variable. */
402 tsv = create_trace_state_variable (name.c_str ());
403 tsv->initial_value = initval;
404
405 observer_notify_tsv_created (tsv);
406
407 printf_filtered (_("Trace state variable $%s "
408 "created, with initial value %s.\n"),
409 tsv->name, plongest (tsv->initial_value));
410 }
411
412 static void
413 delete_trace_variable_command (const char *args, int from_tty)
414 {
415 if (args == NULL)
416 {
417 if (query (_("Delete all trace state variables? ")))
418 VEC_free (tsv_s, tvariables);
419 dont_repeat ();
420 observer_notify_tsv_deleted (NULL);
421 return;
422 }
423
424 gdb_argv argv (args);
425
426 for (char *arg : argv)
427 {
428 if (*arg == '$')
429 delete_trace_state_variable (arg + 1);
430 else
431 warning (_("Name \"%s\" not prefixed with '$', ignoring"), arg);
432 }
433
434 dont_repeat ();
435 }
436
437 void
438 tvariables_info_1 (void)
439 {
440 struct trace_state_variable *tsv;
441 int ix;
442 int count = 0;
443 struct ui_out *uiout = current_uiout;
444
445 if (VEC_length (tsv_s, tvariables) == 0 && !uiout->is_mi_like_p ())
446 {
447 printf_filtered (_("No trace state variables.\n"));
448 return;
449 }
450
451 /* Try to acquire values from the target. */
452 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix, ++count)
453 tsv->value_known = target_get_trace_state_variable_value (tsv->number,
454 &(tsv->value));
455
456 ui_out_emit_table table_emitter (uiout, 3, count, "trace-variables");
457 uiout->table_header (15, ui_left, "name", "Name");
458 uiout->table_header (11, ui_left, "initial", "Initial");
459 uiout->table_header (11, ui_left, "current", "Current");
460
461 uiout->table_body ();
462
463 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
464 {
465 const char *c;
466
467 ui_out_emit_tuple tuple_emitter (uiout, "variable");
468
469 std::string name = std::string ("$") + tsv->name;
470 uiout->field_string ("name", name.c_str ());
471 uiout->field_string ("initial", plongest (tsv->initial_value));
472
473 if (tsv->value_known)
474 c = plongest (tsv->value);
475 else if (uiout->is_mi_like_p ())
476 /* For MI, we prefer not to use magic string constants, but rather
477 omit the field completely. The difference between unknown and
478 undefined does not seem important enough to represent. */
479 c = NULL;
480 else if (current_trace_status ()->running || traceframe_number >= 0)
481 /* The value is/was defined, but we don't have it. */
482 c = "<unknown>";
483 else
484 /* It is not meaningful to ask about the value. */
485 c = "<undefined>";
486 if (c)
487 uiout->field_string ("current", c);
488 uiout->text ("\n");
489 }
490 }
491
492 /* List all the trace state variables. */
493
494 static void
495 info_tvariables_command (const char *args, int from_tty)
496 {
497 tvariables_info_1 ();
498 }
499
500 /* Stash definitions of tsvs into the given file. */
501
502 void
503 save_trace_state_variables (struct ui_file *fp)
504 {
505 struct trace_state_variable *tsv;
506 int ix;
507
508 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
509 {
510 fprintf_unfiltered (fp, "tvariable $%s", tsv->name);
511 if (tsv->initial_value)
512 fprintf_unfiltered (fp, " = %s", plongest (tsv->initial_value));
513 fprintf_unfiltered (fp, "\n");
514 }
515 }
516
517 /* ACTIONS functions: */
518
519 /* The three functions:
520 collect_pseudocommand,
521 while_stepping_pseudocommand, and
522 end_actions_pseudocommand
523 are placeholders for "commands" that are actually ONLY to be used
524 within a tracepoint action list. If the actual function is ever called,
525 it means that somebody issued the "command" at the top level,
526 which is always an error. */
527
528 static void
529 end_actions_pseudocommand (const char *args, int from_tty)
530 {
531 error (_("This command cannot be used at the top level."));
532 }
533
534 static void
535 while_stepping_pseudocommand (const char *args, int from_tty)
536 {
537 error (_("This command can only be used in a tracepoint actions list."));
538 }
539
540 static void
541 collect_pseudocommand (const char *args, int from_tty)
542 {
543 error (_("This command can only be used in a tracepoint actions list."));
544 }
545
546 static void
547 teval_pseudocommand (const char *args, int from_tty)
548 {
549 error (_("This command can only be used in a tracepoint actions list."));
550 }
551
552 /* Parse any collection options, such as /s for strings. */
553
554 const char *
555 decode_agent_options (const char *exp, int *trace_string)
556 {
557 struct value_print_options opts;
558
559 *trace_string = 0;
560
561 if (*exp != '/')
562 return exp;
563
564 /* Call this to borrow the print elements default for collection
565 size. */
566 get_user_print_options (&opts);
567
568 exp++;
569 if (*exp == 's')
570 {
571 if (target_supports_string_tracing ())
572 {
573 /* Allow an optional decimal number giving an explicit maximum
574 string length, defaulting it to the "print elements" value;
575 so "collect/s80 mystr" gets at most 80 bytes of string. */
576 *trace_string = opts.print_max;
577 exp++;
578 if (*exp >= '0' && *exp <= '9')
579 *trace_string = atoi (exp);
580 while (*exp >= '0' && *exp <= '9')
581 exp++;
582 }
583 else
584 error (_("Target does not support \"/s\" option for string tracing."));
585 }
586 else
587 error (_("Undefined collection format \"%c\"."), *exp);
588
589 exp = skip_spaces (exp);
590
591 return exp;
592 }
593
594 /* Enter a list of actions for a tracepoint. */
595 static void
596 actions_command (const char *args, int from_tty)
597 {
598 struct tracepoint *t;
599
600 t = get_tracepoint_by_number (&args, NULL);
601 if (t)
602 {
603 std::string tmpbuf =
604 string_printf ("Enter actions for tracepoint %d, one per line.",
605 t->number);
606
607 command_line_up l = read_command_lines (&tmpbuf[0], from_tty, 1,
608 check_tracepoint_command, t);
609 breakpoint_set_commands (t, std::move (l));
610 }
611 /* else just return */
612 }
613
614 /* Report the results of checking the agent expression, as errors or
615 internal errors. */
616
617 static void
618 report_agent_reqs_errors (struct agent_expr *aexpr)
619 {
620 /* All of the "flaws" are serious bytecode generation issues that
621 should never occur. */
622 if (aexpr->flaw != agent_flaw_none)
623 internal_error (__FILE__, __LINE__, _("expression is malformed"));
624
625 /* If analysis shows a stack underflow, GDB must have done something
626 badly wrong in its bytecode generation. */
627 if (aexpr->min_height < 0)
628 internal_error (__FILE__, __LINE__,
629 _("expression has min height < 0"));
630
631 /* Issue this error if the stack is predicted to get too deep. The
632 limit is rather arbitrary; a better scheme might be for the
633 target to report how much stack it will have available. The
634 depth roughly corresponds to parenthesization, so a limit of 20
635 amounts to 20 levels of expression nesting, which is actually
636 a pretty big hairy expression. */
637 if (aexpr->max_height > 20)
638 error (_("Expression is too complicated."));
639 }
640
641 /* worker function */
642 void
643 validate_actionline (const char *line, struct breakpoint *b)
644 {
645 struct cmd_list_element *c;
646 const char *tmp_p;
647 const char *p;
648 struct bp_location *loc;
649 struct tracepoint *t = (struct tracepoint *) b;
650
651 /* If EOF is typed, *line is NULL. */
652 if (line == NULL)
653 return;
654
655 p = skip_spaces (line);
656
657 /* Symbol lookup etc. */
658 if (*p == '\0') /* empty line: just prompt for another line. */
659 return;
660
661 if (*p == '#') /* comment line */
662 return;
663
664 c = lookup_cmd (&p, cmdlist, "", -1, 1);
665 if (c == 0)
666 error (_("`%s' is not a tracepoint action, or is ambiguous."), p);
667
668 if (cmd_cfunc_eq (c, collect_pseudocommand))
669 {
670 int trace_string = 0;
671
672 if (*p == '/')
673 p = decode_agent_options (p, &trace_string);
674
675 do
676 { /* Repeat over a comma-separated list. */
677 QUIT; /* Allow user to bail out with ^C. */
678 p = skip_spaces (p);
679
680 if (*p == '$') /* Look for special pseudo-symbols. */
681 {
682 if (0 == strncasecmp ("reg", p + 1, 3)
683 || 0 == strncasecmp ("arg", p + 1, 3)
684 || 0 == strncasecmp ("loc", p + 1, 3)
685 || 0 == strncasecmp ("_ret", p + 1, 4)
686 || 0 == strncasecmp ("_sdata", p + 1, 6))
687 {
688 p = strchr (p, ',');
689 continue;
690 }
691 /* else fall thru, treat p as an expression and parse it! */
692 }
693 tmp_p = p;
694 for (loc = t->loc; loc; loc = loc->next)
695 {
696 p = tmp_p;
697 expression_up exp = parse_exp_1 (&p, loc->address,
698 block_for_pc (loc->address), 1);
699
700 if (exp->elts[0].opcode == OP_VAR_VALUE)
701 {
702 if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
703 {
704 error (_("constant `%s' (value %s) "
705 "will not be collected."),
706 SYMBOL_PRINT_NAME (exp->elts[2].symbol),
707 plongest (SYMBOL_VALUE (exp->elts[2].symbol)));
708 }
709 else if (SYMBOL_CLASS (exp->elts[2].symbol)
710 == LOC_OPTIMIZED_OUT)
711 {
712 error (_("`%s' is optimized away "
713 "and cannot be collected."),
714 SYMBOL_PRINT_NAME (exp->elts[2].symbol));
715 }
716 }
717
718 /* We have something to collect, make sure that the expr to
719 bytecode translator can handle it and that it's not too
720 long. */
721 agent_expr_up aexpr = gen_trace_for_expr (loc->address,
722 exp.get (),
723 trace_string);
724
725 if (aexpr->len > MAX_AGENT_EXPR_LEN)
726 error (_("Expression is too complicated."));
727
728 ax_reqs (aexpr.get ());
729
730 report_agent_reqs_errors (aexpr.get ());
731 }
732 }
733 while (p && *p++ == ',');
734 }
735
736 else if (cmd_cfunc_eq (c, teval_pseudocommand))
737 {
738 do
739 { /* Repeat over a comma-separated list. */
740 QUIT; /* Allow user to bail out with ^C. */
741 p = skip_spaces (p);
742
743 tmp_p = p;
744 for (loc = t->loc; loc; loc = loc->next)
745 {
746 p = tmp_p;
747
748 /* Only expressions are allowed for this action. */
749 expression_up exp = parse_exp_1 (&p, loc->address,
750 block_for_pc (loc->address), 1);
751
752 /* We have something to evaluate, make sure that the expr to
753 bytecode translator can handle it and that it's not too
754 long. */
755 agent_expr_up aexpr = gen_eval_for_expr (loc->address, exp.get ());
756
757 if (aexpr->len > MAX_AGENT_EXPR_LEN)
758 error (_("Expression is too complicated."));
759
760 ax_reqs (aexpr.get ());
761 report_agent_reqs_errors (aexpr.get ());
762 }
763 }
764 while (p && *p++ == ',');
765 }
766
767 else if (cmd_cfunc_eq (c, while_stepping_pseudocommand))
768 {
769 char *endp;
770
771 p = skip_spaces (p);
772 t->step_count = strtol (p, &endp, 0);
773 if (endp == p || t->step_count == 0)
774 error (_("while-stepping step count `%s' is malformed."), line);
775 p = endp;
776 }
777
778 else if (cmd_cfunc_eq (c, end_actions_pseudocommand))
779 ;
780
781 else
782 error (_("`%s' is not a supported tracepoint action."), line);
783 }
784
785 enum {
786 memrange_absolute = -1
787 };
788
789 /* MEMRANGE functions: */
790
791 /* Compare memranges for std::sort. */
792
793 static bool
794 memrange_comp (const memrange &a, const memrange &b)
795 {
796 if (a.type == b.type)
797 {
798 if (a.type == memrange_absolute)
799 return (bfd_vma) a.start < (bfd_vma) b.start;
800 else
801 return a.start < b.start;
802 }
803
804 return a.type < b.type;
805 }
806
807 /* Sort the memrange list using std::sort, and merge adjacent memranges. */
808
809 static void
810 memrange_sortmerge (std::vector<memrange> &memranges)
811 {
812 if (!memranges.empty ())
813 {
814 int a, b;
815
816 std::sort (memranges.begin (), memranges.end (), memrange_comp);
817
818 for (a = 0, b = 1; b < memranges.size (); b++)
819 {
820 /* If memrange b overlaps or is adjacent to memrange a,
821 merge them. */
822 if (memranges[a].type == memranges[b].type
823 && memranges[b].start <= memranges[a].end)
824 {
825 if (memranges[b].end > memranges[a].end)
826 memranges[a].end = memranges[b].end;
827 continue; /* next b, same a */
828 }
829 a++; /* next a */
830 if (a != b)
831 memranges[a] = memranges[b];
832 }
833 memranges.resize (a + 1);
834 }
835 }
836
837 /* Add a register to a collection list. */
838
839 void
840 collection_list::add_register (unsigned int regno)
841 {
842 if (info_verbose)
843 printf_filtered ("collect register %d\n", regno);
844 if (regno >= (8 * sizeof (m_regs_mask)))
845 error (_("Internal: register number %d too large for tracepoint"),
846 regno);
847 m_regs_mask[regno / 8] |= 1 << (regno % 8);
848 }
849
850 /* Add a memrange to a collection list. */
851
852 void
853 collection_list::add_memrange (struct gdbarch *gdbarch,
854 int type, bfd_signed_vma base,
855 unsigned long len)
856 {
857 if (info_verbose)
858 printf_filtered ("(%d,%s,%ld)\n", type, paddress (gdbarch, base), len);
859
860 /* type: memrange_absolute == memory, other n == basereg */
861 /* base: addr if memory, offset if reg relative. */
862 /* len: we actually save end (base + len) for convenience */
863 m_memranges.emplace_back (type, base, base + len);
864
865 if (type != memrange_absolute) /* Better collect the base register! */
866 add_register (type);
867 }
868
869 /* Add a symbol to a collection list. */
870
871 void
872 collection_list::collect_symbol (struct symbol *sym,
873 struct gdbarch *gdbarch,
874 long frame_regno, long frame_offset,
875 CORE_ADDR scope,
876 int trace_string)
877 {
878 unsigned long len;
879 unsigned int reg;
880 bfd_signed_vma offset;
881 int treat_as_expr = 0;
882
883 len = TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym)));
884 switch (SYMBOL_CLASS (sym))
885 {
886 default:
887 printf_filtered ("%s: don't know symbol class %d\n",
888 SYMBOL_PRINT_NAME (sym),
889 SYMBOL_CLASS (sym));
890 break;
891 case LOC_CONST:
892 printf_filtered ("constant %s (value %s) will not be collected.\n",
893 SYMBOL_PRINT_NAME (sym), plongest (SYMBOL_VALUE (sym)));
894 break;
895 case LOC_STATIC:
896 offset = SYMBOL_VALUE_ADDRESS (sym);
897 if (info_verbose)
898 {
899 printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n",
900 SYMBOL_PRINT_NAME (sym), len,
901 paddress (gdbarch, offset));
902 }
903 /* A struct may be a C++ class with static fields, go to general
904 expression handling. */
905 if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
906 treat_as_expr = 1;
907 else
908 add_memrange (gdbarch, memrange_absolute, offset, len);
909 break;
910 case LOC_REGISTER:
911 reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
912 if (info_verbose)
913 printf_filtered ("LOC_REG[parm] %s: ",
914 SYMBOL_PRINT_NAME (sym));
915 add_register (reg);
916 /* Check for doubles stored in two registers. */
917 /* FIXME: how about larger types stored in 3 or more regs? */
918 if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT &&
919 len > register_size (gdbarch, reg))
920 add_register (reg + 1);
921 break;
922 case LOC_REF_ARG:
923 printf_filtered ("Sorry, don't know how to do LOC_REF_ARG yet.\n");
924 printf_filtered (" (will not collect %s)\n",
925 SYMBOL_PRINT_NAME (sym));
926 break;
927 case LOC_ARG:
928 reg = frame_regno;
929 offset = frame_offset + SYMBOL_VALUE (sym);
930 if (info_verbose)
931 {
932 printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
933 " from frame ptr reg %d\n",
934 SYMBOL_PRINT_NAME (sym), len,
935 paddress (gdbarch, offset), reg);
936 }
937 add_memrange (gdbarch, reg, offset, len);
938 break;
939 case LOC_REGPARM_ADDR:
940 reg = SYMBOL_VALUE (sym);
941 offset = 0;
942 if (info_verbose)
943 {
944 printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset %s"
945 " from reg %d\n",
946 SYMBOL_PRINT_NAME (sym), len,
947 paddress (gdbarch, offset), reg);
948 }
949 add_memrange (gdbarch, reg, offset, len);
950 break;
951 case LOC_LOCAL:
952 reg = frame_regno;
953 offset = frame_offset + SYMBOL_VALUE (sym);
954 if (info_verbose)
955 {
956 printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
957 " from frame ptr reg %d\n",
958 SYMBOL_PRINT_NAME (sym), len,
959 paddress (gdbarch, offset), reg);
960 }
961 add_memrange (gdbarch, reg, offset, len);
962 break;
963
964 case LOC_UNRESOLVED:
965 treat_as_expr = 1;
966 break;
967
968 case LOC_OPTIMIZED_OUT:
969 printf_filtered ("%s has been optimized out of existence.\n",
970 SYMBOL_PRINT_NAME (sym));
971 break;
972
973 case LOC_COMPUTED:
974 treat_as_expr = 1;
975 break;
976 }
977
978 /* Expressions are the most general case. */
979 if (treat_as_expr)
980 {
981 agent_expr_up aexpr = gen_trace_for_var (scope, gdbarch,
982 sym, trace_string);
983
984 /* It can happen that the symbol is recorded as a computed
985 location, but it's been optimized away and doesn't actually
986 have a location expression. */
987 if (!aexpr)
988 {
989 printf_filtered ("%s has been optimized out of existence.\n",
990 SYMBOL_PRINT_NAME (sym));
991 return;
992 }
993
994 ax_reqs (aexpr.get ());
995
996 report_agent_reqs_errors (aexpr.get ());
997
998 /* Take care of the registers. */
999 if (aexpr->reg_mask_len > 0)
1000 {
1001 for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
1002 {
1003 QUIT; /* Allow user to bail out with ^C. */
1004 if (aexpr->reg_mask[ndx1] != 0)
1005 {
1006 /* Assume chars have 8 bits. */
1007 for (int ndx2 = 0; ndx2 < 8; ndx2++)
1008 if (aexpr->reg_mask[ndx1] & (1 << ndx2))
1009 /* It's used -- record it. */
1010 add_register (ndx1 * 8 + ndx2);
1011 }
1012 }
1013 }
1014
1015 add_aexpr (std::move (aexpr));
1016 }
1017 }
1018
1019 /* Data to be passed around in the calls to the locals and args
1020 iterators. */
1021
1022 struct add_local_symbols_data
1023 {
1024 struct collection_list *collect;
1025 struct gdbarch *gdbarch;
1026 CORE_ADDR pc;
1027 long frame_regno;
1028 long frame_offset;
1029 int count;
1030 int trace_string;
1031 };
1032
1033 /* The callback for the locals and args iterators. */
1034
1035 static void
1036 do_collect_symbol (const char *print_name,
1037 struct symbol *sym,
1038 void *cb_data)
1039 {
1040 struct add_local_symbols_data *p = (struct add_local_symbols_data *) cb_data;
1041
1042 p->collect->collect_symbol (sym, p->gdbarch, p->frame_regno,
1043 p->frame_offset, p->pc, p->trace_string);
1044 p->count++;
1045
1046 p->collect->add_wholly_collected (print_name);
1047 }
1048
1049 void
1050 collection_list::add_wholly_collected (const char *print_name)
1051 {
1052 m_wholly_collected.push_back (print_name);
1053 }
1054
1055 /* Add all locals (or args) symbols to collection list. */
1056
1057 void
1058 collection_list::add_local_symbols (struct gdbarch *gdbarch, CORE_ADDR pc,
1059 long frame_regno, long frame_offset, int type,
1060 int trace_string)
1061 {
1062 const struct block *block;
1063 struct add_local_symbols_data cb_data;
1064
1065 cb_data.collect = this;
1066 cb_data.gdbarch = gdbarch;
1067 cb_data.pc = pc;
1068 cb_data.frame_regno = frame_regno;
1069 cb_data.frame_offset = frame_offset;
1070 cb_data.count = 0;
1071 cb_data.trace_string = trace_string;
1072
1073 if (type == 'L')
1074 {
1075 block = block_for_pc (pc);
1076 if (block == NULL)
1077 {
1078 warning (_("Can't collect locals; "
1079 "no symbol table info available.\n"));
1080 return;
1081 }
1082
1083 iterate_over_block_local_vars (block, do_collect_symbol, &cb_data);
1084 if (cb_data.count == 0)
1085 warning (_("No locals found in scope."));
1086 }
1087 else
1088 {
1089 pc = get_pc_function_start (pc);
1090 block = block_for_pc (pc);
1091 if (block == NULL)
1092 {
1093 warning (_("Can't collect args; no symbol table info available."));
1094 return;
1095 }
1096
1097 iterate_over_block_arg_vars (block, do_collect_symbol, &cb_data);
1098 if (cb_data.count == 0)
1099 warning (_("No args found in scope."));
1100 }
1101 }
1102
1103 void
1104 collection_list::add_static_trace_data ()
1105 {
1106 if (info_verbose)
1107 printf_filtered ("collect static trace data\n");
1108 m_strace_data = true;
1109 }
1110
1111 collection_list::collection_list ()
1112 : m_regs_mask (),
1113 m_strace_data (false)
1114 {
1115 m_memranges.reserve (128);
1116 m_aexprs.reserve (128);
1117 }
1118
1119 /* Reduce a collection list to string form (for gdb protocol). */
1120
1121 std::vector<std::string>
1122 collection_list::stringify ()
1123 {
1124 char temp_buf[2048];
1125 int count;
1126 char *end;
1127 long i;
1128 std::vector<std::string> str_list;
1129
1130 if (m_strace_data)
1131 {
1132 if (info_verbose)
1133 printf_filtered ("\nCollecting static trace data\n");
1134 end = temp_buf;
1135 *end++ = 'L';
1136 str_list.emplace_back (temp_buf, end - temp_buf);
1137 }
1138
1139 for (i = sizeof (m_regs_mask) - 1; i > 0; i--)
1140 if (m_regs_mask[i] != 0) /* Skip leading zeroes in regs_mask. */
1141 break;
1142 if (m_regs_mask[i] != 0) /* Prepare to send regs_mask to the stub. */
1143 {
1144 if (info_verbose)
1145 printf_filtered ("\nCollecting registers (mask): 0x");
1146 end = temp_buf;
1147 *end++ = 'R';
1148 for (; i >= 0; i--)
1149 {
1150 QUIT; /* Allow user to bail out with ^C. */
1151 if (info_verbose)
1152 printf_filtered ("%02X", m_regs_mask[i]);
1153 sprintf (end, "%02X", m_regs_mask[i]);
1154 end += 2;
1155 }
1156 str_list.emplace_back (temp_buf);
1157 }
1158 if (info_verbose)
1159 printf_filtered ("\n");
1160 if (!m_memranges.empty () && info_verbose)
1161 printf_filtered ("Collecting memranges: \n");
1162 for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++)
1163 {
1164 QUIT; /* Allow user to bail out with ^C. */
1165 if (info_verbose)
1166 {
1167 printf_filtered ("(%d, %s, %ld)\n",
1168 m_memranges[i].type,
1169 paddress (target_gdbarch (),
1170 m_memranges[i].start),
1171 (long) (m_memranges[i].end
1172 - m_memranges[i].start));
1173 }
1174 if (count + 27 > MAX_AGENT_EXPR_LEN)
1175 {
1176 str_list.emplace_back (temp_buf, count);
1177 count = 0;
1178 end = temp_buf;
1179 }
1180
1181 {
1182 bfd_signed_vma length
1183 = m_memranges[i].end - m_memranges[i].start;
1184
1185 /* The "%X" conversion specifier expects an unsigned argument,
1186 so passing -1 (memrange_absolute) to it directly gives you
1187 "FFFFFFFF" (or more, depending on sizeof (unsigned)).
1188 Special-case it. */
1189 if (m_memranges[i].type == memrange_absolute)
1190 sprintf (end, "M-1,%s,%lX", phex_nz (m_memranges[i].start, 0),
1191 (long) length);
1192 else
1193 sprintf (end, "M%X,%s,%lX", m_memranges[i].type,
1194 phex_nz (m_memranges[i].start, 0), (long) length);
1195 }
1196
1197 count += strlen (end);
1198 end = temp_buf + count;
1199 }
1200
1201 for (i = 0; i < m_aexprs.size (); i++)
1202 {
1203 QUIT; /* Allow user to bail out with ^C. */
1204 if ((count + 10 + 2 * m_aexprs[i]->len) > MAX_AGENT_EXPR_LEN)
1205 {
1206 str_list.emplace_back (temp_buf, count);
1207 count = 0;
1208 end = temp_buf;
1209 }
1210 sprintf (end, "X%08X,", m_aexprs[i]->len);
1211 end += 10; /* 'X' + 8 hex digits + ',' */
1212 count += 10;
1213
1214 end = mem2hex (m_aexprs[i]->buf, end, m_aexprs[i]->len);
1215 count += 2 * m_aexprs[i]->len;
1216 }
1217
1218 if (count != 0)
1219 {
1220 str_list.emplace_back (temp_buf, count);
1221 count = 0;
1222 end = temp_buf;
1223 }
1224
1225 return str_list;
1226 }
1227
1228 /* Add the printed expression EXP to *LIST. */
1229
1230 void
1231 collection_list::append_exp (struct expression *exp)
1232 {
1233 string_file tmp_stream;
1234
1235 print_expression (exp, &tmp_stream);
1236
1237 m_computed.push_back (std::move (tmp_stream.string ()));
1238 }
1239
1240 void
1241 collection_list::finish ()
1242 {
1243 memrange_sortmerge (m_memranges);
1244 }
1245
1246 static void
1247 encode_actions_1 (struct command_line *action,
1248 struct bp_location *tloc,
1249 int frame_reg,
1250 LONGEST frame_offset,
1251 struct collection_list *collect,
1252 struct collection_list *stepping_list)
1253 {
1254 const char *action_exp;
1255 int i;
1256 struct value *tempval;
1257 struct cmd_list_element *cmd;
1258
1259 for (; action; action = action->next)
1260 {
1261 QUIT; /* Allow user to bail out with ^C. */
1262 action_exp = action->line;
1263 action_exp = skip_spaces (action_exp);
1264
1265 cmd = lookup_cmd (&action_exp, cmdlist, "", -1, 1);
1266 if (cmd == 0)
1267 error (_("Bad action list item: %s"), action_exp);
1268
1269 if (cmd_cfunc_eq (cmd, collect_pseudocommand))
1270 {
1271 int trace_string = 0;
1272
1273 if (*action_exp == '/')
1274 action_exp = decode_agent_options (action_exp, &trace_string);
1275
1276 do
1277 { /* Repeat over a comma-separated list. */
1278 QUIT; /* Allow user to bail out with ^C. */
1279 action_exp = skip_spaces (action_exp);
1280
1281 if (0 == strncasecmp ("$reg", action_exp, 4))
1282 {
1283 for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
1284 collect->add_register (i);
1285 action_exp = strchr (action_exp, ','); /* more? */
1286 }
1287 else if (0 == strncasecmp ("$arg", action_exp, 4))
1288 {
1289 collect->add_local_symbols (target_gdbarch (),
1290 tloc->address,
1291 frame_reg,
1292 frame_offset,
1293 'A',
1294 trace_string);
1295 action_exp = strchr (action_exp, ','); /* more? */
1296 }
1297 else if (0 == strncasecmp ("$loc", action_exp, 4))
1298 {
1299 collect->add_local_symbols (target_gdbarch (),
1300 tloc->address,
1301 frame_reg,
1302 frame_offset,
1303 'L',
1304 trace_string);
1305 action_exp = strchr (action_exp, ','); /* more? */
1306 }
1307 else if (0 == strncasecmp ("$_ret", action_exp, 5))
1308 {
1309 agent_expr_up aexpr
1310 = gen_trace_for_return_address (tloc->address,
1311 target_gdbarch (),
1312 trace_string);
1313
1314 ax_reqs (aexpr.get ());
1315 report_agent_reqs_errors (aexpr.get ());
1316
1317 /* take care of the registers */
1318 if (aexpr->reg_mask_len > 0)
1319 {
1320 for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
1321 {
1322 QUIT; /* allow user to bail out with ^C */
1323 if (aexpr->reg_mask[ndx1] != 0)
1324 {
1325 /* assume chars have 8 bits */
1326 for (int ndx2 = 0; ndx2 < 8; ndx2++)
1327 if (aexpr->reg_mask[ndx1] & (1 << ndx2))
1328 {
1329 /* It's used -- record it. */
1330 collect->add_register (ndx1 * 8 + ndx2);
1331 }
1332 }
1333 }
1334 }
1335
1336 collect->add_aexpr (std::move (aexpr));
1337 action_exp = strchr (action_exp, ','); /* more? */
1338 }
1339 else if (0 == strncasecmp ("$_sdata", action_exp, 7))
1340 {
1341 collect->add_static_trace_data ();
1342 action_exp = strchr (action_exp, ','); /* more? */
1343 }
1344 else
1345 {
1346 unsigned long addr;
1347
1348 expression_up exp = parse_exp_1 (&action_exp, tloc->address,
1349 block_for_pc (tloc->address),
1350 1);
1351
1352 switch (exp->elts[0].opcode)
1353 {
1354 case OP_REGISTER:
1355 {
1356 const char *name = &exp->elts[2].string;
1357
1358 i = user_reg_map_name_to_regnum (target_gdbarch (),
1359 name, strlen (name));
1360 if (i == -1)
1361 internal_error (__FILE__, __LINE__,
1362 _("Register $%s not available"),
1363 name);
1364 if (info_verbose)
1365 printf_filtered ("OP_REGISTER: ");
1366 collect->add_register (i);
1367 break;
1368 }
1369
1370 case UNOP_MEMVAL:
1371 /* Safe because we know it's a simple expression. */
1372 tempval = evaluate_expression (exp.get ());
1373 addr = value_address (tempval);
1374 /* Initialize the TYPE_LENGTH if it is a typedef. */
1375 check_typedef (exp->elts[1].type);
1376 collect->add_memrange (target_gdbarch (),
1377 memrange_absolute, addr,
1378 TYPE_LENGTH (exp->elts[1].type));
1379 collect->append_exp (exp.get ());
1380 break;
1381
1382 case OP_VAR_VALUE:
1383 {
1384 struct symbol *sym = exp->elts[2].symbol;
1385 char_ptr name = (char_ptr) SYMBOL_NATURAL_NAME (sym);
1386
1387 collect->collect_symbol (exp->elts[2].symbol,
1388 target_gdbarch (),
1389 frame_reg,
1390 frame_offset,
1391 tloc->address,
1392 trace_string);
1393 collect->add_wholly_collected (name);
1394 }
1395 break;
1396
1397 default: /* Full-fledged expression. */
1398 agent_expr_up aexpr = gen_trace_for_expr (tloc->address,
1399 exp.get (),
1400 trace_string);
1401
1402 ax_reqs (aexpr.get ());
1403
1404 report_agent_reqs_errors (aexpr.get ());
1405
1406 /* Take care of the registers. */
1407 if (aexpr->reg_mask_len > 0)
1408 {
1409 for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
1410 {
1411 QUIT; /* Allow user to bail out with ^C. */
1412 if (aexpr->reg_mask[ndx1] != 0)
1413 {
1414 /* Assume chars have 8 bits. */
1415 for (int ndx2 = 0; ndx2 < 8; ndx2++)
1416 if (aexpr->reg_mask[ndx1] & (1 << ndx2))
1417 {
1418 /* It's used -- record it. */
1419 collect->add_register (ndx1 * 8 + ndx2);
1420 }
1421 }
1422 }
1423 }
1424
1425 collect->add_aexpr (std::move (aexpr));
1426 collect->append_exp (exp.get ());
1427 break;
1428 } /* switch */
1429 } /* do */
1430 }
1431 while (action_exp && *action_exp++ == ',');
1432 } /* if */
1433 else if (cmd_cfunc_eq (cmd, teval_pseudocommand))
1434 {
1435 do
1436 { /* Repeat over a comma-separated list. */
1437 QUIT; /* Allow user to bail out with ^C. */
1438 action_exp = skip_spaces (action_exp);
1439
1440 {
1441 expression_up exp = parse_exp_1 (&action_exp, tloc->address,
1442 block_for_pc (tloc->address),
1443 1);
1444
1445 agent_expr_up aexpr = gen_eval_for_expr (tloc->address,
1446 exp.get ());
1447
1448 ax_reqs (aexpr.get ());
1449 report_agent_reqs_errors (aexpr.get ());
1450
1451 /* Even though we're not officially collecting, add
1452 to the collect list anyway. */
1453 collect->add_aexpr (std::move (aexpr));
1454 } /* do */
1455 }
1456 while (action_exp && *action_exp++ == ',');
1457 } /* if */
1458 else if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
1459 {
1460 /* We check against nested while-stepping when setting
1461 breakpoint action, so no way to run into nested
1462 here. */
1463 gdb_assert (stepping_list);
1464
1465 encode_actions_1 (action->body_list[0], tloc, frame_reg,
1466 frame_offset, stepping_list, NULL);
1467 }
1468 else
1469 error (_("Invalid tracepoint command '%s'"), action->line);
1470 } /* for */
1471 }
1472
1473 /* Encode actions of tracepoint TLOC->owner and fill TRACEPOINT_LIST
1474 and STEPPING_LIST. */
1475
1476 void
1477 encode_actions (struct bp_location *tloc,
1478 struct collection_list *tracepoint_list,
1479 struct collection_list *stepping_list)
1480 {
1481 struct command_line *actions;
1482 int frame_reg;
1483 LONGEST frame_offset;
1484
1485 gdbarch_virtual_frame_pointer (tloc->gdbarch,
1486 tloc->address, &frame_reg, &frame_offset);
1487
1488 actions = all_tracepoint_actions_and_cleanup (tloc->owner);
1489
1490 encode_actions_1 (actions, tloc, frame_reg, frame_offset,
1491 tracepoint_list, stepping_list);
1492
1493 tracepoint_list->finish ();
1494 stepping_list->finish ();
1495 }
1496
1497 /* Render all actions into gdb protocol. */
1498
1499 void
1500 encode_actions_rsp (struct bp_location *tloc,
1501 std::vector<std::string> *tdp_actions,
1502 std::vector<std::string> *stepping_actions)
1503 {
1504 struct collection_list tracepoint_list, stepping_list;
1505
1506 encode_actions (tloc, &tracepoint_list, &stepping_list);
1507
1508 *tdp_actions = tracepoint_list.stringify ();
1509 *stepping_actions = stepping_list.stringify ();
1510 }
1511
1512 void
1513 collection_list::add_aexpr (agent_expr_up aexpr)
1514 {
1515 m_aexprs.push_back (std::move (aexpr));
1516 }
1517
1518 static void
1519 process_tracepoint_on_disconnect (void)
1520 {
1521 VEC(breakpoint_p) *tp_vec = NULL;
1522 int ix;
1523 struct breakpoint *b;
1524 int has_pending_p = 0;
1525
1526 /* Check whether we still have pending tracepoint. If we have, warn the
1527 user that pending tracepoint will no longer work. */
1528 tp_vec = all_tracepoints ();
1529 for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
1530 {
1531 if (b->loc == NULL)
1532 {
1533 has_pending_p = 1;
1534 break;
1535 }
1536 else
1537 {
1538 struct bp_location *loc1;
1539
1540 for (loc1 = b->loc; loc1; loc1 = loc1->next)
1541 {
1542 if (loc1->shlib_disabled)
1543 {
1544 has_pending_p = 1;
1545 break;
1546 }
1547 }
1548
1549 if (has_pending_p)
1550 break;
1551 }
1552 }
1553 VEC_free (breakpoint_p, tp_vec);
1554
1555 if (has_pending_p)
1556 warning (_("Pending tracepoints will not be resolved while"
1557 " GDB is disconnected\n"));
1558 }
1559
1560 /* Reset local state of tracing. */
1561
1562 void
1563 trace_reset_local_state (void)
1564 {
1565 set_traceframe_num (-1);
1566 set_tracepoint_num (-1);
1567 set_traceframe_context (NULL);
1568 clear_traceframe_info ();
1569 }
1570
1571 void
1572 start_tracing (const char *notes)
1573 {
1574 VEC(breakpoint_p) *tp_vec = NULL;
1575 int ix;
1576 struct breakpoint *b;
1577 struct trace_state_variable *tsv;
1578 int any_enabled = 0, num_to_download = 0;
1579 int ret;
1580
1581 tp_vec = all_tracepoints ();
1582
1583 /* No point in tracing without any tracepoints... */
1584 if (VEC_length (breakpoint_p, tp_vec) == 0)
1585 {
1586 VEC_free (breakpoint_p, tp_vec);
1587 error (_("No tracepoints defined, not starting trace"));
1588 }
1589
1590 for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
1591 {
1592 if (b->enable_state == bp_enabled)
1593 any_enabled = 1;
1594
1595 if ((b->type == bp_fast_tracepoint
1596 ? may_insert_fast_tracepoints
1597 : may_insert_tracepoints))
1598 ++num_to_download;
1599 else
1600 warning (_("May not insert %stracepoints, skipping tracepoint %d"),
1601 (b->type == bp_fast_tracepoint ? "fast " : ""), b->number);
1602 }
1603
1604 if (!any_enabled)
1605 {
1606 if (target_supports_enable_disable_tracepoint ())
1607 warning (_("No tracepoints enabled"));
1608 else
1609 {
1610 /* No point in tracing with only disabled tracepoints that
1611 cannot be re-enabled. */
1612 VEC_free (breakpoint_p, tp_vec);
1613 error (_("No tracepoints enabled, not starting trace"));
1614 }
1615 }
1616
1617 if (num_to_download <= 0)
1618 {
1619 VEC_free (breakpoint_p, tp_vec);
1620 error (_("No tracepoints that may be downloaded, not starting trace"));
1621 }
1622
1623 target_trace_init ();
1624
1625 for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
1626 {
1627 struct tracepoint *t = (struct tracepoint *) b;
1628 struct bp_location *loc;
1629 int bp_location_downloaded = 0;
1630
1631 /* Clear `inserted' flag. */
1632 for (loc = b->loc; loc; loc = loc->next)
1633 loc->inserted = 0;
1634
1635 if ((b->type == bp_fast_tracepoint
1636 ? !may_insert_fast_tracepoints
1637 : !may_insert_tracepoints))
1638 continue;
1639
1640 t->number_on_target = 0;
1641
1642 for (loc = b->loc; loc; loc = loc->next)
1643 {
1644 /* Since tracepoint locations are never duplicated, `inserted'
1645 flag should be zero. */
1646 gdb_assert (!loc->inserted);
1647
1648 target_download_tracepoint (loc);
1649
1650 loc->inserted = 1;
1651 bp_location_downloaded = 1;
1652 }
1653
1654 t->number_on_target = b->number;
1655
1656 for (loc = b->loc; loc; loc = loc->next)
1657 if (loc->probe.prob != NULL)
1658 loc->probe.prob->set_semaphore (loc->probe.objfile,
1659 loc->gdbarch);
1660
1661 if (bp_location_downloaded)
1662 observer_notify_breakpoint_modified (b);
1663 }
1664 VEC_free (breakpoint_p, tp_vec);
1665
1666 /* Send down all the trace state variables too. */
1667 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
1668 {
1669 target_download_trace_state_variable (tsv);
1670 }
1671
1672 /* Tell target to treat text-like sections as transparent. */
1673 target_trace_set_readonly_regions ();
1674 /* Set some mode flags. */
1675 target_set_disconnected_tracing (disconnected_tracing);
1676 target_set_circular_trace_buffer (circular_trace_buffer);
1677 target_set_trace_buffer_size (trace_buffer_size);
1678
1679 if (!notes)
1680 notes = trace_notes;
1681 ret = target_set_trace_notes (trace_user, notes, NULL);
1682
1683 if (!ret && (trace_user || notes))
1684 warning (_("Target does not support trace user/notes, info ignored"));
1685
1686 /* Now insert traps and begin collecting data. */
1687 target_trace_start ();
1688
1689 /* Reset our local state. */
1690 trace_reset_local_state ();
1691 current_trace_status()->running = 1;
1692 }
1693
1694 /* The tstart command requests the target to start a new trace run.
1695 The command passes any arguments it has to the target verbatim, as
1696 an optional "trace note". This is useful as for instance a warning
1697 to other users if the trace runs disconnected, and you don't want
1698 anybody else messing with the target. */
1699
1700 static void
1701 tstart_command (const char *args, int from_tty)
1702 {
1703 dont_repeat (); /* Like "run", dangerous to repeat accidentally. */
1704
1705 if (current_trace_status ()->running)
1706 {
1707 if (from_tty
1708 && !query (_("A trace is running already. Start a new run? ")))
1709 error (_("New trace run not started."));
1710 }
1711
1712 start_tracing (args);
1713 }
1714
1715 /* The tstop command stops the tracing run. The command passes any
1716 supplied arguments to the target verbatim as a "stop note"; if the
1717 target supports trace notes, then it will be reported back as part
1718 of the trace run's status. */
1719
1720 static void
1721 tstop_command (const char *args, int from_tty)
1722 {
1723 if (!current_trace_status ()->running)
1724 error (_("Trace is not running."));
1725
1726 stop_tracing (args);
1727 }
1728
1729 void
1730 stop_tracing (const char *note)
1731 {
1732 int ret;
1733 VEC(breakpoint_p) *tp_vec = NULL;
1734 int ix;
1735 struct breakpoint *t;
1736
1737 target_trace_stop ();
1738
1739 tp_vec = all_tracepoints ();
1740 for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
1741 {
1742 struct bp_location *loc;
1743
1744 if ((t->type == bp_fast_tracepoint
1745 ? !may_insert_fast_tracepoints
1746 : !may_insert_tracepoints))
1747 continue;
1748
1749 for (loc = t->loc; loc; loc = loc->next)
1750 {
1751 /* GDB can be totally absent in some disconnected trace scenarios,
1752 but we don't really care if this semaphore goes out of sync.
1753 That's why we are decrementing it here, but not taking care
1754 in other places. */
1755 if (loc->probe.prob != NULL)
1756 loc->probe.prob->clear_semaphore (loc->probe.objfile,
1757 loc->gdbarch);
1758 }
1759 }
1760
1761 VEC_free (breakpoint_p, tp_vec);
1762
1763 if (!note)
1764 note = trace_stop_notes;
1765 ret = target_set_trace_notes (NULL, NULL, note);
1766
1767 if (!ret && note)
1768 warning (_("Target does not support trace notes, note ignored"));
1769
1770 /* Should change in response to reply? */
1771 current_trace_status ()->running = 0;
1772 }
1773
1774 /* tstatus command */
1775 static void
1776 tstatus_command (const char *args, int from_tty)
1777 {
1778 struct trace_status *ts = current_trace_status ();
1779 int status, ix;
1780 VEC(breakpoint_p) *tp_vec = NULL;
1781 struct breakpoint *t;
1782
1783 status = target_get_trace_status (ts);
1784
1785 if (status == -1)
1786 {
1787 if (ts->filename != NULL)
1788 printf_filtered (_("Using a trace file.\n"));
1789 else
1790 {
1791 printf_filtered (_("Trace can not be run on this target.\n"));
1792 return;
1793 }
1794 }
1795
1796 if (!ts->running_known)
1797 {
1798 printf_filtered (_("Run/stop status is unknown.\n"));
1799 }
1800 else if (ts->running)
1801 {
1802 printf_filtered (_("Trace is running on the target.\n"));
1803 }
1804 else
1805 {
1806 switch (ts->stop_reason)
1807 {
1808 case trace_never_run:
1809 printf_filtered (_("No trace has been run on the target.\n"));
1810 break;
1811 case trace_stop_command:
1812 if (ts->stop_desc)
1813 printf_filtered (_("Trace stopped by a tstop command (%s).\n"),
1814 ts->stop_desc);
1815 else
1816 printf_filtered (_("Trace stopped by a tstop command.\n"));
1817 break;
1818 case trace_buffer_full:
1819 printf_filtered (_("Trace stopped because the buffer was full.\n"));
1820 break;
1821 case trace_disconnected:
1822 printf_filtered (_("Trace stopped because of disconnection.\n"));
1823 break;
1824 case tracepoint_passcount:
1825 printf_filtered (_("Trace stopped by tracepoint %d.\n"),
1826 ts->stopping_tracepoint);
1827 break;
1828 case tracepoint_error:
1829 if (ts->stopping_tracepoint)
1830 printf_filtered (_("Trace stopped by an "
1831 "error (%s, tracepoint %d).\n"),
1832 ts->stop_desc, ts->stopping_tracepoint);
1833 else
1834 printf_filtered (_("Trace stopped by an error (%s).\n"),
1835 ts->stop_desc);
1836 break;
1837 case trace_stop_reason_unknown:
1838 printf_filtered (_("Trace stopped for an unknown reason.\n"));
1839 break;
1840 default:
1841 printf_filtered (_("Trace stopped for some other reason (%d).\n"),
1842 ts->stop_reason);
1843 break;
1844 }
1845 }
1846
1847 if (ts->traceframes_created >= 0
1848 && ts->traceframe_count != ts->traceframes_created)
1849 {
1850 printf_filtered (_("Buffer contains %d trace "
1851 "frames (of %d created total).\n"),
1852 ts->traceframe_count, ts->traceframes_created);
1853 }
1854 else if (ts->traceframe_count >= 0)
1855 {
1856 printf_filtered (_("Collected %d trace frames.\n"),
1857 ts->traceframe_count);
1858 }
1859
1860 if (ts->buffer_free >= 0)
1861 {
1862 if (ts->buffer_size >= 0)
1863 {
1864 printf_filtered (_("Trace buffer has %d bytes of %d bytes free"),
1865 ts->buffer_free, ts->buffer_size);
1866 if (ts->buffer_size > 0)
1867 printf_filtered (_(" (%d%% full)"),
1868 ((int) ((((long long) (ts->buffer_size
1869 - ts->buffer_free)) * 100)
1870 / ts->buffer_size)));
1871 printf_filtered (_(".\n"));
1872 }
1873 else
1874 printf_filtered (_("Trace buffer has %d bytes free.\n"),
1875 ts->buffer_free);
1876 }
1877
1878 if (ts->disconnected_tracing)
1879 printf_filtered (_("Trace will continue if GDB disconnects.\n"));
1880 else
1881 printf_filtered (_("Trace will stop if GDB disconnects.\n"));
1882
1883 if (ts->circular_buffer)
1884 printf_filtered (_("Trace buffer is circular.\n"));
1885
1886 if (ts->user_name && strlen (ts->user_name) > 0)
1887 printf_filtered (_("Trace user is %s.\n"), ts->user_name);
1888
1889 if (ts->notes && strlen (ts->notes) > 0)
1890 printf_filtered (_("Trace notes: %s.\n"), ts->notes);
1891
1892 /* Now report on what we're doing with tfind. */
1893 if (traceframe_number >= 0)
1894 printf_filtered (_("Looking at trace frame %d, tracepoint %d.\n"),
1895 traceframe_number, tracepoint_number);
1896 else
1897 printf_filtered (_("Not looking at any trace frame.\n"));
1898
1899 /* Report start/stop times if supplied. */
1900 if (ts->start_time)
1901 {
1902 if (ts->stop_time)
1903 {
1904 LONGEST run_time = ts->stop_time - ts->start_time;
1905
1906 /* Reporting a run time is more readable than two long numbers. */
1907 printf_filtered (_("Trace started at %ld.%06ld secs, stopped %ld.%06ld secs later.\n"),
1908 (long int) (ts->start_time / 1000000),
1909 (long int) (ts->start_time % 1000000),
1910 (long int) (run_time / 1000000),
1911 (long int) (run_time % 1000000));
1912 }
1913 else
1914 printf_filtered (_("Trace started at %ld.%06ld secs.\n"),
1915 (long int) (ts->start_time / 1000000),
1916 (long int) (ts->start_time % 1000000));
1917 }
1918 else if (ts->stop_time)
1919 printf_filtered (_("Trace stopped at %ld.%06ld secs.\n"),
1920 (long int) (ts->stop_time / 1000000),
1921 (long int) (ts->stop_time % 1000000));
1922
1923 /* Now report any per-tracepoint status available. */
1924 tp_vec = all_tracepoints ();
1925
1926 for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
1927 target_get_tracepoint_status (t, NULL);
1928
1929 VEC_free (breakpoint_p, tp_vec);
1930 }
1931
1932 /* Report the trace status to uiout, in a way suitable for MI, and not
1933 suitable for CLI. If ON_STOP is true, suppress a few fields that
1934 are not meaningful in the -trace-stop response.
1935
1936 The implementation is essentially parallel to trace_status_command, but
1937 merging them will result in unreadable code. */
1938 void
1939 trace_status_mi (int on_stop)
1940 {
1941 struct ui_out *uiout = current_uiout;
1942 struct trace_status *ts = current_trace_status ();
1943 int status;
1944
1945 status = target_get_trace_status (ts);
1946
1947 if (status == -1 && ts->filename == NULL)
1948 {
1949 uiout->field_string ("supported", "0");
1950 return;
1951 }
1952
1953 if (ts->filename != NULL)
1954 uiout->field_string ("supported", "file");
1955 else if (!on_stop)
1956 uiout->field_string ("supported", "1");
1957
1958 if (ts->filename != NULL)
1959 uiout->field_string ("trace-file", ts->filename);
1960
1961 gdb_assert (ts->running_known);
1962
1963 if (ts->running)
1964 {
1965 uiout->field_string ("running", "1");
1966
1967 /* Unlike CLI, do not show the state of 'disconnected-tracing' variable.
1968 Given that the frontend gets the status either on -trace-stop, or from
1969 -trace-status after re-connection, it does not seem like this
1970 information is necessary for anything. It is not necessary for either
1971 figuring the vital state of the target nor for navigation of trace
1972 frames. If the frontend wants to show the current state is some
1973 configure dialog, it can request the value when such dialog is
1974 invoked by the user. */
1975 }
1976 else
1977 {
1978 const char *stop_reason = NULL;
1979 int stopping_tracepoint = -1;
1980
1981 if (!on_stop)
1982 uiout->field_string ("running", "0");
1983
1984 if (ts->stop_reason != trace_stop_reason_unknown)
1985 {
1986 switch (ts->stop_reason)
1987 {
1988 case trace_stop_command:
1989 stop_reason = "request";
1990 break;
1991 case trace_buffer_full:
1992 stop_reason = "overflow";
1993 break;
1994 case trace_disconnected:
1995 stop_reason = "disconnection";
1996 break;
1997 case tracepoint_passcount:
1998 stop_reason = "passcount";
1999 stopping_tracepoint = ts->stopping_tracepoint;
2000 break;
2001 case tracepoint_error:
2002 stop_reason = "error";
2003 stopping_tracepoint = ts->stopping_tracepoint;
2004 break;
2005 }
2006
2007 if (stop_reason)
2008 {
2009 uiout->field_string ("stop-reason", stop_reason);
2010 if (stopping_tracepoint != -1)
2011 uiout->field_int ("stopping-tracepoint",
2012 stopping_tracepoint);
2013 if (ts->stop_reason == tracepoint_error)
2014 uiout->field_string ("error-description",
2015 ts->stop_desc);
2016 }
2017 }
2018 }
2019
2020 if (ts->traceframe_count != -1)
2021 uiout->field_int ("frames", ts->traceframe_count);
2022 if (ts->traceframes_created != -1)
2023 uiout->field_int ("frames-created", ts->traceframes_created);
2024 if (ts->buffer_size != -1)
2025 uiout->field_int ("buffer-size", ts->buffer_size);
2026 if (ts->buffer_free != -1)
2027 uiout->field_int ("buffer-free", ts->buffer_free);
2028
2029 uiout->field_int ("disconnected", ts->disconnected_tracing);
2030 uiout->field_int ("circular", ts->circular_buffer);
2031
2032 uiout->field_string ("user-name", ts->user_name);
2033 uiout->field_string ("notes", ts->notes);
2034
2035 {
2036 char buf[100];
2037
2038 xsnprintf (buf, sizeof buf, "%ld.%06ld",
2039 (long int) (ts->start_time / 1000000),
2040 (long int) (ts->start_time % 1000000));
2041 uiout->field_string ("start-time", buf);
2042 xsnprintf (buf, sizeof buf, "%ld.%06ld",
2043 (long int) (ts->stop_time / 1000000),
2044 (long int) (ts->stop_time % 1000000));
2045 uiout->field_string ("stop-time", buf);
2046 }
2047 }
2048
2049 /* Check if a trace run is ongoing. If so, and FROM_TTY, query the
2050 user if she really wants to detach. */
2051
2052 void
2053 query_if_trace_running (int from_tty)
2054 {
2055 if (!from_tty)
2056 return;
2057
2058 /* It can happen that the target that was tracing went away on its
2059 own, and we didn't notice. Get a status update, and if the
2060 current target doesn't even do tracing, then assume it's not
2061 running anymore. */
2062 if (target_get_trace_status (current_trace_status ()) < 0)
2063 current_trace_status ()->running = 0;
2064
2065 /* If running interactively, give the user the option to cancel and
2066 then decide what to do differently with the run. Scripts are
2067 just going to disconnect and let the target deal with it,
2068 according to how it's been instructed previously via
2069 disconnected-tracing. */
2070 if (current_trace_status ()->running)
2071 {
2072 process_tracepoint_on_disconnect ();
2073
2074 if (current_trace_status ()->disconnected_tracing)
2075 {
2076 if (!query (_("Trace is running and will "
2077 "continue after detach; detach anyway? ")))
2078 error (_("Not confirmed."));
2079 }
2080 else
2081 {
2082 if (!query (_("Trace is running but will "
2083 "stop on detach; detach anyway? ")))
2084 error (_("Not confirmed."));
2085 }
2086 }
2087 }
2088
2089 /* This function handles the details of what to do about an ongoing
2090 tracing run if the user has asked to detach or otherwise disconnect
2091 from the target. */
2092
2093 void
2094 disconnect_tracing (void)
2095 {
2096 /* Also we want to be out of tfind mode, otherwise things can get
2097 confusing upon reconnection. Just use these calls instead of
2098 full tfind_1 behavior because we're in the middle of detaching,
2099 and there's no point to updating current stack frame etc. */
2100 trace_reset_local_state ();
2101 }
2102
2103 /* Worker function for the various flavors of the tfind command. */
2104 void
2105 tfind_1 (enum trace_find_type type, int num,
2106 CORE_ADDR addr1, CORE_ADDR addr2,
2107 int from_tty)
2108 {
2109 int target_frameno = -1, target_tracept = -1;
2110 struct frame_id old_frame_id = null_frame_id;
2111 struct tracepoint *tp;
2112 struct ui_out *uiout = current_uiout;
2113
2114 /* Only try to get the current stack frame if we have a chance of
2115 succeeding. In particular, if we're trying to get a first trace
2116 frame while all threads are running, it's not going to succeed,
2117 so leave it with a default value and let the frame comparison
2118 below (correctly) decide to print out the source location of the
2119 trace frame. */
2120 if (!(type == tfind_number && num == -1)
2121 && (has_stack_frames () || traceframe_number >= 0))
2122 old_frame_id = get_frame_id (get_current_frame ());
2123
2124 target_frameno = target_trace_find (type, num, addr1, addr2,
2125 &target_tracept);
2126
2127 if (type == tfind_number
2128 && num == -1
2129 && target_frameno == -1)
2130 {
2131 /* We told the target to get out of tfind mode, and it did. */
2132 }
2133 else if (target_frameno == -1)
2134 {
2135 /* A request for a non-existent trace frame has failed.
2136 Our response will be different, depending on FROM_TTY:
2137
2138 If FROM_TTY is true, meaning that this command was
2139 typed interactively by the user, then give an error
2140 and DO NOT change the state of traceframe_number etc.
2141
2142 However if FROM_TTY is false, meaning that we're either
2143 in a script, a loop, or a user-defined command, then
2144 DON'T give an error, but DO change the state of
2145 traceframe_number etc. to invalid.
2146
2147 The rationalle is that if you typed the command, you
2148 might just have committed a typo or something, and you'd
2149 like to NOT lose your current debugging state. However
2150 if you're in a user-defined command or especially in a
2151 loop, then you need a way to detect that the command
2152 failed WITHOUT aborting. This allows you to write
2153 scripts that search thru the trace buffer until the end,
2154 and then continue on to do something else. */
2155
2156 if (from_tty)
2157 error (_("Target failed to find requested trace frame."));
2158 else
2159 {
2160 if (info_verbose)
2161 printf_filtered ("End of trace buffer.\n");
2162 #if 0 /* dubious now? */
2163 /* The following will not recurse, since it's
2164 special-cased. */
2165 tfind_command ("-1", from_tty);
2166 #endif
2167 }
2168 }
2169
2170 tp = get_tracepoint_by_number_on_target (target_tracept);
2171
2172 reinit_frame_cache ();
2173 target_dcache_invalidate ();
2174
2175 set_tracepoint_num (tp ? tp->number : target_tracept);
2176
2177 if (target_frameno != get_traceframe_number ())
2178 observer_notify_traceframe_changed (target_frameno, tracepoint_number);
2179
2180 set_current_traceframe (target_frameno);
2181
2182 if (target_frameno == -1)
2183 set_traceframe_context (NULL);
2184 else
2185 set_traceframe_context (get_current_frame ());
2186
2187 if (traceframe_number >= 0)
2188 {
2189 /* Use different branches for MI and CLI to make CLI messages
2190 i18n-eable. */
2191 if (uiout->is_mi_like_p ())
2192 {
2193 uiout->field_string ("found", "1");
2194 uiout->field_int ("tracepoint", tracepoint_number);
2195 uiout->field_int ("traceframe", traceframe_number);
2196 }
2197 else
2198 {
2199 printf_unfiltered (_("Found trace frame %d, tracepoint %d\n"),
2200 traceframe_number, tracepoint_number);
2201 }
2202 }
2203 else
2204 {
2205 if (uiout->is_mi_like_p ())
2206 uiout->field_string ("found", "0");
2207 else if (type == tfind_number && num == -1)
2208 printf_unfiltered (_("No longer looking at any trace frame\n"));
2209 else /* This case may never occur, check. */
2210 printf_unfiltered (_("No trace frame found\n"));
2211 }
2212
2213 /* If we're in nonstop mode and getting out of looking at trace
2214 frames, there won't be any current frame to go back to and
2215 display. */
2216 if (from_tty
2217 && (has_stack_frames () || traceframe_number >= 0))
2218 {
2219 enum print_what print_what;
2220
2221 /* NOTE: in imitation of the step command, try to determine
2222 whether we have made a transition from one function to
2223 another. If so, we'll print the "stack frame" (ie. the new
2224 function and it's arguments) -- otherwise we'll just show the
2225 new source line. */
2226
2227 if (frame_id_eq (old_frame_id,
2228 get_frame_id (get_current_frame ())))
2229 print_what = SRC_LINE;
2230 else
2231 print_what = SRC_AND_LOC;
2232
2233 print_stack_frame (get_selected_frame (NULL), 1, print_what, 1);
2234 do_displays ();
2235 }
2236 }
2237
2238 /* Error on looking at traceframes while trace is running. */
2239
2240 void
2241 check_trace_running (struct trace_status *status)
2242 {
2243 if (status->running && status->filename == NULL)
2244 error (_("May not look at trace frames while trace is running."));
2245 }
2246
2247 /* trace_find_command takes a trace frame number n,
2248 sends "QTFrame:<n>" to the target,
2249 and accepts a reply that may contain several optional pieces
2250 of information: a frame number, a tracepoint number, and an
2251 indication of whether this is a trap frame or a stepping frame.
2252
2253 The minimal response is just "OK" (which indicates that the
2254 target does not give us a frame number or a tracepoint number).
2255 Instead of that, the target may send us a string containing
2256 any combination of:
2257 F<hexnum> (gives the selected frame number)
2258 T<hexnum> (gives the selected tracepoint number)
2259 */
2260
2261 /* tfind command */
2262 static void
2263 tfind_command_1 (const char *args, int from_tty)
2264 { /* This should only be called with a numeric argument. */
2265 int frameno = -1;
2266
2267 check_trace_running (current_trace_status ());
2268
2269 if (args == 0 || *args == 0)
2270 { /* TFIND with no args means find NEXT trace frame. */
2271 if (traceframe_number == -1)
2272 frameno = 0; /* "next" is first one. */
2273 else
2274 frameno = traceframe_number + 1;
2275 }
2276 else if (0 == strcmp (args, "-"))
2277 {
2278 if (traceframe_number == -1)
2279 error (_("not debugging trace buffer"));
2280 else if (from_tty && traceframe_number == 0)
2281 error (_("already at start of trace buffer"));
2282
2283 frameno = traceframe_number - 1;
2284 }
2285 /* A hack to work around eval's need for fp to have been collected. */
2286 else if (0 == strcmp (args, "-1"))
2287 frameno = -1;
2288 else
2289 frameno = parse_and_eval_long (args);
2290
2291 if (frameno < -1)
2292 error (_("invalid input (%d is less than zero)"), frameno);
2293
2294 tfind_1 (tfind_number, frameno, 0, 0, from_tty);
2295 }
2296
2297 static void
2298 tfind_command (const char *args, int from_tty)
2299 {
2300 tfind_command_1 (args, from_tty);
2301 }
2302
2303 /* tfind end */
2304 static void
2305 tfind_end_command (const char *args, int from_tty)
2306 {
2307 tfind_command_1 ("-1", from_tty);
2308 }
2309
2310 /* tfind start */
2311 static void
2312 tfind_start_command (const char *args, int from_tty)
2313 {
2314 tfind_command_1 ("0", from_tty);
2315 }
2316
2317 /* tfind pc command */
2318 static void
2319 tfind_pc_command (const char *args, int from_tty)
2320 {
2321 CORE_ADDR pc;
2322
2323 check_trace_running (current_trace_status ());
2324
2325 if (args == 0 || *args == 0)
2326 pc = regcache_read_pc (get_current_regcache ());
2327 else
2328 pc = parse_and_eval_address (args);
2329
2330 tfind_1 (tfind_pc, 0, pc, 0, from_tty);
2331 }
2332
2333 /* tfind tracepoint command */
2334 static void
2335 tfind_tracepoint_command (const char *args, int from_tty)
2336 {
2337 int tdp;
2338 struct tracepoint *tp;
2339
2340 check_trace_running (current_trace_status ());
2341
2342 if (args == 0 || *args == 0)
2343 {
2344 if (tracepoint_number == -1)
2345 error (_("No current tracepoint -- please supply an argument."));
2346 else
2347 tdp = tracepoint_number; /* Default is current TDP. */
2348 }
2349 else
2350 tdp = parse_and_eval_long (args);
2351
2352 /* If we have the tracepoint on hand, use the number that the
2353 target knows about (which may be different if we disconnected
2354 and reconnected). */
2355 tp = get_tracepoint (tdp);
2356 if (tp)
2357 tdp = tp->number_on_target;
2358
2359 tfind_1 (tfind_tp, tdp, 0, 0, from_tty);
2360 }
2361
2362 /* TFIND LINE command:
2363
2364 This command will take a sourceline for argument, just like BREAK
2365 or TRACE (ie. anything that "decode_line_1" can handle).
2366
2367 With no argument, this command will find the next trace frame
2368 corresponding to a source line OTHER THAN THE CURRENT ONE. */
2369
2370 static void
2371 tfind_line_command (const char *args, int from_tty)
2372 {
2373 check_trace_running (current_trace_status ());
2374
2375 symtab_and_line sal;
2376 if (args == 0 || *args == 0)
2377 {
2378 sal = find_pc_line (get_frame_pc (get_current_frame ()), 0);
2379 }
2380 else
2381 {
2382 std::vector<symtab_and_line> sals
2383 = decode_line_with_current_source (args, DECODE_LINE_FUNFIRSTLINE);
2384 sal = sals[0];
2385 }
2386
2387 if (sal.symtab == 0)
2388 error (_("No line number information available."));
2389
2390 CORE_ADDR start_pc, end_pc;
2391 if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc))
2392 {
2393 if (start_pc == end_pc)
2394 {
2395 printf_filtered ("Line %d of \"%s\"",
2396 sal.line,
2397 symtab_to_filename_for_display (sal.symtab));
2398 wrap_here (" ");
2399 printf_filtered (" is at address ");
2400 print_address (get_current_arch (), start_pc, gdb_stdout);
2401 wrap_here (" ");
2402 printf_filtered (" but contains no code.\n");
2403 sal = find_pc_line (start_pc, 0);
2404 if (sal.line > 0
2405 && find_line_pc_range (sal, &start_pc, &end_pc)
2406 && start_pc != end_pc)
2407 printf_filtered ("Attempting to find line %d instead.\n",
2408 sal.line);
2409 else
2410 error (_("Cannot find a good line."));
2411 }
2412 }
2413 else
2414 /* Is there any case in which we get here, and have an address
2415 which the user would want to see? If we have debugging
2416 symbols and no line numbers? */
2417 error (_("Line number %d is out of range for \"%s\"."),
2418 sal.line, symtab_to_filename_for_display (sal.symtab));
2419
2420 /* Find within range of stated line. */
2421 if (args && *args)
2422 tfind_1 (tfind_range, 0, start_pc, end_pc - 1, from_tty);
2423 else
2424 tfind_1 (tfind_outside, 0, start_pc, end_pc - 1, from_tty);
2425 }
2426
2427 /* tfind range command */
2428 static void
2429 tfind_range_command (const char *args, int from_tty)
2430 {
2431 static CORE_ADDR start, stop;
2432 const char *tmp;
2433
2434 check_trace_running (current_trace_status ());
2435
2436 if (args == 0 || *args == 0)
2437 { /* XXX FIXME: what should default behavior be? */
2438 printf_filtered ("Usage: tfind range <startaddr>,<endaddr>\n");
2439 return;
2440 }
2441
2442 if (0 != (tmp = strchr (args, ',')))
2443 {
2444 std::string start_addr (args, tmp);
2445 ++tmp;
2446 tmp = skip_spaces (tmp);
2447 start = parse_and_eval_address (start_addr.c_str ());
2448 stop = parse_and_eval_address (tmp);
2449 }
2450 else
2451 { /* No explicit end address? */
2452 start = parse_and_eval_address (args);
2453 stop = start + 1; /* ??? */
2454 }
2455
2456 tfind_1 (tfind_range, 0, start, stop, from_tty);
2457 }
2458
2459 /* tfind outside command */
2460 static void
2461 tfind_outside_command (const char *args, int from_tty)
2462 {
2463 CORE_ADDR start, stop;
2464 const char *tmp;
2465
2466 if (current_trace_status ()->running
2467 && current_trace_status ()->filename == NULL)
2468 error (_("May not look at trace frames while trace is running."));
2469
2470 if (args == 0 || *args == 0)
2471 { /* XXX FIXME: what should default behavior be? */
2472 printf_filtered ("Usage: tfind outside <startaddr>,<endaddr>\n");
2473 return;
2474 }
2475
2476 if (0 != (tmp = strchr (args, ',')))
2477 {
2478 std::string start_addr (args, tmp);
2479 ++tmp;
2480 tmp = skip_spaces (tmp);
2481 start = parse_and_eval_address (start_addr.c_str ());
2482 stop = parse_and_eval_address (tmp);
2483 }
2484 else
2485 { /* No explicit end address? */
2486 start = parse_and_eval_address (args);
2487 stop = start + 1; /* ??? */
2488 }
2489
2490 tfind_1 (tfind_outside, 0, start, stop, from_tty);
2491 }
2492
2493 /* info scope command: list the locals for a scope. */
2494 static void
2495 info_scope_command (const char *args_in, int from_tty)
2496 {
2497 struct symbol *sym;
2498 struct bound_minimal_symbol msym;
2499 const struct block *block;
2500 const char *symname;
2501 const char *save_args = args_in;
2502 struct block_iterator iter;
2503 int j, count = 0;
2504 struct gdbarch *gdbarch;
2505 int regno;
2506 const char *args = args_in;
2507
2508 if (args == 0 || *args == 0)
2509 error (_("requires an argument (function, "
2510 "line or *addr) to define a scope"));
2511
2512 event_location_up location = string_to_event_location (&args,
2513 current_language);
2514 std::vector<symtab_and_line> sals
2515 = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE,
2516 NULL, NULL, 0);
2517 if (sals.empty ())
2518 {
2519 /* Presumably decode_line_1 has already warned. */
2520 return;
2521 }
2522
2523 /* Resolve line numbers to PC. */
2524 resolve_sal_pc (&sals[0]);
2525 block = block_for_pc (sals[0].pc);
2526
2527 while (block != 0)
2528 {
2529 QUIT; /* Allow user to bail out with ^C. */
2530 ALL_BLOCK_SYMBOLS (block, iter, sym)
2531 {
2532 QUIT; /* Allow user to bail out with ^C. */
2533 if (count == 0)
2534 printf_filtered ("Scope for %s:\n", save_args);
2535 count++;
2536
2537 symname = SYMBOL_PRINT_NAME (sym);
2538 if (symname == NULL || *symname == '\0')
2539 continue; /* Probably botched, certainly useless. */
2540
2541 gdbarch = symbol_arch (sym);
2542
2543 printf_filtered ("Symbol %s is ", symname);
2544
2545 if (SYMBOL_COMPUTED_OPS (sym) != NULL)
2546 SYMBOL_COMPUTED_OPS (sym)->describe_location (sym,
2547 BLOCK_START (block),
2548 gdb_stdout);
2549 else
2550 {
2551 switch (SYMBOL_CLASS (sym))
2552 {
2553 default:
2554 case LOC_UNDEF: /* Messed up symbol? */
2555 printf_filtered ("a bogus symbol, class %d.\n",
2556 SYMBOL_CLASS (sym));
2557 count--; /* Don't count this one. */
2558 continue;
2559 case LOC_CONST:
2560 printf_filtered ("a constant with value %s (%s)",
2561 plongest (SYMBOL_VALUE (sym)),
2562 hex_string (SYMBOL_VALUE (sym)));
2563 break;
2564 case LOC_CONST_BYTES:
2565 printf_filtered ("constant bytes: ");
2566 if (SYMBOL_TYPE (sym))
2567 for (j = 0; j < TYPE_LENGTH (SYMBOL_TYPE (sym)); j++)
2568 fprintf_filtered (gdb_stdout, " %02x",
2569 (unsigned) SYMBOL_VALUE_BYTES (sym)[j]);
2570 break;
2571 case LOC_STATIC:
2572 printf_filtered ("in static storage at address ");
2573 printf_filtered ("%s", paddress (gdbarch,
2574 SYMBOL_VALUE_ADDRESS (sym)));
2575 break;
2576 case LOC_REGISTER:
2577 /* GDBARCH is the architecture associated with the objfile
2578 the symbol is defined in; the target architecture may be
2579 different, and may provide additional registers. However,
2580 we do not know the target architecture at this point.
2581 We assume the objfile architecture will contain all the
2582 standard registers that occur in debug info in that
2583 objfile. */
2584 regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym,
2585 gdbarch);
2586
2587 if (SYMBOL_IS_ARGUMENT (sym))
2588 printf_filtered ("an argument in register $%s",
2589 gdbarch_register_name (gdbarch, regno));
2590 else
2591 printf_filtered ("a local variable in register $%s",
2592 gdbarch_register_name (gdbarch, regno));
2593 break;
2594 case LOC_ARG:
2595 printf_filtered ("an argument at stack/frame offset %s",
2596 plongest (SYMBOL_VALUE (sym)));
2597 break;
2598 case LOC_LOCAL:
2599 printf_filtered ("a local variable at frame offset %s",
2600 plongest (SYMBOL_VALUE (sym)));
2601 break;
2602 case LOC_REF_ARG:
2603 printf_filtered ("a reference argument at offset %s",
2604 plongest (SYMBOL_VALUE (sym)));
2605 break;
2606 case LOC_REGPARM_ADDR:
2607 /* Note comment at LOC_REGISTER. */
2608 regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym,
2609 gdbarch);
2610 printf_filtered ("the address of an argument, in register $%s",
2611 gdbarch_register_name (gdbarch, regno));
2612 break;
2613 case LOC_TYPEDEF:
2614 printf_filtered ("a typedef.\n");
2615 continue;
2616 case LOC_LABEL:
2617 printf_filtered ("a label at address ");
2618 printf_filtered ("%s", paddress (gdbarch,
2619 SYMBOL_VALUE_ADDRESS (sym)));
2620 break;
2621 case LOC_BLOCK:
2622 printf_filtered ("a function at address ");
2623 printf_filtered ("%s",
2624 paddress (gdbarch, BLOCK_START (SYMBOL_BLOCK_VALUE (sym))));
2625 break;
2626 case LOC_UNRESOLVED:
2627 msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym),
2628 NULL, NULL);
2629 if (msym.minsym == NULL)
2630 printf_filtered ("Unresolved Static");
2631 else
2632 {
2633 printf_filtered ("static storage at address ");
2634 printf_filtered ("%s",
2635 paddress (gdbarch,
2636 BMSYMBOL_VALUE_ADDRESS (msym)));
2637 }
2638 break;
2639 case LOC_OPTIMIZED_OUT:
2640 printf_filtered ("optimized out.\n");
2641 continue;
2642 case LOC_COMPUTED:
2643 gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method"));
2644 }
2645 }
2646 if (SYMBOL_TYPE (sym))
2647 printf_filtered (", length %d.\n",
2648 TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym))));
2649 }
2650 if (BLOCK_FUNCTION (block))
2651 break;
2652 else
2653 block = BLOCK_SUPERBLOCK (block);
2654 }
2655 if (count <= 0)
2656 printf_filtered ("Scope for %s contains no locals or arguments.\n",
2657 save_args);
2658 }
2659
2660 /* Helper for trace_dump_command. Dump the action list starting at
2661 ACTION. STEPPING_ACTIONS is true if we're iterating over the
2662 actions of the body of a while-stepping action. STEPPING_FRAME is
2663 set if the current traceframe was determined to be a while-stepping
2664 traceframe. */
2665
2666 static void
2667 trace_dump_actions (struct command_line *action,
2668 int stepping_actions, int stepping_frame,
2669 int from_tty)
2670 {
2671 const char *action_exp, *next_comma;
2672
2673 for (; action != NULL; action = action->next)
2674 {
2675 struct cmd_list_element *cmd;
2676
2677 QUIT; /* Allow user to bail out with ^C. */
2678 action_exp = action->line;
2679 action_exp = skip_spaces (action_exp);
2680
2681 /* The collection actions to be done while stepping are
2682 bracketed by the commands "while-stepping" and "end". */
2683
2684 if (*action_exp == '#') /* comment line */
2685 continue;
2686
2687 cmd = lookup_cmd (&action_exp, cmdlist, "", -1, 1);
2688 if (cmd == 0)
2689 error (_("Bad action list item: %s"), action_exp);
2690
2691 if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand))
2692 {
2693 int i;
2694
2695 for (i = 0; i < action->body_count; ++i)
2696 trace_dump_actions (action->body_list[i],
2697 1, stepping_frame, from_tty);
2698 }
2699 else if (cmd_cfunc_eq (cmd, collect_pseudocommand))
2700 {
2701 /* Display the collected data.
2702 For the trap frame, display only what was collected at
2703 the trap. Likewise for stepping frames, display only
2704 what was collected while stepping. This means that the
2705 two boolean variables, STEPPING_FRAME and
2706 STEPPING_ACTIONS should be equal. */
2707 if (stepping_frame == stepping_actions)
2708 {
2709 char *cmd = NULL;
2710 struct cleanup *old_chain
2711 = make_cleanup (free_current_contents, &cmd);
2712 int trace_string = 0;
2713
2714 if (*action_exp == '/')
2715 action_exp = decode_agent_options (action_exp, &trace_string);
2716
2717 do
2718 { /* Repeat over a comma-separated list. */
2719 QUIT; /* Allow user to bail out with ^C. */
2720 if (*action_exp == ',')
2721 action_exp++;
2722 action_exp = skip_spaces (action_exp);
2723
2724 next_comma = strchr (action_exp, ',');
2725
2726 if (0 == strncasecmp (action_exp, "$reg", 4))
2727 registers_info (NULL, from_tty);
2728 else if (0 == strncasecmp (action_exp, "$_ret", 5))
2729 ;
2730 else if (0 == strncasecmp (action_exp, "$loc", 4))
2731 info_locals_command (NULL, from_tty);
2732 else if (0 == strncasecmp (action_exp, "$arg", 4))
2733 info_args_command (NULL, from_tty);
2734 else
2735 { /* variable */
2736 if (next_comma != NULL)
2737 {
2738 size_t len = next_comma - action_exp;
2739
2740 cmd = (char *) xrealloc (cmd, len + 1);
2741 memcpy (cmd, action_exp, len);
2742 cmd[len] = 0;
2743 }
2744 else
2745 {
2746 size_t len = strlen (action_exp);
2747
2748 cmd = (char *) xrealloc (cmd, len + 1);
2749 memcpy (cmd, action_exp, len + 1);
2750 }
2751
2752 printf_filtered ("%s = ", cmd);
2753 output_command_const (cmd, from_tty);
2754 printf_filtered ("\n");
2755 }
2756 action_exp = next_comma;
2757 }
2758 while (action_exp && *action_exp == ',');
2759
2760 do_cleanups (old_chain);
2761 }
2762 }
2763 }
2764 }
2765
2766 /* Return bp_location of the tracepoint associated with the current
2767 traceframe. Set *STEPPING_FRAME_P to 1 if the current traceframe
2768 is a stepping traceframe. */
2769
2770 struct bp_location *
2771 get_traceframe_location (int *stepping_frame_p)
2772 {
2773 struct tracepoint *t;
2774 struct bp_location *tloc;
2775 struct regcache *regcache;
2776
2777 if (tracepoint_number == -1)
2778 error (_("No current trace frame."));
2779
2780 t = get_tracepoint (tracepoint_number);
2781
2782 if (t == NULL)
2783 error (_("No known tracepoint matches 'current' tracepoint #%d."),
2784 tracepoint_number);
2785
2786 /* The current frame is a trap frame if the frame PC is equal to the
2787 tracepoint PC. If not, then the current frame was collected
2788 during single-stepping. */
2789 regcache = get_current_regcache ();
2790
2791 /* If the traceframe's address matches any of the tracepoint's
2792 locations, assume it is a direct hit rather than a while-stepping
2793 frame. (FIXME this is not reliable, should record each frame's
2794 type.) */
2795 for (tloc = t->loc; tloc; tloc = tloc->next)
2796 if (tloc->address == regcache_read_pc (regcache))
2797 {
2798 *stepping_frame_p = 0;
2799 return tloc;
2800 }
2801
2802 /* If this is a stepping frame, we don't know which location
2803 triggered. The first is as good (or bad) a guess as any... */
2804 *stepping_frame_p = 1;
2805 return t->loc;
2806 }
2807
2808 /* Return all the actions, including default collect, of a tracepoint
2809 T. It constructs cleanups into the chain, and leaves the caller to
2810 handle them (call do_cleanups). */
2811
2812 static struct command_line *
2813 all_tracepoint_actions_and_cleanup (struct breakpoint *t)
2814 {
2815 struct command_line *actions;
2816
2817 actions = breakpoint_commands (t);
2818
2819 /* If there are default expressions to collect, make up a collect
2820 action and prepend to the action list to encode. Note that since
2821 validation is per-tracepoint (local var "xyz" might be valid for
2822 one tracepoint and not another, etc), we make up the action on
2823 the fly, and don't cache it. */
2824 if (*default_collect)
2825 {
2826 struct command_line *default_collect_action;
2827 char *default_collect_line;
2828
2829 default_collect_line = xstrprintf ("collect %s", default_collect);
2830 make_cleanup (xfree, default_collect_line);
2831
2832 validate_actionline (default_collect_line, t);
2833 default_collect_action = XNEW (struct command_line);
2834 make_cleanup (xfree, default_collect_action);
2835 default_collect_action->next = actions;
2836 default_collect_action->line = default_collect_line;
2837 actions = default_collect_action;
2838 }
2839
2840 return actions;
2841 }
2842
2843 /* The tdump command. */
2844
2845 static void
2846 tdump_command (const char *args, int from_tty)
2847 {
2848 int stepping_frame = 0;
2849 struct bp_location *loc;
2850 struct command_line *actions;
2851
2852 /* This throws an error is not inspecting a trace frame. */
2853 loc = get_traceframe_location (&stepping_frame);
2854
2855 printf_filtered ("Data collected at tracepoint %d, trace frame %d:\n",
2856 tracepoint_number, traceframe_number);
2857
2858 /* This command only makes sense for the current frame, not the
2859 selected frame. */
2860 scoped_restore_current_thread restore_thread;
2861
2862 select_frame (get_current_frame ());
2863
2864 actions = all_tracepoint_actions_and_cleanup (loc->owner);
2865
2866 trace_dump_actions (actions, 0, stepping_frame, from_tty);
2867 }
2868
2869 /* Encode a piece of a tracepoint's source-level definition in a form
2870 that is suitable for both protocol and saving in files. */
2871 /* This version does not do multiple encodes for long strings; it should
2872 return an offset to the next piece to encode. FIXME */
2873
2874 int
2875 encode_source_string (int tpnum, ULONGEST addr,
2876 const char *srctype, const char *src,
2877 char *buf, int buf_size)
2878 {
2879 if (80 + strlen (srctype) > buf_size)
2880 error (_("Buffer too small for source encoding"));
2881 sprintf (buf, "%x:%s:%s:%x:%x:",
2882 tpnum, phex_nz (addr, sizeof (addr)),
2883 srctype, 0, (int) strlen (src));
2884 if (strlen (buf) + strlen (src) * 2 >= buf_size)
2885 error (_("Source string too long for buffer"));
2886 bin2hex ((gdb_byte *) src, buf + strlen (buf), strlen (src));
2887 return -1;
2888 }
2889
2890 /* Tell the target what to do with an ongoing tracing run if GDB
2891 disconnects for some reason. */
2892
2893 static void
2894 set_disconnected_tracing (const char *args, int from_tty,
2895 struct cmd_list_element *c)
2896 {
2897 target_set_disconnected_tracing (disconnected_tracing);
2898 }
2899
2900 static void
2901 set_circular_trace_buffer (const char *args, int from_tty,
2902 struct cmd_list_element *c)
2903 {
2904 target_set_circular_trace_buffer (circular_trace_buffer);
2905 }
2906
2907 static void
2908 set_trace_buffer_size (const char *args, int from_tty,
2909 struct cmd_list_element *c)
2910 {
2911 target_set_trace_buffer_size (trace_buffer_size);
2912 }
2913
2914 static void
2915 set_trace_user (const char *args, int from_tty,
2916 struct cmd_list_element *c)
2917 {
2918 int ret;
2919
2920 ret = target_set_trace_notes (trace_user, NULL, NULL);
2921
2922 if (!ret)
2923 warning (_("Target does not support trace notes, user ignored"));
2924 }
2925
2926 static void
2927 set_trace_notes (const char *args, int from_tty,
2928 struct cmd_list_element *c)
2929 {
2930 int ret;
2931
2932 ret = target_set_trace_notes (NULL, trace_notes, NULL);
2933
2934 if (!ret)
2935 warning (_("Target does not support trace notes, note ignored"));
2936 }
2937
2938 static void
2939 set_trace_stop_notes (const char *args, int from_tty,
2940 struct cmd_list_element *c)
2941 {
2942 int ret;
2943
2944 ret = target_set_trace_notes (NULL, NULL, trace_stop_notes);
2945
2946 if (!ret)
2947 warning (_("Target does not support trace notes, stop note ignored"));
2948 }
2949
2950 /* Convert the memory pointed to by mem into hex, placing result in buf.
2951 * Return a pointer to the last char put in buf (null)
2952 * "stolen" from sparc-stub.c
2953 */
2954
2955 static const char hexchars[] = "0123456789abcdef";
2956
2957 static char *
2958 mem2hex (gdb_byte *mem, char *buf, int count)
2959 {
2960 gdb_byte ch;
2961
2962 while (count-- > 0)
2963 {
2964 ch = *mem++;
2965
2966 *buf++ = hexchars[ch >> 4];
2967 *buf++ = hexchars[ch & 0xf];
2968 }
2969
2970 *buf = 0;
2971
2972 return buf;
2973 }
2974
2975 int
2976 get_traceframe_number (void)
2977 {
2978 return traceframe_number;
2979 }
2980
2981 int
2982 get_tracepoint_number (void)
2983 {
2984 return tracepoint_number;
2985 }
2986
2987 /* Make the traceframe NUM be the current trace frame. Does nothing
2988 if NUM is already current. */
2989
2990 void
2991 set_current_traceframe (int num)
2992 {
2993 int newnum;
2994
2995 if (traceframe_number == num)
2996 {
2997 /* Nothing to do. */
2998 return;
2999 }
3000
3001 newnum = target_trace_find (tfind_number, num, 0, 0, NULL);
3002
3003 if (newnum != num)
3004 warning (_("could not change traceframe"));
3005
3006 set_traceframe_num (newnum);
3007
3008 /* Changing the traceframe changes our view of registers and of the
3009 frame chain. */
3010 registers_changed ();
3011
3012 clear_traceframe_info ();
3013 }
3014
3015 /* A cleanup used when switching away and back from tfind mode. */
3016
3017 struct current_traceframe_cleanup
3018 {
3019 /* The traceframe we were inspecting. */
3020 int traceframe_number;
3021 };
3022
3023 static void
3024 do_restore_current_traceframe_cleanup (void *arg)
3025 {
3026 struct current_traceframe_cleanup *old
3027 = (struct current_traceframe_cleanup *) arg;
3028
3029 set_current_traceframe (old->traceframe_number);
3030 }
3031
3032 static void
3033 restore_current_traceframe_cleanup_dtor (void *arg)
3034 {
3035 struct current_traceframe_cleanup *old
3036 = (struct current_traceframe_cleanup *) arg;
3037
3038 xfree (old);
3039 }
3040
3041 struct cleanup *
3042 make_cleanup_restore_current_traceframe (void)
3043 {
3044 struct current_traceframe_cleanup *old =
3045 XNEW (struct current_traceframe_cleanup);
3046
3047 old->traceframe_number = traceframe_number;
3048
3049 return make_cleanup_dtor (do_restore_current_traceframe_cleanup, old,
3050 restore_current_traceframe_cleanup_dtor);
3051 }
3052
3053 /* Given a number and address, return an uploaded tracepoint with that
3054 number, creating if necessary. */
3055
3056 struct uploaded_tp *
3057 get_uploaded_tp (int num, ULONGEST addr, struct uploaded_tp **utpp)
3058 {
3059 struct uploaded_tp *utp;
3060
3061 for (utp = *utpp; utp; utp = utp->next)
3062 if (utp->number == num && utp->addr == addr)
3063 return utp;
3064
3065 utp = XCNEW (struct uploaded_tp);
3066 utp->number = num;
3067 utp->addr = addr;
3068 utp->actions = NULL;
3069 utp->step_actions = NULL;
3070 utp->cmd_strings = NULL;
3071 utp->next = *utpp;
3072 *utpp = utp;
3073
3074 return utp;
3075 }
3076
3077 void
3078 free_uploaded_tps (struct uploaded_tp **utpp)
3079 {
3080 struct uploaded_tp *next_one;
3081
3082 while (*utpp)
3083 {
3084 next_one = (*utpp)->next;
3085 xfree (*utpp);
3086 *utpp = next_one;
3087 }
3088 }
3089
3090 /* Given a number and address, return an uploaded tracepoint with that
3091 number, creating if necessary. */
3092
3093 struct uploaded_tsv *
3094 get_uploaded_tsv (int num, struct uploaded_tsv **utsvp)
3095 {
3096 struct uploaded_tsv *utsv;
3097
3098 for (utsv = *utsvp; utsv; utsv = utsv->next)
3099 if (utsv->number == num)
3100 return utsv;
3101
3102 utsv = XCNEW (struct uploaded_tsv);
3103 utsv->number = num;
3104 utsv->next = *utsvp;
3105 *utsvp = utsv;
3106
3107 return utsv;
3108 }
3109
3110 void
3111 free_uploaded_tsvs (struct uploaded_tsv **utsvp)
3112 {
3113 struct uploaded_tsv *next_one;
3114
3115 while (*utsvp)
3116 {
3117 next_one = (*utsvp)->next;
3118 xfree (*utsvp);
3119 *utsvp = next_one;
3120 }
3121 }
3122
3123 /* FIXME this function is heuristic and will miss the cases where the
3124 conditional is semantically identical but differs in whitespace,
3125 such as "x == 0" vs "x==0". */
3126
3127 static int
3128 cond_string_is_same (char *str1, char *str2)
3129 {
3130 if (str1 == NULL || str2 == NULL)
3131 return (str1 == str2);
3132
3133 return (strcmp (str1, str2) == 0);
3134 }
3135
3136 /* Look for an existing tracepoint that seems similar enough to the
3137 uploaded one. Enablement isn't compared, because the user can
3138 toggle that freely, and may have done so in anticipation of the
3139 next trace run. Return the location of matched tracepoint. */
3140
3141 static struct bp_location *
3142 find_matching_tracepoint_location (struct uploaded_tp *utp)
3143 {
3144 VEC(breakpoint_p) *tp_vec = all_tracepoints ();
3145 int ix;
3146 struct breakpoint *b;
3147 struct bp_location *loc;
3148
3149 for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, b); ix++)
3150 {
3151 struct tracepoint *t = (struct tracepoint *) b;
3152
3153 if (b->type == utp->type
3154 && t->step_count == utp->step
3155 && t->pass_count == utp->pass
3156 && cond_string_is_same (t->cond_string, utp->cond_string)
3157 /* FIXME also test actions. */
3158 )
3159 {
3160 /* Scan the locations for an address match. */
3161 for (loc = b->loc; loc; loc = loc->next)
3162 {
3163 if (loc->address == utp->addr)
3164 return loc;
3165 }
3166 }
3167 }
3168 return NULL;
3169 }
3170
3171 /* Given a list of tracepoints uploaded from a target, attempt to
3172 match them up with existing tracepoints, and create new ones if not
3173 found. */
3174
3175 void
3176 merge_uploaded_tracepoints (struct uploaded_tp **uploaded_tps)
3177 {
3178 struct uploaded_tp *utp;
3179 /* A set of tracepoints which are modified. */
3180 VEC(breakpoint_p) *modified_tp = NULL;
3181 int ix;
3182 struct breakpoint *b;
3183
3184 /* Look for GDB tracepoints that match up with our uploaded versions. */
3185 for (utp = *uploaded_tps; utp; utp = utp->next)
3186 {
3187 struct bp_location *loc;
3188 struct tracepoint *t;
3189
3190 loc = find_matching_tracepoint_location (utp);
3191 if (loc)
3192 {
3193 int found = 0;
3194
3195 /* Mark this location as already inserted. */
3196 loc->inserted = 1;
3197 t = (struct tracepoint *) loc->owner;
3198 printf_filtered (_("Assuming tracepoint %d is same "
3199 "as target's tracepoint %d at %s.\n"),
3200 loc->owner->number, utp->number,
3201 paddress (loc->gdbarch, utp->addr));
3202
3203 /* The tracepoint LOC->owner was modified (the location LOC
3204 was marked as inserted in the target). Save it in
3205 MODIFIED_TP if not there yet. The 'breakpoint-modified'
3206 observers will be notified later once for each tracepoint
3207 saved in MODIFIED_TP. */
3208 for (ix = 0;
3209 VEC_iterate (breakpoint_p, modified_tp, ix, b);
3210 ix++)
3211 if (b == loc->owner)
3212 {
3213 found = 1;
3214 break;
3215 }
3216 if (!found)
3217 VEC_safe_push (breakpoint_p, modified_tp, loc->owner);
3218 }
3219 else
3220 {
3221 t = create_tracepoint_from_upload (utp);
3222 if (t)
3223 printf_filtered (_("Created tracepoint %d for "
3224 "target's tracepoint %d at %s.\n"),
3225 t->number, utp->number,
3226 paddress (get_current_arch (), utp->addr));
3227 else
3228 printf_filtered (_("Failed to create tracepoint for target's "
3229 "tracepoint %d at %s, skipping it.\n"),
3230 utp->number,
3231 paddress (get_current_arch (), utp->addr));
3232 }
3233 /* Whether found or created, record the number used by the
3234 target, to help with mapping target tracepoints back to their
3235 counterparts here. */
3236 if (t)
3237 t->number_on_target = utp->number;
3238 }
3239
3240 /* Notify 'breakpoint-modified' observer that at least one of B's
3241 locations was changed. */
3242 for (ix = 0; VEC_iterate (breakpoint_p, modified_tp, ix, b); ix++)
3243 observer_notify_breakpoint_modified (b);
3244
3245 VEC_free (breakpoint_p, modified_tp);
3246 free_uploaded_tps (uploaded_tps);
3247 }
3248
3249 /* Trace state variables don't have much to identify them beyond their
3250 name, so just use that to detect matches. */
3251
3252 static struct trace_state_variable *
3253 find_matching_tsv (struct uploaded_tsv *utsv)
3254 {
3255 if (!utsv->name)
3256 return NULL;
3257
3258 return find_trace_state_variable (utsv->name);
3259 }
3260
3261 static struct trace_state_variable *
3262 create_tsv_from_upload (struct uploaded_tsv *utsv)
3263 {
3264 const char *namebase;
3265 std::string buf;
3266 int try_num = 0;
3267 struct trace_state_variable *tsv;
3268
3269 if (utsv->name)
3270 {
3271 namebase = utsv->name;
3272 buf = namebase;
3273 }
3274 else
3275 {
3276 namebase = "__tsv";
3277 buf = string_printf ("%s_%d", namebase, try_num++);
3278 }
3279
3280 /* Fish for a name that is not in use. */
3281 /* (should check against all internal vars?) */
3282 while (find_trace_state_variable (buf.c_str ()))
3283 buf = string_printf ("%s_%d", namebase, try_num++);
3284
3285 /* We have an available name, create the variable. */
3286 tsv = create_trace_state_variable (buf.c_str ());
3287 tsv->initial_value = utsv->initial_value;
3288 tsv->builtin = utsv->builtin;
3289
3290 observer_notify_tsv_created (tsv);
3291
3292 return tsv;
3293 }
3294
3295 /* Given a list of uploaded trace state variables, try to match them
3296 up with existing variables, or create additional ones. */
3297
3298 void
3299 merge_uploaded_trace_state_variables (struct uploaded_tsv **uploaded_tsvs)
3300 {
3301 int ix;
3302 struct uploaded_tsv *utsv;
3303 struct trace_state_variable *tsv;
3304 int highest;
3305
3306 /* Most likely some numbers will have to be reassigned as part of
3307 the merge, so clear them all in anticipation. */
3308 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
3309 tsv->number = 0;
3310
3311 for (utsv = *uploaded_tsvs; utsv; utsv = utsv->next)
3312 {
3313 tsv = find_matching_tsv (utsv);
3314 if (tsv)
3315 {
3316 if (info_verbose)
3317 printf_filtered (_("Assuming trace state variable $%s "
3318 "is same as target's variable %d.\n"),
3319 tsv->name, utsv->number);
3320 }
3321 else
3322 {
3323 tsv = create_tsv_from_upload (utsv);
3324 if (info_verbose)
3325 printf_filtered (_("Created trace state variable "
3326 "$%s for target's variable %d.\n"),
3327 tsv->name, utsv->number);
3328 }
3329 /* Give precedence to numberings that come from the target. */
3330 if (tsv)
3331 tsv->number = utsv->number;
3332 }
3333
3334 /* Renumber everything that didn't get a target-assigned number. */
3335 highest = 0;
3336 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
3337 if (tsv->number > highest)
3338 highest = tsv->number;
3339
3340 ++highest;
3341 for (ix = 0; VEC_iterate (tsv_s, tvariables, ix, tsv); ++ix)
3342 if (tsv->number == 0)
3343 tsv->number = highest++;
3344
3345 free_uploaded_tsvs (uploaded_tsvs);
3346 }
3347
3348 /* Parse the part of trace status syntax that is shared between
3349 the remote protocol and the trace file reader. */
3350
3351 void
3352 parse_trace_status (const char *line, struct trace_status *ts)
3353 {
3354 const char *p = line, *p1, *p2, *p3, *p_temp;
3355 int end;
3356 ULONGEST val;
3357
3358 ts->running_known = 1;
3359 ts->running = (*p++ == '1');
3360 ts->stop_reason = trace_stop_reason_unknown;
3361 xfree (ts->stop_desc);
3362 ts->stop_desc = NULL;
3363 ts->traceframe_count = -1;
3364 ts->traceframes_created = -1;
3365 ts->buffer_free = -1;
3366 ts->buffer_size = -1;
3367 ts->disconnected_tracing = 0;
3368 ts->circular_buffer = 0;
3369 xfree (ts->user_name);
3370 ts->user_name = NULL;
3371 xfree (ts->notes);
3372 ts->notes = NULL;
3373 ts->start_time = ts->stop_time = 0;
3374
3375 while (*p++)
3376 {
3377 p1 = strchr (p, ':');
3378 if (p1 == NULL)
3379 error (_("Malformed trace status, at %s\n\
3380 Status line: '%s'\n"), p, line);
3381 p3 = strchr (p, ';');
3382 if (p3 == NULL)
3383 p3 = p + strlen (p);
3384 if (strncmp (p, stop_reason_names[trace_buffer_full], p1 - p) == 0)
3385 {
3386 p = unpack_varlen_hex (++p1, &val);
3387 ts->stop_reason = trace_buffer_full;
3388 }
3389 else if (strncmp (p, stop_reason_names[trace_never_run], p1 - p) == 0)
3390 {
3391 p = unpack_varlen_hex (++p1, &val);
3392 ts->stop_reason = trace_never_run;
3393 }
3394 else if (strncmp (p, stop_reason_names[tracepoint_passcount],
3395 p1 - p) == 0)
3396 {
3397 p = unpack_varlen_hex (++p1, &val);
3398 ts->stop_reason = tracepoint_passcount;
3399 ts->stopping_tracepoint = val;
3400 }
3401 else if (strncmp (p, stop_reason_names[trace_stop_command], p1 - p) == 0)
3402 {
3403 p2 = strchr (++p1, ':');
3404 if (!p2 || p2 > p3)
3405 {
3406 /*older style*/
3407 p2 = p1;
3408 }
3409 else if (p2 != p1)
3410 {
3411 ts->stop_desc = (char *) xmalloc (strlen (line));
3412 end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
3413 ts->stop_desc[end] = '\0';
3414 }
3415 else
3416 ts->stop_desc = xstrdup ("");
3417
3418 p = unpack_varlen_hex (++p2, &val);
3419 ts->stop_reason = trace_stop_command;
3420 }
3421 else if (strncmp (p, stop_reason_names[trace_disconnected], p1 - p) == 0)
3422 {
3423 p = unpack_varlen_hex (++p1, &val);
3424 ts->stop_reason = trace_disconnected;
3425 }
3426 else if (strncmp (p, stop_reason_names[tracepoint_error], p1 - p) == 0)
3427 {
3428 p2 = strchr (++p1, ':');
3429 if (p2 != p1)
3430 {
3431 ts->stop_desc = (char *) xmalloc ((p2 - p1) / 2 + 1);
3432 end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
3433 ts->stop_desc[end] = '\0';
3434 }
3435 else
3436 ts->stop_desc = xstrdup ("");
3437
3438 p = unpack_varlen_hex (++p2, &val);
3439 ts->stopping_tracepoint = val;
3440 ts->stop_reason = tracepoint_error;
3441 }
3442 else if (strncmp (p, "tframes", p1 - p) == 0)
3443 {
3444 p = unpack_varlen_hex (++p1, &val);
3445 ts->traceframe_count = val;
3446 }
3447 else if (strncmp (p, "tcreated", p1 - p) == 0)
3448 {
3449 p = unpack_varlen_hex (++p1, &val);
3450 ts->traceframes_created = val;
3451 }
3452 else if (strncmp (p, "tfree", p1 - p) == 0)
3453 {
3454 p = unpack_varlen_hex (++p1, &val);
3455 ts->buffer_free = val;
3456 }
3457 else if (strncmp (p, "tsize", p1 - p) == 0)
3458 {
3459 p = unpack_varlen_hex (++p1, &val);
3460 ts->buffer_size = val;
3461 }
3462 else if (strncmp (p, "disconn", p1 - p) == 0)
3463 {
3464 p = unpack_varlen_hex (++p1, &val);
3465 ts->disconnected_tracing = val;
3466 }
3467 else if (strncmp (p, "circular", p1 - p) == 0)
3468 {
3469 p = unpack_varlen_hex (++p1, &val);
3470 ts->circular_buffer = val;
3471 }
3472 else if (strncmp (p, "starttime", p1 - p) == 0)
3473 {
3474 p = unpack_varlen_hex (++p1, &val);
3475 ts->start_time = val;
3476 }
3477 else if (strncmp (p, "stoptime", p1 - p) == 0)
3478 {
3479 p = unpack_varlen_hex (++p1, &val);
3480 ts->stop_time = val;
3481 }
3482 else if (strncmp (p, "username", p1 - p) == 0)
3483 {
3484 ++p1;
3485 ts->user_name = (char *) xmalloc (strlen (p) / 2);
3486 end = hex2bin (p1, (gdb_byte *) ts->user_name, (p3 - p1) / 2);
3487 ts->user_name[end] = '\0';
3488 p = p3;
3489 }
3490 else if (strncmp (p, "notes", p1 - p) == 0)
3491 {
3492 ++p1;
3493 ts->notes = (char *) xmalloc (strlen (p) / 2);
3494 end = hex2bin (p1, (gdb_byte *) ts->notes, (p3 - p1) / 2);
3495 ts->notes[end] = '\0';
3496 p = p3;
3497 }
3498 else
3499 {
3500 /* Silently skip unknown optional info. */
3501 p_temp = strchr (p1 + 1, ';');
3502 if (p_temp)
3503 p = p_temp;
3504 else
3505 /* Must be at the end. */
3506 break;
3507 }
3508 }
3509 }
3510
3511 void
3512 parse_tracepoint_status (const char *p, struct breakpoint *bp,
3513 struct uploaded_tp *utp)
3514 {
3515 ULONGEST uval;
3516 struct tracepoint *tp = (struct tracepoint *) bp;
3517
3518 p = unpack_varlen_hex (p, &uval);
3519 if (tp)
3520 tp->hit_count += uval;
3521 else
3522 utp->hit_count += uval;
3523 p = unpack_varlen_hex (p + 1, &uval);
3524 if (tp)
3525 tp->traceframe_usage += uval;
3526 else
3527 utp->traceframe_usage += uval;
3528 /* Ignore any extra, allowing for future extensions. */
3529 }
3530
3531 /* Given a line of text defining a part of a tracepoint, parse it into
3532 an "uploaded tracepoint". */
3533
3534 void
3535 parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp)
3536 {
3537 const char *p;
3538 char piece;
3539 ULONGEST num, addr, step, pass, orig_size, xlen, start;
3540 int enabled, end;
3541 enum bptype type;
3542 const char *srctype;
3543 char *cond, *buf;
3544 struct uploaded_tp *utp = NULL;
3545
3546 p = line;
3547 /* Both tracepoint and action definitions start with the same number
3548 and address sequence. */
3549 piece = *p++;
3550 p = unpack_varlen_hex (p, &num);
3551 p++; /* skip a colon */
3552 p = unpack_varlen_hex (p, &addr);
3553 p++; /* skip a colon */
3554 if (piece == 'T')
3555 {
3556 enabled = (*p++ == 'E');
3557 p++; /* skip a colon */
3558 p = unpack_varlen_hex (p, &step);
3559 p++; /* skip a colon */
3560 p = unpack_varlen_hex (p, &pass);
3561 type = bp_tracepoint;
3562 cond = NULL;
3563 /* Thumb through optional fields. */
3564 while (*p == ':')
3565 {
3566 p++; /* skip a colon */
3567 if (*p == 'F')
3568 {
3569 type = bp_fast_tracepoint;
3570 p++;
3571 p = unpack_varlen_hex (p, &orig_size);
3572 }
3573 else if (*p == 'S')
3574 {
3575 type = bp_static_tracepoint;
3576 p++;
3577 }
3578 else if (*p == 'X')
3579 {
3580 p++;
3581 p = unpack_varlen_hex (p, &xlen);
3582 p++; /* skip a comma */
3583 cond = (char *) xmalloc (2 * xlen + 1);
3584 strncpy (cond, p, 2 * xlen);
3585 cond[2 * xlen] = '\0';
3586 p += 2 * xlen;
3587 }
3588 else
3589 warning (_("Unrecognized char '%c' in tracepoint "
3590 "definition, skipping rest"), *p);
3591 }
3592 utp = get_uploaded_tp (num, addr, utpp);
3593 utp->type = type;
3594 utp->enabled = enabled;
3595 utp->step = step;
3596 utp->pass = pass;
3597 utp->cond = cond;
3598 }
3599 else if (piece == 'A')
3600 {
3601 utp = get_uploaded_tp (num, addr, utpp);
3602 VEC_safe_push (char_ptr, utp->actions, xstrdup (p));
3603 }
3604 else if (piece == 'S')
3605 {
3606 utp = get_uploaded_tp (num, addr, utpp);
3607 VEC_safe_push (char_ptr, utp->step_actions, xstrdup (p));
3608 }
3609 else if (piece == 'Z')
3610 {
3611 /* Parse a chunk of source form definition. */
3612 utp = get_uploaded_tp (num, addr, utpp);
3613 srctype = p;
3614 p = strchr (p, ':');
3615 p++; /* skip a colon */
3616 p = unpack_varlen_hex (p, &start);
3617 p++; /* skip a colon */
3618 p = unpack_varlen_hex (p, &xlen);
3619 p++; /* skip a colon */
3620
3621 buf = (char *) alloca (strlen (line));
3622
3623 end = hex2bin (p, (gdb_byte *) buf, strlen (p) / 2);
3624 buf[end] = '\0';
3625
3626 if (startswith (srctype, "at:"))
3627 utp->at_string = xstrdup (buf);
3628 else if (startswith (srctype, "cond:"))
3629 utp->cond_string = xstrdup (buf);
3630 else if (startswith (srctype, "cmd:"))
3631 VEC_safe_push (char_ptr, utp->cmd_strings, xstrdup (buf));
3632 }
3633 else if (piece == 'V')
3634 {
3635 utp = get_uploaded_tp (num, addr, utpp);
3636
3637 parse_tracepoint_status (p, NULL, utp);
3638 }
3639 else
3640 {
3641 /* Don't error out, the target might be sending us optional
3642 info that we don't care about. */
3643 warning (_("Unrecognized tracepoint piece '%c', ignoring"), piece);
3644 }
3645 }
3646
3647 /* Convert a textual description of a trace state variable into an
3648 uploaded object. */
3649
3650 void
3651 parse_tsv_definition (const char *line, struct uploaded_tsv **utsvp)
3652 {
3653 const char *p;
3654 char *buf;
3655 ULONGEST num, initval, builtin;
3656 int end;
3657 struct uploaded_tsv *utsv = NULL;
3658
3659 buf = (char *) alloca (strlen (line));
3660
3661 p = line;
3662 p = unpack_varlen_hex (p, &num);
3663 p++; /* skip a colon */
3664 p = unpack_varlen_hex (p, &initval);
3665 p++; /* skip a colon */
3666 p = unpack_varlen_hex (p, &builtin);
3667 p++; /* skip a colon */
3668 end = hex2bin (p, (gdb_byte *) buf, strlen (p) / 2);
3669 buf[end] = '\0';
3670
3671 utsv = get_uploaded_tsv (num, utsvp);
3672 utsv->initial_value = initval;
3673 utsv->builtin = builtin;
3674 utsv->name = xstrdup (buf);
3675 }
3676
3677 void
3678 free_current_marker (void *arg)
3679 {
3680 struct static_tracepoint_marker **marker_p
3681 = (struct static_tracepoint_marker **) arg;
3682
3683 if (*marker_p != NULL)
3684 {
3685 release_static_tracepoint_marker (*marker_p);
3686 xfree (*marker_p);
3687 }
3688 else
3689 *marker_p = NULL;
3690 }
3691
3692 /* Given a line of text defining a static tracepoint marker, parse it
3693 into a "static tracepoint marker" object. Throws an error is
3694 parsing fails. If PP is non-null, it points to one past the end of
3695 the parsed marker definition. */
3696
3697 void
3698 parse_static_tracepoint_marker_definition (const char *line, const char **pp,
3699 struct static_tracepoint_marker *marker)
3700 {
3701 const char *p, *endp;
3702 ULONGEST addr;
3703 int end;
3704
3705 p = line;
3706 p = unpack_varlen_hex (p, &addr);
3707 p++; /* skip a colon */
3708
3709 marker->gdbarch = target_gdbarch ();
3710 marker->address = (CORE_ADDR) addr;
3711
3712 endp = strchr (p, ':');
3713 if (endp == NULL)
3714 error (_("bad marker definition: %s"), line);
3715
3716 marker->str_id = (char *) xmalloc (endp - p + 1);
3717 end = hex2bin (p, (gdb_byte *) marker->str_id, (endp - p + 1) / 2);
3718 marker->str_id[end] = '\0';
3719
3720 p += 2 * end;
3721 p++; /* skip a colon */
3722
3723 marker->extra = (char *) xmalloc (strlen (p) + 1);
3724 end = hex2bin (p, (gdb_byte *) marker->extra, strlen (p) / 2);
3725 marker->extra[end] = '\0';
3726
3727 if (pp)
3728 *pp = p;
3729 }
3730
3731 /* Release a static tracepoint marker's contents. Note that the
3732 object itself isn't released here. There objects are usually on
3733 the stack. */
3734
3735 void
3736 release_static_tracepoint_marker (struct static_tracepoint_marker *marker)
3737 {
3738 xfree (marker->str_id);
3739 marker->str_id = NULL;
3740 }
3741
3742 /* Print MARKER to gdb_stdout. */
3743
3744 static void
3745 print_one_static_tracepoint_marker (int count,
3746 struct static_tracepoint_marker *marker)
3747 {
3748 struct symbol *sym;
3749
3750 char wrap_indent[80];
3751 char extra_field_indent[80];
3752 struct ui_out *uiout = current_uiout;
3753 VEC(breakpoint_p) *tracepoints;
3754
3755 symtab_and_line sal;
3756 sal.pc = marker->address;
3757
3758 tracepoints = static_tracepoints_here (marker->address);
3759
3760 ui_out_emit_tuple tuple_emitter (uiout, "marker");
3761
3762 /* A counter field to help readability. This is not a stable
3763 identifier! */
3764 uiout->field_int ("count", count);
3765
3766 uiout->field_string ("marker-id", marker->str_id);
3767
3768 uiout->field_fmt ("enabled", "%c",
3769 !VEC_empty (breakpoint_p, tracepoints) ? 'y' : 'n');
3770 uiout->spaces (2);
3771
3772 strcpy (wrap_indent, " ");
3773
3774 if (gdbarch_addr_bit (marker->gdbarch) <= 32)
3775 strcat (wrap_indent, " ");
3776 else
3777 strcat (wrap_indent, " ");
3778
3779 strcpy (extra_field_indent, " ");
3780
3781 uiout->field_core_addr ("addr", marker->gdbarch, marker->address);
3782
3783 sal = find_pc_line (marker->address, 0);
3784 sym = find_pc_sect_function (marker->address, NULL);
3785 if (sym)
3786 {
3787 uiout->text ("in ");
3788 uiout->field_string ("func",
3789 SYMBOL_PRINT_NAME (sym));
3790 uiout->wrap_hint (wrap_indent);
3791 uiout->text (" at ");
3792 }
3793 else
3794 uiout->field_skip ("func");
3795
3796 if (sal.symtab != NULL)
3797 {
3798 uiout->field_string ("file",
3799 symtab_to_filename_for_display (sal.symtab));
3800 uiout->text (":");
3801
3802 if (uiout->is_mi_like_p ())
3803 {
3804 const char *fullname = symtab_to_fullname (sal.symtab);
3805
3806 uiout->field_string ("fullname", fullname);
3807 }
3808 else
3809 uiout->field_skip ("fullname");
3810
3811 uiout->field_int ("line", sal.line);
3812 }
3813 else
3814 {
3815 uiout->field_skip ("fullname");
3816 uiout->field_skip ("line");
3817 }
3818
3819 uiout->text ("\n");
3820 uiout->text (extra_field_indent);
3821 uiout->text (_("Data: \""));
3822 uiout->field_string ("extra-data", marker->extra);
3823 uiout->text ("\"\n");
3824
3825 if (!VEC_empty (breakpoint_p, tracepoints))
3826 {
3827 int ix;
3828 struct breakpoint *b;
3829
3830 {
3831 ui_out_emit_tuple tuple_emitter (uiout, "tracepoints-at");
3832
3833 uiout->text (extra_field_indent);
3834 uiout->text (_("Probed by static tracepoints: "));
3835 for (ix = 0; VEC_iterate(breakpoint_p, tracepoints, ix, b); ix++)
3836 {
3837 if (ix > 0)
3838 uiout->text (", ");
3839 uiout->text ("#");
3840 uiout->field_int ("tracepoint-id", b->number);
3841 }
3842 }
3843
3844 if (uiout->is_mi_like_p ())
3845 uiout->field_int ("number-of-tracepoints",
3846 VEC_length(breakpoint_p, tracepoints));
3847 else
3848 uiout->text ("\n");
3849 }
3850 VEC_free (breakpoint_p, tracepoints);
3851 }
3852
3853 static void
3854 info_static_tracepoint_markers_command (const char *arg, int from_tty)
3855 {
3856 VEC(static_tracepoint_marker_p) *markers;
3857 struct cleanup *old_chain;
3858 struct static_tracepoint_marker *marker;
3859 struct ui_out *uiout = current_uiout;
3860 int i;
3861
3862 /* We don't have to check target_can_use_agent and agent's capability on
3863 static tracepoint here, in order to be compatible with older GDBserver.
3864 We don't check USE_AGENT is true or not, because static tracepoints
3865 don't work without in-process agent, so we don't bother users to type
3866 `set agent on' when to use static tracepoint. */
3867
3868 ui_out_emit_table table_emitter (uiout, 5, -1,
3869 "StaticTracepointMarkersTable");
3870
3871 uiout->table_header (7, ui_left, "counter", "Cnt");
3872
3873 uiout->table_header (40, ui_left, "marker-id", "ID");
3874
3875 uiout->table_header (3, ui_left, "enabled", "Enb");
3876 if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
3877 uiout->table_header (10, ui_left, "addr", "Address");
3878 else
3879 uiout->table_header (18, ui_left, "addr", "Address");
3880 uiout->table_header (40, ui_noalign, "what", "What");
3881
3882 uiout->table_body ();
3883
3884 markers = target_static_tracepoint_markers_by_strid (NULL);
3885 old_chain = make_cleanup (VEC_cleanup (static_tracepoint_marker_p), &markers);
3886
3887 for (i = 0;
3888 VEC_iterate (static_tracepoint_marker_p,
3889 markers, i, marker);
3890 i++)
3891 {
3892 print_one_static_tracepoint_marker (i + 1, marker);
3893 release_static_tracepoint_marker (marker);
3894 }
3895
3896 do_cleanups (old_chain);
3897 }
3898
3899 /* The $_sdata convenience variable is a bit special. We don't know
3900 for sure type of the value until we actually have a chance to fetch
3901 the data --- the size of the object depends on what has been
3902 collected. We solve this by making $_sdata be an internalvar that
3903 creates a new value on access. */
3904
3905 /* Return a new value with the correct type for the sdata object of
3906 the current trace frame. Return a void value if there's no object
3907 available. */
3908
3909 static struct value *
3910 sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
3911 void *ignore)
3912 {
3913 LONGEST size;
3914 gdb_byte *buf;
3915
3916 /* We need to read the whole object before we know its size. */
3917 size = target_read_alloc (&current_target,
3918 TARGET_OBJECT_STATIC_TRACE_DATA,
3919 NULL, &buf);
3920 if (size >= 0)
3921 {
3922 struct value *v;
3923 struct type *type;
3924
3925 type = init_vector_type (builtin_type (gdbarch)->builtin_true_char,
3926 size);
3927 v = allocate_value (type);
3928 memcpy (value_contents_raw (v), buf, size);
3929 xfree (buf);
3930 return v;
3931 }
3932 else
3933 return allocate_value (builtin_type (gdbarch)->builtin_void);
3934 }
3935
3936 #if !defined(HAVE_LIBEXPAT)
3937
3938 struct std::unique_ptr<traceframe_info>
3939 parse_traceframe_info (const char *tframe_info)
3940 {
3941 static int have_warned;
3942
3943 if (!have_warned)
3944 {
3945 have_warned = 1;
3946 warning (_("Can not parse XML trace frame info; XML support "
3947 "was disabled at compile time"));
3948 }
3949
3950 return NULL;
3951 }
3952
3953 #else /* HAVE_LIBEXPAT */
3954
3955 #include "xml-support.h"
3956
3957 /* Handle the start of a <memory> element. */
3958
3959 static void
3960 traceframe_info_start_memory (struct gdb_xml_parser *parser,
3961 const struct gdb_xml_element *element,
3962 void *user_data, VEC(gdb_xml_value_s) *attributes)
3963 {
3964 struct traceframe_info *info = (struct traceframe_info *) user_data;
3965 ULONGEST *start_p, *length_p;
3966
3967 start_p
3968 = (ULONGEST *) xml_find_attribute (attributes, "start")->value;
3969 length_p
3970 = (ULONGEST *) xml_find_attribute (attributes, "length")->value;
3971
3972 info->memory.emplace_back (*start_p, *length_p);
3973 }
3974
3975 /* Handle the start of a <tvar> element. */
3976
3977 static void
3978 traceframe_info_start_tvar (struct gdb_xml_parser *parser,
3979 const struct gdb_xml_element *element,
3980 void *user_data,
3981 VEC(gdb_xml_value_s) *attributes)
3982 {
3983 struct traceframe_info *info = (struct traceframe_info *) user_data;
3984 const char *id_attrib
3985 = (const char *) xml_find_attribute (attributes, "id")->value;
3986 int id = gdb_xml_parse_ulongest (parser, id_attrib);
3987
3988 info->tvars.push_back (id);
3989 }
3990
3991 /* The allowed elements and attributes for an XML memory map. */
3992
3993 static const struct gdb_xml_attribute memory_attributes[] = {
3994 { "start", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
3995 { "length", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
3996 { NULL, GDB_XML_AF_NONE, NULL, NULL }
3997 };
3998
3999 static const struct gdb_xml_attribute tvar_attributes[] = {
4000 { "id", GDB_XML_AF_NONE, NULL, NULL },
4001 { NULL, GDB_XML_AF_NONE, NULL, NULL }
4002 };
4003
4004 static const struct gdb_xml_element traceframe_info_children[] = {
4005 { "memory", memory_attributes, NULL,
4006 GDB_XML_EF_REPEATABLE | GDB_XML_EF_OPTIONAL,
4007 traceframe_info_start_memory, NULL },
4008 { "tvar", tvar_attributes, NULL,
4009 GDB_XML_EF_REPEATABLE | GDB_XML_EF_OPTIONAL,
4010 traceframe_info_start_tvar, NULL },
4011 { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
4012 };
4013
4014 static const struct gdb_xml_element traceframe_info_elements[] = {
4015 { "traceframe-info", NULL, traceframe_info_children, GDB_XML_EF_NONE,
4016 NULL, NULL },
4017 { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
4018 };
4019
4020 /* Parse a traceframe-info XML document. */
4021
4022 traceframe_info_up
4023 parse_traceframe_info (const char *tframe_info)
4024 {
4025 traceframe_info_up result (new traceframe_info);
4026
4027 if (gdb_xml_parse_quick (_("trace frame info"),
4028 "traceframe-info.dtd", traceframe_info_elements,
4029 tframe_info, result.get ()) == 0)
4030 return result;
4031
4032 return NULL;
4033 }
4034
4035 #endif /* HAVE_LIBEXPAT */
4036
4037 /* Returns the traceframe_info object for the current traceframe.
4038 This is where we avoid re-fetching the object from the target if we
4039 already have it cached. */
4040
4041 struct traceframe_info *
4042 get_traceframe_info (void)
4043 {
4044 if (current_traceframe_info == NULL)
4045 current_traceframe_info = target_traceframe_info ();
4046
4047 return current_traceframe_info.get ();
4048 }
4049
4050 /* If the target supports the query, return in RESULT the set of
4051 collected memory in the current traceframe, found within the LEN
4052 bytes range starting at MEMADDR. Returns true if the target
4053 supports the query, otherwise returns false, and RESULT is left
4054 undefined. */
4055
4056 int
4057 traceframe_available_memory (std::vector<mem_range> *result,
4058 CORE_ADDR memaddr, ULONGEST len)
4059 {
4060 struct traceframe_info *info = get_traceframe_info ();
4061
4062 if (info != NULL)
4063 {
4064 result->clear ();
4065
4066 for (mem_range &r : info->memory)
4067 if (mem_ranges_overlap (r.start, r.length, memaddr, len))
4068 {
4069 ULONGEST lo1, hi1, lo2, hi2;
4070
4071 lo1 = memaddr;
4072 hi1 = memaddr + len;
4073
4074 lo2 = r.start;
4075 hi2 = r.start + r.length;
4076
4077 CORE_ADDR start = std::max (lo1, lo2);
4078 int length = std::min (hi1, hi2) - start;
4079
4080 result->emplace_back (start, length);
4081 }
4082
4083 normalize_mem_ranges (result);
4084 return 1;
4085 }
4086
4087 return 0;
4088 }
4089
4090 /* Implementation of `sdata' variable. */
4091
4092 static const struct internalvar_funcs sdata_funcs =
4093 {
4094 sdata_make_value,
4095 NULL,
4096 NULL
4097 };
4098
4099 /* module initialization */
4100 void
4101 _initialize_tracepoint (void)
4102 {
4103 struct cmd_list_element *c;
4104
4105 /* Explicitly create without lookup, since that tries to create a
4106 value with a void typed value, and when we get here, gdbarch
4107 isn't initialized yet. At this point, we're quite sure there
4108 isn't another convenience variable of the same name. */
4109 create_internalvar_type_lazy ("_sdata", &sdata_funcs, NULL);
4110
4111 traceframe_number = -1;
4112 tracepoint_number = -1;
4113
4114 add_info ("scope", info_scope_command,
4115 _("List the variables local to a scope"));
4116
4117 add_cmd ("tracepoints", class_trace,
4118 _("Tracing of program execution without stopping the program."),
4119 &cmdlist);
4120
4121 add_com ("tdump", class_trace, tdump_command,
4122 _("Print everything collected at the current tracepoint."));
4123
4124 c = add_com ("tvariable", class_trace, trace_variable_command,_("\
4125 Define a trace state variable.\n\
4126 Argument is a $-prefixed name, optionally followed\n\
4127 by '=' and an expression that sets the initial value\n\
4128 at the start of tracing."));
4129 set_cmd_completer (c, expression_completer);
4130
4131 add_cmd ("tvariable", class_trace, delete_trace_variable_command, _("\
4132 Delete one or more trace state variables.\n\
4133 Arguments are the names of the variables to delete.\n\
4134 If no arguments are supplied, delete all variables."), &deletelist);
4135 /* FIXME add a trace variable completer. */
4136
4137 add_info ("tvariables", info_tvariables_command, _("\
4138 Status of trace state variables and their values.\n\
4139 "));
4140
4141 add_info ("static-tracepoint-markers",
4142 info_static_tracepoint_markers_command, _("\
4143 List target static tracepoints markers.\n\
4144 "));
4145
4146 add_prefix_cmd ("tfind", class_trace, tfind_command, _("\
4147 Select a trace frame;\n\
4148 No argument means forward by one frame; '-' means backward by one frame."),
4149 &tfindlist, "tfind ", 1, &cmdlist);
4150
4151 add_cmd ("outside", class_trace, tfind_outside_command, _("\
4152 Select a trace frame whose PC is outside the given range (exclusive).\n\
4153 Usage: tfind outside addr1, addr2"),
4154 &tfindlist);
4155
4156 add_cmd ("range", class_trace, tfind_range_command, _("\
4157 Select a trace frame whose PC is in the given range (inclusive).\n\
4158 Usage: tfind range addr1,addr2"),
4159 &tfindlist);
4160
4161 add_cmd ("line", class_trace, tfind_line_command, _("\
4162 Select a trace frame by source line.\n\
4163 Argument can be a line number (with optional source file),\n\
4164 a function name, or '*' followed by an address.\n\
4165 Default argument is 'the next source line that was traced'."),
4166 &tfindlist);
4167
4168 add_cmd ("tracepoint", class_trace, tfind_tracepoint_command, _("\
4169 Select a trace frame by tracepoint number.\n\
4170 Default is the tracepoint for the current trace frame."),
4171 &tfindlist);
4172
4173 add_cmd ("pc", class_trace, tfind_pc_command, _("\
4174 Select a trace frame by PC.\n\
4175 Default is the current PC, or the PC of the current trace frame."),
4176 &tfindlist);
4177
4178 add_cmd ("end", class_trace, tfind_end_command, _("\
4179 De-select any trace frame and resume 'live' debugging."),
4180 &tfindlist);
4181
4182 add_alias_cmd ("none", "end", class_trace, 0, &tfindlist);
4183
4184 add_cmd ("start", class_trace, tfind_start_command,
4185 _("Select the first trace frame in the trace buffer."),
4186 &tfindlist);
4187
4188 add_com ("tstatus", class_trace, tstatus_command,
4189 _("Display the status of the current trace data collection."));
4190
4191 add_com ("tstop", class_trace, tstop_command, _("\
4192 Stop trace data collection.\n\
4193 Usage: tstop [ <notes> ... ]\n\
4194 Any arguments supplied are recorded with the trace as a stop reason and\n\
4195 reported by tstatus (if the target supports trace notes)."));
4196
4197 add_com ("tstart", class_trace, tstart_command, _("\
4198 Start trace data collection.\n\
4199 Usage: tstart [ <notes> ... ]\n\
4200 Any arguments supplied are recorded with the trace as a note and\n\
4201 reported by tstatus (if the target supports trace notes)."));
4202
4203 add_com ("end", class_trace, end_actions_pseudocommand, _("\
4204 Ends a list of commands or actions.\n\
4205 Several GDB commands allow you to enter a list of commands or actions.\n\
4206 Entering \"end\" on a line by itself is the normal way to terminate\n\
4207 such a list.\n\n\
4208 Note: the \"end\" command cannot be used at the gdb prompt."));
4209
4210 add_com ("while-stepping", class_trace, while_stepping_pseudocommand, _("\
4211 Specify single-stepping behavior at a tracepoint.\n\
4212 Argument is number of instructions to trace in single-step mode\n\
4213 following the tracepoint. This command is normally followed by\n\
4214 one or more \"collect\" commands, to specify what to collect\n\
4215 while single-stepping.\n\n\
4216 Note: this command can only be used in a tracepoint \"actions\" list."));
4217
4218 add_com_alias ("ws", "while-stepping", class_alias, 0);
4219 add_com_alias ("stepping", "while-stepping", class_alias, 0);
4220
4221 add_com ("collect", class_trace, collect_pseudocommand, _("\
4222 Specify one or more data items to be collected at a tracepoint.\n\
4223 Accepts a comma-separated list of (one or more) expressions. GDB will\n\
4224 collect all data (variables, registers) referenced by that expression.\n\
4225 Also accepts the following special arguments:\n\
4226 $regs -- all registers.\n\
4227 $args -- all function arguments.\n\
4228 $locals -- all variables local to the block/function scope.\n\
4229 $_sdata -- static tracepoint data (ignored for non-static tracepoints).\n\
4230 Note: this command can only be used in a tracepoint \"actions\" list."));
4231
4232 add_com ("teval", class_trace, teval_pseudocommand, _("\
4233 Specify one or more expressions to be evaluated at a tracepoint.\n\
4234 Accepts a comma-separated list of (one or more) expressions.\n\
4235 The result of each evaluation will be discarded.\n\
4236 Note: this command can only be used in a tracepoint \"actions\" list."));
4237
4238 add_com ("actions", class_trace, actions_command, _("\
4239 Specify the actions to be taken at a tracepoint.\n\
4240 Tracepoint actions may include collecting of specified data,\n\
4241 single-stepping, or enabling/disabling other tracepoints,\n\
4242 depending on target's capabilities."));
4243
4244 default_collect = xstrdup ("");
4245 add_setshow_string_cmd ("default-collect", class_trace,
4246 &default_collect, _("\
4247 Set the list of expressions to collect by default"), _("\
4248 Show the list of expressions to collect by default"), NULL,
4249 NULL, NULL,
4250 &setlist, &showlist);
4251
4252 add_setshow_boolean_cmd ("disconnected-tracing", no_class,
4253 &disconnected_tracing, _("\
4254 Set whether tracing continues after GDB disconnects."), _("\
4255 Show whether tracing continues after GDB disconnects."), _("\
4256 Use this to continue a tracing run even if GDB disconnects\n\
4257 or detaches from the target. You can reconnect later and look at\n\
4258 trace data collected in the meantime."),
4259 set_disconnected_tracing,
4260 NULL,
4261 &setlist,
4262 &showlist);
4263
4264 add_setshow_boolean_cmd ("circular-trace-buffer", no_class,
4265 &circular_trace_buffer, _("\
4266 Set target's use of circular trace buffer."), _("\
4267 Show target's use of circular trace buffer."), _("\
4268 Use this to make the trace buffer into a circular buffer,\n\
4269 which will discard traceframes (oldest first) instead of filling\n\
4270 up and stopping the trace run."),
4271 set_circular_trace_buffer,
4272 NULL,
4273 &setlist,
4274 &showlist);
4275
4276 add_setshow_zuinteger_unlimited_cmd ("trace-buffer-size", no_class,
4277 &trace_buffer_size, _("\
4278 Set requested size of trace buffer."), _("\
4279 Show requested size of trace buffer."), _("\
4280 Use this to choose a size for the trace buffer. Some targets\n\
4281 may have fixed or limited buffer sizes. Specifying \"unlimited\" or -1\n\
4282 disables any attempt to set the buffer size and lets the target choose."),
4283 set_trace_buffer_size, NULL,
4284 &setlist, &showlist);
4285
4286 add_setshow_string_cmd ("trace-user", class_trace,
4287 &trace_user, _("\
4288 Set the user name to use for current and future trace runs"), _("\
4289 Show the user name to use for current and future trace runs"), NULL,
4290 set_trace_user, NULL,
4291 &setlist, &showlist);
4292
4293 add_setshow_string_cmd ("trace-notes", class_trace,
4294 &trace_notes, _("\
4295 Set notes string to use for current and future trace runs"), _("\
4296 Show the notes string to use for current and future trace runs"), NULL,
4297 set_trace_notes, NULL,
4298 &setlist, &showlist);
4299
4300 add_setshow_string_cmd ("trace-stop-notes", class_trace,
4301 &trace_stop_notes, _("\
4302 Set notes string to use for future tstop commands"), _("\
4303 Show the notes string to use for future tstop commands"), NULL,
4304 set_trace_stop_notes, NULL,
4305 &setlist, &showlist);
4306 }
error_no_arg
void error_no_arg(const char *why)
Definition: cli-cmds.c:185
target_gdbarch
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
memrange::type
int type
Definition: tracepoint.h:238
gdbarch
Definition: gdbarch.c:127
current_traceframe_cleanup
Definition: tracepoint.c:3017
string
const char * string
Definition: signals.c:50
command_line::body_count
int body_count
Definition: cli-script.h:67
set_trace_user
static void set_trace_user(const char *args, int from_tty, struct cmd_list_element *c)
Definition: tracepoint.c:2915
command_line
Definition: cli-script.h:51
tstatus_command
static void tstatus_command(const char *args, int from_tty)
Definition: tracepoint.c:1776
collection_list::m_wholly_collected
std::vector< std::string > m_wholly_collected
Definition: tracepoint.h:293
hex_string
char * hex_string(LONGEST num)
Definition: print-utils.c:220
traceframe_info::memory
std::vector< mem_range > memory
Definition: tracepoint.h:34
extract_bp_kind::loc
breakpoint::loc
bp_location * loc
Definition: breakpoint.h:702
get_traceframe_info
struct traceframe_info * get_traceframe_info(void)
Definition: tracepoint.c:4042
release_static_tracepoint_marker
void release_static_tracepoint_marker(struct static_tracepoint_marker *marker)
Definition: tracepoint.c:3736
symtab_to_filename_for_display
const char * symtab_to_filename_for_display(struct symtab *symtab)
Definition: source.c:1168
breakpoint_commands
struct command_line * breakpoint_commands(struct breakpoint *b)
Definition: breakpoint.c:303
completer.h
add_local_symbols_data
Definition: tracepoint.c:1022
add_local_symbols_data::trace_string
int trace_string
Definition: tracepoint.c:1030
encode_actions_1
static void encode_actions_1(struct command_line *action, struct bp_location *tloc, int frame_reg, LONGEST frame_offset, struct collection_list *collect, struct collection_list *stepping_list)
Definition: tracepoint.c:1247
memrange
Definition: tracepoint.h:227
get_selected_frame
struct frame_info * get_selected_frame(const char *message)
Definition: frame.c:1638
hexchars
static const char hexchars[]
Definition: tracepoint.c:2955
bp_enabled
Definition: breakpoint.h:202
memrange.h
static_tracepoint_marker::str_id
char * str_id
Definition: tracepoint.h:221
uploaded_tp::pass
int pass
Definition: tracepoint.h:173
ui_out::field_core_addr
void field_core_addr(const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address)
Definition: ui-out.c:513
collection_list::finish
void finish()
Definition: tracepoint.c:1241
get_frame_pc
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2376
SYMBOL_PRINT_NAME
#define SYMBOL_PRINT_NAME(symbol)
Definition: symtab.h:542
agent_expr_up
std::unique_ptr< agent_expr > agent_expr_up
Definition: ax.h:159
trace_status::buffer_free
int buffer_free
Definition: tracepoint.h:127
check_tracepoint_command
void check_tracepoint_command(char *line, void *closure)
Definition: breakpoint.c:1219
get_current_frame
struct frame_info * get_current_frame(void)
Definition: frame.c:1563
ui_out::field_string
void field_string(const char *fldname, const char *string)
Definition: ui-out.c:544
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
ax_reqs
void ax_reqs(struct agent_expr *ax)
Definition: ax-general.c:468
gdb_xml_value::value
void * value
Definition: xml-support.h:78
ui_out_emit_type
Definition: ui-out.h:192
print_one_static_tracepoint_marker
static void print_one_static_tracepoint_marker(int count, struct static_tracepoint_marker *marker)
Definition: tracepoint.c:3745
print_address
void print_address(struct gdbarch *, CORE_ADDR, struct ui_file *)
Definition: printcmd.c:706
uploaded_tp::number
int number
Definition: tracepoint.h:168
make_cleanup_restore_current_traceframe
struct cleanup * make_cleanup_restore_current_traceframe(void)
Definition: tracepoint.c:3042
expression_up
gdb::unique_xmalloc_ptr< expression > expression_up
Definition: expression.h:87
uploaded_tsv::initial_value
LONGEST initial_value
Definition: tracepoint.h:208
do_displays
void do_displays(void)
Definition: printcmd.c:2016
xfree
void xfree(void *)
add_local_symbols_data::gdbarch
struct gdbarch * gdbarch
Definition: tracepoint.c:1025
LOC_BLOCK
Definition: symtab.h:854
may_insert_fast_tracepoints
int may_insert_fast_tracepoints
info_static_tracepoint_markers_command
static void info_static_tracepoint_markers_command(const char *arg, int from_tty)
Definition: tracepoint.c:3854
target-dcache.h
no_class
Definition: command.h:41
TARGET_OBJECT_STATIC_TRACE_DATA
Definition: target.h:183
value_as_long
LONGEST value_as_long(struct value *val)
Definition: value.c:2749
cmd_list_element
Definition: cli-decode.h:46
sdata_funcs
static const struct internalvar_funcs sdata_funcs
Definition: tracepoint.c:4092
BMSYMBOL_VALUE_ADDRESS
#define BMSYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:691
stop_tracing
void stop_tracing(const char *note)
Definition: tracepoint.c:1730
warning
void warning(const char *fmt,...)
Definition: errors.c:26
ui_out::wrap_hint
void void wrap_hint(const char *identstring)
Definition: ui-out.c:597
tracepoint
Definition: breakpoint.h:874
regcache::regcache
regcache(gdbarch *gdbarch)
Definition: regcache.h:235
collection_list::add_aexpr
void add_aexpr(agent_expr_up aexpr)
Definition: tracepoint.c:1513
cmd_cfunc_eq
int cmd_cfunc_eq(struct cmd_list_element *cmd, cmd_const_cfunc_ftype *cfunc)
Definition: cli-decode.c:136
trace_never_run
Definition: tracepoint.h:80
decode_agent_options
const char * decode_agent_options(const char *exp, int *trace_string)
Definition: tracepoint.c:555
query
int query(const char *ctlstr,...)
Definition: utils.c:1063
find_matching_tracepoint_location
static struct bp_location * find_matching_tracepoint_location(struct uploaded_tp *utp)
Definition: tracepoint.c:3142
target_supports_enable_disable_tracepoint
#define target_supports_enable_disable_tracepoint()
Definition: target.h:1419
find_pc_sect_function
struct symbol * find_pc_sect_function(CORE_ADDR pc, struct obj_section *section)
Definition: blockframe.c:136
SRC_LINE
Definition: frame.h:663
plongest
char * plongest(LONGEST l)
Definition: print-utils.c:137
bin2hex
int bin2hex(const gdb_byte *bin, char *hex, int count)
Definition: rsp-low.c:173
traceframe_info::tvars
std::vector< int > tvars
Definition: tracepoint.h:37
target_read_alloc
LONGEST target_read_alloc(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte **buf_p)
Definition: target.c:1918
tfind_tracepoint_command
static void tfind_tracepoint_command(const char *args, int from_tty)
Definition: tracepoint.c:2335
tfind_outside
Definition: tracepoint.h:390
trace_status::circular_buffer
int circular_buffer
Definition: tracepoint.h:137
ui_out::field_skip
void field_skip(const char *fldname)
Definition: ui-out.c:532
gdb_xml_parser
Definition: xml-support.c:68
set_trace_stop_notes
static void set_trace_stop_notes(const char *args, int from_tty, struct cmd_list_element *c)
Definition: tracepoint.c:2939
add_info
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
Definition: cli-decode.c:886
free_uploaded_tps
void free_uploaded_tps(struct uploaded_tp **utpp)
Definition: tracepoint.c:3078
breakpoint::number
int number
Definition: breakpoint.h:699
traceframe_info_children
static const struct gdb_xml_element traceframe_info_children[]
Definition: tracepoint.c:4004
gdb_xml_value
Definition: xml-support.h:75
select_frame
void select_frame(struct frame_info *fi)
Definition: frame.c:1677
uploaded_tp::enabled
int enabled
Definition: tracepoint.h:171
deprecated_trace_find_hook
void(* deprecated_trace_find_hook)(char *arg, int from_tty)
Definition: tracepoint.c:82
SYMBOL_CLASS
#define SYMBOL_CLASS(symbol)
Definition: symtab.h:1155
memset
void * memset(T *s, int c, size_t n)=delete
internal_error
void internal_error(const char *file, int line, const char *fmt,...)
Definition: errors.c:50
null_frame_id
const struct frame_id null_frame_id
Definition: frame.c:575
ui_out::table_header
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
Definition: ui-out.c:365
collect_pseudocommand
static void collect_pseudocommand(const char *args, int from_tty)
Definition: tracepoint.c:541
ax-gdb.h
lookup_cmd
struct cmd_list_element * lookup_cmd(const char **line, struct cmd_list_element *list, const char *cmdtype, int allow_unknown, int ignore_help_classes)
Definition: cli-decode.c:1515
info_verbose
int info_verbose
Definition: top.c:1791
static_tracepoint_marker::gdbarch
struct gdbarch * gdbarch
Definition: tracepoint.h:217
target_set_trace_buffer_size
#define target_set_trace_buffer_size(val)
Definition: target.h:2191
get_frame_pc_if_available
int get_frame_pc_if_available(struct frame_info *frame, CORE_ADDR *pc)
Definition: frame.c:2383
deletelist
struct cmd_list_element * deletelist
Definition: cli-cmds.c:99
VEC_unordered_remove
#define VEC_unordered_remove(T, V, I)
Definition: vec.h:367
LOC_UNDEF
Definition: symtab.h:797
find_matching_tsv
static struct trace_state_variable * find_matching_tsv(struct uploaded_tsv *utsv)
Definition: tracepoint.c:3253
deprecated_trace_start_stop_hook
void(* deprecated_trace_start_stop_hook)(int start, int from_tty)
Definition: tracepoint.c:83
trace_buffer_full
Definition: tracepoint.h:82
trace_status::traceframes_created
int traceframes_created
Definition: tracepoint.h:119
trace_status_mi
void trace_status_mi(int on_stop)
Definition: tracepoint.c:1939
add_cmd
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition: cli-decode.c:262
DEF_VEC_O
DEF_VEC_O(tsv_s)
tvar_attributes
static const struct gdb_xml_attribute tvar_attributes[]
Definition: tracepoint.c:3999
symbol_arch
struct gdbarch * symbol_arch(const struct symbol *symbol)
Definition: symtab.c:5793
agent_expr
Definition: ax.h:83
report_agent_reqs_errors
static void report_agent_reqs_errors(struct agent_expr *aexpr)
Definition: tracepoint.c:618
frame_info
Definition: frame.c:85
parse_exp_1
expression_up parse_exp_1(const char **, CORE_ADDR pc, const struct block *, int)
Definition: parse.c:1089
all_tracepoint_actions_and_cleanup
static struct command_line * all_tracepoint_actions_and_cleanup(struct breakpoint *t)
Definition: tracepoint.c:2813
validate_actionline
void validate_actionline(const char *line, struct breakpoint *b)
Definition: tracepoint.c:643
get_traceframe_location
struct bp_location * get_traceframe_location(int *stepping_frame_p)
Definition: tracepoint.c:2771
LOC_TYPEDEF
Definition: symtab.h:844
VEC_safe_push
#define VEC_safe_push(T, V, O)
Definition: vec.h:276
do_restore_current_traceframe_cleanup
static void do_restore_current_traceframe_cleanup(void *arg)
Definition: tracepoint.c:3024
tfind_number
Definition: tracepoint.h:386
cmdlist
struct cmd_list_element * cmdlist
Definition: cli-cmds.c:79
save_trace_state_variables
void save_trace_state_variables(struct ui_file *fp)
Definition: tracepoint.c:503
gdbarch_num_regs
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:2039
get_tracepoint
struct tracepoint * get_tracepoint(int num)
Definition: breakpoint.c:15018
add_local_symbols_data::collect
struct collection_list * collect
Definition: tracepoint.c:1024
agent_expr::max_height
int max_height
Definition: ax.h:114
lookup_internalvar
struct internalvar * lookup_internalvar(const char *name)
Definition: value.c:2212
skip_spaces
char * skip_spaces(char *chp)
Definition: common-utils.c:337
cleanup
Definition: cleanups.c:38
traceframe_info_start_tvar
static void traceframe_info_start_tvar(struct gdb_xml_parser *parser, const struct gdb_xml_element *element, void *user_data, VEC(gdb_xml_value_s) *attributes)
Definition: tracepoint.c:3978
_
#define _(String)
Definition: gdb_locale.h:35
ui_file
Definition: ui-file.h:26
uploaded_tp::traceframe_usage
ULONGEST traceframe_usage
Definition: tracepoint.h:197
ui_left
Definition: ui-out.h:44
defs.h
char_ptr
char * char_ptr
Definition: gdb_vecs.h:25
builtin_type
Definition: gdbtypes.h:1495
BLOCK_START
#define BLOCK_START(bl)
Definition: block.h:105
LOC_ARG
Definition: symtab.h:823
internalvar
Definition: value.c:2070
agent_expr::flaw
enum agent_flaws flaw
Definition: ax.h:107
trace_state_variable::initial_value
LONGEST initial_value
Definition: tracepoint.h:59
target_get_tracepoint_status
#define target_get_tracepoint_status(tp, utp)
Definition: target.h:2155
teval_pseudocommand
static void teval_pseudocommand(const char *args, int from_tty)
Definition: tracepoint.c:547
DECODE_LINE_FUNFIRSTLINE
Definition: linespec.h:31
trace_state_variable::number
int number
Definition: tracepoint.h:56
read_command_lines
command_line_up read_command_lines(char *prompt_arg, int from_tty, int parse_commands, void(*validator)(char *, void *), void *closure)
Definition: cli-script.c:1198
add_local_symbols_data::pc
CORE_ADDR pc
Definition: tracepoint.c:1026
trace_status::stop_time
LONGEST stop_time
Definition: tracepoint.h:153
allocate_value
struct value * allocate_value(struct type *type)
Definition: value.c:1036
ui_out::text
void text(const char *string)
Definition: ui-out.c:581
ax.h
process_tracepoint_on_disconnect
static void process_tracepoint_on_disconnect(void)
Definition: tracepoint.c:1519
get_current_regcache
struct regcache * get_current_regcache(void)
Definition: regcache.c:446
block_for_pc
const struct block * block_for_pc(CORE_ADDR pc)
Definition: block.c:282
actions_command
static void actions_command(const char *args, int from_tty)
Definition: tracepoint.c:596
free_uploaded_tsvs
void free_uploaded_tsvs(struct uploaded_tsv **utsvp)
Definition: tracepoint.c:3111
GDB_XML_AF_NONE
Definition: xml-support.h:106
may_insert_tracepoints
int may_insert_tracepoints
LOC_LOCAL
Definition: symtab.h:839
printf_filtered
void printf_filtered(const char *format,...)
Definition: utils.c:2045
paddress
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2745
objfiles.h
info_tvariables_command
static void info_tvariables_command(const char *args, int from_tty)
Definition: tracepoint.c:495
target_set_circular_trace_buffer
#define target_set_circular_trace_buffer(val)
Definition: target.h:2188
arch-utils.h
XNEW
#define XNEW(T)
Definition: poison.h:109
set_tracepoint_num
static void set_tracepoint_num(int num)
Definition: tracepoint.c:213
trace_find_type
trace_find_type
Definition: tracepoint.h:384
tracepoint::step_count
long step_count
Definition: breakpoint.h:878
observer_notify_traceframe_changed
void observer_notify_traceframe_changed(int tfnum, int tpnum)
BLOCK_FUNCTION
#define BLOCK_FUNCTION(bl)
Definition: block.h:107
LOC_REGISTER
Definition: symtab.h:819
observer.h
symtab_to_fullname
const char * symtab_to_fullname(struct symtab *s)
Definition: source.c:1131
add_prefix_cmd
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
Definition: cli-decode.c:367
current_trace_status
struct trace_status * current_trace_status(void)
Definition: tracepoint.c:189
breakpoint::hit_count
int hit_count
Definition: breakpoint.h:773
uploaded_tp::at_string
char * at_string
Definition: tracepoint.h:185
target_get_trace_state_variable_value
#define target_get_trace_state_variable_value(tsv, val)
Definition: target.h:2165
rsp-low.h
evaluate_expression
struct value * evaluate_expression(struct expression *exp)
Definition: eval.c:144
symtab.h
frame_id_eq
int frame_id_eq(struct frame_id l, struct frame_id r)
Definition: frame.c:674
command_line::line
char * line
Definition: cli-script.h:54
gdb_argv
Definition: utils.h:128
get_uploaded_tp
struct uploaded_tp * get_uploaded_tp(int num, ULONGEST addr, struct uploaded_tp **utpp)
Definition: tracepoint.c:3057
tfind_pc
Definition: tracepoint.h:387
extract_bp_kind::bp
setlist
struct cmd_list_element * setlist
Definition: cli-cmds.c:111
name
const char *const name
Definition: aarch64-tdep.c:76
VEC_iterate
#define VEC_iterate(T, V, I, P)
Definition: vec.h:181
internalvar_funcs
Definition: value.h:946
mem_ranges_overlap
int mem_ranges_overlap(CORE_ADDR start1, int len1, CORE_ADDR start2, int len2)
Definition: memrange.c:25
target_trace_find
#define target_trace_find(type, num, addr1, addr2, tpp)
Definition: target.h:2161
get_tracepoint_by_number_on_target
struct tracepoint * get_tracepoint_by_number_on_target(int num)
Definition: breakpoint.c:15034
uploaded_tp::type
enum bptype type
Definition: tracepoint.h:169
get_frame_id
struct frame_id get_frame_id(struct frame_info *fi)
Definition: frame.c:520
collection_list::m_computed
std::vector< std::string > m_computed
Definition: tracepoint.h:295
check_typedef
struct type * check_typedef(struct type *type)
Definition: gdbtypes.c:2421
SYMBOL_VALUE_ADDRESS
#define SYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:464
LOC_CONST_BYTES
Definition: symtab.h:859
target_dcache_invalidate
void target_dcache_invalidate(void)
Definition: target-dcache.c:52
LOC_COMPUTED
Definition: symtab.h:892
GDB_XML_EF_NONE
Definition: xml-support.h:127
MAX_AGENT_EXPR_LEN
#define MAX_AGENT_EXPR_LEN
Definition: tracepoint.c:78
value_print_options
Definition: valprint.h:25
make_cleanup_dtor
struct cleanup * make_cleanup_dtor(make_cleanup_ftype *function, void *arg, make_cleanup_dtor_ftype *dtor)
Definition: cleanups.c:125
merge_uploaded_tracepoints
void merge_uploaded_tracepoints(struct uploaded_tp **uploaded_tps)
Definition: tracepoint.c:3176
info_locals_command
void info_locals_command(const char *, int)
Definition: stack.c:2110
end_actions_pseudocommand
static void end_actions_pseudocommand(const char *args, int from_tty)
Definition: tracepoint.c:529
create_tracepoint_from_upload
struct tracepoint * create_tracepoint_from_upload(struct uploaded_tp *utp)
Definition: breakpoint.c:14792
breakpoint::type
bptype type
Definition: breakpoint.h:693
uploaded_tp::hit_count
int hit_count
Definition: tracepoint.h:194
get_uploaded_tsv
struct uploaded_tsv * get_uploaded_tsv(int num, struct uploaded_tsv **utsvp)
Definition: tracepoint.c:3094
gdb_xml_parse_quick
int gdb_xml_parse_quick(const char *name, const char *dtd_name, const struct gdb_xml_element *elements, const char *document, void *user_data)
Definition: xml-support.c:647
current_target
struct target_ops current_target
agent_flaw_none
Definition: ax.h:57
xml_find_attribute
struct gdb_xml_value * xml_find_attribute(VEC(gdb_xml_value_s) *attributes, const char *name)
Definition: xml-support.c:231
wrap_indent
static const char * wrap_indent
Definition: utils.c:1332
find_pc_line
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition: symtab.c:3288
uploaded_tp::cond_string
char * cond_string
Definition: tracepoint.h:188
get_tracepoint_by_number
struct tracepoint * get_tracepoint_by_number(const char **arg, number_or_range_parser *parser)
Definition: breakpoint.c:15055
mem_range
Definition: memrange.h:27
uploaded_tsv::next
struct uploaded_tsv * next
Definition: tracepoint.h:210
set_trace_buffer_size
static void set_trace_buffer_size(const char *args, int from_tty, struct cmd_list_element *c)
Definition: tracepoint.c:2908
tracefile.h
merge_uploaded_trace_state_variables
void merge_uploaded_trace_state_variables(struct uploaded_tsv **uploaded_tsvs)
Definition: tracepoint.c:3299
trace_status
Definition: tracepoint.h:88
fprintf_filtered
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2008
free_current_marker
void free_current_marker(void *arg)
Definition: tracepoint.c:3678
uploaded_tsv::name
const char * name
Definition: tracepoint.h:206
find_pc_function
struct symbol * find_pc_function(CORE_ADDR pc)
Definition: blockframe.c:150
set_cmd_completer
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition: cli-decode.c:160
set_trace_notes
static void set_trace_notes(const char *args, int from_tty, struct cmd_list_element *c)
Definition: tracepoint.c:2927
memrange::start
bfd_signed_vma start
Definition: tracepoint.h:239
class_trace
Definition: command.h:42
trace_state_variable::builtin
int builtin
Definition: tracepoint.h:71
collection_list::add_static_trace_data
void add_static_trace_data()
Definition: tracepoint.c:1104
regcache.h
tfind_outside_command
static void tfind_outside_command(const char *args, int from_tty)
Definition: tracepoint.c:2461
bound_minimal_symbol
Definition: minsyms.h:29
trace_reset_local_state
void trace_reset_local_state(void)
Definition: tracepoint.c:1563
VEC
static VEC(tsv_s)
Definition: tracepoint.c:120
memory_attributes
static const struct gdb_xml_attribute memory_attributes[]
Definition: tracepoint.c:3993
uploaded_tsv::number
int number
Definition: tracepoint.h:207
uploaded_tp::orig_size
int orig_size
Definition: tracepoint.h:174
fprintf_unfiltered
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2018
breakpoint::cond_string
char * cond_string
Definition: breakpoint.h:749
collection_list::append_exp
void append_exp(struct expression *exp)
Definition: tracepoint.c:1231
tfind_end_command
static void tfind_end_command(const char *args, int from_tty)
Definition: tracepoint.c:2305
traceframe_available_memory
int traceframe_available_memory(std::vector< mem_range > *result, CORE_ADDR memaddr, ULONGEST len)
Definition: tracepoint.c:4057
print_expression
void print_expression(struct expression *exp, struct ui_file *stream)
Definition: expprint.c:36
showlist
struct cmd_list_element * showlist
Definition: cli-cmds.c:119
add_com_alias
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
Definition: cli-decode.c:912
uploaded_tp::next
struct uploaded_tp * next
Definition: tracepoint.h:199
mem2hex
static char * mem2hex(gdb_byte *mem, char *buf, int count)
Definition: tracepoint.c:2958
trace_status::stop_reason
enum trace_stop_reason stop_reason
Definition: tracepoint.h:100
cli-utils.h
expression
Definition: expression.h:78
frame.h
TYPE_CODE_FLT
Definition: gdbtypes.h:116
expression.h
static_tracepoint_marker
Definition: tracepoint.h:215
bp_fast_tracepoint
Definition: breakpoint.h:169
gdb_assert_not_reached
#define gdb_assert_not_reached(message)
Definition: gdb_assert.h:55
trace_dump_actions
static void trace_dump_actions(struct command_line *action, int stepping_actions, int stepping_frame, int from_tty)
Definition: tracepoint.c:2667
free_current_contents
void free_current_contents(void *ptr)
Definition: utils.c:199
parse_tracepoint_status
void parse_tracepoint_status(const char *p, struct breakpoint *bp, struct uploaded_tp *utp)
Definition: tracepoint.c:3512
memrange_absolute
Definition: tracepoint.c:786
collection_list::collect_symbol
void collect_symbol(struct symbol *sym, struct gdbarch *gdbarch, long frame_regno, long frame_offset, CORE_ADDR scope, int trace_string)
Definition: tracepoint.c:872
SYMBOL_REGISTER_OPS
#define SYMBOL_REGISTER_OPS(symbol)
Definition: symtab.h:1165
SYMBOL_COMPUTED_OPS
#define SYMBOL_COMPUTED_OPS(symbol)
Definition: symtab.h:1163
normalize_mem_ranges
void normalize_mem_ranges(std::vector< mem_range > *memory)
Definition: memrange.c:45
VEC_length
#define VEC_length(T, V)
Definition: vec.h:140
gdbthread.h
current_uiout
#define current_uiout
Definition: ui-out.h:39
get_traceframe_number
int get_traceframe_number(void)
Definition: tracepoint.c:2976
iterate_over_block_local_vars
void iterate_over_block_local_vars(const struct block *block, iterate_over_block_arg_local_vars_cb cb, void *cb_data)
Definition: stack.c:1994
breakpoint
Definition: breakpoint.h:684
parse_trace_status
void parse_trace_status(const char *line, struct trace_status *ts)
Definition: tracepoint.c:3352
inferior.h
make_cleanup
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:116
parse_traceframe_info
traceframe_info_up parse_traceframe_info(const char *tframe_info)
Definition: tracepoint.c:4023
trace_status::buffer_size
int buffer_size
Definition: tracepoint.h:123
trace_variable_command
static void trace_variable_command(const char *args, int from_tty)
Definition: tracepoint.c:357
type
Definition: gdbtypes.h:749
tdump_command
static void tdump_command(const char *args, int from_tty)
Definition: tracepoint.c:2846
class_alias
Definition: command.h:43
language.h
trace_status::filename
const char * filename
Definition: tracepoint.h:92
default_collect
char * default_collect
tracepoint.h
init_vector_type
struct type * init_vector_type(struct type *elt_type, int n)
Definition: gdbtypes.c:1334
add_setshow_string_cmd
void add_setshow_string_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:613
add_local_symbols_data::frame_regno
long frame_regno
Definition: tracepoint.c:1027
tfind_start_command
static void tfind_start_command(const char *args, int from_tty)
Definition: tracepoint.c:2312
xml-support.h
SRC_AND_LOC
Definition: frame.h:668
LOC_CONST
Definition: symtab.h:801
LOC_UNRESOLVED
Definition: symtab.h:883
BLOCK_SUPERBLOCK
#define BLOCK_SUPERBLOCK(bl)
Definition: block.h:108
bp_location::next
bp_location * next
Definition: breakpoint.h:324
get_current_arch
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:798
tracepoint::pass_count
int pass_count
Definition: breakpoint.h:882
collection_list::m_regs_mask
unsigned char m_regs_mask[32]
Definition: tracepoint.h:282
type
static const char * type
Definition: language.c:113
trace_status::user_name
char * user_name
Definition: tracepoint.h:142
traceframe_info_start_memory
static void traceframe_info_start_memory(struct gdb_xml_parser *parser, const struct gdb_xml_element *element, void *user_data, VEC(gdb_xml_value_s) *attributes)
Definition: tracepoint.c:3960
tracepoint::number_on_target
int number_on_target
Definition: breakpoint.h:885
trace_stop_command
Definition: tracepoint.h:81
SYMBOL_LINKAGE_NAME
#define SYMBOL_LINKAGE_NAME(symbol)
Definition: symtab.h:523
gdbarch_register_name
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
Definition: gdbarch.c:2282
target_static_tracepoint_markers_by_strid
#define target_static_tracepoint_markers_by_strid(marker_id)
Definition: target.h:2208
status
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
Definition: gnu-nat.c:1822
tfind_range_command
static void tfind_range_command(const char *args, int from_tty)
Definition: tracepoint.c:2429
target_download_tracepoint
#define target_download_tracepoint(t)
Definition: target.h:2131
startswith
static int startswith(const char *string, const char *pattern)
Definition: common-utils.h:107
linespec.h
trace_status::stopping_tracepoint
int stopping_tracepoint
Definition: tracepoint.h:105
observer_notify_tsv_modified
void observer_notify_tsv_modified(const struct trace_state_variable *tsv)
start_tracing
void start_tracing(const char *notes)
Definition: tracepoint.c:1572
ui_noalign
Definition: ui-out.h:47
ctf.h
collection_list::add_wholly_collected
void add_wholly_collected(const char *print_name)
Definition: tracepoint.c:1050
LOC_STATIC
Definition: symtab.h:805
set_disconnected_tracing
static void set_disconnected_tracing(const char *args, int from_tty, struct cmd_list_element *c)
Definition: tracepoint.c:2894
event_location_up
std::unique_ptr< event_location, event_location_deleter > event_location_up
Definition: location.h:140
GDB_XML_EF_REPEATABLE
Definition: xml-support.h:129
target_set_trace_notes
#define target_set_trace_notes(user, notes, stopnotes)
Definition: target.h:2194
gdbarch_addr_bit
int gdbarch_addr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1848
print_what
print_what
Definition: frame.h:660
collection_list::m_memranges
std::vector< memrange > m_memranges
Definition: tracepoint.h:284
trace_disconnected
Definition: tracepoint.h:83
xstrprintf
char * xstrprintf(const char *format,...)
Definition: common-utils.c:107
validate_trace_state_variable_name
void validate_trace_state_variable_name(const char *name)
Definition: tracepoint.c:333
breakpoint.h
printf_unfiltered
void printf_unfiltered(const char *format,...)
Definition: utils.c:2056
check_trace_running
void check_trace_running(struct trace_status *status)
Definition: tracepoint.c:2241
collection_list::collection_list
collection_list()
Definition: tracepoint.c:1111
LOC_REGPARM_ADDR
Definition: symtab.h:835
user_reg_map_name_to_regnum
int user_reg_map_name_to_regnum(struct gdbarch *gdbarch, const char *name, int len)
Definition: user-regs.c:130
traceframe_info
Definition: tracepoint.h:31
gdb_xml_parse_ulongest
ULONGEST gdb_xml_parse_ulongest(struct gdb_xml_parser *parser, const char *value)
Definition: xml-support.c:684
xmalloc
void * xmalloc(YYSIZE_T)
stop_reason_names
const char * stop_reason_names[]
symtab_and_line::symtab
struct symtab * symtab
Definition: symtab.h:1751
gdb_xml_element
Definition: xml-support.h:165
agent_expr::min_height
int min_height
Definition: ax.h:114
gen_trace_for_expr
agent_expr_up gen_trace_for_expr(CORE_ADDR scope, struct expression *expr, int trace_string)
Definition: ax-gdb.c:2466
TYPE_CODE_STRUCT
Definition: gdbtypes.h:106
bp_tracepoint
Definition: breakpoint.h:168
target_download_trace_state_variable
#define target_download_trace_state_variable(tsv)
Definition: target.h:2137
breakpoint_set_commands
void breakpoint_set_commands(struct breakpoint *b, command_line_up &&commands)
Definition: breakpoint.c:1169
trace_stop_reason_unknown
Definition: tracepoint.h:79
bptype
bptype
Definition: breakpoint.h:67
collection_list::stringify
std::vector< std::string > stringify()
Definition: tracepoint.c:1122
add_alias_cmd
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition: cli-decode.c:306
sdata_make_value
static struct value * sdata_make_value(struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
Definition: tracepoint.c:3910
SYMBOL_VALUE
#define SYMBOL_VALUE(symbol)
Definition: symtab.h:463
ui_out::spaces
void void spaces(int numspaces)
Definition: ui-out.c:575
reg
Definition: regdef.h:22
string_file::string
std::string & string()
Definition: ui-file.h:132
user-regs.h
LOC_REF_ARG
Definition: symtab.h:827
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
block
Definition: block.h:60
create_tsv_from_upload
static struct trace_state_variable * create_tsv_from_upload(struct uploaded_tsv *utsv)
Definition: tracepoint.c:3262
VEC_empty
#define VEC_empty(T, V)
Definition: vec.h:148
decode_line_1
std::vector< symtab_and_line > decode_line_1(const struct event_location *location, int flags, struct program_space *search_pspace, struct symtab *default_symtab, int default_line)
Definition: linespec.c:3346
value
Definition: value.c:169
target_traceframe_info
#define target_traceframe_info()
Definition: target.h:2212
gen_trace_for_return_address
agent_expr_up gen_trace_for_return_address(CORE_ADDR scope, struct gdbarch *gdbarch, int trace_string)
Definition: ax-gdb.c:2516
wrap_here
void wrap_here(const char *indent)
Definition: utils.c:1596
ui_out
Definition: ui-out.h:77
bp_location::address
CORE_ADDR address
Definition: breakpoint.h:427
uploaded_tp::step
int step
Definition: tracepoint.h:172
tfind_command_1
static void tfind_command_1(const char *args, int from_tty)
Definition: tracepoint.c:2263
xrealloc
PTR xrealloc(PTR ptr, size_t size)
Definition: common-utils.c:52
tracepoint_error
Definition: tracepoint.h:85
trace_status::running_known
int running_known
Definition: tracepoint.h:95
print_stack_frame
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
Definition: stack.c:165
target_get_trace_status
#define target_get_trace_status(ts)
Definition: target.h:2152
trace_status::stop_desc
char * stop_desc
Definition: tracepoint.h:111
symtab_and_line
Definition: symtab.h:1746
restore_current_traceframe_cleanup_dtor
static void restore_current_traceframe_cleanup_dtor(void *arg)
Definition: tracepoint.c:3033
observer_notify_tsv_deleted
void observer_notify_tsv_deleted(const struct trace_state_variable *tsv)
command_line::next
struct command_line * next
Definition: cli-script.h:53
uploaded_tsv::builtin
int builtin
Definition: tracepoint.h:209
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
find_line_pc_range
int find_line_pc_range(struct symtab_and_line sal, CORE_ADDR *startptr, CORE_ADDR *endptr)
Definition: symtab.c:3483
trace_status::traceframe_count
int traceframe_count
Definition: tracepoint.h:115
static_tracepoint_marker::address
CORE_ADDR address
Definition: tracepoint.h:218
trace_status::notes
char * notes
Definition: tracepoint.h:147
traceframe_info_up
std::unique_ptr< traceframe_info > traceframe_info_up
Definition: tracepoint.h:40
get_tracepoint_number
int get_tracepoint_number(void)
Definition: tracepoint.c:2982
current_language
const struct language_defn * current_language
Definition: language.c:81
cond_string_is_same
static int cond_string_is_same(char *str1, char *str2)
Definition: tracepoint.c:3128
source.h
phex_nz
char * phex_nz(ULONGEST l, int sizeof_l)
Definition: print-utils.c:182
encode_source_string
int encode_source_string(int tpnum, ULONGEST addr, const char *srctype, const char *src, char *buf, int buf_size)
Definition: tracepoint.c:2875
tfind_1
void tfind_1(enum trace_find_type type, int num, CORE_ADDR addr1, CORE_ADDR addr2, int from_tty)
Definition: tracepoint.c:2105
add_local_symbols_data::count
int count
Definition: tracepoint.c:1029
memrange_comp
static bool memrange_comp(const memrange &a, const memrange &b)
Definition: tracepoint.c:794
gen_trace_for_var
agent_expr_up gen_trace_for_var(CORE_ADDR scope, struct gdbarch *gdbarch, struct symbol *var, int trace_string)
Definition: ax-gdb.c:2433
XCNEW
#define XCNEW(T)
Definition: poison.h:121
gdbcore.h
do_collect_symbol
static void do_collect_symbol(const char *print_name, struct symbol *sym, void *cb_data)
Definition: tracepoint.c:1036
tracepoint::traceframe_usage
ULONGEST traceframe_usage
Definition: breakpoint.h:889
xsnprintf
int xsnprintf(char *str, size_t size, const char *format,...)
Definition: common-utils.c:134
SYMBOL_BLOCK_VALUE
#define SYMBOL_BLOCK_VALUE(symbol)
Definition: symtab.h:467
parse_and_eval_address
CORE_ADDR parse_and_eval_address(const char *exp)
Definition: eval.c:101
TYPE_CODE
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1238
set_internalvar_string
void set_internalvar_string(struct internalvar *var, const char *string)
Definition: value.c:2453
bp_location::inserted
bool inserted
Definition: breakpoint.h:388
ui_out::field_int
void field_int(const char *fldname, int value)
Definition: ui-out.c:486
bp_location::shlib_disabled
bool shlib_disabled
Definition: breakpoint.h:382
expression_completer
void expression_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition: completer.c:1076
regcache_read_pc
CORE_ADDR regcache_read_pc(struct regcache *regcache)
Definition: regcache.c:1229
trace_state_variable::value
LONGEST value
Definition: tracepoint.h:67
uploaded_tp::cond
char * cond
Definition: tracepoint.h:177
bound_minimal_symbol::minsym
struct minimal_symbol * minsym
Definition: minsyms.h:34
ui_out::table_body
void table_body()
Definition: ui-out.c:379
set_internalvar_integer
void set_internalvar_integer(struct internalvar *var, LONGEST l)
Definition: value.c:2442
trace_state_variable
Definition: tracepoint.h:49
uploaded_tsv
Definition: tracepoint.h:204
add_local_symbols_data::frame_offset
long frame_offset
Definition: tracepoint.c:1028
decode_line_with_current_source
std::vector< symtab_and_line > decode_line_with_current_source(const char *string, int flags)
Definition: linespec.c:3371
trace_status::disconnected_tracing
int disconnected_tracing
Definition: tracepoint.h:132
offset
int offset
Definition: agent.c:65
get_user_print_options
void get_user_print_options(struct value_print_options *opts)
Definition: valprint.c:120
add_setshow_boolean_cmd
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:569
set_current_traceframe
void set_current_traceframe(int num)
Definition: tracepoint.c:2991
tvariables_info_1
void tvariables_info_1(void)
Definition: tracepoint.c:438
registers_changed
void registers_changed(void)
Definition: regcache.c:522
set_traceframe_num
static void set_traceframe_num(int num)
Definition: tracepoint.c:205
VEC_free
#define VEC_free(T, V)
Definition: vec.h:196
tfind_line_command
static void tfind_line_command(const char *args, int from_tty)
Definition: tracepoint.c:2371
parse_tsv_definition
void parse_tsv_definition(const char *line, struct uploaded_tsv **utsvp)
Definition: tracepoint.c:3651
remote.h
tfind_pc_command
static void tfind_pc_command(const char *args, int from_tty)
Definition: tracepoint.c:2319
LOC_LABEL
Definition: symtab.h:848
create_trace_state_variable
struct trace_state_variable * create_trace_state_variable(const char *name)
Definition: tracepoint.c:268
clear_internalvar
void clear_internalvar(struct internalvar *var)
Definition: value.c:2475
symtab_and_line::pc
CORE_ADDR pc
Definition: symtab.h:1759
delete_trace_state_variable
static void delete_trace_state_variable(const char *name)
Definition: tracepoint.c:310
probe.h
collection_list::m_strace_data
bool m_strace_data
Definition: tracepoint.h:290
target.h
uploaded_tp::addr
ULONGEST addr
Definition: tracepoint.h:170
_initialize_tracepoint
void _initialize_tracepoint(void)
Definition: tracepoint.c:4101
string_printf
std::string string_printf(const char *fmt,...)
Definition: common-utils.c:150
value.h
tfind_tp
Definition: tracepoint.h:388
location.h
block_iterator
Definition: block.h:197
uploaded_tp
Definition: tracepoint.h:166
SYMBOL_NATURAL_NAME
#define SYMBOL_NATURAL_NAME(symbol)
Definition: symtab.h:513
gdb_xml_parse_attr_ulongest
gdb_xml_attribute_handler gdb_xml_parse_attr_ulongest
gdbtypes.h
collection_list::add_memrange
void add_memrange(struct gdbarch *gdbarch, int type, bfd_signed_vma base, unsigned long len)
Definition: tracepoint.c:853
parse_and_eval
struct value * parse_and_eval(const char *exp)
Definition: eval.c:119
ULONGEST
unsigned long long ULONGEST
Definition: common-types.h:53
target_trace_start
#define target_trace_start()
Definition: target.h:2146
target_set_disconnected_tracing
#define target_set_disconnected_tracing(val)
Definition: target.h:2185
ignore
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: corelow.c:879
encode_actions
void encode_actions(struct bp_location *tloc, struct collection_list *tracepoint_list, struct collection_list *stepping_list)
Definition: tracepoint.c:1477
target_trace_set_readonly_regions
#define target_trace_set_readonly_regions()
Definition: target.h:2149
tfind_command
static void tfind_command(const char *args, int from_tty)
Definition: tracepoint.c:2298
register_size
int register_size(struct gdbarch *gdbarch, int regnum)
Definition: regcache.c:164
regcache
Definition: regcache.h:232
VEC_cleanup
#define VEC_cleanup(T)
Definition: vec.h:203
delete_trace_variable_command
static void delete_trace_variable_command(const char *args, int from_tty)
Definition: tracepoint.c:413
disconnect_tracing
void disconnect_tracing(void)
Definition: tracepoint.c:2094
iterate_over_block_arg_vars
void iterate_over_block_arg_vars(const struct block *b, iterate_over_block_arg_local_vars_cb cb, void *cb_data)
Definition: stack.c:2121
bp_static_tracepoint
Definition: breakpoint.h:170
collection_list::add_register
void add_register(unsigned int regno)
Definition: tracepoint.c:840
find_trace_state_variable
struct trace_state_variable * find_trace_state_variable(const char *name)
Definition: tracepoint.c:281
gdb_xml_attribute
Definition: xml-support.h:114
collection_list
Definition: tracepoint.h:243
value_print_options::print_max
unsigned int print_max
Definition: valprint.h:53
SYMBOL_TYPE
#define SYMBOL_TYPE(symbol)
Definition: symtab.h:1161
trace_status::running
int running
Definition: tracepoint.h:98
mem_range::length
int length
Definition: memrange.h:50
symbol
Definition: symtab.h:1049
GDB_XML_EF_OPTIONAL
Definition: xml-support.h:128
bp_location::gdbarch
struct gdbarch * gdbarch
Definition: breakpoint.h:413
LOC_OPTIMIZED_OUT
Definition: symtab.h:888
find_trace_state_variable_by_number
struct trace_state_variable * find_trace_state_variable_by_number(int number)
Definition: tracepoint.c:297
gen_eval_for_expr
agent_expr_up gen_eval_for_expr(CORE_ADDR scope, struct expression *expr)
Definition: ax-gdb.c:2496
registers_info
void registers_info(const char *addr_exp, int fpregs)
Definition: infcmd.c:2410
hex2bin
int hex2bin(const char *hex, gdb_byte *bin, int count)
Definition: rsp-low.c:115
command_line_up
std::unique_ptr< command_line, command_lines_deleter > command_line_up
Definition: cli-script.h:88
value_contents_raw
gdb_byte * value_contents_raw(struct value *value)
Definition: value.c:1158
symtab_and_line::line
int line
Definition: symtab.h:1757
info_scope_command
static void info_scope_command(const char *args_in, int from_tty)
Definition: tracepoint.c:2495
gdb.argv
argv
Definition: __init__.py:63
TYPE_LENGTH
#define TYPE_LENGTH(thistype)
Definition: gdbtypes.h:1235
unpack_varlen_hex
const char * unpack_varlen_hex(const char *buff, ULONGEST *result)
Definition: rsp-low.c:96
clear_traceframe_info
static void clear_traceframe_info(void)
Definition: tracepoint.c:198
output_command_const
void output_command_const(const char *exp, int from_tty)
Definition: printcmd.c:1240
dont_repeat
void dont_repeat(void)
Definition: top.c:695
reinit_frame_cache
void reinit_frame_cache(void)
Definition: frame.c:1809
get_pc_function_start
CORE_ADDR get_pc_function_start(CORE_ADDR pc)
Definition: blockframe.c:86
bp_location::owner
breakpoint * owner
Definition: breakpoint.h:341
filestuff.h
tstart_command
static void tstart_command(const char *args, int from_tty)
Definition: tracepoint.c:1701
SYMBOL_VALUE_BYTES
#define SYMBOL_VALUE_BYTES(symbol)
Definition: symtab.h:465
QUIT
#define QUIT
Definition: defs.h:179
resolve_sal_pc
void resolve_sal_pc(struct symtab_and_line *sal)
Definition: breakpoint.c:9543
set_traceframe_context
static void set_traceframe_context(struct frame_info *trace_frame)
Definition: tracepoint.c:223
add_com
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc)
Definition: cli-decode.c:902
breakpoint::enable_state
enum enable_state enable_state
Definition: breakpoint.h:695
info_args_command
void info_args_command(const char *, int)
Definition: stack.c:2192
valprint.h
value_address
CORE_ADDR value_address(const struct value *value)
Definition: value.c:1529
static_tracepoint_marker::extra
char * extra
Definition: tracepoint.h:224
lookup_minimal_symbol
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:311
stack.h
tracepoint_passcount
Definition: tracepoint.h:84
tstop_command
static void tstop_command(const char *args, int from_tty)
Definition: tracepoint.c:1721
command_line::body_list
struct command_line ** body_list
Definition: cli-script.h:71
query_if_trace_running
void query_if_trace_running(int from_tty)
Definition: tracepoint.c:2053
gdbcmd.h
has_stack_frames
int has_stack_frames(void)
Definition: frame.c:1609
target_trace_stop
#define target_trace_stop()
Definition: target.h:2158
collection_list::add_local_symbols
void add_local_symbols(struct gdbarch *gdbarch, CORE_ADDR pc, long frame_regno, long frame_offset, int type, int trace_string)
Definition: tracepoint.c:1058
gdbarch_virtual_frame_pointer
void gdbarch_virtual_frame_pointer(struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset)
Definition: gdbarch.c:1950
create_internalvar_type_lazy
struct internalvar * create_internalvar_type_lazy(const char *name, const struct internalvar_funcs *funcs, void *data)
Definition: value.c:2177
parse_static_tracepoint_marker_definition
void parse_static_tracepoint_marker_definition(const char *line, const char **pp, struct static_tracepoint_marker *marker)
Definition: tracepoint.c:3698
ui_out_emit_table
Definition: ui-out.h:219
target_trace_init
#define target_trace_init()
Definition: target.h:2128
string_to_event_location
event_location_up string_to_event_location(const char **stringp, const struct language_defn *language, symbol_name_match_type match_type)
Definition: location.c:917
add_setshow_zuinteger_unlimited_cmd
void add_setshow_zuinteger_unlimited_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:765
error
void error(const char *fmt,...)
Definition: errors.c:38
trace_state_variable::value_known
int value_known
Definition: tracepoint.h:64
size
size_t size
Definition: go32-nat.c:242
ALL_BLOCK_SYMBOLS
#define ALL_BLOCK_SYMBOLS(block, iter, sym)
Definition: block.h:310
frame_id
Definition: frame.h:111
dictionary.h
parse_tracepoint_definition
void parse_tracepoint_definition(const char *line, struct uploaded_tp **utpp)
Definition: tracepoint.c:3535
collection_list::m_aexprs
std::vector< agent_expr_up > m_aexprs
Definition: tracepoint.h:286
block.h
set_circular_trace_buffer
static void set_circular_trace_buffer(const char *args, int from_tty, struct cmd_list_element *c)
Definition: tracepoint.c:2901
LONGEST
long long LONGEST
Definition: common-types.h:52
memrange_sortmerge
static void memrange_sortmerge(std::vector< memrange > &memranges)
Definition: tracepoint.c:810
do_cleanups
void do_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:174
observer_notify_tsv_created
void observer_notify_tsv_created(const struct trace_state_variable *tsv)
scoped_restore_current_thread
Definition: gdbthread.h:600
ui_out::is_mi_like_p
bool is_mi_like_p()
Definition: ui-out.c:622
SYMBOL_IS_ARGUMENT
#define SYMBOL_IS_ARGUMENT(symbol)
Definition: symtab.h:1157
bp_location
Definition: breakpoint.h:315
ui_out::field_fmt
void field_fmt(const char *fldname, const char *format,...) ATTRIBUTE_PRINTF(3
Definition: ui-out.c:557
observer_notify_breakpoint_modified
void observer_notify_breakpoint_modified(struct breakpoint *b)
encode_actions_rsp
void encode_actions_rsp(struct bp_location *tloc, std::vector< std::string > *tdp_actions, std::vector< std::string > *stepping_actions)
Definition: tracepoint.c:1500
target_supports_string_tracing
#define target_supports_string_tracing()
Definition: target.h:1422
tfind_range
Definition: tracepoint.h:389
gdb_stdout
#define gdb_stdout
Definition: utils.h:340
while_stepping_pseudocommand
static void while_stepping_pseudocommand(const char *args, int from_tty)
Definition: tracepoint.c:535
current_traceframe_cleanup::traceframe_number
int traceframe_number
Definition: tracepoint.c:3020
traceframe_info_elements
static const struct gdb_xml_element traceframe_info_elements[]
Definition: tracepoint.c:4014
trace_state_variable::name
const char * name
Definition: tracepoint.h:53
string_file
Definition: ui-file.h:106
mem_range::start
CORE_ADDR start
Definition: memrange.h:47
trace_status::start_time
LONGEST start_time
Definition: tracepoint.h:152
parse_and_eval_long
LONGEST parse_and_eval_long(const char *exp)
Definition: eval.c:111