Index: cpukit/Makefile.am
===================================================================
--- cpukit/Makefile.am	(revision f0ae613ba72bc4b95797e2482c4bd0fa5546331d)
+++ cpukit/Makefile.am	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -477,4 +477,10 @@
 librtemscpu_a_SOURCES += libstdthreads/thrd.c
 librtemscpu_a_SOURCES += libstdthreads/tss.c
+librtemscpu_a_SOURCES += libtrace/record/record.c
+librtemscpu_a_SOURCES += libtrace/record/record-client.c
+librtemscpu_a_SOURCES += libtrace/record/record-server.c
+librtemscpu_a_SOURCES += libtrace/record/record-sysinit.c
+librtemscpu_a_SOURCES += libtrace/record/record-text.c
+librtemscpu_a_SOURCES += libtrace/record/record-userext.c
 librtemscpu_a_SOURCES += posix/src/adjtime.c
 librtemscpu_a_SOURCES += posix/src/aio_suspend.c
Index: cpukit/headers.am
===================================================================
--- cpukit/headers.am	(revision f0ae613ba72bc4b95797e2482c4bd0fa5546331d)
+++ cpukit/headers.am	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -137,4 +137,7 @@
 include_rtems_HEADERS += include/rtems/rbheap.h
 include_rtems_HEADERS += include/rtems/rbtree.h
+include_rtems_HEADERS += include/rtems/record.h
+include_rtems_HEADERS += include/rtems/recordclient.h
+include_rtems_HEADERS += include/rtems/recorddata.h
 include_rtems_HEADERS += include/rtems/ringbuf.h
 include_rtems_HEADERS += include/rtems/rtc.h
