cpukit/libbtrace: reformat

Fixes #5455.
This commit is contained in:
Gedare Bloom
2026-02-05 09:19:01 -06:00
committed by Kinsey Moore
parent 2948d1ed8f
commit f058d040e0
17 changed files with 1960 additions and 2040 deletions
File diff suppressed because it is too large Load Diff
+15 -17
View File
@@ -65,11 +65,11 @@ typedef enum {
} rtems_record_client_status;
typedef rtems_record_client_status ( *rtems_record_client_handler )(
uint64_t bt,
uint32_t cpu,
rtems_record_event event,
uint64_t data,
void *arg
uint64_t bt,
uint32_t cpu,
rtems_record_event event,
uint64_t data,
void *arg
);
typedef struct {
@@ -130,27 +130,27 @@ typedef struct {
} rtems_record_client_per_cpu;
typedef struct rtems_record_client_context {
uint64_t to_bt_scaler;
uint64_t to_bt_scaler;
rtems_record_client_per_cpu per_cpu[ RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT ];
uint32_t cpu;
uint32_t cpu_count;
uint32_t per_cpu_items;
uint32_t cpu;
uint32_t cpu_count;
uint32_t per_cpu_items;
union {
rtems_record_item_32 format_32;
rtems_record_item_64 format_64;
} item;
size_t todo;
void *pos;
void *pos;
rtems_record_client_status ( *consume )(
struct rtems_record_client_context *,
const void *,
size_t
);
rtems_record_client_handler handler;
void *handler_arg;
size_t data_size;
uint32_t header[ 2 ];
rtems_record_client_status status;
void *handler_arg;
size_t data_size;
uint32_t header[ 2 ];
rtems_record_client_status status;
} rtems_record_client_context;
/**
@@ -190,9 +190,7 @@ rtems_record_client_status rtems_record_client_run(
*
* @param ctx The record client context.
*/
void rtems_record_client_destroy(
rtems_record_client_context *ctx
);
void rtems_record_client_destroy( rtems_record_client_context *ctx );
static inline void rtems_record_client_set_handler(
rtems_record_client_context *ctx,
+2 -2
View File
@@ -1189,7 +1189,7 @@ typedef unsigned long rtems_record_data;
/**
* @brief The native record item.
*/
typedef struct __attribute__((__packed__)) {
typedef struct __attribute__(( __packed__ )) {
uint32_t event;
rtems_record_data data;
} rtems_record_item;
@@ -1205,7 +1205,7 @@ typedef struct {
/**
* @brief The 64-bit format record item.
*/
typedef struct __attribute__((__packed__)) {
typedef struct __attribute__(( __packed__ )) {
uint32_t event;
uint64_t data;
} rtems_record_item_64;
+11 -14
View File
@@ -63,10 +63,7 @@ typedef void ( *rtems_record_dump_chunk )(
* @param flush Handler to flush the data.
* @param arg The argument for the handlers.
*/
void rtems_record_dump(
rtems_record_dump_chunk chunk,
void *arg
);
void rtems_record_dump( rtems_record_dump_chunk chunk, void *arg );
/**
* @brief Dumps the event records in base64 encoding.
@@ -83,14 +80,14 @@ void rtems_record_dump_base64( void ( *put_char )( int, void * ), void *arg );
* encoding.
*/
typedef struct {
void ( *put_char )( int, void * );
void *arg;
int out;
unsigned char buf[ 57 ];
z_stream stream;
char *mem_begin;
size_t mem_available;
char mem[ 0x80000 ];
void ( *put_char )( int, void * );
void *arg;
int out;
unsigned char buf[ 57 ];
z_stream stream;
char *mem_begin;
size_t mem_available;
char mem[ 0x80000 ];
} rtems_record_dump_base64_zlib_context;
/**
@@ -105,8 +102,8 @@ typedef struct {
*/
void rtems_record_dump_zlib_base64(
rtems_record_dump_base64_zlib_context *ctx,
void ( *put_char )( int, void * ),
void *arg
void ( *put_char )( int, void * ),
void *arg
);
/** @} */
+18 -26
View File
@@ -143,7 +143,7 @@ static uint64_t time_bt(
time_accumulated = per_cpu->uptime.time_accumulated;
if ( has_time( event) ) {
if ( has_time( event ) ) {
time_accumulated += ( time - per_cpu->uptime.time_last ) & TIME_MASK;
per_cpu->uptime.time_last = time;
per_cpu->uptime.time_accumulated = time_accumulated;
@@ -192,10 +192,10 @@ static rtems_record_client_status resolve_hold_back(
rtems_record_client_per_cpu *per_cpu
)
{
rtems_record_item_64 *items;
uint32_t last;
uint64_t accumulated;
size_t index;
rtems_record_item_64 *items;
uint32_t last;
uint64_t accumulated;
size_t index;
rtems_record_client_uptime uptime;
items = per_cpu->items;
@@ -222,7 +222,7 @@ static rtems_record_client_status resolve_hold_back(
per_cpu->uptime.time_accumulated = 0;
for ( index = 0; index < per_cpu->item_index; ++index ) {
uint32_t time_event;
uint32_t time_event;
rtems_record_client_status status;
time_event = items[ index ].event;
@@ -317,7 +317,7 @@ static rtems_record_client_status visit(
per_cpu->uptime.time_last = time;
per_cpu->uptime.time_accumulated = 0;
if (do_hold_back) {
if ( do_hold_back ) {
status = resolve_hold_back( ctx, per_cpu );
if ( status != RTEMS_RECORD_CLIENT_SUCCESS ) {
@@ -382,7 +382,7 @@ static rtems_record_client_status consume_32(
{
while ( n > 0 ) {
size_t m;
char *pos;
char *pos;
m = ctx->todo < n ? ctx->todo : n;
pos = ctx->pos;
@@ -422,7 +422,7 @@ static rtems_record_client_status consume_64(
{
while ( n > 0 ) {
size_t m;
char *pos;
char *pos;
m = ctx->todo < n ? ctx->todo : n;
pos = ctx->pos;
@@ -462,7 +462,7 @@ static rtems_record_client_status consume_swap_32(
{
while ( n > 0 ) {
size_t m;
char *pos;
char *pos;
m = ctx->todo < n ? ctx->todo : n;
pos = ctx->pos;
@@ -502,7 +502,7 @@ static rtems_record_client_status consume_swap_64(
{
while ( n > 0 ) {
size_t m;
char *pos;
char *pos;
m = ctx->todo < n ? ctx->todo : n;
pos = ctx->pos;
@@ -542,7 +542,7 @@ static rtems_record_client_status consume_init(
{
while ( n > 0 ) {
size_t m;
char *pos;
char *pos;
m = ctx->todo < n ? ctx->todo : n;
pos = ctx->pos;
@@ -631,7 +631,7 @@ static rtems_record_client_status consume_init(
return RTEMS_RECORD_CLIENT_SUCCESS;
}
rtems_record_client_status rtems_record_client_init(
rtems_record_client_status rtems_record_client_init(
rtems_record_client_context *ctx,
rtems_record_client_handler handler,
void *arg
@@ -669,9 +669,9 @@ static void calculate_best_effort_uptime(
)
{
rtems_record_item_64 *items;
uint32_t last;
uint64_t accumulated;
size_t index;
uint32_t last;
uint64_t accumulated;
size_t index;
items = per_cpu->items;
accumulated = 0;
@@ -701,9 +701,7 @@ static void calculate_best_effort_uptime(
per_cpu->uptime.time_accumulated = 0;
}
void rtems_record_client_destroy(
rtems_record_client_context *ctx
)
void rtems_record_client_destroy( rtems_record_client_context *ctx )
{
uint32_t cpu;
@@ -714,13 +712,7 @@ void rtems_record_client_destroy(
per_cpu = &ctx->per_cpu[ cpu ];
if ( per_cpu->hold_back && per_cpu->item_index > 0 ) {
(void) call_handler(
ctx,
per_cpu,
0,
RTEMS_RECORD_UNRELIABLE_TIME,
0
);
(void) call_handler( ctx, per_cpu, 0, RTEMS_RECORD_UNRELIABLE_TIME, 0 );
calculate_best_effort_uptime( ctx, per_cpu );
(void) resolve_hold_back( ctx, per_cpu );
}
+5 -5
View File
@@ -37,11 +37,11 @@
#include <rtems/base64.h>
typedef struct {
IO_Put_char put_char;
void *arg;
int out;
size_t index;
char buf[ 57 ];
IO_Put_char put_char;
void *arg;
int out;
size_t index;
char buf[ 57 ];
} dump_context;
static void put_char( int c, void *arg )
+7 -15
View File
@@ -37,8 +37,9 @@
#include <rtems/score/timecounter.h>
#if ISR_LOCK_NEEDS_OBJECT
static ISR_lock_Control _Record_Dump_base64_lock =
ISR_LOCK_INITIALIZER( "Record Dump base64" );
static ISR_lock_Control _Record_Dump_base64_lock = ISR_LOCK_INITIALIZER(
"Record Dump base64"
);
#endif
static bool _Record_Dump_base64_done;
@@ -73,22 +74,13 @@ void _Record_Fatal_dump_base64(
rtems_record_commit_critical( &record_context );
rtems_record_prepare_critical( &record_context, cpu_self );
rtems_record_add(
&record_context,
RTEMS_RECORD_FATAL_SOURCE,
source
);
rtems_record_add(
&record_context,
RTEMS_RECORD_FATAL_CODE,
code
);
rtems_record_add( &record_context, RTEMS_RECORD_FATAL_SOURCE, source );
rtems_record_add( &record_context, RTEMS_RECORD_FATAL_CODE, code );
rtems_record_commit_critical( &record_context );
#if defined(RTEMS_SMP)
#if defined( RTEMS_SMP )
if (
source == RTEMS_FATAL_SOURCE_SMP &&
code == SMP_FATAL_SHUTDOWN_RESPONSE
source == RTEMS_FATAL_SOURCE_SMP && code == SMP_FATAL_SHUTDOWN_RESPONSE
) {
return;
}
+19 -5
View File
@@ -97,7 +97,14 @@ static void chunk( void *arg, const void *data, size_t length )
ctx->stream.next_out = &ctx->buf[ 0 ];
ctx->stream.avail_out = sizeof( ctx->buf );
_Base64_Encode( put_char, ctx, ctx->buf, sizeof( ctx->buf ), NULL, INT_MAX );
_Base64_Encode(
put_char,
ctx,
ctx->buf,
sizeof( ctx->buf ),
NULL,
INT_MAX
);
}
}
}
@@ -116,7 +123,14 @@ static void flush( rtems_record_dump_base64_zlib_context *ctx )
ctx->stream.next_out = &ctx->buf[ 0 ];
ctx->stream.avail_out = sizeof( ctx->buf );
_Base64_Encode( put_char, ctx, ctx->buf, sizeof( ctx->buf ), NULL, INT_MAX );
_Base64_Encode(
put_char,
ctx,
ctx->buf,
sizeof( ctx->buf ),
NULL,
INT_MAX
);
}
}
@@ -132,8 +146,8 @@ static void flush( rtems_record_dump_base64_zlib_context *ctx )
void rtems_record_dump_zlib_base64(
rtems_record_dump_base64_zlib_context *ctx,
void ( *put_char )( int, void * ),
void *arg
void ( *put_char )( int, void * ),
void *arg
)
{
int err;
@@ -148,7 +162,7 @@ void rtems_record_dump_zlib_base64(
ctx->mem_available = sizeof( ctx->mem );
err = deflateInit( &ctx->stream, Z_BEST_COMPRESSION );
if (err != Z_OK) {
if ( err != Z_OK ) {
return;
}
+7 -15
View File
@@ -37,8 +37,9 @@
#include <rtems/score/timecounter.h>
#if ISR_LOCK_NEEDS_OBJECT
static ISR_lock_Control _Record_Dump_base64_zlib_lock =
ISR_LOCK_INITIALIZER( "Record Dump base64 zlib" );
static ISR_lock_Control _Record_Dump_base64_zlib_lock = ISR_LOCK_INITIALIZER(
"Record Dump base64 zlib"
);
#endif
static bool _Record_Dump_base64_zlib_done;
@@ -75,22 +76,13 @@ void _Record_Fatal_dump_base64_zlib(
rtems_record_commit_critical( &record_context );
rtems_record_prepare_critical( &record_context, cpu_self );
rtems_record_add(
&record_context,
RTEMS_RECORD_FATAL_SOURCE,
source
);
rtems_record_add(
&record_context,
RTEMS_RECORD_FATAL_CODE,
code
);
rtems_record_add( &record_context, RTEMS_RECORD_FATAL_SOURCE, source );
rtems_record_add( &record_context, RTEMS_RECORD_FATAL_CODE, code );
rtems_record_commit_critical( &record_context );
#if defined(RTEMS_SMP)
#if defined( RTEMS_SMP )
if (
source == RTEMS_FATAL_SOURCE_SMP &&
code == SMP_FATAL_SHUTDOWN_RESPONSE
source == RTEMS_FATAL_SOURCE_SMP && code == SMP_FATAL_SHUTDOWN_RESPONSE
) {
return;
}
+9 -12
View File
@@ -33,8 +33,8 @@
#include <rtems/score/threadimpl.h>
typedef struct {
rtems_record_dump_chunk chunk;
void *arg;
rtems_record_dump_chunk chunk;
void *arg;
} dump_context;
static void dump_chunk( dump_context *ctx, const void *data, size_t length )
@@ -44,12 +44,12 @@ static void dump_chunk( dump_context *ctx, const void *data, size_t length )
static bool thread_names_visitor( rtems_tcb *tcb, void *arg )
{
dump_context *ctx;
char name[ 2 * THREAD_DEFAULT_MAXIMUM_NAME_SIZE ];
size_t n;
size_t i;
rtems_record_item item;
rtems_record_data data;
dump_context *ctx;
char name[ 2 * THREAD_DEFAULT_MAXIMUM_NAME_SIZE ];
size_t n;
size_t i;
rtems_record_item item;
rtems_record_data data;
ctx = arg;
item.event = RTEMS_RECORD_THREAD_ID;
@@ -80,10 +80,7 @@ static bool thread_names_visitor( rtems_tcb *tcb, void *arg )
return false;
}
void rtems_record_dump(
rtems_record_dump_chunk chunk,
void *arg
)
void rtems_record_dump( rtems_record_dump_chunk chunk, void *arg )
{
Record_Stream_header header;
size_t size;
+5 -5
View File
@@ -50,12 +50,13 @@
size_t rtems_record_get_item_count_for_fetch( void )
{
return _Record_Configuration.item_count + RECORD_FETCH_HEADER_ITEMS
return _Record_Configuration.item_count +
RECORD_FETCH_HEADER_ITEMS
#ifdef RTEMS_SMP
/* See red zone comment below */
- 1
/* See red zone comment below */
- 1
#endif
;
;
}
void rtems_record_fetch_initialize(
@@ -69,7 +70,6 @@ void rtems_record_fetch_initialize(
control->internal.storage_item_count = count;
}
rtems_record_fetch_status rtems_record_fetch(
rtems_record_fetch_control *control
)
+17 -21
View File
@@ -80,8 +80,8 @@ static void send_header( int fd )
}
typedef struct {
int fd;
size_t index;
int fd;
size_t index;
rtems_record_item items[ 128 ];
} thread_names_context;
@@ -97,7 +97,7 @@ static void thread_names_produce(
ctx->items[ i ].event = RTEMS_RECORD_TIME_EVENT( 0, event );
ctx->items[ i ].data = data;
if (i == RTEMS_ARRAY_SIZE(ctx->items) - 1) {
if ( i == RTEMS_ARRAY_SIZE( ctx->items ) - 1 ) {
ctx->index = 0;
(void) write( ctx->fd, ctx->items, sizeof( ctx->items ) );
} else {
@@ -150,11 +150,7 @@ static void send_thread_names( int fd )
}
}
static void fetch_and_write(
int fd,
rtems_record_item *items,
size_t count
)
static void fetch_and_write( int fd, rtems_record_item *items, size_t count )
{
rtems_record_fetch_control control;
@@ -184,13 +180,13 @@ static void fetch_and_write(
void rtems_record_server( uint16_t port, rtems_interval period )
{
rtems_status_code sc;
rtems_id self;
rtems_id timer;
rtems_status_code sc;
rtems_id self;
rtems_id timer;
struct sockaddr_in addr;
int sd;
int rv;
size_t count;
int sd;
int rv;
size_t count;
rtems_record_item *items;
self = rtems_task_self();
@@ -207,7 +203,7 @@ void rtems_record_server( uint16_t port, rtems_interval period )
}
sd = socket( PF_INET, SOCK_STREAM, 0 );
if (sd < 0) {
if ( sd < 0 ) {
goto socket_error;
}
@@ -217,12 +213,12 @@ void rtems_record_server( uint16_t port, rtems_interval period )
addr.sin_addr.s_addr = htonl( INADDR_ANY );
rv = bind( sd, (const struct sockaddr *) &addr, sizeof( addr ) );
if (rv != 0) {
if ( rv != 0 ) {
goto error;
}
rv = listen( sd, 0 );
if (rv != 0) {
if ( rv != 0 ) {
goto error;
}
@@ -265,14 +261,14 @@ typedef struct {
static void server( rtems_task_argument arg )
{
server_arg *sarg;
uint16_t port;
rtems_interval period;
server_arg *sarg;
uint16_t port;
rtems_interval period;
sarg = (server_arg *) arg;
port = sarg->port;
period = sarg->period;
wakeup(sarg->task);
wakeup( sarg->task );
rtems_record_server( port, period );
rtems_task_exit();
}
+12 -5
View File
@@ -68,15 +68,22 @@ size_t _Record_Stream_header_initialize( Record_Stream_header *header )
header->Version.event = RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_VERSION );
header->Version.data = RTEMS_RECORD_THE_VERSION;
header->Processor_maximum.event =
RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_PROCESSOR_MAXIMUM );
header->Processor_maximum.event = RTEMS_RECORD_TIME_EVENT(
0,
RTEMS_RECORD_PROCESSOR_MAXIMUM
);
header->Processor_maximum.data = rtems_scheduler_get_processor_maximum() - 1;
header->Count.event = RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_PER_CPU_COUNT );
header->Count.event = RTEMS_RECORD_TIME_EVENT(
0,
RTEMS_RECORD_PER_CPU_COUNT
);
header->Count.data = _Record_Configuration.item_count;
header->Frequency.event =
RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_FREQUENCY );
header->Frequency.event = RTEMS_RECORD_TIME_EVENT(
0,
RTEMS_RECORD_FREQUENCY
);
header->Frequency.data = rtems_counter_frequency();
items = header->Info;
File diff suppressed because it is too large Load Diff
+9 -27
View File
@@ -68,10 +68,7 @@ void _Record_Thread_start(
{
(void) executing;
rtems_record_produce(
RTEMS_RECORD_THREAD_START,
started->Object.id
);
rtems_record_produce( RTEMS_RECORD_THREAD_START, started->Object.id );
}
void _Record_Thread_restart(
@@ -81,10 +78,7 @@ void _Record_Thread_restart(
{
(void) executing;
rtems_record_produce(
RTEMS_RECORD_THREAD_RESTART,
restarted->Object.id
);
rtems_record_produce( RTEMS_RECORD_THREAD_RESTART, restarted->Object.id );
}
void _Record_Thread_delete(
@@ -94,10 +88,7 @@ void _Record_Thread_delete(
{
(void) executing;
rtems_record_produce(
RTEMS_RECORD_THREAD_DELETE,
deleted->Object.id
);
rtems_record_produce( RTEMS_RECORD_THREAD_DELETE, deleted->Object.id );
}
void _Record_Thread_switch(
@@ -111,9 +102,9 @@ void _Record_Thread_switch(
items[ 0 ].data = executing->Object.id;
items[ 1 ].event = RTEMS_RECORD_THREAD_STACK_CURRENT;
items[ 1 ].data =
#if defined(__GNUC__)
(uintptr_t) __builtin_frame_address( 0 )
- (uintptr_t) executing->Start.Initial_stack.area;
#if defined( __GNUC__ )
(uintptr_t) __builtin_frame_address( 0 ) -
(uintptr_t) executing->Start.Initial_stack.area;
#else
0;
#endif
@@ -124,24 +115,15 @@ void _Record_Thread_switch(
void _Record_Thread_begin( struct _Thread_Control *executing )
{
rtems_record_produce(
RTEMS_RECORD_THREAD_BEGIN,
executing->Object.id
);
rtems_record_produce( RTEMS_RECORD_THREAD_BEGIN, executing->Object.id );
}
void _Record_Thread_exitted( struct _Thread_Control *executing )
{
rtems_record_produce(
RTEMS_RECORD_THREAD_EXITTED,
executing->Object.id
);
rtems_record_produce( RTEMS_RECORD_THREAD_EXITTED, executing->Object.id );
}
void _Record_Thread_terminate( struct _Thread_Control *executing )
{
rtems_record_produce(
RTEMS_RECORD_THREAD_TERMINATE,
executing->Object.id
);
rtems_record_produce( RTEMS_RECORD_THREAD_TERMINATE, executing->Object.id );
}
File diff suppressed because it is too large Load Diff
+6 -9
View File
@@ -68,10 +68,7 @@ void rtems_record_produce_2(
rtems_record_commit( &context );
}
void rtems_record_produce_n(
const rtems_record_item *items,
size_t n
)
void rtems_record_produce_n( const rtems_record_item *items, size_t n )
{
rtems_record_context context;
@@ -89,11 +86,11 @@ void rtems_record_produce_n(
}
size_t _Record_String_to_items(
rtems_record_event event,
const char *str,
size_t len,
rtems_record_item *items,
size_t item_count
rtems_record_event event,
const char *str,
size_t len,
rtems_record_item *items,
size_t item_count
)
{
size_t s;