GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> TRC / V1-0-8 > trc / rhel5-32
#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <PBI/Endianness.h>
#include <CPU_DB/CPU_DB_pubdefs.h>
#include <FBS/FBS_pubrtos.h>
#include <MDB/MDB_pubdefs.h>
#include <PBS/CACHE.h>
#include <PBS/MBA.h>
#include <PBS/PTS.h>
#include <PBS/RW.ih>
#include <TRC/TRC_msgs.h>
#include <TRC_prvdefs.h>
Functions | |
static void | recover (TRC_Buffer *trc) |
Try to recover if the row pointers are messed up. | |
static unsigned int | validName (const char *name, const char *func) |
Validate a trace name. | |
static __inline void | record (TRC_Buffer *trc, unsigned long long tim, unsigned int fui, unsigned int *dat) |
Insert a record in the trace (worker bee). | |
unsigned int | TRC_advertise (TRC_Buffer *trc) |
Use a MSG to advertise the location of the system trace blob. | |
unsigned int | TRC_correlateTime (TRC_Buffer *trc) |
Place a time correlation record in a trace buffer header. | |
unsigned int | TRC_create (TRC_Buffer **trc, unsigned int rows, unsigned int id, const char *nam) |
Create a user trace buffer (no snaphost or telemetry capability). | |
unsigned int | TRC_delete (TRC_Buffer *trc) |
Create a user trace buffer. | |
unsigned long long | TRC_record (TRC_Buffer *trc, unsigned int fui, unsigned int *dat) |
Insert a record into a trace. | |
unsigned int | TRC_sizeofTrace (TRC_Buffer *trc) |
Return the size of a complete compound trace (buffer plus common). | |
int | TRC_tdb2tid (int tdb) |
Translate a task ID (CPU_DB/ITC style) to a VxWorks task ID. | |
unsigned int | TRC_write (TRC_Buffer *trc, const char *fil) |
Write a (compound) trace snapshot to a file. | |
Variables | |
static const char | s_noData [TRC_DATA_ROW_SIZE<< 2] |
Data recorded when the user specifies a NULL data pointer. | |
static const char | s_misaligned [TRC_DATA_ROW_SIZE<< 2] |
Data recorded when the user specifies a misaligned data pointer. | |
const char * | TRC_noData = s_noData |
External pointer to the fixed "no data" string. | |
const char * | TRC_misaligned = s_misaligned |
External pointer to the fixed "data misaligned" string. |
CVS $Id: TRC_trace.c,v 1.6 2011/03/29 00:59:53 apw Exp $
static __inline void record | ( | TRC_Buffer * | trc, | |
unsigned long long | tim, | |||
unsigned int | fui, | |||
unsigned int * | dat | |||
) | [static] |
Insert a record in the trace (worker bee).
trc | (in) Trace buffer to use | |
tim | (in) Timestamp (value from CPU's timebase register) | |
fui | (in) Record format (as unsigned int) | |
dat | (in) Record data (always 6 longwords, must long word aligned) |
References _TRC_Buffer::count, _TRC_Row::dat, _TRC_Buffer::first, _TRC_Row::fui, _TRC_Buffer::last, _TRC_Buffer::max, _TRC_Buffer::min, _TRC_Buffer::row, and _TRC_Row::tics.
Referenced by TRC_record().
static void recover | ( | TRC_Buffer * | trc | ) | [static] |
Try to recover if the row pointers are messed up.
trc | (in) Trace buffer to recover |
References _TRC_Buffer::max, _TRC_Buffer::min, _TRC_Buffer::rec, _TRC_Buffer::row, _TRC_Buffer::rows, _TRC_Buffer::size, TRC_CACHE_LINE_PAD, TRC_L_ROWS_MAX, and TRC_L_ROWS_MIN.
Referenced by TRC_record().
unsigned int TRC_advertise | ( | TRC_Buffer * | trc | ) |
Use a MSG to advertise the location of the system trace blob.
TRC_NOTINIT | System trace not in state initialized | |
TRC_SUCCESS | Success |
References _TRC_Control::com, _TRC_Buffer::id, _TRC_Buffer::nam, _TRC_Control::nxt, _TRC_Common::size, _TRC_Buffer::size, TRC_tcb, and TRC_validTrace().
unsigned int TRC_correlateTime | ( | TRC_Buffer * | trc | ) |
Place a time correlation record in a trace buffer header.
TRC_NOTINIT | System trace not in state initialized | |
TRC_NOTTRACE | Invalid trace pointer | |
TRC_SUCCESS | Success |
References _TRC_Buffer::itic, _TRC_Buffer::itim, _TRC_Control::rwi, TRC_tcb, and TRC_validTrace().
unsigned int TRC_create | ( | TRC_Buffer ** | trc, | |
unsigned int | rows, | |||
unsigned int | id, | |||
const char * | nam | |||
) |
Create a user trace buffer (no snaphost or telemetry capability).
trc | (out) Trace buffer handle | |
rows | (in) Number of rows in trace buffer (default 1024) | |
id | (in) Trace identity (user defined, a number 1-255) | |
nam | (in) Trace name (user defined, 15 characters max) |
TRC_ALLOCMEM | Cannot allocate memory | |
TRC_PARMNULL | NULL parameter detected | |
TRC_NOTINIT | System trace not in state initialized | |
TRC_SUCCESS | Success |
References _TRC_Buffer::chk, _TRC_Control::com, _TRC_Buffer::com, _TRC_Buffer::frame, _TRC_Buffer::id, _TRC_Buffer::max, _TRC_Buffer::min, _TRC_Buffer::nam, _TRC_Buffer::nxt, _TRC_Control::nxt, _TRC_Buffer::row, _TRC_Buffer::rows, _TRC_Control::rwi, _TRC_Buffer::size, _TRC_Control::state, TRC_CACHE_LINE_PAD, TRC_CTL_INITIALIZED, TRC_L_ROWS_MAX, TRC_L_ROWS_MIN, TRC_M_BUFFER, TRC_tcb, and validName().
unsigned int TRC_delete | ( | TRC_Buffer * | trc | ) |
Create a user trace buffer.
trc | (in) Trace buffer handle |
TRC_NOSYSDEL | Cannot delete the system trace | |
TRC_NOTTRACE | Not a vlid trace pointer | |
TRC_SUCCESS | Success |
References _TRC_Buffer::fcb, _TRC_Buffer::nxt, _TRC_Control::nxt, _TRC_Control::rwi, TRC_tcb, and TRC_validTrace().
unsigned long long TRC_record | ( | TRC_Buffer * | trc, | |
unsigned int | fui, | |||
unsigned int * | dat | |||
) |
Insert a record into a trace.
trc | (in) Trace buffer to use (NULL => "system" trace buffer) | |
fui | (in) Record format | |
dat | (in) Record data (always 6 longwords = 24 bytes) |
x | The timestamp captured from the CPU time-base register |
A trace buffer row is data cache line aligned and one cache line long (i.e. it's 32 bytes). The contents of the first eight bytes are defined by TRC. The first four bytes capture the low half of of the CPU's time base register, the next two bytes capture the information that allows the trace dump routine to figure out how to format the dump. The third byte records the task ID of the task in scope during which the call to TRC_record(). The last byte is reserved.
The caller's responsibility is to put formatting information into the upper two bytes of fui, and fill in 24 bytes of user data into dat.
References _TRC_Control::chk, _TRC_Buffer::frame, _TRC_Buffer::max, _TRC_Buffer::min, _TRC_Control::nxt, record(), recover(), _TRC_Buffer::row, _TRC_Buffer::rows, _TRC_Control::rwi, TRC_M_BUFFER, and TRC_tcb.
unsigned int TRC_sizeofTrace | ( | TRC_Buffer * | trc | ) |
Return the size of a complete compound trace (buffer plus common).
trc | (in) Trace buffer (NULL => system trace) |
0 | Cannot locate trace buffer | |
x | Size of a complete trace buffer |
In normal operation, there can be one or more TRC_Buffer structures, but only one TRC_Common area. The "system trace" has the privilege of having the TRC_Common located area contiguously behind the TRC_Buffer area.
TRC_sizeTrace() can therefore be used two ways. When called with a NULL pointer, it returns the size of the extant system trace (system trace buffer plus common area). When called with a pointer to a user trace buffer, it returns the size of a buffer necessary to accomodate the common area and the user's trace buffer back-to-back (with all necessary padding). The latter can be useful for user manipulation of trace buffers via facilities like TRC_copy().
References _TRC_Control::com, _TRC_Common::size, _TRC_Buffer::size, TRC_tcb, and TRC_validTrace().
int TRC_tdb2tid | ( | int | tdb | ) |
Translate a task ID (CPU_DB/ITC style) to a VxWorks task ID.
tdb | (in) Task ID (CPU_DB/ITC definition) (0 => "self") |
0 | No translation available | |
x | VxWorks task ID |
References _TRC_Control::chk, _TRC_Control::com, _TRC_Common::t2nbas, _TRC_Task2Name::tid, TRC_L_TASKLIST, and TRC_tcb.
unsigned int TRC_write | ( | TRC_Buffer * | trc, | |
const char * | fil | |||
) |
Write a (compound) trace snapshot to a file.
trc | (in) The buffer handle | |
fil | (in) File name |
References _TRC_Buffer::frame, _TRC_Common::size, _TRC_Buffer::size, and TRC_M_BUFFER.
Referenced by TRC_sendFile().
static unsigned int validName | ( | const char * | name, | |
const char * | func | |||
) | [static] |
Validate a trace name.
name | (in) Trace name | |
func | (in) Name of calling routine |
TRC_NAMELEN | Trace name length out of valid range | |
TRC_NAMENULL | Trace name is a NULL pointer | |
TRC_NAMESNTX | Trace name has invalid syntax | |
TRC_SUCCESS | Success |
References TRC_L_TRACENAME.
Referenced by TRC_create().
static const char s_misaligned[TRC_DATA_ROW_SIZE<< 2] [static] |
Initial value:
{ TRC_DAT_MISALIGN }
static const char s_noData[TRC_DATA_ROW_SIZE<< 2] [static] |