GDB (xrefs)

Classes | Macros | Functions | Variables
/tmp/gdb-8.1/gdb/ctf.c File Reference
`#include "defs.h"`
`#include "ctf.h"`
`#include "tracepoint.h"`
`#include "regcache.h"`
`#include <sys/stat.h>`
`#include "exec.h"`
`#include "completer.h"`
`#include "inferior.h"`
`#include "gdbthread.h"`
`#include "tracefile.h"`
`#include <ctype.h>`
`#include <algorithm>`

Go to the source code of this file.

## Classes
struct | trace_write_handler
struct | ctf_trace_file_writer

## Macros
#define | CTF_MAGIC 0xC1FC1FC1
#define | CTF_SAVE_MAJOR 1
#define | CTF_SAVE_MINOR 8
#define | CTF_METADATA_NAME "metadata"
#define | CTF_DATASTREAM_NAME "datastream"
#define | CTF_EVENT_ID_REGISTER 0
#define | CTF_EVENT_ID_TSV 1
#define | CTF_EVENT_ID_MEMORY 2
#define | CTF_EVENT_ID_FRAME 3
#define | CTF_EVENT_ID_STATUS 4
#define | CTF_EVENT_ID_TSV_DEF 5
#define | CTF_EVENT_ID_TP_DEF 6
#define | CTF_PID (2)
#define | ctf_save_write_uint32(HANDLER, U32) ctf_save_write (HANDLER, (gdb_byte *) &U32, 4)
#define | ctf_save_write_int32(HANDLER, INT32) ctf_save_write ((HANDLER), (gdb_byte *) &(INT32), 4)
#define | HOST_ENDIANNESS "le"