Index: cpukit/include/rtems/confdefs.h
===================================================================
--- cpukit/include/rtems/confdefs.h	(revision f0ae613ba72bc4b95797e2482c4bd0fa5546331d)
+++ cpukit/include/rtems/confdefs.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -2124,4 +2124,8 @@
     (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
   static const rtems_extensions_table Configuration_Initial_Extensions[] = {
+    #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0 && \
+      defined(CONFIGURE_RECORD_EXTENSIONS_ENABLED)
+      RECORD_EXTENSION,
+    #endif
     #if !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)
       RTEMS_NEWLIB_EXTENSION,
@@ -2966,4 +2970,31 @@
     #endif
   };
+
+  #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0
+    #include <rtems/record.h>
+
+    #if (CONFIGURE_RECORD_PER_PROCESSOR_ITEMS & (CONFIGURE_RECORD_PER_PROCESSOR_ITEMS - 1)) != 0
+      #error "CONFIGURE_RECORD_PER_PROCESSOR_ITEMS must be a power of two"
+    #endif
+
+    #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS < 16
+      #error "CONFIGURE_RECORD_PER_PROCESSOR_ITEMS must be at least 16"
+    #endif
+
+    const unsigned int _Record_Item_count = CONFIGURE_RECORD_PER_PROCESSOR_ITEMS;
+
+    struct Record_Configured_control {
+      Record_Control    Control;
+      rtems_record_item Items[ CONFIGURE_RECORD_PER_PROCESSOR_ITEMS ];
+    };
+
+    PER_CPU_DATA_ITEM( Record_Configured_control, _Record_Per_CPU );
+
+    RTEMS_SYSINIT_ITEM(
+      _Record_Initialize,
+      RTEMS_SYSINIT_RECORD,
+      RTEMS_SYSINIT_ORDER_MIDDLE
+    );
+  #endif
 #endif
 
Index: cpukit/include/rtems/record.h
===================================================================
--- cpukit/include/rtems/record.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/include/rtems/record.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,334 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTEMS_RECORD_H
+#define _RTEMS_RECORD_H
+
+#include "recorddata.h"
+
+#include <rtems/score/atomic.h>
+#include <rtems/score/cpu.h>
+#include <rtems/score/percpudata.h>
+#include <rtems/score/watchdog.h>
+#include <rtems/rtems/intr.h>
+#include <rtems/rtems/tasks.h>
+#include <rtems/counter.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct Record_Control {
+  Atomic_Uint       head;
+  unsigned int      tail;
+  unsigned int      mask;
+  Watchdog_Control  Watchdog;
+  rtems_record_item Header[ 3 ];
+  rtems_record_item Items[ RTEMS_ZERO_LENGTH_ARRAY ];
+};
+
+typedef struct Record_Control Record_Control;
+
+typedef RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
+  struct Record_Configured_control Record_Configured_control;
+
+typedef struct {
+  Record_Control        *control;
+  unsigned int           head;
+  uint32_t               now;
+  rtems_interrupt_level  level;
+} rtems_record_context;
+
+PER_CPU_DATA_ITEM_DECLARE( Record_Configured_control, _Record_Per_CPU );
+
+extern const unsigned int _Record_Item_count;
+
+void _Record_Initialize( void );
+
+bool _Record_Thread_create(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *created
+);
+
+void _Record_Thread_start(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *started
+);
+
+void _Record_Thread_restart(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *restarted
+);
+
+void _Record_Thread_delete(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *deleted
+);
+
+void _Record_Thread_switch(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *heir
+);
+
+void _Record_Thread_begin( struct _Thread_Control *executing );
+
+void _Record_Thread_exitted( struct _Thread_Control *executing );
+
+void _Record_Thread_terminate(
+  struct _Thread_Control *executing
+);
+
+#define RECORD_EXTENSION \
+  { \
+    _Record_Thread_create, \
+    _Record_Thread_start, \
+    _Record_Thread_restart, \
+    _Record_Thread_delete, \
+    _Record_Thread_switch, \
+    _Record_Thread_begin, \
+    _Record_Thread_exitted, \
+    NULL, \
+    _Record_Thread_terminate \
+  }
+
+RTEMS_INLINE_ROUTINE unsigned int _Record_Index(
+  const Record_Control *control,
+  unsigned int          index
+)
+{
+  return index & control->mask;
+}
+
+RTEMS_INLINE_ROUTINE unsigned int _Record_Head( const Record_Control *control )
+{
+  return _Atomic_Load_uint( &control->head, ATOMIC_ORDER_RELAXED );
+}
+
+RTEMS_INLINE_ROUTINE unsigned int _Record_Tail( const Record_Control *control )
+{
+  return control->tail;
+}
+
+RTEMS_INLINE_ROUTINE bool _Record_Is_overflow(
+  const Record_Control *control,
+  unsigned int          tail,
+  unsigned int          head
+)
+{
+  return head - tail >= control->mask + 1U;
+}
+
+RTEMS_INLINE_ROUTINE unsigned int _Record_Capacity(
+  const Record_Control *control,
+  unsigned int          tail,
+  unsigned int          head
+)
+{
+  return ( tail - head - 1U ) & control->mask;
+}
+
+RTEMS_INLINE_ROUTINE rtems_counter_ticks _Record_Now( void )
+{
+  return rtems_counter_read();
+}
+
+typedef struct RTEMS_PACKED {
+  uint32_t format;
+  uint32_t magic;
+  rtems_record_item Version;
+  rtems_record_item Processor_maximum;
+  rtems_record_item Count;
+  rtems_record_item Frequency;
+} Record_Stream_header;
+
+void _Record_Stream_header_initialize( Record_Stream_header *header );
+
+/**
+ * @addtogroup RTEMSRecord
+ *
+ * @{
+ */
+
+/**
+ * @brief Prepares to add and commit record items.
+ *
+ * This function disables interrupts.
+ *
+ * @param context The record context which must be used for the following
+ *   rtems_record_add() and rtems_record_commit() calls.  The record context
+ *   may have an arbitrary content at function entry.
+ *
+ * @see rtems_record_produce().
+ */
+RTEMS_INLINE_ROUTINE void rtems_record_prepare( rtems_record_context *context )
+{
+  rtems_interrupt_level  level;
+  const Per_CPU_Control *cpu_self;
+  Record_Control        *control;
+  unsigned int           head;
+
+  rtems_interrupt_local_disable( level );
+  context->now = RTEMS_RECORD_TIME_EVENT( _Record_Now(), 0 );
+  context->level = level;
+  cpu_self = _Per_CPU_Get();
+  control = cpu_self->record;
+  context->control = control;
+  head = _Record_Head( control );
+  context->head = head;
+}
+
+/**
+ * @brief Adds a record item.
+ *
+ * @param context The record context initialized via rtems_record_prepare().
+ * @param event The record event without a time stamp for the item.
+ * @param data The record data for the item.
+ */
+RTEMS_INLINE_ROUTINE void rtems_record_add(
+  rtems_record_context *context,
+  rtems_record_event    event,
+  rtems_record_data     data
+)
+{
+  Record_Control    *control;
+  rtems_record_item *item;
+  unsigned int       head;
+
+  control = context->control;
+  head = context->head;
+  item = &control->Items[ _Record_Index( control, head ) ];
+  context->head = head + 1;
+
+  item->event = context->now | event;
+  item->data = data;
+}
+
+/**
+ * @brief Commits a set of record items.
+ *
+ * @param context The record context initialized via rtems_record_prepare().
+ */
+RTEMS_INLINE_ROUTINE void rtems_record_commit( rtems_record_context *context )
+{
+  _Atomic_Store_uint(
+    &context->control->head,
+    context->head,
+    ATOMIC_ORDER_RELEASE
+  );
+  rtems_interrupt_local_enable( context->level );
+}
+
+/**
+ * @brief Produces a record item.
+ *
+ * @param event The record event without a time stamp for the item.
+ * @param data The record data for the item.
+ */
+void rtems_record_produce( rtems_record_event event, rtems_record_data data );
+
+/**
+ * @brief Produces two record items.
+ *
+ * @param event_0 The record event without a time stamp for the first item.
+ * @param data_0 The record data for the first item.
+ * @param event_1 The record event without a time stamp for the second item.
+ * @param data_1 The record data for the second item.
+ */
+void rtems_record_produce_2(
+  rtems_record_event event_0,
+  rtems_record_data  data_0,
+  rtems_record_event event_1,
+  rtems_record_data  data_1
+);
+
+/**
+ * @brief Produces n record items.
+ *
+ * @param item The record items without a time stamps.
+ * @param n The count of record items.
+ */
+void rtems_record_produce_n(
+  const rtems_record_item *items,
+  size_t                   n
+);
+
+typedef void ( *rtems_record_drain_visitor )(
+  const rtems_record_item *items,
+  size_t                   count,
+  void                    *arg
+);
+
+/**
+ * @brief Drains the record items on all processors.
+ *
+ * Calls the visitor function for each drained item set.
+ *
+ * @param visitor The visitor function.
+ * @param arg The argument for the visitor function.
+ */
+void rtems_record_drain( rtems_record_drain_visitor visitor, void *arg );
+
+/**
+ * @brief Drains the record items on all processors an writes them to the file
+ * descriptor.
+ *
+ * @param fd The file descriptor.
+ * @param written Set to true if items were written to the file descriptor,
+ *   otherwise set to false.
+ *
+ * @retval The bytes written to the file descriptor.
+ */
+ssize_t rtems_record_writev( int fd, bool *written );
+
+/**
+ * @brief Runs a record TCP server loop.
+ *
+ * @param port The TCP port to listen in host byte order.
+ * @param period The drain period in clock ticks.
+ */
+void rtems_record_server( uint16_t port, rtems_interval period );
+
+/**
+ * @brief Starts a record TCP server task.
+ *
+ * @param priority The task priority.
+ * @param port The TCP port to listen in host byte order.
+ * @param period The drain period in clock ticks.
+ */
+rtems_status_code rtems_record_start_server(
+  rtems_task_priority priority,
+  uint16_t            port,
+  rtems_interval      period
+);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_RECORD_H */
Index: cpukit/include/rtems/recordclient.h
===================================================================
--- cpukit/include/rtems/recordclient.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/include/rtems/recordclient.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,139 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file must be compatible to general purpose POSIX system, e.g. Linux,
+ * FreeBSD.  It may be used for utility programs.
+ */
+
+#ifndef _RTEMS_RECORDCLIENT_H
+#define _RTEMS_RECORDCLIENT_H
+
+#include "recorddata.h"
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @addtogroup RTEMSRecord
+ *
+ * @{
+ */
+
+#define RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT 32
+
+typedef enum {
+  RTEMS_RECORD_CLIENT_SUCCESS,
+  RTEMS_RECORD_CLIENT_ERROR_INVALID_MAGIC,
+  RTEMS_RECORD_CLIENT_ERROR_UNKNOWN_FORMAT,
+  RTEMS_RECORD_CLIENT_ERROR_UNSUPPORTED_VERSION,
+  RTEMS_RECORD_CLIENT_ERROR_UNSUPPORTED_CPU
+} rtems_record_client_status;
+
+typedef rtems_record_client_status ( *rtems_record_client_handler )(
+  uint32_t            seconds,
+  uint32_t            nanoseconds,
+  uint32_t            cpu,
+  rtems_record_event  event,
+  uint64_t            data,
+  void               *arg
+);
+
+typedef struct {
+  struct {
+    uint64_t bt;
+    uint32_t time_at_bt;
+    uint32_t time_last;
+    uint32_t time_accumulated;
+  } uptime;
+  uint32_t tail[ 2 ];
+  uint32_t head[ 2 ];
+  size_t index;
+} rtems_record_client_per_cpu;
+
+typedef struct rtems_record_client_context {
+  uint64_t to_bt_scaler;
+  rtems_record_client_per_cpu per_cpu[ RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT ];
+  uint64_t data;
+  uint32_t cpu;
+  uint32_t event;
+  uint32_t count;
+  union {
+    rtems_record_item_32 format_32;
+    rtems_record_item_64 format_64;
+  } item;
+  size_t todo;
+  void *pos;
+  rtems_record_client_status ( *consume )(
+    struct rtems_record_client_context *,
+    const void *,
+    size_t
+  );
+  rtems_record_client_handler handler;
+  void *handler_arg;
+  uint32_t header[ 2 ];
+} rtems_record_client_context;
+
+/**
+ * @brief Initializes a record client.
+ *
+ * The record client consumes a record item stream produces by the record
+ * server.
+ *
+ * @param ctx The record client context to initialize.
+ * @param handler The handler is invoked for each received record item.
+ * @param arg The handler argument.
+ */
+void rtems_record_client_init(
+  rtems_record_client_context *ctx,
+  rtems_record_client_handler  handler,
+  void                        *arg
+);
+
+/**
+ * @brief Runs the record client to consume new stream data.
+ *
+ * @param ctx The record client context.
+ * @param buf The buffer with new stream data.
+ * @param n The size of the buffer.
+ */
+rtems_record_client_status rtems_record_client_run(
+  rtems_record_client_context *ctx,
+  const void                  *buf,
+  size_t                       n
+);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_RECORDCLIENT_H */
Index: cpukit/include/rtems/recorddata.h
===================================================================
--- cpukit/include/rtems/recorddata.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/include/rtems/recorddata.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,317 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file must be compatible to general purpose POSIX system, e.g. Linux,
+ * FreeBSD.  It may be used for utility programs.
+ */
+
+#ifndef _RTEMS_RECORDDATA_H
+#define _RTEMS_RECORDDATA_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup RTEMSRecord Event Recording
+ *
+ * @brief Low-level event recording support.
+ *
+ * @{
+ */
+
+/**
+ * @brief The record version.
+ *
+ * The record version reflects the record event definitions.  It is reported by
+ * the RTEMS_RECORD_VERSION event.
+ */
+#define RTEMS_RECORD_THE_VERSION 1
+
+/**
+ * @brief The items are in 32-bit little-endian format.
+ */
+#define RTEMS_RECORD_FORMAT_LE_32 0x11111111
+
+/**
+ * @brief The items are in 64-bit little-endian format.
+ */
+#define RTEMS_RECORD_FORMAT_LE_64 0x22222222
+
+/**
+ * @brief The items are in 32-bit big-endian format.
+ */
+#define RTEMS_RECORD_FORMAT_BE_32 0x33333333
+
+/**
+ * @brief The items are in 64-bit big-endian format.
+ */
+#define RTEMS_RECORD_FORMAT_BE_64 0x44444444
+
+/**
+ * @brief Magic number to identify a record item stream.
+ *
+ * This is a random number.
+ */
+#define RTEMS_RECORD_MAGIC 0x82e14ec1
+
+/**
+ * @brief The record events.
+ */
+typedef enum {
+  /* There are 512 events reserved for the system */
+  RTEMS_RECORD_EMPTY,
+  RTEMS_RECORD_VERSION,
+
+  /*
+   * Keep the following system events in lexicographical order, increment
+   * RTEMS_RECORD_THE_VERSION after each change.
+   */
+  RTEMS_RECORD_ACCEPT,
+  RTEMS_RECORD_BIND,
+  RTEMS_RECORD_BUFFER,
+  RTEMS_RECORD_CHOWN,
+  RTEMS_RECORD_CLOSE,
+  RTEMS_RECORD_CONNECT,
+  RTEMS_RECORD_COUNT,
+  RTEMS_RECORD_ETHER_INPUT,
+  RTEMS_RECORD_ETHER_OUTPUT,
+  RTEMS_RECORD_FCHMOD,
+  RTEMS_RECORD_FCNTL,
+  RTEMS_RECORD_FDATASYNC,
+  RTEMS_RECORD_FREQUENCY,
+  RTEMS_RECORD_FSTAT,
+  RTEMS_RECORD_FSYNC,
+  RTEMS_RECORD_FTRUNCATE,
+  RTEMS_RECORD_GIT_HASH,
+  RTEMS_RECORD_HEAD,
+  RTEMS_RECORD_HEAP_ALLOC,
+  RTEMS_RECORD_HEAP_FREE,
+  RTEMS_RECORD_HEAP_SIZE,
+  RTEMS_RECORD_HEAP_USAGE,
+  RTEMS_RECORD_INTERUPT_BEGIN,
+  RTEMS_RECORD_INTERUPT_END,
+  RTEMS_RECORD_INTERUPT_INSTALL,
+  RTEMS_RECORD_INTERUPT_REMOVE,
+  RTEMS_RECORD_IOCTL,
+  RTEMS_RECORD_IP6_INPUT,
+  RTEMS_RECORD_IP6_OUTPUT,
+  RTEMS_RECORD_IP_INPUT,
+  RTEMS_RECORD_IP_OUTPUT,
+  RTEMS_RECORD_KEVENT,
+  RTEMS_RECORD_KQUEUE,
+  RTEMS_RECORD_LENGTH,
+  RTEMS_RECORD_LINK,
+  RTEMS_RECORD_LSEEK,
+  RTEMS_RECORD_MKNOD,
+  RTEMS_RECORD_MMAP,
+  RTEMS_RECORD_MOUNT,
+  RTEMS_RECORD_OPEN,
+  RTEMS_RECORD_OVERFLOW,
+  RTEMS_RECORD_PAGE_ALLOC,
+  RTEMS_RECORD_PAGE_FREE,
+  RTEMS_RECORD_POLL,
+  RTEMS_RECORD_PROCESSOR,
+  RTEMS_RECORD_PROCESSOR_MAXIMUM,
+  RTEMS_RECORD_READ,
+  RTEMS_RECORD_READLINK,
+  RTEMS_RECORD_READV,
+  RTEMS_RECORD_RECV,
+  RTEMS_RECORD_RECVFROM,
+  RTEMS_RECORD_RECVMSG,
+  RTEMS_RECORD_RENAME,
+  RTEMS_RECORD_RTEMS_BARRIER_CREATE,
+  RTEMS_RECORD_RTEMS_BARRIER_DELETE,
+  RTEMS_RECORD_RTEMS_BARRIER_RELEASE,
+  RTEMS_RECORD_RTEMS_BARRIER_WAIT,
+  RTEMS_RECORD_RTEMS_EVENT_RECEIVE,
+  RTEMS_RECORD_RTEMS_EVENT_SEND,
+  RTEMS_RECORD_RTEMS_EVENT_SYSTEM_RECEIVE,
+  RTEMS_RECORD_RTEMS_EVENT_SYSTEM_SEND,
+  RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_BROADCAST,
+  RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_CREATE,
+  RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_DELETE,
+  RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_FLUSH,
+  RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_RECEIVE,
+  RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_SEND,
+  RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_URGENT,
+  RTEMS_RECORD_RTEMS_PARTITION_CREATE,
+  RTEMS_RECORD_RTEMS_PARTITION_DELETE,
+  RTEMS_RECORD_RTEMS_PARTITION_GET_BUFFER,
+  RTEMS_RECORD_RTEMS_PARTITION_RETURN_BUFFER,
+  RTEMS_RECORD_RTEMS_RATE_MONOTONIC_CANCEL,
+  RTEMS_RECORD_RTEMS_RATE_MONOTONIC_CREATE,
+  RTEMS_RECORD_RTEMS_RATE_MONOTONIC_DELETE,
+  RTEMS_RECORD_RTEMS_RATE_MONOTONIC_PERIOD,
+  RTEMS_RECORD_RTEMS_SEMAPHORE_CREATE,
+  RTEMS_RECORD_RTEMS_SEMAPHORE_DELETE,
+  RTEMS_RECORD_RTEMS_SEMAPHORE_FLUSH,
+  RTEMS_RECORD_RTEMS_SEMAPHORE_OBTAIN,
+  RTEMS_RECORD_RTEMS_SEMAPHORE_RELEASE,
+  RTEMS_RECORD_RTEMS_TIMER_CANCEL,
+  RTEMS_RECORD_RTEMS_TIMER_CREATE,
+  RTEMS_RECORD_RTEMS_TIMER_DELETE,
+  RTEMS_RECORD_RTEMS_TIMER_FIRE_AFTER,
+  RTEMS_RECORD_RTEMS_TIMER_FIRE_WHEN,
+  RTEMS_RECORD_RTEMS_TIMER_RESET,
+  RTEMS_RECORD_RTEMS_TIMER_SERVER_FIRE_AFTER,
+  RTEMS_RECORD_RTEMS_TIMER_SERVER_FIRE_WHEN,
+  RTEMS_RECORD_SELECT,
+  RTEMS_RECORD_SEND,
+  RTEMS_RECORD_SENDMSG,
+  RTEMS_RECORD_SENDTO,
+  RTEMS_RECORD_SOCKET,
+  RTEMS_RECORD_STATVFS,
+  RTEMS_RECORD_SYMLINK,
+  RTEMS_RECORD_TAIL,
+  RTEMS_RECORD_TCP_INPUT,
+  RTEMS_RECORD_TCP_OUTPUT,
+  RTEMS_RECORD_THREAD_BEGIN,
+  RTEMS_RECORD_THREAD_CREATE,
+  RTEMS_RECORD_THREAD_DELETE,
+  RTEMS_RECORD_THREAD_EXIT,
+  RTEMS_RECORD_THREAD_EXITTED,
+  RTEMS_RECORD_THREAD_ID,
+  RTEMS_RECORD_THREAD_PRIO_CURRENT_HIGH,
+  RTEMS_RECORD_THREAD_PRIO_CURRENT_LOW,
+  RTEMS_RECORD_THREAD_PRIO_REAL_HIGH,
+  RTEMS_RECORD_THREAD_PRIO_REAL_LOW,
+  RTEMS_RECORD_THREAD_QUEUE_ENQUEUE,
+  RTEMS_RECORD_THREAD_QUEUE_ENQUEUE_STICKY,
+  RTEMS_RECORD_THREAD_QUEUE_EXTRACT,
+  RTEMS_RECORD_THREAD_QUEUE_SURRENDER,
+  RTEMS_RECORD_THREAD_QUEUE_SURRENDER_STICKY,
+  RTEMS_RECORD_THREAD_RESTART,
+  RTEMS_RECORD_THREAD_STACK_CURRENT,
+  RTEMS_RECORD_THREAD_STACK_SIZE,
+  RTEMS_RECORD_THREAD_STACK_USAGE,
+  RTEMS_RECORD_THREAD_START,
+  RTEMS_RECORD_THREAD_STATE_CLEAR,
+  RTEMS_RECORD_THREAD_STATE_SET,
+  RTEMS_RECORD_THREAD_SWITCH_IN,
+  RTEMS_RECORD_THREAD_SWITCH_OUT,
+  RTEMS_RECORD_THREAD_TERMINATE,
+  RTEMS_RECORD_UDP_INPUT,
+  RTEMS_RECORD_UDP_OUTPUT,
+  RTEMS_RECORD_UMA_ALLOC_PTR,
+  RTEMS_RECORD_UMA_ALLOC_ZONE,
+  RTEMS_RECORD_UMA_FREE_PTR,
+  RTEMS_RECORD_UMA_FREE_ZONE,
+  RTEMS_RECORD_UNLINK,
+  RTEMS_RECORD_UNMOUNT,
+  RTEMS_RECORD_UPTIME_HIGH,
+  RTEMS_RECORD_UPTIME_LOW,
+  RTEMS_RECORD_WORKSPACE_ALLOC,
+  RTEMS_RECORD_WORKSPACE_FREE,
+  RTEMS_RECORD_WORKSPACE_SIZE,
+  RTEMS_RECORD_WORKSPACE_USAGE,
+  RTEMS_RECORD_WRITE,
+  RTEMS_RECORD_WRITEV,
+
+  /* There are 512 events reserved for the user */
+  RTEMS_RECORD_USER = 512,
+
+  RTEMS_RECORD_LAST = 1023
+} rtems_record_event;
+
+/**
+ * @brief Bits in the record item event member reserved for the actual event.
+ */
+#define RTEMS_RECORD_EVENT_BITS 10
+
+/**
+ * @brief Bits in the record item event member reserved for the time of the
+ * event.
+ */
+#define RTEMS_RECORD_TIME_BITS 22
+
+/**
+ * @brief Builds a time event for the specified time stamp and event.
+ *
+ * The events are stored in the record item with a time stamp.  There are 22
+ * bits allocated to the time stamp and 10 bits allocated to the event.  The 22
+ * bits are enough to get reliable time stamps on a system with a 4GHz CPU
+ * counter and a 1000Hz clock tick.
+ */
+#define RTEMS_RECORD_TIME_EVENT( time, event ) \
+  ( ( ( time ) << RTEMS_RECORD_EVENT_BITS ) | ( event ) )
+
+/**
+ * @brief Gets the time of a time event.
+ */
+#define RTEMS_RECORD_GET_TIME( time_event ) \
+  ( ( time_event ) >> RTEMS_RECORD_EVENT_BITS )
+
+/**
+ * @brief Gets the event of a time event.
+ */
+#define RTEMS_RECORD_GET_EVENT( time_event ) \
+  ( ( time_event ) & ( ( 1U << RTEMS_RECORD_EVENT_BITS ) - 1U ) )
+
+/**
+ * @brief The record data integer type.
+ *
+ * It is big enough to store 32-bit integers and pointers.
+ */
+typedef unsigned long rtems_record_data;
+
+/**
+ * @brief The native record item.
+ */
+typedef struct __attribute__((__packed__)) {
+  uint32_t          event;
+  rtems_record_data data;
+} rtems_record_item;
+
+/**
+ * @brief The 32-bit format record item.
+ */
+typedef struct {
+  uint32_t event;
+  uint32_t data;
+} rtems_record_item_32;
+
+/**
+ * @brief The 64-bit format record item.
+ */
+typedef struct __attribute__((__packed__)) {
+  uint32_t event;
+  uint64_t data;
+} rtems_record_item_64;
+
+const char *rtems_record_event_text( rtems_record_event event );
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_RECORDDATA_H */
Index: cpukit/include/rtems/score/percpu.h
===================================================================
--- cpukit/include/rtems/score/percpu.h	(revision f0ae613ba72bc4b95797e2482c4bd0fa5546331d)
+++ cpukit/include/rtems/score/percpu.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -69,4 +69,6 @@
 
 #if !defined( ASM )
+
+struct Record_Control;
 
 struct _Thread_Control;
@@ -514,4 +516,6 @@
   #endif
 
+  struct Record_Control *record;
+
   Per_CPU_Stats Stats;
 } Per_CPU_Control;
Index: cpukit/include/rtems/sysinit.h
===================================================================
--- cpukit/include/rtems/sysinit.h	(revision f0ae613ba72bc4b95797e2482c4bd0fa5546331d)
+++ cpukit/include/rtems/sysinit.h	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -34,4 +34,5 @@
 #define RTEMS_SYSINIT_DATA_STRUCTURES            000600
 #define RTEMS_SYSINIT_MP                         000700
+#define RTEMS_SYSINIT_RECORD                     000800
 #define RTEMS_SYSINIT_USER_EXTENSIONS            000900
 #define RTEMS_SYSINIT_CLASSIC_TASKS              000a00
Index: cpukit/libtrace/record/record-client.c
===================================================================
--- cpukit/libtrace/record/record-client.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/libtrace/record/record-client.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,448 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file must be compatible to general purpose POSIX system, e.g. Linux,
+ * FreeBSD.  It may be used for utility programs.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/recordclient.h>
+
+#include <string.h>
+
+static void set_to_bt_scaler(
+  rtems_record_client_context *ctx,
+  uint32_t                     frequency
+)
+{
+  uint64_t bin_per_s;
+
+  bin_per_s = UINT64_C( 1 ) << 32;
+  ctx->to_bt_scaler = ( ( bin_per_s << 31 ) + frequency - 1 ) / frequency;
+}
+
+static rtems_record_client_status call_handler(
+  const rtems_record_client_context *ctx,
+  uint64_t                           bt,
+  rtems_record_event                 event,
+  uint64_t                           data
+)
+{
+  uint32_t seconds;
+  uint32_t nanosec;
+
+  seconds = (uint32_t) ( bt >> 32 );
+  nanosec = (uint32_t) ( ( UINT64_C( 1000000000 ) * (uint32_t) bt ) >> 32 );
+
+  return ( *ctx->handler )(
+    seconds,
+    nanosec,
+    ctx->cpu,
+    event,
+    data,
+    ctx->handler_arg
+  );
+}
+
+static void check_overflow(
+  const rtems_record_client_context *ctx,
+  const rtems_record_client_per_cpu *per_cpu,
+  uint32_t                           new_head
+)
+{
+  uint32_t last_tail;
+  uint32_t last_head;
+  uint32_t capacity;
+  uint32_t new_content;
+  uint64_t bt;
+
+  last_tail = per_cpu->tail[ per_cpu->index ];
+  last_head = per_cpu->head[ per_cpu->index ];
+
+  if ( last_tail == last_head ) {
+    return;
+  }
+
+  capacity = ( last_tail - last_head - 1 ) & ( ctx->count - 1 );
+  new_content = new_head - last_head;
+
+  if ( new_content <= capacity ) {
+    return;
+  }
+
+  bt = ( per_cpu->uptime.time_accumulated * ctx->to_bt_scaler ) >> 31;
+  bt += per_cpu->uptime.bt;
+
+  call_handler(
+    ctx,
+    bt,
+    RTEMS_RECORD_OVERFLOW,
+    new_content - capacity
+  );
+}
+
+static rtems_record_client_status visit( rtems_record_client_context *ctx )
+{
+  rtems_record_client_per_cpu *per_cpu;
+  uint32_t                     time;
+  rtems_record_event           event;
+  uint64_t                     data;
+  uint64_t                     bt;
+
+  per_cpu = &ctx->per_cpu[ ctx->cpu ];
+  time = RTEMS_RECORD_GET_TIME( ctx->event );
+  event = RTEMS_RECORD_GET_EVENT( ctx->event );
+  data = ctx->data;
+
+  switch ( event ) {
+    case RTEMS_RECORD_PROCESSOR:
+      if ( data >= RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT ) {
+        return RTEMS_RECORD_CLIENT_ERROR_UNSUPPORTED_CPU;
+      }
+
+      ctx->cpu = (uint32_t) data;
+      per_cpu = &ctx->per_cpu[ ctx->cpu ];
+      break;
+    case RTEMS_RECORD_UPTIME_LOW:
+      per_cpu->uptime.bt = (uint32_t) data;
+      per_cpu->uptime.time_at_bt = time;
+      per_cpu->uptime.time_last = time;
+      per_cpu->uptime.time_accumulated = 0;
+      time = 0;
+      break;
+    case RTEMS_RECORD_UPTIME_HIGH:
+      per_cpu->uptime.bt += (int64_t) data << 32;
+      time = 0;
+      break;
+    case RTEMS_RECORD_TAIL:
+      per_cpu->tail[ per_cpu->index ] = (uint32_t) data;
+      break;
+    case RTEMS_RECORD_HEAD:
+      per_cpu->head[ per_cpu->index ]= (uint32_t) data;
+      per_cpu->index ^= 1;
+      check_overflow( ctx, per_cpu, (uint32_t) data );
+      break;
+    case RTEMS_RECORD_COUNT:
+      ctx->count = (uint32_t) data;
+      break;
+    case RTEMS_RECORD_FREQUENCY:
+      set_to_bt_scaler( ctx, (uint32_t) data );
+      break;
+    case RTEMS_RECORD_VERSION:
+      if ( data != RTEMS_RECORD_THE_VERSION ) {
+        return RTEMS_RECORD_CLIENT_ERROR_UNSUPPORTED_VERSION;
+      }
+
+      break;
+    default:
+      break;
+  }
+
+  if ( time != 0 ) {
+    uint32_t delta;
+
+    delta = ( time - per_cpu->uptime.time_last )
+      & ( ( UINT32_C( 1 ) << RTEMS_RECORD_TIME_BITS ) - 1 );
+    per_cpu->uptime.time_last = time;
+    per_cpu->uptime.time_accumulated += delta;
+    bt = ( per_cpu->uptime.time_accumulated * ctx->to_bt_scaler ) >> 31;
+    bt += per_cpu->uptime.bt;
+  } else {
+    bt = 0;
+  }
+
+  return call_handler( ctx, bt, event, data );
+}
+
+static rtems_record_client_status consume_32(
+  rtems_record_client_context *ctx,
+  const void                  *buf,
+  size_t                       n
+)
+{
+  while ( n > 0 ) {
+    size_t m;
+    char *pos;
+
+    m = ctx->todo < n ? ctx->todo : n;
+    pos = ctx->pos;
+    pos = memcpy( pos, buf, m );
+    n -= m;
+    buf = (char *) buf + m;
+
+    if ( m == ctx->todo ) {
+      rtems_record_client_status status;
+
+      ctx->todo = sizeof( ctx->item.format_32 );
+      ctx->pos = &ctx->item.format_32;
+      ctx->event = ctx->item.format_32.event;
+      ctx->data = ctx->item.format_32.data;
+
+      status = visit( ctx );
+
+      if ( status != RTEMS_RECORD_CLIENT_SUCCESS ) {
+        return status;
+      }
+    } else {
+      ctx->todo -= m;
+      ctx->pos = pos + m;
+    }
+  }
+
+  return RTEMS_RECORD_CLIENT_SUCCESS;
+}
+
+static rtems_record_client_status consume_64(
+  rtems_record_client_context *ctx,
+  const void                  *buf,
+  size_t                       n
+)
+{
+  while ( n > 0 ) {
+    size_t m;
+    char *pos;
+
+    m = ctx->todo < n ? ctx->todo : n;
+    pos = ctx->pos;
+    pos = memcpy( pos, buf, m );
+    n -= m;
+    buf = (char *) buf + m;
+
+    if ( m == ctx->todo ) {
+      rtems_record_client_status status;
+
+      ctx->todo = sizeof( ctx->item.format_64 );
+      ctx->pos = &ctx->item.format_64;
+      ctx->event = ctx->item.format_64.event;
+      ctx->data = ctx->item.format_64.data;
+
+      status = visit( ctx );
+
+      if ( status != RTEMS_RECORD_CLIENT_SUCCESS ) {
+        return status;
+      }
+    } else {
+      ctx->todo -= m;
+      ctx->pos = pos + m;
+    }
+  }
+
+  return RTEMS_RECORD_CLIENT_SUCCESS;
+}
+
+static rtems_record_client_status consume_swap_32(
+  rtems_record_client_context *ctx,
+  const void                  *buf,
+  size_t                       n
+)
+{
+  while ( n > 0 ) {
+    size_t m;
+    char *pos;
+
+    m = ctx->todo < n ? ctx->todo : n;
+    pos = ctx->pos;
+    pos = memcpy( pos, buf, m );
+    n -= m;
+    buf = (char *) buf + m;
+
+    if ( m == ctx->todo ) {
+      rtems_record_client_status status;
+
+      ctx->todo = sizeof( ctx->item.format_32 );
+      ctx->pos = &ctx->item.format_32;
+      ctx->event = __builtin_bswap32( ctx->item.format_32.event );
+      ctx->data = __builtin_bswap32( ctx->item.format_32.data );
+
+      status = visit( ctx );
+
+      if ( status != RTEMS_RECORD_CLIENT_SUCCESS ) {
+        return status;
+      }
+    } else {
+      ctx->todo -= m;
+      ctx->pos = pos + m;
+    }
+  }
+
+  return RTEMS_RECORD_CLIENT_SUCCESS;
+}
+
+static rtems_record_client_status consume_swap_64(
+  rtems_record_client_context *ctx,
+  const void                  *buf,
+  size_t                       n
+)
+{
+  while ( n > 0 ) {
+    size_t m;
+    char *pos;
+
+    m = ctx->todo < n ? ctx->todo : n;
+    pos = ctx->pos;
+    pos = memcpy( pos, buf, m );
+    n -= m;
+    buf = (char *) buf + m;
+
+    if ( m == ctx->todo ) {
+      rtems_record_client_status status;
+
+      ctx->todo = sizeof( ctx->item.format_64 );
+      ctx->pos = &ctx->item.format_64;
+      ctx->event = __builtin_bswap32( ctx->item.format_64.event );
+      ctx->data = __builtin_bswap64( ctx->item.format_64.data );
+
+      status = visit( ctx );
+
+      if ( status != RTEMS_RECORD_CLIENT_SUCCESS ) {
+        return status;
+      }
+    } else {
+      ctx->todo -= m;
+      ctx->pos = pos + m;
+    }
+  }
+
+  return RTEMS_RECORD_CLIENT_SUCCESS;
+}
+
+static rtems_record_client_status consume_init(
+  rtems_record_client_context *ctx,
+  const void                  *buf,
+  size_t                       n
+)
+{
+  while ( n > 0 ) {
+    size_t m;
+    char *pos;
+
+    m = ctx->todo < n ? ctx->todo : n;
+    pos = ctx->pos;
+    pos = memcpy( pos, buf, m );
+    n -= m;
+    buf = (char *) buf + m;
+
+    if ( m == ctx->todo ) {
+      uint32_t magic;
+
+      magic = ctx->header[ 1 ];
+
+      switch ( ctx->header[ 0 ] ) {
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+        case RTEMS_RECORD_FORMAT_LE_32:
+          ctx->todo = sizeof( ctx->item.format_32 );
+          ctx->pos = &ctx->item.format_32;
+          ctx->consume = consume_32;
+          break;
+        case RTEMS_RECORD_FORMAT_LE_64:
+          ctx->todo = sizeof( ctx->item.format_64 );
+          ctx->pos = &ctx->item.format_64;
+          ctx->consume = consume_64;
+          break;
+        case RTEMS_RECORD_FORMAT_BE_32:
+          ctx->todo = sizeof( ctx->item.format_32 );
+          ctx->pos = &ctx->item.format_32;
+          ctx->consume = consume_swap_32;
+          magic = __builtin_bswap32( magic );
+          break;
+        case RTEMS_RECORD_FORMAT_BE_64:
+          ctx->todo = sizeof( ctx->item.format_64 );
+          ctx->pos = &ctx->item.format_64;
+          ctx->consume = consume_swap_64;
+          magic = __builtin_bswap32( magic );
+          break;
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+        case RTEMS_RECORD_FORMAT_LE_32:
+          ctx->todo = sizeof( ctx->item.format_32 );
+          ctx->pos = &ctx->item.format_32;
+          ctx->consume = consume_swap_32;
+          magic = __builtin_bswap32( magic );
+          break;
+        case RTEMS_RECORD_FORMAT_LE_64:
+          ctx->todo = sizeof( ctx->item.format_64 );
+          ctx->pos = &ctx->item.format_64;
+          ctx->consume = consume_swap_64;
+          magic = __builtin_bswap32( magic );
+          break;
+        case RTEMS_RECORD_FORMAT_BE_32:
+          ctx->todo = sizeof( ctx->item.format_32 );
+          ctx->pos = &ctx->item.format_32;
+          ctx->consume = consume_32;
+          break;
+        case RTEMS_RECORD_FORMAT_BE_64:
+          ctx->todo = sizeof( ctx->item.format_64 );
+          ctx->pos = &ctx->item.format_64;
+          ctx->consume = consume_64;
+          break;
+#else
+#error "unexpected __BYTE_ORDER__"
+#endif
+        default:
+          return RTEMS_RECORD_CLIENT_ERROR_UNKNOWN_FORMAT;
+      }
+
+      if ( magic != RTEMS_RECORD_MAGIC ) {
+        return RTEMS_RECORD_CLIENT_ERROR_INVALID_MAGIC;
+      }
+
+      return rtems_record_client_run( ctx, buf, n );
+    } else {
+      ctx->todo -= m;
+      ctx->pos = pos + m;
+    }
+  }
+
+  return RTEMS_RECORD_CLIENT_SUCCESS;
+}
+
+void rtems_record_client_init(
+  rtems_record_client_context *ctx,
+  rtems_record_client_handler  handler,
+  void                        *arg
+)
+{
+  ctx = memset( ctx, 0, sizeof( *ctx ) );
+  ctx->to_bt_scaler = UINT64_C( 1 ) << 31;
+  ctx->handler = handler;
+  ctx->handler_arg = arg;
+  ctx->todo = sizeof( ctx->header );
+  ctx->pos = &ctx->header;
+  ctx->consume = consume_init;
+}
+
+rtems_record_client_status rtems_record_client_run(
+  rtems_record_client_context *ctx,
+  const void                  *buf,
+  size_t                       n
+)
+{
+  return ( *ctx->consume )( ctx, buf, n );
+}
Index: cpukit/libtrace/record/record-server.c
===================================================================
--- cpukit/libtrace/record/record-server.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/libtrace/record/record-server.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,290 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/record.h>
+#include <rtems.h>
+
+#include <sys/endian.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <netinet/in.h>
+
+#ifdef RTEMS_SMP
+#define CHUNKS (3 * CPU_MAXIMUM_PROCESSORS)
+#else
+#define CHUNKS 4
+#endif
+
+typedef struct {
+  int           available;
+  struct iovec *current;
+  struct iovec  iov[CHUNKS];
+} writev_visitor_context;
+
+static void writev_visitor(
+  const rtems_record_item *items,
+  size_t                   count,
+  void                    *arg
+)
+{
+  writev_visitor_context *ctx;
+
+  ctx = arg;
+
+  if ( ctx->available > 0 ) {
+    ctx->current->iov_base = RTEMS_DECONST( rtems_record_item *, items );
+    ctx->current->iov_len = count * sizeof( *items );
+    --ctx->available;
+    ++ctx->current;
+  }
+}
+
+ssize_t rtems_record_writev( int fd, bool *written )
+{
+  writev_visitor_context ctx;
+  int n;
+
+  ctx.available = CHUNKS;
+  ctx.current = &ctx.iov[ 0 ];
+  rtems_record_drain( writev_visitor, &ctx );
+  n = CHUNKS - ctx.available;
+
+  if ( n > 0 ) {
+    *written = true;
+    return writev( fd, &ctx.iov[ 0 ], n );
+  } else {
+    *written = false;
+    return 0;
+  }
+}
+
+#define WAKEUP_EVENT RTEMS_EVENT_0
+
+static void wakeup( rtems_id task )
+{
+  (void) rtems_event_send( task, WAKEUP_EVENT );
+}
+
+static void wait( rtems_option options )
+{
+  rtems_event_set events;
+
+  (void) rtems_event_receive(
+    WAKEUP_EVENT,
+    RTEMS_EVENT_ANY | options,
+    RTEMS_NO_TIMEOUT,
+    &events
+  );
+}
+
+static void wakeup_timer( rtems_id timer, void *arg )
+{
+  rtems_id *server;
+
+  server = arg;
+  wakeup( *server );
+  (void) rtems_timer_reset( timer );
+}
+
+void _Record_Stream_header_initialize( Record_Stream_header *header )
+{
+#if BYTE_ORDER == LITTLE_ENDIAN
+#if __INTPTR_WIDTH__ == 32
+  header->format = RTEMS_RECORD_FORMAT_LE_32,
+#elif __INTPTR_WIDTH__ == 64
+  header->format = RTEMS_RECORD_FORMAT_LE_64,
+#else
+#error "unexpected __INTPTR_WIDTH__"
+#endif
+#elif BYTE_ORDER == BIG_ENDIAN
+#if __INTPTR_WIDTH__ == 32
+  header->format = RTEMS_RECORD_FORMAT_BE_32,
+#elif __INTPTR_WIDTH__ == 64
+  header->format = RTEMS_RECORD_FORMAT_BE_64,
+#else
+#error "unexpected __INTPTR_WIDTH__"
+#endif
+#else
+#error "unexpected BYTE_ORDER"
+#endif
+
+  header->magic = RTEMS_RECORD_MAGIC;
+
+  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.data = rtems_get_processor_count() - 1;
+
+  header->Count.event = RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_COUNT );
+  header->Count.data = _Record_Item_count;
+
+  header->Frequency.event =
+    RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_FREQUENCY );
+  header->Frequency.data = rtems_counter_frequency();
+}
+
+static void send_header( int fd )
+{
+  Record_Stream_header header;
+
+  _Record_Stream_header_initialize( &header );
+  (void) write( fd, &header, sizeof( header ) );
+}
+
+void rtems_record_server( uint16_t port, rtems_interval period )
+{
+  rtems_status_code sc;
+  rtems_id self;
+  rtems_id timer;
+  struct sockaddr_in addr;
+  int sd;
+  int rv;
+
+  sd = -1;
+  self = rtems_task_self();
+
+  sc = rtems_timer_create( rtems_build_name( 'R', 'C', 'R', 'D' ), &timer );
+  if ( sc != RTEMS_SUCCESSFUL ) {
+    return;
+  }
+
+  sd = socket( PF_INET, SOCK_STREAM, 0 );
+  if (sd < 0) {
+    goto error;
+  }
+
+  memset( &addr, 0, sizeof( addr ) );
+  addr.sin_family = AF_INET;
+  addr.sin_port = htons( port );
+  addr.sin_addr.s_addr = htonl( INADDR_ANY );
+
+  rv = bind( sd, (const struct sockaddr *) &addr, sizeof( addr ) );
+  if (rv != 0) {
+    goto error;
+  }
+
+  rv = listen( sd, 0 );
+  if (rv != 0) {
+    goto error;
+  }
+
+  while ( true ) {
+    int cd;
+    bool written;
+    ssize_t n;
+
+    cd = accept( sd, NULL, NULL );
+
+    if ( cd < 0 ) {
+      break;
+    }
+
+    wait( RTEMS_NO_WAIT );
+    (void) rtems_timer_fire_after( timer, period, wakeup_timer, &self );
+    send_header( cd );
+
+    while ( true ) {
+      n = rtems_record_writev( cd, &written );
+
+      if ( written && n <= 0 ) {
+        break;
+      }
+
+      wait( RTEMS_WAIT );
+    }
+
+    (void) rtems_timer_cancel( timer );
+    (void) close( cd );
+  }
+
+error:
+
+  (void) close( sd );
+  (void) rtems_timer_delete( timer );
+}
+
+typedef struct {
+  rtems_id       task;
+  uint16_t       port;
+  rtems_interval period;
+} server_arg;
+
+static void server( rtems_task_argument arg )
+{
+  server_arg     *sarg;
+  uint16_t        port;
+  rtems_interval  period;
+
+  sarg = (server_arg *) arg;
+  port = sarg->port;
+  period = sarg->period;
+  wakeup(sarg->task);
+  rtems_record_server( port, period );
+  rtems_task_exit();
+}
+
+rtems_status_code rtems_record_start_server(
+  rtems_task_priority priority,
+  uint16_t            port,
+  rtems_interval      period
+)
+{
+  rtems_status_code sc;
+  rtems_id          id;
+  server_arg        sarg;
+
+  sarg.port = port;
+  sarg.period = period;
+  sarg.task = rtems_task_self();
+
+  sc = rtems_task_create(
+    rtems_build_name( 'R', 'C', 'R', 'D' ),
+    priority,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &id
+  );
+  if ( sc != RTEMS_SUCCESSFUL ) {
+    return sc;
+  }
+
+  (void) rtems_task_start( id, server, (rtems_task_argument) &sarg );
+  wait( RTEMS_WAIT );
+
+  return RTEMS_SUCCESSFUL;
+}
Index: cpukit/libtrace/record/record-sysinit.c
===================================================================
--- cpukit/libtrace/record/record-sysinit.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/libtrace/record/record-sysinit.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,128 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/record.h>
+#include <rtems/config.h>
+#include <rtems/sysinit.h>
+#include <rtems/score/timecounter.h>
+#include <rtems/score/watchdogimpl.h>
+
+static Watchdog_Interval _Record_Tick_interval;
+
+void _Record_Initialize( void )
+{
+  uint32_t  cpu_max;
+  uint32_t  cpu_index;
+  uintptr_t offset;
+
+  cpu_max = rtems_configuration_get_maximum_processors();
+  offset = PER_CPU_DATA_OFFSET( _Record_Per_CPU );
+
+  for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
+    Per_CPU_Control *cpu;
+    Record_Control  *control;
+
+    cpu = _Per_CPU_Get_by_index( cpu_index );
+    control = PER_CPU_DATA_GET_BY_OFFSET( cpu, Record_Control, offset );
+    control->mask = _Record_Item_count - 1U;
+    cpu->record = control;
+  }
+}
+
+static void _Record_Watchdog( Watchdog_Control *watchdog )
+{
+  ISR_Level  level;
+  sbintime_t now;
+
+  _ISR_Local_disable( level );
+  _Watchdog_Per_CPU_insert_ticks(
+    watchdog,
+    _Watchdog_Get_CPU( watchdog ),
+    _Record_Tick_interval
+  );
+  _ISR_Local_enable( level );
+
+  now = _Timecounter_Sbinuptime();
+  rtems_record_produce_2(
+    RTEMS_RECORD_UPTIME_LOW,
+    (uint32_t) ( now >> 0 ),
+    RTEMS_RECORD_UPTIME_HIGH,
+    (uint32_t) ( now >> 32 )
+  );
+}
+
+static void _Record_Initialize_watchdogs( void )
+{
+  Watchdog_Interval interval;
+  uint32_t          cpu_max;
+  uint32_t          cpu_index;
+  sbintime_t        now;
+
+  interval = rtems_counter_frequency() / _Watchdog_Ticks_per_second;
+  interval = ( UINT32_C( 1 ) << 22 ) / interval;
+
+  if ( interval == 0 ) {
+    interval = 1;
+  }
+
+  _Record_Tick_interval = interval;
+
+  cpu_max = rtems_configuration_get_maximum_processors();
+
+  for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
+    Per_CPU_Control *cpu;
+    Record_Control  *control;
+
+    cpu = _Per_CPU_Get_by_index( cpu_index );
+    control = cpu->record;
+    _Watchdog_Preinitialize( &control->Watchdog, cpu );
+    _Watchdog_Initialize( &control->Watchdog, _Record_Watchdog );
+    _Watchdog_Per_CPU_insert_ticks(
+      &control->Watchdog,
+      cpu,
+      _Record_Tick_interval
+    );
+  }
+
+  now = _Timecounter_Sbinuptime();
+  rtems_record_produce_2(
+    RTEMS_RECORD_UPTIME_LOW,
+    (uint32_t) ( now >> 0 ),
+    RTEMS_RECORD_UPTIME_HIGH,
+    (uint32_t) ( now >> 32 )
+  );
+}
+
+RTEMS_SYSINIT_ITEM(
+  _Record_Initialize_watchdogs,
+  RTEMS_SYSINIT_DEVICE_DRIVERS,
+  RTEMS_SYSINIT_ORDER_LAST
+);
Index: cpukit/libtrace/record/record-text.c
===================================================================
--- cpukit/libtrace/record/record-text.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/libtrace/record/record-text.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,197 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This file must be compatible to general purpose POSIX system, e.g. Linux,
+ * FreeBSD.  It may be used for utility programs.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/recorddata.h>
+
+#include <stddef.h>
+
+static const char * const event_text[] = {
+  [ RTEMS_RECORD_EMPTY ] = "EMPTY",
+  [ RTEMS_RECORD_VERSION ] = "VERSION",
+  [ RTEMS_RECORD_ACCEPT ] = "ACCEPT",
+  [ RTEMS_RECORD_BIND ] = "BIND",
+  [ RTEMS_RECORD_BUFFER ] = "BUFFER",
+  [ RTEMS_RECORD_CHOWN ] = "CHOWN",
+  [ RTEMS_RECORD_CLOSE ] = "CLOSE",
+  [ RTEMS_RECORD_CONNECT ] = "CONNECT",
+  [ RTEMS_RECORD_COUNT ] = "COUNT",
+  [ RTEMS_RECORD_ETHER_INPUT ] = "ETHER_INPUT",
+  [ RTEMS_RECORD_ETHER_OUTPUT ] = "ETHER_OUTPUT",
+  [ RTEMS_RECORD_FCHMOD ] = "FCHMOD",
+  [ RTEMS_RECORD_FCNTL ] = "FCNTL",
+  [ RTEMS_RECORD_FDATASYNC ] = "FDATASYNC",
+  [ RTEMS_RECORD_FREQUENCY ] = "FREQUENCY",
+  [ RTEMS_RECORD_FSTAT ] = "FSTAT",
+  [ RTEMS_RECORD_FSYNC ] = "FSYNC",
+  [ RTEMS_RECORD_FTRUNCATE ] = "FTRUNCATE",
+  [ RTEMS_RECORD_GIT_HASH ] = "GIT_HASH",
+  [ RTEMS_RECORD_HEAD ] = "HEAD",
+  [ RTEMS_RECORD_HEAP_ALLOC ] = "HEAP_ALLOC",
+  [ RTEMS_RECORD_HEAP_FREE ] = "HEAP_FREE",
+  [ RTEMS_RECORD_HEAP_SIZE ] = "HEAP_SIZE",
+  [ RTEMS_RECORD_HEAP_USAGE ] = "HEAP_USAGE",
+  [ RTEMS_RECORD_INTERUPT_BEGIN ] = "INTERUPT_BEGIN",
+  [ RTEMS_RECORD_INTERUPT_END ] = "INTERUPT_END",
+  [ RTEMS_RECORD_INTERUPT_INSTALL ] = "INTERUPT_INSTALL",
+  [ RTEMS_RECORD_INTERUPT_REMOVE ] = "INTERUPT_REMOVE",
+  [ RTEMS_RECORD_IOCTL ] = "IOCTL",
+  [ RTEMS_RECORD_IP6_INPUT ] = "IP6_INPUT",
+  [ RTEMS_RECORD_IP6_OUTPUT ] = "IP6_OUTPUT",
+  [ RTEMS_RECORD_IP_INPUT ] = "IP_INPUT",
+  [ RTEMS_RECORD_IP_OUTPUT ] = "IP_OUTPUT",
+  [ RTEMS_RECORD_KEVENT ] = "KEVENT",
+  [ RTEMS_RECORD_KQUEUE ] = "KQUEUE",
+  [ RTEMS_RECORD_LENGTH ] = "LENGTH",
+  [ RTEMS_RECORD_LINK ] = "LINK",
+  [ RTEMS_RECORD_LSEEK ] = "LSEEK",
+  [ RTEMS_RECORD_MKNOD ] = "MKNOD",
+  [ RTEMS_RECORD_MMAP ] = "MMAP",
+  [ RTEMS_RECORD_MOUNT ] = "MOUNT",
+  [ RTEMS_RECORD_OPEN ] = "OPEN",
+  [ RTEMS_RECORD_OVERFLOW ] = "OVERFLOW",
+  [ RTEMS_RECORD_PAGE_ALLOC ] = "PAGE_ALLOC",
+  [ RTEMS_RECORD_PAGE_FREE ] = "PAGE_FREE",
+  [ RTEMS_RECORD_POLL ] = "POLL",
+  [ RTEMS_RECORD_PROCESSOR ] = "PROCESSOR",
+  [ RTEMS_RECORD_PROCESSOR_MAXIMUM ] = "PROCESSOR_MAXIMUM",
+  [ RTEMS_RECORD_READ ] = "READ",
+  [ RTEMS_RECORD_READLINK ] = "READLINK",
+  [ RTEMS_RECORD_READV ] = "READV",
+  [ RTEMS_RECORD_RECV ] = "RECV",
+  [ RTEMS_RECORD_RECVFROM ] = "RECVFROM",
+  [ RTEMS_RECORD_RECVMSG ] = "RECVMSG",
+  [ RTEMS_RECORD_RENAME ] = "RENAME",
+  [ RTEMS_RECORD_RTEMS_BARRIER_CREATE ] = "RTEMS_BARRIER_CREATE",
+  [ RTEMS_RECORD_RTEMS_BARRIER_DELETE ] = "RTEMS_BARRIER_DELETE",
+  [ RTEMS_RECORD_RTEMS_BARRIER_RELEASE ] = "RTEMS_BARRIER_RELEASE",
+  [ RTEMS_RECORD_RTEMS_BARRIER_WAIT ] = "RTEMS_BARRIER_WAIT",
+  [ RTEMS_RECORD_RTEMS_EVENT_RECEIVE ] = "RTEMS_EVENT_RECEIVE",
+  [ RTEMS_RECORD_RTEMS_EVENT_SEND ] = "RTEMS_EVENT_SEND",
+  [ RTEMS_RECORD_RTEMS_EVENT_SYSTEM_RECEIVE ] = "RTEMS_EVENT_SYSTEM_RECEIVE",
+  [ RTEMS_RECORD_RTEMS_EVENT_SYSTEM_SEND ] = "RTEMS_EVENT_SYSTEM_SEND",
+  [ RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_BROADCAST ] = "RTEMS_MESSAGE_QUEUE_BROADCAST",
+  [ RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_CREATE ] = "RTEMS_MESSAGE_QUEUE_CREATE",
+  [ RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_DELETE ] = "RTEMS_MESSAGE_QUEUE_DELETE",
+  [ RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_FLUSH ] = "RTEMS_MESSAGE_QUEUE_FLUSH",
+  [ RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_RECEIVE ] = "RTEMS_MESSAGE_QUEUE_RECEIVE",
+  [ RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_SEND ] = "RTEMS_MESSAGE_QUEUE_SEND",
+  [ RTEMS_RECORD_RTEMS_MESSAGE_QUEUE_URGENT ] = "RTEMS_MESSAGE_QUEUE_URGENT",
+  [ RTEMS_RECORD_RTEMS_PARTITION_CREATE ] = "RTEMS_PARTITION_CREATE",
+  [ RTEMS_RECORD_RTEMS_PARTITION_DELETE ] = "RTEMS_PARTITION_DELETE",
+  [ RTEMS_RECORD_RTEMS_PARTITION_GET_BUFFER ] = "RTEMS_PARTITION_GET_BUFFER",
+  [ RTEMS_RECORD_RTEMS_PARTITION_RETURN_BUFFER ] = "RTEMS_PARTITION_RETURN_BUFFER",
+  [ RTEMS_RECORD_RTEMS_RATE_MONOTONIC_CANCEL ] = "RTEMS_RATE_MONOTONIC_CANCEL",
+  [ RTEMS_RECORD_RTEMS_RATE_MONOTONIC_CREATE ] = "RTEMS_RATE_MONOTONIC_CREATE",
+  [ RTEMS_RECORD_RTEMS_RATE_MONOTONIC_DELETE ] = "RTEMS_RATE_MONOTONIC_DELETE",
+  [ RTEMS_RECORD_RTEMS_RATE_MONOTONIC_PERIOD ] = "RTEMS_RATE_MONOTONIC_PERIOD",
+  [ RTEMS_RECORD_RTEMS_SEMAPHORE_CREATE ] = "RTEMS_SEMAPHORE_CREATE",
+  [ RTEMS_RECORD_RTEMS_SEMAPHORE_DELETE ] = "RTEMS_SEMAPHORE_DELETE",
+  [ RTEMS_RECORD_RTEMS_SEMAPHORE_FLUSH ] = "RTEMS_SEMAPHORE_FLUSH",
+  [ RTEMS_RECORD_RTEMS_SEMAPHORE_OBTAIN ] = "RTEMS_SEMAPHORE_OBTAIN",
+  [ RTEMS_RECORD_RTEMS_SEMAPHORE_RELEASE ] = "RTEMS_SEMAPHORE_RELEASE",
+  [ RTEMS_RECORD_RTEMS_TIMER_CANCEL ] = "RTEMS_TIMER_CANCEL",
+  [ RTEMS_RECORD_RTEMS_TIMER_CREATE ] = "RTEMS_TIMER_CREATE",
+  [ RTEMS_RECORD_RTEMS_TIMER_DELETE ] = "RTEMS_TIMER_DELETE",
+  [ RTEMS_RECORD_RTEMS_TIMER_FIRE_AFTER ] = "RTEMS_TIMER_FIRE_AFTER",
+  [ RTEMS_RECORD_RTEMS_TIMER_FIRE_WHEN ] = "RTEMS_TIMER_FIRE_WHEN",
+  [ RTEMS_RECORD_RTEMS_TIMER_RESET ] = "RTEMS_TIMER_RESET",
+  [ RTEMS_RECORD_RTEMS_TIMER_SERVER_FIRE_AFTER ] = "RTEMS_TIMER_SERVER_FIRE_AFTER",
+  [ RTEMS_RECORD_RTEMS_TIMER_SERVER_FIRE_WHEN ] = "RTEMS_TIMER_SERVER_FIRE_WHEN",
+  [ RTEMS_RECORD_SELECT ] = "SELECT",
+  [ RTEMS_RECORD_SEND ] = "SEND",
+  [ RTEMS_RECORD_SENDMSG ] = "SENDMSG",
+  [ RTEMS_RECORD_SENDTO ] = "SENDTO",
+  [ RTEMS_RECORD_SOCKET ] = "SOCKET",
+  [ RTEMS_RECORD_STATVFS ] = "STATVFS",
+  [ RTEMS_RECORD_SYMLINK ] = "SYMLINK",
+  [ RTEMS_RECORD_TAIL ] = "TAIL",
+  [ RTEMS_RECORD_TCP_INPUT ] = "TCP_INPUT",
+  [ RTEMS_RECORD_TCP_OUTPUT ] = "TCP_OUTPUT",
+  [ RTEMS_RECORD_THREAD_BEGIN ] = "THREAD_BEGIN",
+  [ RTEMS_RECORD_THREAD_CREATE ] = "THREAD_CREATE",
+  [ RTEMS_RECORD_THREAD_DELETE ] = "THREAD_DELETE",
+  [ RTEMS_RECORD_THREAD_EXIT ] = "THREAD_EXIT",
+  [ RTEMS_RECORD_THREAD_EXITTED ] = "THREAD_EXITTED",
+  [ RTEMS_RECORD_THREAD_ID ] = "THREAD_ID",
+  [ RTEMS_RECORD_THREAD_PRIO_CURRENT_HIGH ] = "THREAD_PRIO_CURRENT_HIGH",
+  [ RTEMS_RECORD_THREAD_PRIO_CURRENT_LOW ] = "THREAD_PRIO_CURRENT_LOW",
+  [ RTEMS_RECORD_THREAD_PRIO_REAL_HIGH ] = "THREAD_PRIO_REAL_HIGH",
+  [ RTEMS_RECORD_THREAD_PRIO_REAL_LOW ] = "THREAD_PRIO_REAL_LOW",
+  [ RTEMS_RECORD_THREAD_QUEUE_ENQUEUE ] = "THREAD_QUEUE_ENQUEUE",
+  [ RTEMS_RECORD_THREAD_QUEUE_ENQUEUE_STICKY ] = "THREAD_QUEUE_ENQUEUE_STICKY",
+  [ RTEMS_RECORD_THREAD_QUEUE_EXTRACT ] = "THREAD_QUEUE_EXTRACT",
+  [ RTEMS_RECORD_THREAD_QUEUE_SURRENDER ] = "THREAD_QUEUE_SURRENDER",
+  [ RTEMS_RECORD_THREAD_QUEUE_SURRENDER_STICKY ] = "THREAD_QUEUE_SURRENDER_STICKY",
+  [ RTEMS_RECORD_THREAD_RESTART ] = "THREAD_RESTART",
+  [ RTEMS_RECORD_THREAD_STACK_CURRENT ] = "THREAD_STACK_CURRENT",
+  [ RTEMS_RECORD_THREAD_STACK_SIZE ] = "THREAD_STACK_SIZE",
+  [ RTEMS_RECORD_THREAD_STACK_USAGE ] = "THREAD_STACK_USAGE",
+  [ RTEMS_RECORD_THREAD_START ] = "THREAD_START",
+  [ RTEMS_RECORD_THREAD_STATE_CLEAR ] = "THREAD_STATE_CLEAR",
+  [ RTEMS_RECORD_THREAD_STATE_SET ] = "THREAD_STATE_SET",
+  [ RTEMS_RECORD_THREAD_SWITCH_IN ] = "THREAD_SWITCH_IN",
+  [ RTEMS_RECORD_THREAD_SWITCH_OUT ] = "THREAD_SWITCH_OUT",
+  [ RTEMS_RECORD_THREAD_TERMINATE ] = "THREAD_TERMINATE",
+  [ RTEMS_RECORD_UDP_INPUT ] = "UDP_INPUT",
+  [ RTEMS_RECORD_UDP_OUTPUT ] = "UDP_OUTPUT",
+  [ RTEMS_RECORD_UMA_ALLOC_PTR ] = "UMA_ALLOC_PTR",
+  [ RTEMS_RECORD_UMA_ALLOC_ZONE ] = "UMA_ALLOC_ZONE",
+  [ RTEMS_RECORD_UMA_FREE_PTR ] = "UMA_FREE_PTR",
+  [ RTEMS_RECORD_UMA_FREE_ZONE ] = "UMA_FREE_ZONE",
+  [ RTEMS_RECORD_UNLINK ] = "UNLINK",
+  [ RTEMS_RECORD_UNMOUNT ] = "UNMOUNT",
+  [ RTEMS_RECORD_UPTIME_HIGH ] = "UPTIME_HIGH",
+  [ RTEMS_RECORD_UPTIME_LOW ] = "UPTIME_LOW",
+  [ RTEMS_RECORD_WORKSPACE_ALLOC ] = "WORKSPACE_ALLOC",
+  [ RTEMS_RECORD_WORKSPACE_FREE ] = "WORKSPACE_FREE",
+  [ RTEMS_RECORD_WORKSPACE_SIZE ] = "WORKSPACE_SIZE",
+  [ RTEMS_RECORD_WORKSPACE_USAGE ] = "WORKSPACE_USAGE",
+  [ RTEMS_RECORD_WRITE ] = "WRITE",
+  [ RTEMS_RECORD_WRITEV ] = "WRITEV"
+};
+
+const char *rtems_record_event_text( rtems_record_event event )
+{
+  size_t n;
+
+  n = event;
+
+  if ( n < sizeof( event_text ) / sizeof( event_text[ 0 ] ) ) {
+    return event_text[ n ];
+  }
+
+  return NULL;
+}
Index: cpukit/libtrace/record/record-userext.c
===================================================================
--- cpukit/libtrace/record/record-userext.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/libtrace/record/record-userext.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,125 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/record.h>
+#include <rtems/score/thread.h>
+
+bool _Record_Thread_create(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *created
+)
+{
+  rtems_record_produce(
+    RTEMS_RECORD_THREAD_CREATE,
+    created->Object.id
+  );
+
+  return true;
+}
+
+void _Record_Thread_start(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *started
+)
+{
+  rtems_record_produce(
+    RTEMS_RECORD_THREAD_START,
+    started->Object.id
+  );
+}
+
+void _Record_Thread_restart(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *restarted
+)
+{
+  rtems_record_produce(
+    RTEMS_RECORD_THREAD_RESTART,
+    restarted->Object.id
+  );
+}
+
+void _Record_Thread_delete(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *deleted
+)
+{
+  rtems_record_produce(
+    RTEMS_RECORD_THREAD_DELETE,
+    deleted->Object.id
+  );
+}
+
+void _Record_Thread_switch(
+  struct _Thread_Control *executing,
+  struct _Thread_Control *heir
+)
+{
+  rtems_record_item items[ 3 ];
+
+  items[ 0 ].event = RTEMS_RECORD_THREAD_SWITCH_OUT;
+  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;
+#else
+    0;
+#endif
+  items[ 2 ].event = RTEMS_RECORD_THREAD_SWITCH_IN;
+  items[ 2 ].data = heir->Object.id;
+  rtems_record_produce_n( items, RTEMS_ARRAY_SIZE( items ) );
+}
+
+void _Record_Thread_begin( struct _Thread_Control *executing )
+{
+  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
+  );
+}
+
+void _Record_Thread_terminate( struct _Thread_Control *executing )
+{
+  rtems_record_produce(
+    RTEMS_RECORD_THREAD_TERMINATE,
+    executing->Object.id
+  );
+}
Index: cpukit/libtrace/record/record.c
===================================================================
--- cpukit/libtrace/record/record.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ cpukit/libtrace/record/record.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,132 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/record.h>
+#include <rtems/config.h>
+#include <rtems/score/assert.h>
+
+#include <string.h>
+
+void rtems_record_produce( rtems_record_event event, rtems_record_data data )
+{
+  rtems_record_context context;
+
+  rtems_record_prepare( &context );
+  rtems_record_add( &context, event, data );
+  rtems_record_commit( &context );
+}
+
+void rtems_record_produce_2(
+  rtems_record_event event_0,
+  rtems_record_data  data_0,
+  rtems_record_event event_1,
+  rtems_record_data  data_1
+)
+{
+  rtems_record_context context;
+
+  rtems_record_prepare( &context );
+  rtems_record_add( &context, event_0, data_0 );
+  rtems_record_add( &context, event_1, data_1 );
+  rtems_record_commit( &context );
+}
+
+void rtems_record_produce_n(
+  const rtems_record_item *items,
+  size_t                   n
+)
+{
+  rtems_record_context context;
+
+  _Assert( n > 0 );
+
+  rtems_record_prepare( &context );
+
+  do {
+    rtems_record_add( &context, items->event, items->data );
+    ++items;
+    --n;
+  } while ( n > 0 );
+
+  rtems_record_commit( &context );
+}
+
+void rtems_record_drain( rtems_record_drain_visitor visitor, void *arg )
+{
+  uint32_t cpu_max;
+  uint32_t cpu_index;
+
+  cpu_max = rtems_configuration_get_maximum_processors();
+
+  for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
+    Per_CPU_Control   *cpu;
+    Record_Control    *control;
+    unsigned int       tail;
+    unsigned int       head;
+
+    cpu = _Per_CPU_Get_by_index( cpu_index );
+    control = cpu->record;
+
+    tail = _Record_Tail( control );
+    head = _Atomic_Load_uint( &control->head, ATOMIC_ORDER_ACQUIRE );
+
+    if ( tail == head ) {
+      continue;
+    }
+
+    control->tail = head;
+
+    control->Header[ 0 ].event = RTEMS_RECORD_PROCESSOR;
+    control->Header[ 0 ].data = cpu_index;
+    control->Header[ 1 ].event = RTEMS_RECORD_TAIL;
+    control->Header[ 1 ].data = tail;
+    control->Header[ 2 ].event = RTEMS_RECORD_HEAD;
+    control->Header[ 2 ].data = head;
+    ( *visitor )( control->Header, RTEMS_ARRAY_SIZE( control->Header ), arg );
+
+    if ( _Record_Is_overflow( control, tail, head ) ) {
+      tail = head + 1;
+    }
+
+    tail = _Record_Index( control, tail );
+    head = _Record_Index( control, head );
+
+    if ( tail < head ) {
+      ( *visitor )( &control->Items[ tail ], head - tail, arg );
+    } else {
+      ( *visitor )( &control->Items[ tail ], control->mask + 1 - tail, arg );
+
+      if ( head > 0 ) {
+        ( *visitor )( &control->Items[ 0 ], head, arg );
+      }
+    }
+  }
+}
Index: testsuites/libtests/Makefile.am
===================================================================
--- testsuites/libtests/Makefile.am	(revision f0ae613ba72bc4b95797e2482c4bd0fa5546331d)
+++ testsuites/libtests/Makefile.am	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -994,4 +994,22 @@
 realloc_norun_SOURCES = POSIX/realloc.c
 realloc_norun_LDADD = $(RTEMS_ROOT)cpukit/librtemsdefaultconfig.a $(LDADD)
