GDB (xrefs)

Classes | Macros | Typedefs | Functions | Variables
/tmp/gdb-8.1/gdb/tracefile-tfile.c File Reference
`#include "defs.h"`
`#include "tracefile.h"`
`#include "readline/tilde.h"`
`#include "filestuff.h"`
`#include "rsp-low.h"`
`#include "regcache.h"`
`#include "inferior.h"`
`#include "gdbthread.h"`
`#include "exec.h"`
`#include "completer.h"`
`#include "filenames.h"`
`#include "remote.h"`
`#include "xml-tdesc.h"`
`#include "target-descriptions.h"`
`#include "buffer.h"`
`#include <algorithm>`

Go to the source code of this file.

## Classes
struct | tfile_trace_file_writer

## Macros
#define | O_LARGEFILE 0
#define | MAX_TRACE_UPLOAD 2000
#define | TRACE_HEADER_SIZE 8
#define | TFILE_PID (1)

## Typedefs
typedef int(* | walk_blocks_callback_func) (char blocktype, void *data)

## Functions
static int | tfile_target_save (struct trace_file_writer *self, const char *filename)
static void | tfile_dtor (struct trace_file_writer *self)
static void | tfile_start (struct trace_file_writer *self, const char *filename)
static void | tfile_write_header (struct trace_file_writer *self)
static void | tfile_write_regblock_type (struct trace_file_writer *self, int size)
static void | tfile_write_status (struct trace_file_writer *self, struct trace_status *ts)
static void | tfile_write_uploaded_tsv (struct trace_file_writer *self, struct uploaded_tsv *utsv)
static void | tfile_write_uploaded_tp (struct trace_file_writer *self, struct uploaded_tp *utp)
static void | tfile_write_tdesc (struct trace_file_writer *self)
static void | tfile_write_definition_end (struct trace_file_writer *self)
static void | tfile_write_raw_data (struct trace_file_writer *self, gdb_byte *buf, LONGEST len)
static void | tfile_end (struct trace_file_writer *self)
struct trace_file_writer * | tfile_trace_file_writer_new (void)
static void | tfile_append_tdesc_line (const char *line)
static void | tfile_interp_line (char *line, struct uploaded_tp **utpp, struct uploaded_tsv **utsvp)
static void | tfile_read (gdb_byte *readbuf, int size)
static void | tfile_open (const char *arg, int from_tty)
static void | tfile_close (struct target_ops *self)
static void | tfile_files_info (struct target_ops *t)
static void | tfile_get_tracepoint_status (struct target_ops *self, struct breakpoint *tp, struct uploaded_tp *utp)
static CORE_ADDR | tfile_get_traceframe_address (off_t tframe_offset)
static int | tfile_trace_find (struct target_ops *self, enum trace_find_type type, int num, CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
static int | match_blocktype (char blocktype, void *data)
static int | traceframe_walk_blocks (walk_blocks_callback_func callback, int pos, void *data)
static int | traceframe_find_block_type (char type_wanted, int pos)
static void | tfile_fetch_registers (struct target_ops *ops, struct regcache *regcache, int regno)
static enum target_xfer_status | tfile_xfer_partial_features (struct target_ops *ops, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
static enum target_xfer_status | tfile_xfer_partial (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
static int | tfile_get_trace_state_variable_value (struct target_ops *self, int tsvnum, LONGEST *val)
static int | build_traceframe_info (char blocktype, void *data)
static traceframe_info_up | tfile_traceframe_info (struct target_ops *self)
static void | init_tfile_ops (void)
void | _initialize_tracefile_tfile (void)

## Variables
static const struct trace_file_write_ops | tfile_write_ops
static struct target_ops | tfile_ops
static char * | trace_filename
static int | trace_fd = -1
static off_t | trace_frames_offset
static off_t | cur_offset
static int | cur_data_size
int | trace_regblock_size
static struct buffer | trace_tdesc

## Macro Definition Documentation

## ◆ MAX_TRACE_UPLOAD

#define MAX_TRACE_UPLOAD 2000

Definition at line 213 of file tracefile-tfile.c.

Referenced by tfile_write_uploaded_tp().

## ◆ O_LARGEFILE

#define O_LARGEFILE 0

Definition at line 38 of file tracefile-tfile.c.

Referenced by tfile_open().

## ◆ TFILE_PID

#define TFILE_PID (1)

Definition at line 389 of file tracefile-tfile.c.

Referenced by tfile_open().

## ◆ TRACE_HEADER_SIZE

#define TRACE_HEADER_SIZE 8

Definition at line 387 of file tracefile-tfile.c.

Referenced by tfile_open().

## Typedef Documentation

## ◆ walk_blocks_callback_func

typedef int(* walk_blocks_callback_func) (char blocktype, void *data)

Definition at line 755 of file tracefile-tfile.c.

## Function Documentation

## ◆ _initialize_tracefile_tfile()

void _initialize_tracefile_tfile | ( | void |  | ) |

Definition at line 1132 of file tracefile-tfile.c.

References add_target_with_completer(), filename_completer(), init_tfile_ops(), and tfile_ops.

## ◆ build_traceframe_info()

static int build_traceframe_info | ( | char | blocktype,
|  | void * | data
| ) |  |
| static

Definition at line 1044 of file tracefile-tfile.c.

References _, extract_unsigned_integer(), gdbarch_byte_order(), traceframe_info::memory, target_gdbarch(), tfile_read(), traceframe_info::tvars, and warning().

Referenced by tfile_traceframe_info().

## ◆ init_tfile_ops()

static void init_tfile_ops | ( | void |  | ) |
| static

Definition at line 1111 of file tracefile-tfile.c.

References init_tracefile_ops(), tfile_close(), tfile_fetch_registers(), tfile_files_info(), tfile_get_trace_state_variable_value(), tfile_get_tracepoint_status(), tfile_open(), tfile_ops, tfile_trace_find(), tfile_traceframe_info(), tfile_xfer_partial(), target_ops::to_close, target_ops::to_doc, target_ops::to_fetch_registers, target_ops::to_files_info, target_ops::to_get_trace_state_variable_value, target_ops::to_get_tracepoint_status, target_ops::to_longname, target_ops::to_open, target_ops::to_shortname, target_ops::to_trace_find, target_ops::to_traceframe_info, and target_ops::to_xfer_partial.

Referenced by _initialize_tracefile_tfile().

## ◆ match_blocktype()

static int match_blocktype | ( | char | blocktype,
|  | void * | data
| ) |  |
| static

Definition at line 761 of file tracefile-tfile.c.

Referenced by traceframe_find_block_type().

## ◆ tfile_append_tdesc_line()

static void tfile_append_tdesc_line | ( | const char * | line | ) |
| static

Definition at line 1104 of file tracefile-tfile.c.

References buffer_grow_str, and trace_tdesc.

Referenced by tfile_interp_line().

## ◆ tfile_close()

static void tfile_close | ( | struct target_ops * | self | ) |
| static

Definition at line 586 of file tracefile-tfile.c.

References buffer_free(), exit_inferior_silent(), inferior_ptid, null_ptid, pid, ptid_get_pid(), trace_fd, trace_filename, trace_reset_local_state(), trace_tdesc, and xfree().

Referenced by init_tfile_ops().

## ◆ tfile_dtor()

static void tfile_dtor | ( | struct trace_file_writer * | self | ) |
| static

Definition at line 70 of file tracefile-tfile.c.

References tfile_trace_file_writer::fp, tfile_trace_file_writer::pathname, and xfree().

## ◆ tfile_end()

static void tfile_end | ( | struct trace_file_writer * | self | ) |
| static

Definition at line 336 of file tracefile-tfile.c.

References tfile_trace_file_writer::fp, tfile_trace_file_writer::pathname, and perror_with_name().

## ◆ tfile_fetch_registers()

static void tfile_fetch_registers | ( | struct target_ops * | ops,
|  | struct regcache * | regcache,
|  | int | regno
| ) |  |
| static

Definition at line 842 of file tracefile-tfile.c.

References regcache::arch(), dummy, gdbarch_num_regs(), offset, REG_UNKNOWN, regcache_raw_supply(), regcache_register_status(), register_size(), remote_register_number_and_offset(), tfile_read(), trace_regblock_size, tracefile_fetch_registers(), and traceframe_find_block_type().

Referenced by init_tfile_ops().

## ◆ tfile_files_info()

static void tfile_files_info | ( | struct target_ops * | t | ) |
| static

Definition at line 607 of file tracefile-tfile.c.

References printf_filtered(), and trace_filename.

Referenced by init_tfile_ops().

## ◆ tfile_get_trace_state_variable_value()

static int tfile_get_trace_state_variable_value | ( | struct target_ops * | self,
|  | int | tsvnum,
|  | LONGEST * | val
| ) |  |
| static

Definition at line 1007 of file tracefile-tfile.c.

References extract_signed_integer(), gdbarch_byte_order(), target_gdbarch(), tfile_read(), and traceframe_find_block_type().

Referenced by init_tfile_ops().

## ◆ tfile_get_traceframe_address()

static CORE_ADDR tfile_get_traceframe_address | ( | off_t | tframe_offset | ) |
| static

Definition at line 626 of file tracefile-tfile.c.

References bp_location::address, cur_offset, extract_signed_integer(), gdbarch_byte_order(), get_tracepoint_by_number_on_target(), breakpoint::loc, SEEK_SET, target_gdbarch(), tfile_read(), and trace_fd.

Referenced by tfile_trace_find().

## ◆ tfile_get_tracepoint_status()

static void tfile_get_tracepoint_status | ( | struct target_ops * | self,
|  | struct breakpoint * | tp,
|  | struct uploaded_tp * | utp
| ) |  |
| static

Definition at line 613 of file tracefile-tfile.c.

Referenced by init_tfile_ops().

## ◆ tfile_interp_line()

static void tfile_interp_line | ( | char * | line,
|  | struct uploaded_tp ** | utpp,
|  | struct uploaded_tsv ** | utsvp
| ) |  |
| static

Definition at line 549 of file tracefile-tfile.c.

References _, current_trace_status(), parse_trace_status(), parse_tracepoint_definition(), parse_tsv_definition(), startswith(), tfile_append_tdesc_line(), trace_regblock_size, and warning().

Referenced by tfile_open().

## ◆ tfile_open()

static void tfile_open | ( | const char * | arg,
|  | int | from_tty
| ) |  |
| static

Definition at line 423 of file tracefile-tfile.c.

References _, add_thread_silent(), buffer_free(), trace_status::buffer_free, CATCH, trace_status::circular_buffer, current_directory, current_inferior(), current_trace_status(), trace_status::disconnected_tracing, END_CATCH, error(), trace_status::filename, flags, gdb_open_cloexec(), inferior_appeared(), inferior_ptid, merge_uploaded_trace_state_variables(), merge_uploaded_tracepoints(), O_BINARY, O_LARGEFILE, perror_with_name(), pid_to_ptid(), post_create_inferior(), push_target(), RETURN_MASK_ALL, trace_status::running_known, startswith(), trace_status::stop_reason, target_find_description(), target_preopen(), tfile_interp_line(), tfile_ops, TFILE_PID, tfile_read(), throw_exception(), trace_fd, trace_filename, trace_frames_offset, TRACE_HEADER_SIZE, trace_regblock_size, trace_stop_reason_unknown, trace_tdesc, trace_status::traceframe_count, TRY, unpush_target(), and warning().

Referenced by init_tfile_ops().

## ◆ tfile_read()

static void tfile_read | ( | gdb_byte * | readbuf,
|  | int | size
| ) |  |
| static

Definition at line 411 of file tracefile-tfile.c.

References _, error(), perror_with_name(), read(), size, trace_fd, and trace_filename.

Referenced by build_traceframe_info(), tfile_fetch_registers(), tfile_get_trace_state_variable_value(), tfile_get_traceframe_address(), tfile_open(), tfile_trace_find(), tfile_xfer_partial(), and traceframe_walk_blocks().

## ◆ tfile_start()

static void tfile_start | ( | struct trace_file_writer * | self,
|  | const char * | filename
| ) |  |
| static

Definition at line 86 of file tracefile-tfile.c.

References _, error(), tfile_trace_file_writer::fp, gdb_fopen_cloexec(), tfile_trace_file_writer::pathname, and safe_strerror().

## ◆ tfile_target_save()

static int tfile_target_save | ( | struct trace_file_writer * | self,
|  | const char * | filename
| ) |  |
| static

Definition at line 58 of file tracefile-tfile.c.

References err, and target_save_trace_data.

## ◆ tfile_trace_file_writer_new()

struct trace_file_writer* tfile_trace_file_writer_new | ( | void |  | ) |

Definition at line 369 of file tracefile-tfile.c.

References tfile_trace_file_writer::base, tfile_trace_file_writer::fp, trace_file_writer::ops, tfile_trace_file_writer::pathname, tfile_write_ops, and XNEW.

Referenced by trace_save_tfile(), and tsave_command().

## ◆ tfile_trace_find()

static int tfile_trace_find | ( | struct target_ops * | self,
|  | enum trace_find_type | type,
|  | int | num,
|  | CORE_ADDR | addr1,
|  | CORE_ADDR | addr2,
|  | int * | tpp
| ) |  |
| static

Definition at line 659 of file tracefile-tfile.c.

References _, cur_data_size, cur_offset, extract_signed_integer(), extract_unsigned_integer(), gdbarch_byte_order(), get_traceframe_number(), get_tracepoint(), internal_error(), tracepoint::number_on_target, offset, SEEK_CUR, SEEK_SET, target_gdbarch(), tfile_get_traceframe_address(), tfile_read(), tfind_number, tfind_outside, tfind_pc, tfind_range, tfind_tp, trace_fd, and trace_frames_offset.

Referenced by init_tfile_ops().

## ◆ tfile_traceframe_info()

static traceframe_info_up tfile_traceframe_info | ( | struct target_ops * | self | ) |
| static

Definition at line 1091 of file tracefile-tfile.c.

References build_traceframe_info(), and traceframe_walk_blocks().

Referenced by init_tfile_ops().

## ◆ tfile_write_definition_end()

static void tfile_write_definition_end | ( | struct trace_file_writer * | self | ) |
| static

Definition at line 310 of file tracefile-tfile.c.

References tfile_trace_file_writer::fp.

## ◆ tfile_write_header()

static void tfile_write_header | ( | struct trace_file_writer * | self | ) |
| static

Definition at line 102 of file tracefile-tfile.c.

References tfile_trace_file_writer::fp, tfile_trace_file_writer::pathname, and perror_with_name().

## ◆ tfile_write_raw_data()

static void tfile_write_raw_data | ( | struct trace_file_writer * | self,
|  | gdb_byte * | buf,
|  | LONGEST | len
| ) |  |
| static

Definition at line 322 of file tracefile-tfile.c.

References tfile_trace_file_writer::fp, tfile_trace_file_writer::pathname, and perror_with_name().

## ◆ tfile_write_regblock_type()

static void tfile_write_regblock_type | ( | struct trace_file_writer * | self,
|  | int | size
| ) |  |
| static

Definition at line 120 of file tracefile-tfile.c.

References tfile_trace_file_writer::fp, and size.

## ◆ tfile_write_status()

static void tfile_write_status | ( | struct trace_file_writer * | self,
|  | struct trace_status * | ts
| ) |  |
| static

Definition at line 132 of file tracefile-tfile.c.

References bin2hex(), trace_status::buffer_free, trace_status::buffer_size, trace_status::circular_buffer, trace_status::disconnected_tracing, tfile_trace_file_writer::fp, trace_status::notes, phex_nz(), trace_status::running, trace_status::start_time, trace_status::stop_desc, trace_status::stop_reason, stop_reason_names, trace_status::stop_time, trace_status::stopping_tracepoint, trace_stop_command, trace_status::traceframe_count, trace_status::traceframes_created, tracepoint_error, and trace_status::user_name.

## ◆ tfile_write_tdesc()

static void tfile_write_tdesc | ( | struct trace_file_writer * | self | ) |
| static

Definition at line 274 of file tracefile-tfile.c.

References current_target, tfile_trace_file_writer::fp, and target_fetch_description_xml().

## ◆ tfile_write_uploaded_tp()

static void tfile_write_uploaded_tp | ( | struct trace_file_writer * | self,
|  | struct uploaded_tp * | utp
| ) |  |
| static

Definition at line 219 of file tracefile-tfile.c.

References uploaded_tp::addr, uploaded_tp::at_string, bp_fast_tracepoint, uploaded_tp::cond, uploaded_tp::cond_string, uploaded_tp::enabled, encode_source_string(), tfile_trace_file_writer::fp, uploaded_tp::hit_count, MAX_TRACE_UPLOAD, uploaded_tp::number, uploaded_tp::orig_size, uploaded_tp::pass, phex_nz(), uploaded_tp::step, uploaded_tp::traceframe_usage, uploaded_tp::type, and VEC_iterate.

## ◆ tfile_write_uploaded_tsv()

static void tfile_write_uploaded_tsv | ( | struct trace_file_writer * | self,
|  | struct uploaded_tsv * | utsv
| ) |  |
| static

Definition at line 192 of file tracefile-tfile.c.

References bin2hex(), uploaded_tsv::builtin, tfile_trace_file_writer::fp, uploaded_tsv::initial_value, uploaded_tsv::name, uploaded_tsv::number, phex_nz(), xfree(), and xmalloc().

## ◆ tfile_xfer_partial()

static enum target_xfer_status tfile_xfer_partial | ( | struct target_ops * | ops,
|  | enum target_object | object,
|  | const char * | annex,
|  | gdb_byte * | readbuf,
|  | const gdb_byte * | writebuf,
|  | ULONGEST | offset,
|  | ULONGEST | len,
|  | ULONGEST * | xfered_len
| ) |  |
| static

Definition at line 915 of file tracefile-tfile.c.

References _, gdbarch::byte_order, error(), exec_read_partial_read_only(), extract_unsigned_integer(), gdbarch_byte_order(), get_traceframe_number(), offset, section_table_read_available_memory(), SEEK_CUR, target_gdbarch(), TARGET_OBJECT_AVAILABLE_FEATURES, TARGET_OBJECT_MEMORY, TARGET_XFER_E_IO, TARGET_XFER_OK, TARGET_XFER_UNAVAILABLE, tfile_read(), tfile_xfer_partial_features(), trace_fd, and traceframe_find_block_type().

Referenced by init_tfile_ops().

## ◆ tfile_xfer_partial_features()

static enum target_xfer_status tfile_xfer_partial_features | ( | struct target_ops * | ops,
|  | const char * | annex,
|  | gdb_byte * | readbuf,
|  | const gdb_byte * | writebuf,
|  | ULONGEST | offset,
|  | ULONGEST | len,
|  | ULONGEST * | xfered_len
| ) |  |
| static

Definition at line 888 of file tracefile-tfile.c.

References _, buffer::buffer, error(), offset, TARGET_XFER_E_IO, TARGET_XFER_EOF, TARGET_XFER_OK, trace_tdesc, and buffer::used_size.

Referenced by tfile_xfer_partial().

## ◆ traceframe_find_block_type()

static int traceframe_find_block_type | ( | char | type_wanted,
|  | int | pos
| ) |  |
| static

Definition at line 833 of file tracefile-tfile.c.

References match_blocktype(), and traceframe_walk_blocks().

Referenced by tfile_fetch_registers(), tfile_get_trace_state_variable_value(), and tfile_xfer_partial().

## ◆ traceframe_walk_blocks()

static int traceframe_walk_blocks | ( | walk_blocks_callback_func | callback,
|  | int | pos,
|  | void * | data
| ) |  |
| static

Definition at line 779 of file tracefile-tfile.c.

References _, cur_data_size, cur_offset, error(), extract_unsigned_integer(), gdbarch_byte_order(), SEEK_CUR, SEEK_SET, target_gdbarch(), tfile_read(), trace_fd, and trace_regblock_size.

Referenced by tfile_traceframe_info(), and traceframe_find_block_type().

## Variable Documentation

## ◆ cur_data_size

int cur_data_size
| static

Definition at line 395 of file tracefile-tfile.c.

Referenced by tfile_trace_find(), and traceframe_walk_blocks().

## ◆ cur_offset

off_t cur_offset
| static

Definition at line 394 of file tracefile-tfile.c.

Referenced by tfile_get_traceframe_address(), tfile_trace_find(), and traceframe_walk_blocks().

## ◆ tfile_ops

struct target_ops tfile_ops
| static

Definition at line 383 of file tracefile-tfile.c.

Referenced by _initialize_tracefile_tfile(), init_tfile_ops(), and tfile_open().

## ◆ tfile_write_ops

const struct trace_file_write_ops tfile_write_ops
| static

Initial value:
=
{
tfile_dtor,
tfile_target_save,
tfile_start,
tfile_write_header,
tfile_write_regblock_type,
tfile_write_status,
tfile_write_uploaded_tsv,
tfile_write_uploaded_tp,
tfile_write_tdesc,
tfile_write_definition_end,
tfile_write_raw_data,
NULL,
tfile_end,
}
tfile_dtor
static void tfile_dtor(struct trace_file_writer *self)
Definition: tracefile-tfile.c:70
tfile_write_uploaded_tsv
static void tfile_write_uploaded_tsv(struct trace_file_writer *self, struct uploaded_tsv *utsv)
Definition: tracefile-tfile.c:192
tfile_write_regblock_type
static void tfile_write_regblock_type(struct trace_file_writer *self, int size)
Definition: tracefile-tfile.c:120
tfile_write_definition_end
static void tfile_write_definition_end(struct trace_file_writer *self)
Definition: tracefile-tfile.c:310
tfile_target_save
static int tfile_target_save(struct trace_file_writer *self, const char *filename)
Definition: tracefile-tfile.c:58
tfile_write_tdesc
static void tfile_write_tdesc(struct trace_file_writer *self)
Definition: tracefile-tfile.c:274
tfile_write_header
static void tfile_write_header(struct trace_file_writer *self)
Definition: tracefile-tfile.c:102
tfile_write_uploaded_tp
static void tfile_write_uploaded_tp(struct trace_file_writer *self, struct uploaded_tp *utp)
Definition: tracefile-tfile.c:219
tfile_end
static void tfile_end(struct trace_file_writer *self)
Definition: tracefile-tfile.c:336
tfile_start
static void tfile_start(struct trace_file_writer *self, const char *filename)
Definition: tracefile-tfile.c:86
tfile_write_raw_data
static void tfile_write_raw_data(struct trace_file_writer *self, gdb_byte *buf, LONGEST len)
Definition: tracefile-tfile.c:322
tfile_write_status
static void tfile_write_status(struct trace_file_writer *self, struct trace_status *ts)
Definition: tracefile-tfile.c:132

Definition at line 349 of file tracefile-tfile.c.

Referenced by tfile_trace_file_writer_new().

## ◆ trace_fd

int trace_fd = -1
| static

Definition at line 392 of file tracefile-tfile.c.

Referenced by tfile_close(), tfile_get_traceframe_address(), tfile_open(), tfile_read(), tfile_trace_find(), tfile_xfer_partial(), and traceframe_walk_blocks().

## ◆ trace_filename

char* trace_filename
| static

Definition at line 391 of file tracefile-tfile.c.

Referenced by tfile_close(), tfile_files_info(), tfile_open(), and tfile_read().

## ◆ trace_frames_offset

off_t trace_frames_offset
| static

Definition at line 393 of file tracefile-tfile.c.

Referenced by tfile_open(), and tfile_trace_find().

## ◆ trace_regblock_size

int trace_regblock_size

Definition at line 396 of file tracefile-tfile.c.

Referenced by remote_get_trace_status(), tfile_fetch_registers(), tfile_interp_line(), tfile_open(), trace_save(), and traceframe_walk_blocks().

## ◆ trace_tdesc

struct buffer trace_tdesc
| static

Definition at line 397 of file tracefile-tfile.c.

Referenced by tfile_append_tdesc_line(), tfile_close(), tfile_open(), and tfile_xfer_partial_features().