## Functions
static void | ctf_save_write_metadata (struct trace_write_handler *handler, const char *format,...) ATTRIBUTE_PRINTF(2
static int | ctf_save_write (struct trace_write_handler *handler, const gdb_byte *buf, size_t size)
static int | ctf_save_fseek (struct trace_write_handler *handler, long offset, int whence)
static int | ctf_save_align_write (struct trace_write_handler *handler, const gdb_byte *buf, size_t size, size_t align_size)
static void | ctf_save_next_packet (struct trace_write_handler *handler)
static void | ctf_save_metadata_header (struct trace_write_handler *handler)
static void | ctf_dtor (struct trace_file_writer *self)
static int | ctf_target_save (struct trace_file_writer *self, const char *dirname)
static void | ctf_start (struct trace_file_writer *self, const char *dirname)
static void | ctf_write_header (struct trace_file_writer *self)
static void | ctf_write_regblock_type (struct trace_file_writer *self, int size)
static void | ctf_write_status (struct trace_file_writer *self, struct trace_status *ts)
static void | ctf_write_uploaded_tsv (struct trace_file_writer *self, struct uploaded_tsv *tsv)
static void | ctf_write_uploaded_tp (struct trace_file_writer *self, struct uploaded_tp *tp)
static void | ctf_write_tdesc (struct trace_file_writer *self)
static void | ctf_write_definition_end (struct trace_file_writer *self)
static void | ctf_end (struct trace_file_writer *self)
static void | ctf_write_frame_start (struct trace_file_writer *self, uint16_t tpnum)
static void | ctf_write_frame_r_block (struct trace_file_writer *self, gdb_byte *buf, int32_t size)
static void | ctf_write_frame_m_block_header (struct trace_file_writer *self, uint64_t addr, uint16_t length)
static void | ctf_write_frame_m_block_memory (struct trace_file_writer *self, gdb_byte *buf, uint16_t length)
static void | ctf_write_frame_v_block (struct trace_file_writer *self, int32_t num, uint64_t val)
static void | ctf_write_frame_end (struct trace_file_writer *self)
struct trace_file_writer * | ctf_trace_file_writer_new (void)
void | _initialize_ctf (void)

## Variables
static const struct trace_frame_write_ops | ctf_write_frame_ops
static const struct trace_file_write_ops | ctf_write_ops

## Macro Definition Documentation

## ◆ CTF_DATASTREAM_NAME

#define CTF_DATASTREAM_NAME "datastream"

Definition at line 70 of file ctf.c.

Referenced by ctf_start().

## ◆ CTF_EVENT_ID_FRAME

#define CTF_EVENT_ID_FRAME 3

Definition at line 77 of file ctf.c.

Referenced by ctf_write_frame_start(), and ctf_write_header().

## ◆ CTF_EVENT_ID_MEMORY

#define CTF_EVENT_ID_MEMORY 2

Definition at line 76 of file ctf.c.

Referenced by ctf_write_frame_m_block_header(), and ctf_write_header().

## ◆ CTF_EVENT_ID_REGISTER

#define CTF_EVENT_ID_REGISTER 0

Definition at line 74 of file ctf.c.

Referenced by ctf_write_frame_r_block(), and ctf_write_regblock_type().

## ◆ CTF_EVENT_ID_STATUS

#define CTF_EVENT_ID_STATUS 4

Definition at line 78 of file ctf.c.

Referenced by ctf_write_status().

## ◆ CTF_EVENT_ID_TP_DEF

#define CTF_EVENT_ID_TP_DEF 6

Definition at line 80 of file ctf.c.

Referenced by ctf_write_header(), and ctf_write_uploaded_tp().

## ◆ CTF_EVENT_ID_TSV

#define CTF_EVENT_ID_TSV 1

Definition at line 75 of file ctf.c.

Referenced by ctf_write_frame_v_block(), and ctf_write_header().

## ◆ CTF_EVENT_ID_TSV_DEF

#define CTF_EVENT_ID_TSV_DEF 5

Definition at line 79 of file ctf.c.

Referenced by ctf_write_header(), and ctf_write_uploaded_tsv().

## ◆ CTF_MAGIC

#define CTF_MAGIC 0xC1FC1FC1

Definition at line 65 of file ctf.c.

Referenced by ctf_write_frame_start().

## ◆ CTF_METADATA_NAME

#define CTF_METADATA_NAME "metadata"

Definition at line 69 of file ctf.c.

Referenced by ctf_start().

## ◆ CTF_PID

#define CTF_PID (2)

Definition at line 82 of file ctf.c.

## ◆ CTF_SAVE_MAJOR

#define CTF_SAVE_MAJOR 1

Definition at line 66 of file ctf.c.

Referenced by ctf_save_metadata_header().

## ◆ CTF_SAVE_MINOR

#define CTF_SAVE_MINOR 8

Definition at line 67 of file ctf.c.

Referenced by ctf_save_metadata_header().

## ◆ ctf_save_write_int32

#define ctf_save_write_int32 | ( |  | HANDLER,
|  |  | INT32
| ) |  | ctf_save_write ((HANDLER), (gdb_byte *) &(INT32), 4)

Definition at line 145 of file ctf.c.

Referenced by ctf_write_status(), ctf_write_uploaded_tp(), and ctf_write_uploaded_tsv().

## ◆ ctf_save_write_uint32

#define ctf_save_write_uint32 | ( |  | HANDLER,
|  |  | U32
| ) |  | ctf_save_write (HANDLER, (gdb_byte *) &U32, 4)

Definition at line 139 of file ctf.c.

Referenced by ctf_write_frame_end(), and ctf_write_frame_start().

## ◆ HOST_ENDIANNESS

#define HOST_ENDIANNESS "le"

Referenced by ctf_save_metadata_header().

## Function Documentation

## ◆ _initialize_ctf()

void _initialize_ctf | ( | void |  | ) |

Definition at line 1715 of file ctf.c.

References add_target_with_completer(), and filename_completer().

## ◆ ctf_dtor()

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

Definition at line 283 of file ctf.c.

References trace_write_handler::datastream_fd, trace_write_handler::metadata_fd, and ctf_trace_file_writer::tcs.

## ◆ ctf_end()

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

Definition at line 625 of file ctf.c.

References trace_write_handler::content_size, gdb_assert, and ctf_trace_file_writer::tcs.

## ◆ ctf_save_align_write()

static int ctf_save_align_write | ( | struct trace_write_handler * | handler,
|  | const gdb_byte * | buf,
|  | size_t | size,
|  | size_t | align_size
| ) |  |
| static

