LiveDebugger.Services.TraceService (LiveDebugger v0.1.4)

View Source

This module provides functions that manages traces in the debugged application via ETS. Created table is an ordered_set with non-positive integer keys.

Summary

Functions

Deletes all traces for the given table id and CID or PID.

Returns the ETS table id for the given socket id.

Returns all existing traces for the given table id.

Returns existing traces for the given table id and CID or PID. It returns up to limit traces.

Gets a trace from the ETS table by its id.

Inserts a new trace into the ETS table.

Initializes an ETS table with the given id if it doesn't exist.

Creates the id of next tuple based on the first tuple in the ETS table. We need to store traces in this table in descending order. To achieve this table is implemented as ordered_set with non-positive integer keys. Because of that the element with the smallest key is the first element in the table.

Functions

clear_traces(table_id, cid)

@spec clear_traces(atom(), pid() | LiveDebugger.CommonTypes.cid()) :: true

Deletes all traces for the given table id and CID or PID.

ets_table_id(socket_id)

@spec ets_table_id(String.t()) :: :ets.table()

Returns the ETS table id for the given socket id.

existing_traces(table_id)

@spec existing_traces(atom()) :: [LiveDebugger.Structs.Trace.t()]

Returns all existing traces for the given table id.

existing_traces(table_id, id, limit)

@spec existing_traces(atom(), pid() | LiveDebugger.CommonTypes.cid(), pos_integer()) ::
  [
    LiveDebugger.Structs.Trace.t()
  ]

Returns existing traces for the given table id and CID or PID. It returns up to limit traces.

get(table_id, id)

@spec get(:ets.table(), integer()) :: LiveDebugger.Structs.Trace.t() | nil

Gets a trace from the ETS table by its id.

insert(table_id, id, trace)

@spec insert(:ets.table(), integer(), LiveDebugger.Structs.Trace.t()) :: true

Inserts a new trace into the ETS table.

maybe_init_ets(ets_table_id)

@spec maybe_init_ets(:ets.table()) :: :ets.table()

Initializes an ETS table with the given id if it doesn't exist.

next_tuple_id(ets_table_id)

@spec next_tuple_id(:ets.table()) :: integer()

Creates the id of next tuple based on the first tuple in the ETS table. We need to store traces in this table in descending order. To achieve this table is implemented as ordered_set with non-positive integer keys. Because of that the element with the smallest key is the first element in the table.