+endif
+
+if TEST_record01
+lib_tests += record01
+lib_screens += record01/record01.scn
+lib_docs += record01/record01.doc
+record01_SOURCES = record01/init.c
+record01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_record01) \
+	$(support_includes) -I$(RTEMS_SOURCE_ROOT)/cpukit/libnetworking
+endif
+
+if TEST_record02
+lib_tests += record02
+lib_screens += record02/record02.scn
+lib_docs += record02/record02.doc
+record02_SOURCES = record02/init.c
+record02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_record02) \
+	$(support_includes)
 endif
 
Index: testsuites/libtests/configure.ac
===================================================================
--- testsuites/libtests/configure.ac	(revision f0ae613ba72bc4b95797e2482c4bd0fa5546331d)
+++ testsuites/libtests/configure.ac	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -190,4 +190,6 @@
 RTEMS_TEST_CHECK([readv])
 RTEMS_TEST_CHECK([realloc])
+RTEMS_TEST_CHECK([record01])
+RTEMS_TEST_CHECK([record02])
 RTEMS_TEST_CHECK([rtmonuse])
 RTEMS_TEST_CHECK([setjmp])
Index: testsuites/libtests/record01/init.c
===================================================================
--- testsuites/libtests/record01/init.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ testsuites/libtests/record01/init.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,714 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/record.h>
+#include <rtems.h>
+
+#include <sys/endian.h>
+#include <sys/socket.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <netinet/in.h>
+
+#ifdef RTEMS_NETWORKING
+#include <rtems/rtems_bsdnet.h>
+#endif
+
+#include <tmacros.h>
+
+const char rtems_test_name[] = "RECORD 1";
+
+#define ITEM_COUNT 4
+
+#define ITEM_SIZE (ITEM_COUNT * sizeof(rtems_record_item))
+
+typedef struct {
+  Record_Control control;
+  rtems_record_item items[ITEM_COUNT];
+} test_context;
+
+static test_context test_instance;
+
+const unsigned int _Record_Item_count = ITEM_COUNT;
+
+#define UE(user) (RTEMS_RECORD_USER + (user))
+
+#define TE(t, e) RTEMS_RECORD_TIME_EVENT(t, e)
+
+static const rtems_record_item expected_items_0[ITEM_COUNT] = {
+  { .event = TE(2, UE(1)), .data = 3 }
+};
+
+static const rtems_record_item expected_items_1[ITEM_COUNT] = {
+  { .event = TE(2, UE(1)), .data = 3 },
+  { .event = TE(6, UE(5)), .data = 7 }
+};
+
+static const rtems_record_item expected_items_2[ITEM_COUNT] = {
+  { .event = TE(2, UE(1)), .data = 3 },
+  { .event = TE(6, UE(5)), .data = 7 },
+  { .event = TE(10, UE(9)), .data = 11 }
+};
+
+static const rtems_record_item expected_items_3[ITEM_COUNT] = {
+  { .event = TE(2, UE(1)), .data = 3 },
+  { .event = TE(6, UE(5)), .data = 7 },
+  { .event = TE(10, UE(9)), .data = 11 },
+  { .event = TE(14, UE(13)), .data = 15 }
+};
+
+static const rtems_record_item expected_items_4[ITEM_COUNT] = {
+  { .event = TE(18, UE(17)), .data = 19 },
+  { .event = TE(6, UE(5)), .data = 7 },
+  { .event = TE(10, UE(9)), .data = 11 },
+  { .event = TE(14, UE(13)), .data = 15 }
+};
+
+static const rtems_record_item expected_items_5[ITEM_COUNT] = {
+  { .event = TE(2, UE(1)), .data = 3 }
+};
+
+static const rtems_record_item expected_items_6[ITEM_COUNT] = {
+  { .event = TE(2, UE(1)), .data = 3 },
+  { .event = TE(6, UE(5)), .data = 7 }
+};
+
+static const rtems_record_item expected_items_7[ITEM_COUNT] = {
+  { .event = TE(2, UE(1)), .data = 3 },
+  { .event = TE(6, UE(5)), .data = 7 },
+  { .event = TE(10, UE(9)), .data = 11 }
+};
+
+static const rtems_record_item expected_items_8[] = {
+  { .event = TE(0, RTEMS_RECORD_PROCESSOR), .data = 0 },
+  { .event = TE(0, RTEMS_RECORD_TAIL), .data = 0 },
+  { .event = TE(0, RTEMS_RECORD_HEAD), .data = 3 },
+  { .event = TE(2, UE(1)), .data = 3 },
+  { .event = TE(5, UE(4)), .data = 6 },
+  { .event = TE(8, UE(7)), .data = 9 }
+};
+
+static const rtems_record_item expected_items_9[] = {
+  { .event = TE(0, RTEMS_RECORD_PROCESSOR), .data = 0 },
+  { .event = TE(0, RTEMS_RECORD_TAIL), .data = 3 },
+  { .event = TE(0, RTEMS_RECORD_HEAD), .data = 5 },
+  { .event = TE(11, UE(10)), .data = 12 },
+  { .event = TE(14, UE(13)), .data = 15 }
+};
+
+static const rtems_record_item expected_items_10[] = {
+  { .event = TE(0, RTEMS_RECORD_PROCESSOR), .data = 0 },
+  { .event = TE(0, RTEMS_RECORD_TAIL), .data = 5 },
+  { .event = TE(0, RTEMS_RECORD_HEAD), .data = 8 },
+  { .event = TE(17, UE(16)), .data = 18 },
+  { .event = TE(20, UE(19)), .data = 21 },
+  { .event = TE(23, UE(22)), .data = 24 }
+};
+
+static const rtems_record_item expected_items_11[] = {
+  { .event = TE(0, RTEMS_RECORD_PROCESSOR), .data = 0 },
+  { .event = TE(0, RTEMS_RECORD_TAIL), .data = 8 },
+  { .event = TE(0, RTEMS_RECORD_HEAD), .data = 9 },
+  { .event = TE(26, UE(25)), .data = 27 }
+};
+
+static const rtems_record_item expected_items_12[] = {
+  { .event = TE(0, RTEMS_RECORD_PROCESSOR), .data = 0 },
+  { .event = TE(0, RTEMS_RECORD_TAIL), .data = 9 },
+  { .event = TE(0, RTEMS_RECORD_HEAD), .data = 15 },
+  { .event = TE(38, UE(37)), .data = 39 },
+  { .event = TE(41, UE(40)), .data = 42 },
+  { .event = TE(44, UE(43)), .data = 45 }
+};
+
+static void init_context(test_context *ctx)
+{
+  memset(ctx, 0, sizeof(*ctx));
+  ctx->control.mask = ITEM_COUNT - 1;
+}
+
+static void test_capacity(const Record_Control *control)
+{
+  unsigned int capacity;
+
+  capacity = _Record_Capacity(control, 0, 0);
+  rtems_test_assert(capacity == 3);
+
+  capacity = _Record_Capacity(control, 0, 1);
+  rtems_test_assert(capacity == 2);
+
+  capacity = _Record_Capacity(control, 0, 2);
+  rtems_test_assert(capacity == 1);
+
+  capacity = _Record_Capacity(control, 0, 3);
+  rtems_test_assert(capacity == 0);
+
+  capacity = _Record_Capacity(control, 3, 3);
+  rtems_test_assert(capacity == 3);
+
+  capacity = _Record_Capacity(control, 3, 0);
+  rtems_test_assert(capacity == 2);
+
+  capacity = _Record_Capacity(control, 3, 1);
+  rtems_test_assert(capacity == 1);
+
+  capacity = _Record_Capacity(control, 3, 2);
+  rtems_test_assert(capacity == 0);
+}
+
+static void test_index(const Record_Control *control)
+{
+  unsigned int index;
+
+  index = _Record_Index(control, 0);
+  rtems_test_assert(index == 0);
+
+  index = _Record_Index(control, 1);
+  rtems_test_assert(index == 1);
+
+  index = _Record_Index(control, 2);
+  rtems_test_assert(index == 2);
+
+  index = _Record_Index(control, 3);
+  rtems_test_assert(index == 3);
+
+  index = _Record_Index(control, 4);
+  rtems_test_assert(index == 0);
+}
+
+static void test_add_2_items(test_context *ctx, Record_Control *control)
+{
+  rtems_record_context rc;
+
+  init_context(ctx);
+
+  rtems_record_prepare(&rc);
+  rtems_test_assert(rc.control == control);
+  rtems_test_assert(rc.head == 0);
+  rtems_test_assert(_Record_Head(control) == 0);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rc.now = RTEMS_RECORD_TIME_EVENT(2, 0);
+  rtems_record_add(&rc, UE(1), 3);
+  rtems_test_assert(rc.head == 1);
+  rtems_test_assert(memcmp(control->Items, expected_items_0, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 0);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rc.now = RTEMS_RECORD_TIME_EVENT(6, 0);
+  rtems_record_add(&rc, UE(5), 7);
+  rtems_record_commit(&rc);
+  rtems_test_assert(rc.head == 2);
+  rtems_test_assert(memcmp(control->Items, expected_items_1, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 2);
+  rtems_test_assert(_Record_Tail(control) == 0);
+}
+
+static void test_add_3_items(test_context *ctx, Record_Control *control)
+{
+  rtems_record_context rc;
+
+  init_context(ctx);
+
+  rtems_record_prepare(&rc);
+  rtems_test_assert(rc.control == control);
+  rtems_test_assert(rc.head == 0);
+  rtems_test_assert(_Record_Head(control) == 0);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rc.now = RTEMS_RECORD_TIME_EVENT(2, 0);
+  rtems_record_add(&rc, UE(1), 3);
+  rtems_test_assert(rc.head == 1);
+  rtems_test_assert(memcmp(control->Items, expected_items_5, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 0);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rc.now = RTEMS_RECORD_TIME_EVENT(6, 0);
+  rtems_record_add(&rc, UE(5), 7);
+  rtems_test_assert(rc.head == 2);
+  rtems_test_assert(memcmp(control->Items, expected_items_6, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 0);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rc.now = RTEMS_RECORD_TIME_EVENT(10, 0);
+  rtems_record_add(&rc, UE(9), 11);
+  rtems_record_commit(&rc);
+  rtems_test_assert(rc.head == 3);
+  rtems_test_assert(memcmp(control->Items, expected_items_7, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 3);
+  rtems_test_assert(_Record_Tail(control) == 0);
+}
+
+static void set_time(rtems_record_item *item, uint32_t time)
+{
+  uint32_t event;
+
+  event = item->event;
+  event &= 0x3ff;
+  event |= time << 10;
+  item->event = event;
+}
+
+static void test_produce(test_context *ctx, Record_Control *control)
+{
+  init_context(ctx);
+
+  rtems_record_produce(UE(1), 3);
+  set_time(&control->Items[0], 2);
+  rtems_test_assert(memcmp(control->Items, expected_items_0, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 1);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rtems_record_produce(UE(5), 7);
+  set_time(&control->Items[1], 6);
+  rtems_test_assert(memcmp(control->Items, expected_items_1, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 2);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rtems_record_produce(UE(9), 11);
+  set_time(&control->Items[2], 10);
+  rtems_test_assert(memcmp(control->Items, expected_items_2, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 3);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rtems_record_produce(UE(13), 15);
+  set_time(&control->Items[3], 14);
+  rtems_test_assert(memcmp(control->Items, expected_items_3, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 4);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rtems_record_produce(UE(17), 19);
+  set_time(&control->Items[0], 18);
+  rtems_test_assert(memcmp(control->Items, expected_items_4, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 5);
+  rtems_test_assert(_Record_Tail(control) == 0);
+}
+
+static void test_produce_2(test_context *ctx, Record_Control *control)
+{
+  init_context(ctx);
+
+  rtems_record_produce_2(UE(1), 3, UE(5), 7);
+  set_time(&control->Items[0], 2);
+  set_time(&control->Items[1], 6);
+  rtems_test_assert(memcmp(control->Items, expected_items_1, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 2);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rtems_record_produce(UE(9), 11);
+  set_time(&control->Items[2], 10);
+  rtems_test_assert(memcmp(control->Items, expected_items_2, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 3);
+  rtems_test_assert(_Record_Tail(control) == 0);
+
+  rtems_record_produce_2(UE(13), 15, UE(17), 19);
+  set_time(&control->Items[3], 14);
+  set_time(&control->Items[0], 18);
+  rtems_test_assert(memcmp(control->Items, expected_items_4, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 5);
+  rtems_test_assert(_Record_Tail(control) == 0);
+}
+
+static void test_produce_n(test_context *ctx, Record_Control *control)
+{
+  rtems_record_item items[5];
+
+  init_context(ctx);
+
+  items[0].event = UE(1);
+  items[0].data = 3;
+  items[1].event = UE(5);
+  items[1].data = 7;
+  items[2].event = UE(9);
+  items[2].data = 11;
+  items[3].event = UE(13);
+  items[3].data = 15;
+  items[4].event = UE(17);
+  items[4].data = 19;
+  rtems_record_produce_n(items, RTEMS_ARRAY_SIZE(items));
+  set_time(&control->Items[1], 6);
+  set_time(&control->Items[2], 10);
+  set_time(&control->Items[3], 14);
+  set_time(&control->Items[0], 18);
+  rtems_test_assert(memcmp(control->Items, expected_items_4, ITEM_SIZE) == 0);
+  rtems_test_assert(_Record_Head(control) == 5);
+  rtems_test_assert(_Record_Tail(control) == 0);
+}
+
+typedef struct {
+  size_t todo;
+  const rtems_record_item *items;
+} visitor_context;
+
+static void visitor(const rtems_record_item *items, size_t count, void *arg)
+{
+  visitor_context *vctx;
+
+  vctx = arg;
+  rtems_test_assert(vctx->todo >= count);
+
+  while (count > 0) {
+    rtems_test_assert(memcmp(items, vctx->items, sizeof(*items)) == 0);
+    ++items;
+    ++vctx->items;
+    --count;
+    --vctx->todo;
+  }
+}
+
+static void test_drain(test_context *ctx, Record_Control *control)
+{
+  visitor_context vctx;
+
+  init_context(ctx);
+
+  vctx.todo = 0;
+  vctx.items = NULL;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  rtems_record_produce(UE(1), 3);
+  set_time(&control->Items[0], 2);
+  rtems_record_produce(UE(4), 6);
+  set_time(&control->Items[1], 5);
+  rtems_record_produce(UE(7), 9);
+  set_time(&control->Items[2], 8);
+
+  vctx.todo = RTEMS_ARRAY_SIZE(expected_items_8);
+  vctx.items = expected_items_8;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  vctx.todo = 0;
+  vctx.items = NULL;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  rtems_record_produce(UE(10), 12);
+  set_time(&control->Items[3], 11);
+  rtems_record_produce(UE(13), 15);
+  set_time(&control->Items[0], 14);
+
+  vctx.todo = RTEMS_ARRAY_SIZE(expected_items_9);
+  vctx.items = expected_items_9;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  vctx.todo = 0;
+  vctx.items = NULL;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  rtems_record_produce(UE(16), 18);
+  set_time(&control->Items[1], 17);
+  rtems_record_produce(UE(19), 21);
+  set_time(&control->Items[2], 20);
+  rtems_record_produce(UE(22), 24);
+  set_time(&control->Items[3], 23);
+
+  vctx.todo = RTEMS_ARRAY_SIZE(expected_items_10);
+  vctx.items = expected_items_10;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  vctx.todo = 0;
+  vctx.items = NULL;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  rtems_record_produce(UE(25), 27);
+  set_time(&control->Items[0], 26);
+
+  vctx.todo = RTEMS_ARRAY_SIZE(expected_items_11);
+  vctx.items = expected_items_11;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  vctx.todo = 0;
+  vctx.items = NULL;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  rtems_record_produce(UE(28), 30);
+  set_time(&control->Items[1], 29);
+  rtems_record_produce(UE(31), 33);
+  set_time(&control->Items[2], 32);
+  rtems_record_produce(UE(34), 36);
+  set_time(&control->Items[3], 35);
+  rtems_record_produce(UE(37), 39);
+  set_time(&control->Items[0], 38);
+  rtems_record_produce(UE(40), 42);
+  set_time(&control->Items[1], 41);
+  rtems_record_produce(UE(43), 45);
+  set_time(&control->Items[2], 44);
+
+  vctx.todo = RTEMS_ARRAY_SIZE(expected_items_12);
+  vctx.items = expected_items_12;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+
+  vctx.todo = 0;
+  vctx.items = NULL;
+  rtems_record_drain(visitor, &vctx);
+  rtems_test_assert(vctx.todo == 0);
+}
+
+#ifdef RTEMS_NETWORKING
+#define PORT 1234
+
+static uint32_t get_format(void)
+{
+  uint32_t format;
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#if __INTPTR_WIDTH__ == 32
+  format = RTEMS_RECORD_FORMAT_LE_32;
+#elif __INTPTR_WIDTH__ == 64
+  format = RTEMS_RECORD_FORMAT_LE_64;
+#else
+#error "unexpected __INTPTR_WIDTH__"
+#endif
+#elif BYTE_ORDER == BIG_ENDIAN
+#if __INTPTR_WIDTH__ == 32
+  format = RTEMS_RECORD_FORMAT_BE_32;
+#elif __INTPTR_WIDTH__ == 64
+  format = RTEMS_RECORD_FORMAT_BE_64;
+#else
+#error "unexpected __INTPTR_WIDTH__"
+#endif
+#else
+#error "unexpected BYTE_ORDER"
+#endif
+
+  return format;
+}
+
+static int connect_client(void)
+{
+  struct sockaddr_in addr;
+  int fd;
+  int rv;
+  ssize_t n;
+  uint32_t v;
+  rtems_record_item item;
+
+  fd = socket(PF_INET, SOCK_STREAM, 0);
+  rtems_test_assert(fd >= 0);
+
+  memset(&addr, 0, sizeof(addr));
+  addr.sin_family = AF_INET;
+  addr.sin_port = htons(PORT);
+  addr.sin_addr.s_addr = htonl(INADDR_ANY);
+  rv = connect(fd, (struct sockaddr *) &addr, sizeof(addr));
+  rtems_test_assert(rv == 0);
+
+  n = read(fd, &v, sizeof(v));
+  rtems_test_assert(n == 4);
+  rtems_test_assert(v == get_format());
+
+  n = read(fd, &v, sizeof(v));
+  rtems_test_assert(n == 4);
+  rtems_test_assert(v == RTEMS_RECORD_MAGIC);
+
+  n = read(fd, &item, sizeof(item));
+  rtems_test_assert(n == (ssize_t) sizeof(item));
+  rtems_test_assert(item.event == TE(0, RTEMS_RECORD_VERSION));
+  rtems_test_assert(item.data == RTEMS_RECORD_THE_VERSION);
+
+  n = read(fd, &item, sizeof(item));
+  rtems_test_assert(n == (ssize_t) sizeof(item));
+  rtems_test_assert(item.event == TE(0, RTEMS_RECORD_PROCESSOR_MAXIMUM));
+  rtems_test_assert(item.data == 0);
+
+  n = read(fd, &item, sizeof(item));
+  rtems_test_assert(n == (ssize_t) sizeof(item));
+  rtems_test_assert(item.event == TE(0, RTEMS_RECORD_COUNT));
+  rtems_test_assert(item.data == ITEM_COUNT);
+
+  n = read(fd, &item, sizeof(item));
+  rtems_test_assert(n == (ssize_t) sizeof(item));
+  rtems_test_assert(item.event == TE(0, RTEMS_RECORD_FREQUENCY));
+  rtems_test_assert(item.data == rtems_counter_frequency());
+
+  return fd;
+}
+
+static void produce_and_read(int fd, Record_Control *control)
+{
+  rtems_record_item items[6];
+  ssize_t n;
+
+  rtems_record_produce(UE(1), 3);
+  set_time(&control->Items[0], 2);
+  rtems_record_produce(UE(4), 6);
+  set_time(&control->Items[1], 5);
+  rtems_record_produce(UE(7), 9);
+  set_time(&control->Items[2], 8);
+
+  n = read(fd, items, sizeof(expected_items_8));
+  rtems_test_assert(n == (ssize_t) sizeof(expected_items_8));
+  rtems_test_assert(
+    memcmp(items, expected_items_8, sizeof(expected_items_8)) == 0
+  );
+
+  rtems_record_produce(UE(10), 12);
+  set_time(&control->Items[3], 11);
+  rtems_record_produce(UE(13), 15);
+  set_time(&control->Items[0], 14);
+
+  n = read(fd, items, sizeof(expected_items_9));
+  rtems_test_assert(n == (ssize_t) sizeof(expected_items_9));
+  rtems_test_assert(
+    memcmp(items, expected_items_9, sizeof(expected_items_9)) == 0
+  );
+
+  rtems_record_produce(UE(16), 18);
+  set_time(&control->Items[1], 17);
+  rtems_record_produce(UE(19), 21);
+  set_time(&control->Items[2], 20);
+  rtems_record_produce(UE(22), 24);
+  set_time(&control->Items[3], 23);
+
+  n = read(fd, items, sizeof(expected_items_10));
+  rtems_test_assert(n == (ssize_t) sizeof(expected_items_10));
+  rtems_test_assert(
+    memcmp(items, expected_items_10, sizeof(expected_items_10)) == 0
+  );
+
+  rtems_record_produce(UE(25), 27);
+  set_time(&control->Items[0], 26);
+
+  n = read(fd, items, sizeof(expected_items_11));
+  rtems_test_assert(n == (ssize_t) sizeof(expected_items_11));
+  rtems_test_assert(
+    memcmp(items, expected_items_11, sizeof(expected_items_11)) == 0
+  );
+
+  rtems_record_produce(UE(28), 30);
+  set_time(&control->Items[1], 29);
+  rtems_record_produce(UE(31), 33);
+  set_time(&control->Items[2], 32);
+  rtems_record_produce(UE(34), 36);
+  set_time(&control->Items[3], 35);
+  rtems_record_produce(UE(37), 39);
+  set_time(&control->Items[0], 38);
+  rtems_record_produce(UE(40), 42);
+  set_time(&control->Items[1], 41);
+  rtems_record_produce(UE(43), 45);
+  set_time(&control->Items[2], 44);
+
+  n = read(fd, items, sizeof(expected_items_12));
+  rtems_test_assert(n == (ssize_t) sizeof(expected_items_12));
+  rtems_test_assert(
+    memcmp(items, expected_items_12, sizeof(expected_items_12)) == 0
+  );
+}
+
+static void test_server(test_context *ctx, Record_Control *control)
+{
+  rtems_status_code sc;
+  int rv;
+  int fd;
+
+  init_context(ctx);
+
+  rv = rtems_bsdnet_initialize_network();
+  rtems_test_assert(rv == 0);
+
+  sc = rtems_record_start_server(1, PORT, 1);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  fd = connect_client();
+  produce_and_read(fd, control);
+
+  rv = close(fd);
+  rtems_test_assert(rv == 0);
+}
+#endif
+
+static void Init(rtems_task_argument arg)
+{
+  test_context *ctx;
+  Per_CPU_Control *cpu_self;
+
+  TEST_BEGIN();
+
+  ctx = &test_instance;
+
+  cpu_self = _Per_CPU_Get_snapshot();
+  cpu_self->record = &ctx->control;
+
+  init_context(ctx);
+  test_capacity(&ctx->control);
+  test_index(&ctx->control);
+  test_add_2_items(ctx, &ctx->control);
+  test_add_3_items(ctx, &ctx->control);
+  test_produce(ctx, &ctx->control);
+  test_produce_2(ctx, &ctx->control);
+  test_produce_n(ctx, &ctx->control);
+  test_drain(ctx, &ctx->control);
+#ifdef RTEMS_NETWORKING
+  test_server(ctx, &ctx->control);
+#endif
+
+  TEST_END();
+  rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
+
+#ifdef RTEMS_NETWORKING
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 7
+
+#define CONFIGURE_MAXIMUM_TASKS 3
+
+#define CONFIGURE_MAXIMUM_TIMERS 1
+
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
+#else
+#define CONFIGURE_MAXIMUM_TASKS 1
+#endif
+
+#define CONFIGURE_INIT_TASK_PRIORITY 2
+
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
Index: testsuites/libtests/record01/record01.scn
===================================================================
--- testsuites/libtests/record01/record01.scn	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ testsuites/libtests/record01/record01.scn	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,7 @@
+*** BEGIN OF TEST RECORD 1 ***
+*** TEST VERSION: 5.0.0.f0ae613ba72bc4b95797e2482c4bd0fa5546331d
+*** TEST STATE: EXPECTED-PASS
+*** TEST BUILD: RTEMS_NETWORKING
+*** TEST TOOLS: 7.4.0 20181206 (RTEMS 5, RSB 376edee1c734fb412b731a7d9e57757dd4cc5f07, Newlib dc6e94551f09d3a983afd571478d63a09d6f66fa)
+
+*** END OF TEST RECORD 1 ***
Index: testsuites/libtests/record02/init.c
===================================================================
--- testsuites/libtests/record02/init.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ testsuites/libtests/record02/init.c	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,132 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2018, 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/record.h>
+#include <rtems/recordclient.h>
+#include <rtems.h>
+
+#include <string.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "RECORD 2";
+
+typedef struct {
+  rtems_record_client_context client;
+} test_context;
+
+static test_context test_instance;
+
+static rtems_record_client_status client_handler(
+  uint32_t            seconds,
+  uint32_t            nanoseconds,
+  uint32_t            cpu,
+  rtems_record_event  event,
+  uint64_t            data,
+  void               *arg
+)
+{
+  const char *event_text;
+
+  (void) arg;
+
+  if ( seconds != 0 && nanoseconds != 0 ) {
+    printf( "%" PRIu32 ".%09" PRIu32 ":", seconds, nanoseconds );
+  } else {
+    printf( "*:" );
+  }
+
+  event_text = rtems_record_event_text( event );
+
+  if ( event_text != NULL ) {
+    printf( "%" PRIu32 ":%s:%" PRIx64 "\n", cpu, event_text, data );
+  } else {
+    printf( "%" PRIu32 ":%i:%" PRIx64 "\n", cpu, event, data );
+  }
+
+  return RTEMS_RECORD_CLIENT_SUCCESS;
+}
+
+static void drain_visitor(
+  const rtems_record_item *items,
+  size_t                   count,
+  void                    *arg
+)
+{
+  test_context *ctx;
+  rtems_record_client_status cs;
+
+  ctx = arg;
+  cs = rtems_record_client_run(&ctx->client, items, count * sizeof(*items));
+  rtems_test_assert(cs == RTEMS_RECORD_CLIENT_SUCCESS);
+}
+
+static void Init(rtems_task_argument arg)
+{
+  test_context *ctx;
+  Record_Stream_header header;
+  rtems_record_client_status cs;
+  int i;
+
+  TEST_BEGIN();
+  ctx = &test_instance;
+
+  for (i = 0; i < 10; ++i) {
+    rtems_task_wake_after(1);
+  }
+
+  rtems_record_client_init(&ctx->client, client_handler, NULL);
+  _Record_Stream_header_initialize(&header);
+  cs = rtems_record_client_run(&ctx->client, &header, sizeof(header));
+  rtems_test_assert(cs == RTEMS_RECORD_CLIENT_SUCCESS);
+  rtems_record_drain(drain_visitor, ctx);
+
+  TEST_END();
+  rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_RECORD_PER_PROCESSOR_ITEMS 128
+
+#define CONFIGURE_RECORD_EXTENSIONS_ENABLED
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
Index: testsuites/libtests/record02/record02.scn
===================================================================
--- testsuites/libtests/record02/record02.scn	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
+++ testsuites/libtests/record02/record02.scn	(revision dca618404ee61c1be8a883ddb679889dbfea284b)
@@ -0,0 +1,82 @@
+*** BEGIN OF TEST RECORD 2 ***
+*** TEST VERSION: 5.0.0.f0ae613ba72bc4b95797e2482c4bd0fa5546331d
+*** TEST STATE: EXPECTED-PASS
+*** TEST BUILD: RTEMS_NETWORKING
+*** TEST TOOLS: 7.4.0 20181206 (RTEMS 5, RSB 376edee1c734fb412b731a7d9e57757dd4cc5f07, Newlib dc6e94551f09d3a983afd571478d63a09d6f66fa)
+*:0:VERSION:1
+*:0:PROCESSOR_MAXIMUM:0
+*:0:COUNT:80
+*:0:FREQUENCY:f4240
+*:0:PROCESSOR:0
+*:0:TAIL:0
+*:0:HEAD:44
+*:0:THREAD_CREATE:9010001
+*:0:THREAD_START:9010001
+*:0:UPTIME_LOW:9a240
+*:0:UPTIME_HIGH:1
+1.000537999:0:THREAD_CREATE:a010001
+1.000843999:0:THREAD_START:a010001
+1.003692999:0:THREAD_BEGIN:a010001
+1.005548999:0:THREAD_SWITCH_OUT:a010001
+1.005548999:0:THREAD_STACK_CURRENT:d48
+1.005548999:0:THREAD_SWITCH_IN:9010001
+1.005645999:0:THREAD_BEGIN:9010001
+1.013832999:0:THREAD_SWITCH_OUT:9010001
+1.013832999:0:THREAD_STACK_CURRENT:d38
+1.013832999:0:THREAD_SWITCH_IN:a010001
+1.014077999:0:THREAD_SWITCH_OUT:a010001
+1.014077999:0:THREAD_STACK_CURRENT:d48
+1.014077999:0:THREAD_SWITCH_IN:9010001
+1.023821999:0:THREAD_SWITCH_OUT:9010001
+1.023821999:0:THREAD_STACK_CURRENT:d38
+1.023821999:0:THREAD_SWITCH_IN:a010001
+1.024065999:0:THREAD_SWITCH_OUT:a010001
+1.024065999:0:THREAD_STACK_CURRENT:d48
+1.024065999:0:THREAD_SWITCH_IN:9010001
+1.033821999:0:THREAD_SWITCH_OUT:9010001
+1.033821999:0:THREAD_STACK_CURRENT:d38
+1.033821999:0:THREAD_SWITCH_IN:a010001
+1.034065999:0:THREAD_SWITCH_OUT:a010001
+1.034065999:0:THREAD_STACK_CURRENT:d48
+1.034065999:0:THREAD_SWITCH_IN:9010001
+1.043821999:0:THREAD_SWITCH_OUT:9010001
+1.043821999:0:THREAD_STACK_CURRENT:d38
+1.043821999:0:THREAD_SWITCH_IN:a010001
+1.044065999:0:THREAD_SWITCH_OUT:a010001
+1.044065999:0:THREAD_STACK_CURRENT:d48
+1.044065999:0:THREAD_SWITCH_IN:9010001
+1.053821999:0:THREAD_SWITCH_OUT:9010001
+1.053821999:0:THREAD_STACK_CURRENT:d38
+1.053821999:0:THREAD_SWITCH_IN:a010001
+1.054065999:0:THREAD_SWITCH_OUT:a010001
+1.054065999:0:THREAD_STACK_CURRENT:d48
+1.054065999:0:THREAD_SWITCH_IN:9010001
+1.063821999:0:THREAD_SWITCH_OUT:9010001
+1.063821999:0:THREAD_STACK_CURRENT:d38
+1.063821999:0:THREAD_SWITCH_IN:a010001
+1.064065999:0:THREAD_SWITCH_OUT:a010001
+1.064065999:0:THREAD_STACK_CURRENT:d48
+1.064065999:0:THREAD_SWITCH_IN:9010001
+1.073821999:0:THREAD_SWITCH_OUT:9010001
+1.073821999:0:THREAD_STACK_CURRENT:d38
+1.073821999:0:THREAD_SWITCH_IN:a010001
+1.074065999:0:THREAD_SWITCH_OUT:a010001
+1.074065999:0:THREAD_STACK_CURRENT:d48
+1.074065999:0:THREAD_SWITCH_IN:9010001
+1.083821999:0:THREAD_SWITCH_OUT:9010001
+1.083821999:0:THREAD_STACK_CURRENT:d38
+1.083821999:0:THREAD_SWITCH_IN:a010001
+1.084065999:0:THREAD_SWITCH_OUT:a010001
+1.084065999:0:THREAD_STACK_CURRENT:d48
+1.084065999:0:THREAD_SWITCH_IN:9010001
+1.093821999:0:THREAD_SWITCH_OUT:9010001
+1.093821999:0:THREAD_STACK_CURRENT:d38
+1.093821999:0:THREAD_SWITCH_IN:a010001
+1.094065999:0:THREAD_SWITCH_OUT:a010001
+1.094065999:0:THREAD_STACK_CURRENT:d48
+1.094065999:0:THREAD_SWITCH_IN:9010001
+1.103821999:0:THREAD_SWITCH_OUT:9010001
+1.103821999:0:THREAD_STACK_CURRENT:d38
+1.103821999:0:THREAD_SWITCH_IN:a010001
+
+*** END OF TEST RECORD 2 ***