Definition at line 173 of file ctf.c.

References align_up(), trace_write_handler::content_size, ctf_save_fseek(), ctf_save_write(), offset, SEEK_CUR, and size.

Referenced by ctf_write_frame_m_block_header(), ctf_write_frame_m_block_memory(), ctf_write_frame_r_block(), ctf_write_frame_start(), ctf_write_frame_v_block(), ctf_write_status(), ctf_write_uploaded_tp(), and ctf_write_uploaded_tsv().

## ◆ ctf_save_fseek()

static int ctf_save_fseek | ( | struct trace_write_handler * | handler,
|  | long | offset,
|  | int | whence
| ) |  |
| static

Definition at line 152 of file ctf.c.

References _, trace_write_handler::content_size, trace_write_handler::datastream_fd, error(), gdb_assert, offset, trace_write_handler::packet_start, safe_strerror(), SEEK_CUR, and SEEK_SET.

Referenced by ctf_save_align_write(), ctf_save_next_packet(), ctf_write_frame_end(), and ctf_write_frame_start().

## ◆ ctf_save_metadata_header()

static void ctf_save_metadata_header | ( | struct trace_write_handler * | handler | ) |
| static

Definition at line 203 of file ctf.c.

References CTF_SAVE_MAJOR, CTF_SAVE_MINOR, ctf_save_write_metadata(), and HOST_ENDIANNESS.

Referenced by ctf_start().

## ◆ ctf_save_next_packet()

static void ctf_save_next_packet | ( | struct trace_write_handler * | handler | ) |
| static

Definition at line 193 of file ctf.c.

References trace_write_handler::content_size, ctf_save_fseek(), trace_write_handler::packet_start, and SEEK_SET.

Referenced by ctf_write_frame_end().

## ◆ ctf_save_write()

static int ctf_save_write | ( | struct trace_write_handler * | handler,
|  | const gdb_byte * | buf,
|  | size_t | size
| ) |  |
| static

Definition at line 124 of file ctf.c.

References _, trace_write_handler::content_size, trace_write_handler::datastream_fd, error(), safe_strerror(), and size.

Referenced by ctf_save_align_write(), ctf_write_frame_start(), ctf_write_uploaded_tp(), and ctf_write_uploaded_tsv().

## ◆ ctf_save_write_metadata()

static void static void ctf_save_write_metadata | ( | struct trace_write_handler * | handler,
|  | const char * | format,
|  |  | ...
| ) |  |
| static

Definition at line 108 of file ctf.c.

References _, error(), and safe_strerror().

Referenced by ctf_save_metadata_header(), ctf_write_header(), ctf_write_regblock_type(), and ctf_write_status().

## ◆ ctf_start()

static void ctf_start | ( | struct trace_file_writer * | self,
|  | const char * | dirname
| ) |  |
| static

Definition at line 312 of file ctf.c.

References _, CTF_DATASTREAM_NAME, CTF_METADATA_NAME, ctf_save_metadata_header(), trace_write_handler::datastream_fd, error(), memset(), trace_write_handler::metadata_fd, safe_strerror(), string, string_printf(), and ctf_trace_file_writer::tcs.

## ◆ ctf_target_save()

static int ctf_target_save | ( | struct trace_file_writer * | self,
|  | const char * | dirname
| ) |  |
| static

Definition at line 300 of file ctf.c.

## ◆ ctf_trace_file_writer_new()

struct trace_file_writer* ctf_trace_file_writer_new | ( | void |  | ) |

Definition at line 802 of file ctf.c.

References ctf_trace_file_writer::base, ctf_write_ops, trace_file_writer::ops, and XNEW.

Referenced by trace_save_ctf(), and tsave_command().

## ◆ ctf_write_definition_end()

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

Definition at line 616 of file ctf.c.

## ◆ ctf_write_frame_end()

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

Definition at line 736 of file ctf.c.

References trace_write_handler::content_size, ctf_save_fseek(), ctf_save_next_packet(), ctf_save_write_uint32, trace_write_handler::packet_start, SEEK_SET, TARGET_CHAR_BIT, and ctf_trace_file_writer::tcs.

