15796c8dcSSimon Schubert /* Data structures associated with tracepoints in GDB. 2*ef5ccd6cSJohn Marino Copyright (C) 1997-2013 Free Software Foundation, Inc. 35796c8dcSSimon Schubert 45796c8dcSSimon Schubert This file is part of GDB. 55796c8dcSSimon Schubert 65796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 75796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 85796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 95796c8dcSSimon Schubert (at your option) any later version. 105796c8dcSSimon Schubert 115796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 125796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 135796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 145796c8dcSSimon Schubert GNU General Public License for more details. 155796c8dcSSimon Schubert 165796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 175796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 185796c8dcSSimon Schubert 195796c8dcSSimon Schubert #if !defined (TRACEPOINT_H) 205796c8dcSSimon Schubert #define TRACEPOINT_H 1 215796c8dcSSimon Schubert 22cf7f2e2dSJohn Marino #include "breakpoint.h" 23cf7f2e2dSJohn Marino #include "target.h" 24c50c785cSJohn Marino #include "memrange.h" 25*ef5ccd6cSJohn Marino #include "gdb_vecs.h" 26cf7f2e2dSJohn Marino 27cf7f2e2dSJohn Marino /* A trace state variable is a value managed by a target being 28cf7f2e2dSJohn Marino traced. A trace state variable (or tsv for short) can be accessed 29cf7f2e2dSJohn Marino and assigned to by tracepoint actions and conditionals, but is not 30cf7f2e2dSJohn Marino part of the program being traced, and it doesn't have to be 31cf7f2e2dSJohn Marino collected. Effectively the variables are scratch space for 32cf7f2e2dSJohn Marino tracepoints. */ 33cf7f2e2dSJohn Marino 34cf7f2e2dSJohn Marino struct trace_state_variable 355796c8dcSSimon Schubert { 36cf7f2e2dSJohn Marino /* The variable's name. The user has to prefix with a dollar sign, 37cf7f2e2dSJohn Marino but we don't store that internally. */ 38cf7f2e2dSJohn Marino const char *name; 39cf7f2e2dSJohn Marino 40cf7f2e2dSJohn Marino /* An id number assigned by GDB, and transmitted to targets. */ 41cf7f2e2dSJohn Marino int number; 42cf7f2e2dSJohn Marino 43cf7f2e2dSJohn Marino /* The initial value of a variable is a 64-bit signed integer. */ 44cf7f2e2dSJohn Marino LONGEST initial_value; 45cf7f2e2dSJohn Marino 46cf7f2e2dSJohn Marino /* 1 if the value is known, else 0. The value is known during a 47cf7f2e2dSJohn Marino trace run, or in tfind mode if the variable was collected into 48cf7f2e2dSJohn Marino the current trace frame. */ 49cf7f2e2dSJohn Marino int value_known; 50cf7f2e2dSJohn Marino 51cf7f2e2dSJohn Marino /* The value of a variable is a 64-bit signed integer. */ 52cf7f2e2dSJohn Marino LONGEST value; 53cf7f2e2dSJohn Marino 54cf7f2e2dSJohn Marino /* This is true for variables that are predefined and built into 55cf7f2e2dSJohn Marino the target. */ 56cf7f2e2dSJohn Marino int builtin; 575796c8dcSSimon Schubert }; 585796c8dcSSimon Schubert 59cf7f2e2dSJohn Marino /* The trace status encompasses various info about the general state 60cf7f2e2dSJohn Marino of the tracing run. */ 61cf7f2e2dSJohn Marino 62cf7f2e2dSJohn Marino enum trace_stop_reason 635796c8dcSSimon Schubert { 64cf7f2e2dSJohn Marino trace_stop_reason_unknown, 65cf7f2e2dSJohn Marino trace_never_run, 66cf7f2e2dSJohn Marino tstop_command, 67cf7f2e2dSJohn Marino trace_buffer_full, 68cf7f2e2dSJohn Marino trace_disconnected, 69cf7f2e2dSJohn Marino tracepoint_passcount, 70cf7f2e2dSJohn Marino tracepoint_error 715796c8dcSSimon Schubert }; 725796c8dcSSimon Schubert 73cf7f2e2dSJohn Marino struct trace_status 74cf7f2e2dSJohn Marino { 75*ef5ccd6cSJohn Marino /* If the status is coming from a file rather than a live target, 76*ef5ccd6cSJohn Marino this points at the file's filename. Otherwise, this is NULL. */ 77*ef5ccd6cSJohn Marino const char *filename; 78cf7f2e2dSJohn Marino 79cf7f2e2dSJohn Marino /* This is true if the value of the running field is known. */ 80cf7f2e2dSJohn Marino int running_known; 81cf7f2e2dSJohn Marino 82a45ae5f8SJohn Marino /* This is true when the trace experiment is actually running. */ 83cf7f2e2dSJohn Marino int running; 84cf7f2e2dSJohn Marino 85cf7f2e2dSJohn Marino enum trace_stop_reason stop_reason; 86cf7f2e2dSJohn Marino 87cf7f2e2dSJohn Marino /* If stop_reason is tracepoint_passcount or tracepoint_error, this 88cf7f2e2dSJohn Marino is the (on-target) number of the tracepoint which caused the 89cf7f2e2dSJohn Marino stop. */ 90cf7f2e2dSJohn Marino int stopping_tracepoint; 91cf7f2e2dSJohn Marino 92a45ae5f8SJohn Marino /* If stop_reason is tstop_command or tracepoint_error, this is an 93a45ae5f8SJohn Marino arbitrary string that may describe the reason for the stop in 94a45ae5f8SJohn Marino more detail. */ 95a45ae5f8SJohn Marino 96a45ae5f8SJohn Marino char *stop_desc; 97cf7f2e2dSJohn Marino 98cf7f2e2dSJohn Marino /* Number of traceframes currently in the buffer. */ 99cf7f2e2dSJohn Marino 100cf7f2e2dSJohn Marino int traceframe_count; 101cf7f2e2dSJohn Marino 102cf7f2e2dSJohn Marino /* Number of traceframes created since start of run. */ 103cf7f2e2dSJohn Marino 104cf7f2e2dSJohn Marino int traceframes_created; 105cf7f2e2dSJohn Marino 106cf7f2e2dSJohn Marino /* Total size of the target's trace buffer. */ 107cf7f2e2dSJohn Marino 108cf7f2e2dSJohn Marino int buffer_size; 109cf7f2e2dSJohn Marino 110cf7f2e2dSJohn Marino /* Unused bytes left in the target's trace buffer. */ 111cf7f2e2dSJohn Marino 112cf7f2e2dSJohn Marino int buffer_free; 113cf7f2e2dSJohn Marino 114cf7f2e2dSJohn Marino /* 1 if the target will continue tracing after disconnection, else 115cf7f2e2dSJohn Marino 0. If the target does not report a value, assume 0. */ 116cf7f2e2dSJohn Marino 117cf7f2e2dSJohn Marino int disconnected_tracing; 118cf7f2e2dSJohn Marino 119cf7f2e2dSJohn Marino /* 1 if the target is using a circular trace buffer, else 0. If the 120cf7f2e2dSJohn Marino target does not report a value, assume 0. */ 121cf7f2e2dSJohn Marino 122cf7f2e2dSJohn Marino int circular_buffer; 123a45ae5f8SJohn Marino 124a45ae5f8SJohn Marino /* The "name" of the person running the trace. This is an 125a45ae5f8SJohn Marino arbitrary string. */ 126a45ae5f8SJohn Marino 127a45ae5f8SJohn Marino char *user_name; 128a45ae5f8SJohn Marino 129a45ae5f8SJohn Marino /* "Notes" about the trace. This is an arbitrary string not 130a45ae5f8SJohn Marino interpreted by GDBserver in any special way. */ 131a45ae5f8SJohn Marino 132a45ae5f8SJohn Marino char *notes; 133a45ae5f8SJohn Marino 134a45ae5f8SJohn Marino /* The calendar times at which the trace run started and stopped, 135a45ae5f8SJohn Marino both expressed in microseconds of Unix time. */ 136a45ae5f8SJohn Marino 137a45ae5f8SJohn Marino LONGEST start_time; 138a45ae5f8SJohn Marino LONGEST stop_time; 139cf7f2e2dSJohn Marino }; 140cf7f2e2dSJohn Marino 141cf7f2e2dSJohn Marino struct trace_status *current_trace_status (void); 142cf7f2e2dSJohn Marino 143cf7f2e2dSJohn Marino extern char *default_collect; 144cf7f2e2dSJohn Marino 145cf7f2e2dSJohn Marino /* Struct to collect random info about tracepoints on the target. */ 146cf7f2e2dSJohn Marino 147cf7f2e2dSJohn Marino struct uploaded_tp 148cf7f2e2dSJohn Marino { 149cf7f2e2dSJohn Marino int number; 150cf7f2e2dSJohn Marino enum bptype type; 151cf7f2e2dSJohn Marino ULONGEST addr; 152cf7f2e2dSJohn Marino int enabled; 153cf7f2e2dSJohn Marino int step; 154cf7f2e2dSJohn Marino int pass; 155cf7f2e2dSJohn Marino int orig_size; 156cf7f2e2dSJohn Marino 157cf7f2e2dSJohn Marino /* String that is the encoded form of the tracepoint's condition. */ 158cf7f2e2dSJohn Marino char *cond; 159cf7f2e2dSJohn Marino 160c50c785cSJohn Marino /* Vectors of strings that are the encoded forms of a tracepoint's 161c50c785cSJohn Marino actions. */ 162cf7f2e2dSJohn Marino VEC(char_ptr) *actions; 163cf7f2e2dSJohn Marino VEC(char_ptr) *step_actions; 164cf7f2e2dSJohn Marino 165cf7f2e2dSJohn Marino /* The original string defining the location of the tracepoint. */ 166cf7f2e2dSJohn Marino char *at_string; 167cf7f2e2dSJohn Marino 168cf7f2e2dSJohn Marino /* The original string defining the tracepoint's condition. */ 169cf7f2e2dSJohn Marino char *cond_string; 170cf7f2e2dSJohn Marino 171cf7f2e2dSJohn Marino /* List of original strings defining the tracepoint's actions. */ 172cf7f2e2dSJohn Marino VEC(char_ptr) *cmd_strings; 173cf7f2e2dSJohn Marino 174a45ae5f8SJohn Marino /* The tracepoint's current hit count. */ 175a45ae5f8SJohn Marino int hit_count; 176a45ae5f8SJohn Marino 177a45ae5f8SJohn Marino /* The tracepoint's current traceframe usage. */ 178a45ae5f8SJohn Marino ULONGEST traceframe_usage; 179a45ae5f8SJohn Marino 180cf7f2e2dSJohn Marino struct uploaded_tp *next; 181cf7f2e2dSJohn Marino }; 182cf7f2e2dSJohn Marino 183cf7f2e2dSJohn Marino /* Struct recording info about trace state variables on the target. */ 184cf7f2e2dSJohn Marino 185cf7f2e2dSJohn Marino struct uploaded_tsv 186cf7f2e2dSJohn Marino { 187cf7f2e2dSJohn Marino const char *name; 188cf7f2e2dSJohn Marino int number; 189cf7f2e2dSJohn Marino LONGEST initial_value; 190cf7f2e2dSJohn Marino int builtin; 191cf7f2e2dSJohn Marino struct uploaded_tsv *next; 192cf7f2e2dSJohn Marino }; 193cf7f2e2dSJohn Marino 194cf7f2e2dSJohn Marino /* Struct recording info about a target static tracepoint marker. */ 195cf7f2e2dSJohn Marino 196cf7f2e2dSJohn Marino struct static_tracepoint_marker 197cf7f2e2dSJohn Marino { 198cf7f2e2dSJohn Marino struct gdbarch *gdbarch; 199cf7f2e2dSJohn Marino CORE_ADDR address; 200cf7f2e2dSJohn Marino 201cf7f2e2dSJohn Marino /* The string ID of the marker. */ 202cf7f2e2dSJohn Marino char *str_id; 203cf7f2e2dSJohn Marino 204cf7f2e2dSJohn Marino /* Extra target reported info associated with the marker. */ 205cf7f2e2dSJohn Marino char *extra; 206cf7f2e2dSJohn Marino }; 207cf7f2e2dSJohn Marino 208cf7f2e2dSJohn Marino extern void parse_static_tracepoint_marker_definition 209cf7f2e2dSJohn Marino (char *line, char **pp, 210cf7f2e2dSJohn Marino struct static_tracepoint_marker *marker); 211cf7f2e2dSJohn Marino extern void release_static_tracepoint_marker (struct static_tracepoint_marker *); 212*ef5ccd6cSJohn Marino extern void free_current_marker (void *arg); 2135796c8dcSSimon Schubert 2145796c8dcSSimon Schubert /* A hook used to notify the UI of tracepoint operations. */ 2155796c8dcSSimon Schubert 216cf7f2e2dSJohn Marino extern void (*deprecated_trace_find_hook) (char *arg, int from_tty); 217cf7f2e2dSJohn Marino extern void (*deprecated_trace_start_stop_hook) (int start, int from_tty); 2185796c8dcSSimon Schubert 219c50c785cSJohn Marino /* Returns the current traceframe number. */ 220c50c785cSJohn Marino extern int get_traceframe_number (void); 221c50c785cSJohn Marino 222c50c785cSJohn Marino /* Make the traceframe NUM be the current GDB trace frame number, and 223c50c785cSJohn Marino do nothing more. In particular, this does not flush the 224c50c785cSJohn Marino register/frame caches or notify the target about the trace frame 225c50c785cSJohn Marino change, so that is can be used when we need to momentarily access 226c50c785cSJohn Marino live memory. Targets lazily switch their current traceframe to 227c50c785cSJohn Marino match GDB's traceframe number, at the appropriate times. */ 228c50c785cSJohn Marino extern void set_traceframe_number (int); 229c50c785cSJohn Marino 230c50c785cSJohn Marino /* Make the traceframe NUM be the current trace frame, all the way to 231c50c785cSJohn Marino the target, and flushes all global state (register/frame caches, 232c50c785cSJohn Marino etc.). */ 233c50c785cSJohn Marino extern void set_current_traceframe (int num); 234c50c785cSJohn Marino 235cf7f2e2dSJohn Marino struct cleanup *make_cleanup_restore_current_traceframe (void); 236c50c785cSJohn Marino struct cleanup *make_cleanup_restore_traceframe_number (void); 237cf7f2e2dSJohn Marino 2385796c8dcSSimon Schubert void free_actions (struct breakpoint *); 239a45ae5f8SJohn Marino 240a45ae5f8SJohn Marino extern char *decode_agent_options (char *exp); 241a45ae5f8SJohn Marino 242*ef5ccd6cSJohn Marino extern void encode_actions (struct breakpoint *t, struct bp_location *tloc, 243*ef5ccd6cSJohn Marino char ***tdp_actions, char ***stepping_actions); 2445796c8dcSSimon Schubert 245*ef5ccd6cSJohn Marino extern void validate_actionline (char **, struct breakpoint *); 246*ef5ccd6cSJohn Marino extern void validate_trace_state_variable_name (const char *name); 2475796c8dcSSimon Schubert 248cf7f2e2dSJohn Marino extern struct trace_state_variable *find_trace_state_variable (const char *name); 249cf7f2e2dSJohn Marino extern struct trace_state_variable *create_trace_state_variable (const char *name); 250cf7f2e2dSJohn Marino 251cf7f2e2dSJohn Marino extern int encode_source_string (int num, ULONGEST addr, 252cf7f2e2dSJohn Marino char *srctype, char *src, 253cf7f2e2dSJohn Marino char *buf, int buf_size); 254cf7f2e2dSJohn Marino 255cf7f2e2dSJohn Marino extern void parse_trace_status (char *line, struct trace_status *ts); 256cf7f2e2dSJohn Marino 257a45ae5f8SJohn Marino extern void parse_tracepoint_status (char *p, struct breakpoint *tp, 258a45ae5f8SJohn Marino struct uploaded_tp *utp); 259a45ae5f8SJohn Marino 260c50c785cSJohn Marino extern void parse_tracepoint_definition (char *line, 261c50c785cSJohn Marino struct uploaded_tp **utpp); 262cf7f2e2dSJohn Marino extern void parse_tsv_definition (char *line, struct uploaded_tsv **utsvp); 263cf7f2e2dSJohn Marino 264cf7f2e2dSJohn Marino extern struct uploaded_tp *get_uploaded_tp (int num, ULONGEST addr, 265cf7f2e2dSJohn Marino struct uploaded_tp **utpp); 266a45ae5f8SJohn Marino extern struct tracepoint *create_tracepoint_from_upload (struct uploaded_tp *utp); 267cf7f2e2dSJohn Marino extern void merge_uploaded_tracepoints (struct uploaded_tp **utpp); 268cf7f2e2dSJohn Marino extern void merge_uploaded_trace_state_variables (struct uploaded_tsv **utsvp); 269cf7f2e2dSJohn Marino 270cf7f2e2dSJohn Marino extern void disconnect_tracing (int from_tty); 271cf7f2e2dSJohn Marino 272a45ae5f8SJohn Marino extern void start_tracing (char *notes); 273a45ae5f8SJohn Marino extern void stop_tracing (char *notes); 274cf7f2e2dSJohn Marino 275cf7f2e2dSJohn Marino extern void trace_status_mi (int on_stop); 276cf7f2e2dSJohn Marino 277cf7f2e2dSJohn Marino extern void tvariables_info_1 (void); 278cf7f2e2dSJohn Marino extern void save_trace_state_variables (struct ui_file *fp); 279cf7f2e2dSJohn Marino 280cf7f2e2dSJohn Marino extern void tfind_1 (enum trace_find_type type, int num, 281cf7f2e2dSJohn Marino ULONGEST addr1, ULONGEST addr2, 282cf7f2e2dSJohn Marino int from_tty); 283cf7f2e2dSJohn Marino 284cf7f2e2dSJohn Marino extern void trace_save (const char *filename, int target_does_save); 285cf7f2e2dSJohn Marino 286c50c785cSJohn Marino extern struct traceframe_info *parse_traceframe_info (const char *tframe_info); 287c50c785cSJohn Marino 288c50c785cSJohn Marino extern int traceframe_available_memory (VEC(mem_range_s) **result, 289c50c785cSJohn Marino CORE_ADDR memaddr, ULONGEST len); 290c50c785cSJohn Marino 2915796c8dcSSimon Schubert #endif /* TRACEPOINT_H */ 292