gdb/tracepoint.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* Data structures associated with tracepoints in GDB.
  2.    Copyright (C) 1997-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #if !defined (TRACEPOINT_H)
  15. #define TRACEPOINT_H 1

  16. #include "breakpoint.h"
  17. #include "target.h"
  18. #include "memrange.h"
  19. #include "gdb_vecs.h"

  20. /* An object describing the contents of a traceframe.  */

  21. struct traceframe_info
  22. {
  23.   /* Collected memory.  */
  24.   VEC(mem_range_s) *memory;

  25.   /* Collected trace state variables.  */
  26.   VEC(int) *tvars;
  27. };

  28. /* A trace state variable is a value managed by a target being
  29.    traced.  A trace state variable (or tsv for short) can be accessed
  30.    and assigned to by tracepoint actions and conditionals, but is not
  31.    part of the program being traced, and it doesn't have to be
  32.    collected.  Effectively the variables are scratch space for
  33.    tracepoints.  */

  34. struct trace_state_variable
  35.   {
  36.     /* The variable's name.  The user has to prefix with a dollar sign,
  37.        but we don't store that internally.  */
  38.     const char *name;

  39.     /* An id number assigned by GDB, and transmitted to targets.  */
  40.     int number;

  41.     /* The initial value of a variable is a 64-bit signed integer.  */
  42.     LONGEST initial_value;

  43.     /* 1 if the value is known, else 0.  The value is known during a
  44.        trace run, or in tfind mode if the variable was collected into
  45.        the current trace frame.  */
  46.     int value_known;

  47.     /* The value of a variable is a 64-bit signed integer.  */
  48.     LONGEST value;

  49.     /* This is true for variables that are predefined and built into
  50.        the target.  */
  51.     int builtin;
  52.    };

  53. /* The trace status encompasses various info about the general state
  54.    of the tracing run.  */

  55. enum trace_stop_reason
  56.   {
  57.     trace_stop_reason_unknown,
  58.     trace_never_run,
  59.     tstop_command,
  60.     trace_buffer_full,
  61.     trace_disconnected,
  62.     tracepoint_passcount,
  63.     tracepoint_error
  64.   };

  65. struct trace_status
  66. {
  67.   /* If the status is coming from a file rather than a live target,
  68.      this points at the file's filename.  Otherwise, this is NULL.  */
  69.   const char *filename;

  70.   /* This is true if the value of the running field is known.  */
  71.   int running_known;

  72.   /* This is true when the trace experiment is actually running.  */
  73.   int running;

  74.   enum trace_stop_reason stop_reason;

  75.   /* If stop_reason is tracepoint_passcount or tracepoint_error, this
  76.      is the (on-target) number of the tracepoint which caused the
  77.      stop.  */
  78.   int stopping_tracepoint;

  79.   /* If stop_reason is tstop_command or tracepoint_error, this is an
  80.      arbitrary string that may describe the reason for the stop in
  81.      more detail.  */

  82.   char *stop_desc;

  83.   /* Number of traceframes currently in the buffer.  */

  84.   int traceframe_count;

  85.   /* Number of traceframes created since start of run.  */

  86.   int traceframes_created;

  87.   /* Total size of the target's trace buffer.  */

  88.   int buffer_size;

  89.   /* Unused bytes left in the target's trace buffer.  */

  90.   int buffer_free;

  91.   /* 1 if the target will continue tracing after disconnection, else
  92.      0.  If the target does not report a value, assume 0.  */

  93.   int disconnected_tracing;

  94.   /* 1 if the target is using a circular trace buffer, else 0.  If the
  95.      target does not report a value, assume 0.  */

  96.   int circular_buffer;

  97.   /* The "name" of the person running the trace.  This is an
  98.      arbitrary string.  */

  99.   char *user_name;

  100.   /* "Notes" about the trace.  This is an arbitrary string not
  101.      interpreted by GDBserver in any special way.  */

  102.   char *notes;

  103.   /* The calendar times at which the trace run started and stopped,
  104.      both expressed in microseconds of Unix time.  */

  105.   LONGEST start_time;
  106.   LONGEST stop_time;
  107. };

  108. struct trace_status *current_trace_status (void);

  109. extern char *default_collect;

  110. extern int trace_regblock_size;

  111. extern const char *stop_reason_names[];

  112. /* Struct to collect random info about tracepoints on the target.  */

  113. struct uploaded_tp
  114. {
  115.   int number;
  116.   enum bptype type;
  117.   ULONGEST addr;
  118.   int enabled;
  119.   int step;
  120.   int pass;
  121.   int orig_size;

  122.   /* String that is the encoded form of the tracepoint's condition.  */
  123.   char *cond;

  124.   /* Vectors of strings that are the encoded forms of a tracepoint's
  125.      actions.  */
  126.   VEC(char_ptr) *actions;
  127.   VEC(char_ptr) *step_actions;

  128.   /* The original string defining the location of the tracepoint.  */
  129.   char *at_string;

  130.   /* The original string defining the tracepoint's condition.  */
  131.   char *cond_string;

  132.   /* List of original strings defining the tracepoint's actions.  */
  133.   VEC(char_ptr) *cmd_strings;

  134.   /* The tracepoint's current hit count.  */
  135.   int hit_count;

  136.   /* The tracepoint's current traceframe usage.  */
  137.   ULONGEST traceframe_usage;

  138.   struct uploaded_tp *next;
  139. };

  140. /* Struct recording info about trace state variables on the target.  */

  141. struct uploaded_tsv
  142. {
  143.   const char *name;
  144.   int number;
  145.   LONGEST initial_value;
  146.   int builtin;
  147.   struct uploaded_tsv *next;
  148. };

  149. /* Struct recording info about a target static tracepoint marker.  */

  150. struct static_tracepoint_marker
  151. {
  152.   struct gdbarch *gdbarch;
  153.   CORE_ADDR address;

  154.   /* The string ID of the marker.  */
  155.   char *str_id;

  156.   /* Extra target reported info associated with the marker.  */
  157.   char *extra;
  158. };

  159. struct memrange
  160. {
  161.   /* memrange_absolute for absolute memory range, else basereg
  162.      number.  */
  163.   int type;
  164.   bfd_signed_vma start;
  165.   bfd_signed_vma end;
  166. };

  167. struct collection_list
  168. {
  169.   /* room for up to 256 regs */
  170.   unsigned char regs_mask[32];
  171.   long listsize;
  172.   long next_memrange;
  173.   struct memrange *list;

  174.   /* size of array pointed to by expr_list elt.  */
  175.   long aexpr_listsize;
  176.   long next_aexpr_elt;
  177.   struct agent_expr **aexpr_list;

  178.   /* True is the user requested a collection of "$_sdata", "static
  179.      tracepoint data".  */
  180.   int strace_data;

  181.   /* A set of names of wholly collected objects.  */
  182.   VEC(char_ptr) *wholly_collected;
  183.   /* A set of computed expressions.  */
  184.   VEC(char_ptr) *computed;
  185. };

  186. extern void parse_static_tracepoint_marker_definition
  187.   (char *line, char **pp,
  188.    struct static_tracepoint_marker *marker);
  189. extern void release_static_tracepoint_marker (struct static_tracepoint_marker *);
  190. extern void free_current_marker (void *arg);

  191. /* A hook used to notify the UI of tracepoint operations.  */

  192. extern void (*deprecated_trace_find_hook) (char *arg, int from_tty);
  193. extern void (*deprecated_trace_start_stop_hook) (int start, int from_tty);

  194. /* Returns the current traceframe number.  */
  195. extern int get_traceframe_number (void);

  196. /* Returns the tracepoint number for current traceframe.  */
  197. extern int get_tracepoint_number (void);

  198. /* Make the traceframe NUM be the current trace frame, all the way to
  199.    the target, and flushes all global state (register/frame caches,
  200.    etc.).  */
  201. extern void set_current_traceframe (int num);

  202. struct cleanup *make_cleanup_restore_current_traceframe (void);

  203. void free_actions (struct breakpoint *);

  204. extern const char *decode_agent_options (const char *exp, int *trace_string);

  205. extern struct cleanup *
  206.   encode_actions_and_make_cleanup (struct bp_location *tloc,
  207.                                    struct collection_list *tracepoint_list,
  208.                                    struct collection_list *stepping_list);

  209. extern void encode_actions_rsp (struct bp_location *tloc,
  210.                                 char ***tdp_actions, char ***stepping_actions);

  211. extern void validate_actionline (const char *, struct breakpoint *);
  212. extern void validate_trace_state_variable_name (const char *name);

  213. extern struct trace_state_variable *find_trace_state_variable (const char *name);
  214. extern struct trace_state_variable *
  215.   find_trace_state_variable_by_number (int number);

  216. extern struct trace_state_variable *create_trace_state_variable (const char *name);

  217. extern int encode_source_string (int num, ULONGEST addr,
  218.                                  char *srctype, char *src,
  219.                                  char *buf, int buf_size);

  220. extern void parse_trace_status (char *line, struct trace_status *ts);

  221. extern void parse_tracepoint_status (char *p, struct breakpoint *tp,
  222.                                      struct uploaded_tp *utp);

  223. extern void parse_tracepoint_definition (char *line,
  224.                                          struct uploaded_tp **utpp);
  225. extern void parse_tsv_definition (char *line, struct uploaded_tsv **utsvp);

  226. extern struct uploaded_tp *get_uploaded_tp (int num, ULONGEST addr,
  227.                                             struct uploaded_tp **utpp);
  228. extern void free_uploaded_tps (struct uploaded_tp **utpp);

  229. extern struct uploaded_tsv *get_uploaded_tsv (int num,
  230.                                               struct uploaded_tsv **utsvp);
  231. extern void free_uploaded_tsvs (struct uploaded_tsv **utsvp);
  232. extern struct tracepoint *create_tracepoint_from_upload (struct uploaded_tp *utp);
  233. extern void merge_uploaded_tracepoints (struct uploaded_tp **utpp);
  234. extern void merge_uploaded_trace_state_variables (struct uploaded_tsv **utsvp);

  235. extern void query_if_trace_running (int from_tty);
  236. extern void disconnect_tracing (void);
  237. extern void trace_reset_local_state (void);

  238. extern void check_trace_running (struct trace_status *);

  239. extern void start_tracing (char *notes);
  240. extern void stop_tracing (char *notes);

  241. extern void trace_status_mi (int on_stop);

  242. extern void tvariables_info_1 (void);
  243. extern void save_trace_state_variables (struct ui_file *fp);

  244. extern void tfind_1 (enum trace_find_type type, int num,
  245.                      CORE_ADDR addr1, CORE_ADDR addr2,
  246.                      int from_tty);

  247. extern void trace_save_tfile (const char *filename,
  248.                               int target_does_save);
  249. extern void trace_save_ctf (const char *dirname,
  250.                             int target_does_save);

  251. extern struct traceframe_info *parse_traceframe_info (const char *tframe_info);

  252. extern int traceframe_available_memory (VEC(mem_range_s) **result,
  253.                                         CORE_ADDR memaddr, ULONGEST len);

  254. extern struct traceframe_info *get_traceframe_info (void);

  255. extern struct bp_location *get_traceframe_location (int *stepping_frame_p);

  256. #endif        /* TRACEPOINT_H */