## ◆ ctf_write_frame_m_block_header()

static void ctf_write_frame_m_block_header | ( | struct trace_file_writer * | self,
|  | uint64_t | addr,
|  | uint16_t | length
| ) |  |
| static

Definition at line 681 of file ctf.c.

References CTF_EVENT_ID_MEMORY, ctf_save_align_write(), and ctf_trace_file_writer::tcs.

## ◆ ctf_write_frame_m_block_memory()

static void ctf_write_frame_m_block_memory | ( | struct trace_file_writer * | self,
|  | gdb_byte * | buf,
|  | uint16_t | length
| ) |  |
| static

Definition at line 702 of file ctf.c.

References ctf_save_align_write(), and ctf_trace_file_writer::tcs.

## ◆ ctf_write_frame_r_block()

static void ctf_write_frame_r_block | ( | struct trace_file_writer * | self,
|  | gdb_byte * | buf,
|  | int32_t | size
| ) |  |
| static

Definition at line 663 of file ctf.c.

References CTF_EVENT_ID_REGISTER, ctf_save_align_write(), size, and ctf_trace_file_writer::tcs.

## ◆ ctf_write_frame_start()

static void ctf_write_frame_start | ( | struct trace_file_writer * | self,
|  | uint16_t | tpnum
| ) |  |
| static

Definition at line 636 of file ctf.c.

References CTF_EVENT_ID_FRAME, CTF_MAGIC, ctf_save_align_write(), ctf_save_fseek(), ctf_save_write(), ctf_save_write_uint32, SEEK_CUR, and ctf_trace_file_writer::tcs.

## ◆ ctf_write_frame_v_block()

static void ctf_write_frame_v_block | ( | struct trace_file_writer * | self,
|  | int32_t | num,
|  | uint64_t | val
| ) |  |
| static

Definition at line 716 of file ctf.c.

References CTF_EVENT_ID_TSV, ctf_save_align_write(), and ctf_trace_file_writer::tcs.

## ◆ ctf_write_header()

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

Definition at line 346 of file ctf.c.

References trace_write_handler::content_size, CTF_EVENT_ID_FRAME, CTF_EVENT_ID_MEMORY, CTF_EVENT_ID_TP_DEF, CTF_EVENT_ID_TSV, CTF_EVENT_ID_TSV_DEF, ctf_save_write_metadata(), gdb_assert, trace_write_handler::packet_start, and ctf_trace_file_writer::tcs.

## ◆ ctf_write_regblock_type()

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

Definition at line 429 of file ctf.c.

References CTF_EVENT_ID_REGISTER, ctf_save_write_metadata(), size, and ctf_trace_file_writer::tcs.

## ◆ ctf_write_status()

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

Definition at line 449 of file ctf.c.

References trace_status::buffer_free, trace_status::buffer_size, trace_status::circular_buffer, CTF_EVENT_ID_STATUS, ctf_save_align_write(), ctf_save_write_int32, ctf_save_write_metadata(), trace_status::disconnected_tracing, trace_status::stop_reason, trace_status::stopping_tracepoint, ctf_trace_file_writer::tcs, trace_status::traceframe_count, and trace_status::traceframes_created.

## ◆ ctf_write_tdesc()

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

Definition at line 607 of file ctf.c.

## ◆ ctf_write_uploaded_tp()

static void ctf_write_uploaded_tp | ( | struct trace_file_writer * | self,
|  | struct uploaded_tp * | tp
| ) |  |
| static

Definition at line 524 of file ctf.c.

References uploaded_tp::addr, uploaded_tp::at_string, uploaded_tp::cond, uploaded_tp::cond_string, CTF_EVENT_ID_TP_DEF, ctf_save_align_write(), ctf_save_write(), ctf_save_write_int32, uploaded_tp::enabled, uploaded_tp::hit_count, uploaded_tp::number, uploaded_tp::pass, uploaded_tp::step, ctf_trace_file_writer::tcs, uploaded_tp::traceframe_usage, uploaded_tp::type, VEC_iterate, and VEC_length.

## ◆ ctf_write_uploaded_tsv()

static void ctf_write_uploaded_tsv | ( | struct trace_file_writer * | self,
|  | struct uploaded_tsv * | tsv
| ) |  |
| static

Definition at line 490 of file ctf.c.

References uploaded_tsv::builtin, CTF_EVENT_ID_TSV_DEF, ctf_save_align_write(), ctf_save_write(), ctf_save_write_int32, uploaded_tsv::initial_value, uploaded_tsv::name, uploaded_tsv::number, and ctf_trace_file_writer::tcs.

## Variable Documentation

## ◆ ctf_write_frame_ops

const struct trace_frame_write_ops ctf_write_frame_ops
| static

Initial value:
=
{
ctf_write_frame_start,
ctf_write_frame_r_block,
ctf_write_frame_m_block_header,
ctf_write_frame_m_block_memory,
ctf_write_frame_v_block,
ctf_write_frame_end,
}
ctf_write_frame_m_block_header
static void ctf_write_frame_m_block_header(struct trace_file_writer *self, uint64_t addr, uint16_t length)
Definition: ctf.c:681
ctf_write_frame_end
static void ctf_write_frame_end(struct trace_file_writer *self)
Definition: ctf.c:736
ctf_write_frame_r_block
static void ctf_write_frame_r_block(struct trace_file_writer *self, gdb_byte *buf, int32_t size)
Definition: ctf.c:663
ctf_write_frame_v_block
static void ctf_write_frame_v_block(struct trace_file_writer *self, int32_t num, uint64_t val)
Definition: ctf.c:716
ctf_write_frame_m_block_memory
static void ctf_write_frame_m_block_memory(struct trace_file_writer *self, gdb_byte *buf, uint16_t length)
Definition: ctf.c:702
ctf_write_frame_start
static void ctf_write_frame_start(struct trace_file_writer *self, uint16_t tpnum)
Definition: ctf.c:636

Definition at line 770 of file ctf.c.

## ◆ ctf_write_ops

const struct trace_file_write_ops ctf_write_ops
| static

Initial value:
=
{
ctf_dtor,
ctf_target_save,
ctf_start,
ctf_write_header,
ctf_write_regblock_type,
ctf_write_status,
ctf_write_uploaded_tsv,
ctf_write_uploaded_tp,
ctf_write_tdesc,
ctf_write_definition_end,
NULL,
&ctf_write_frame_ops,
ctf_end,
}
ctf_dtor
static void ctf_dtor(struct trace_file_writer *self)
Definition: ctf.c:283
ctf_write_tdesc
static void ctf_write_tdesc(struct trace_file_writer *self)
Definition: ctf.c:607
ctf_write_uploaded_tp
static void ctf_write_uploaded_tp(struct trace_file_writer *self, struct uploaded_tp *tp)
Definition: ctf.c:524
ctf_write_uploaded_tsv
static void ctf_write_uploaded_tsv(struct trace_file_writer *self, struct uploaded_tsv *tsv)
Definition: ctf.c:490
ctf_end
static void ctf_end(struct trace_file_writer *self)
Definition: ctf.c:625
ctf_write_status
static void ctf_write_status(struct trace_file_writer *self, struct trace_status *ts)
Definition: ctf.c:449
ctf_write_definition_end
static void ctf_write_definition_end(struct trace_file_writer *self)
Definition: ctf.c:616
ctf_write_regblock_type
static void ctf_write_regblock_type(struct trace_file_writer *self, int size)
Definition: ctf.c:429
ctf_write_frame_ops
static const struct trace_frame_write_ops ctf_write_frame_ops
Definition: ctf.c:770
ctf_target_save
static int ctf_target_save(struct trace_file_writer *self, const char *dirname)
Definition: ctf.c:300
ctf_write_header
static void ctf_write_header(struct trace_file_writer *self)
Definition: ctf.c:346
ctf_start
static void ctf_start(struct trace_file_writer *self, const char *dirname)
Definition: ctf.c:312

Definition at line 782 of file ctf.c.

Referenced by ctf_trace_file_writer_new().