summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests/record02
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-28 11:36:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-01-29 13:51:33 +0100
commitdca618404ee61c1be8a883ddb679889dbfea284b (patch)
tree49a61cb40d4fcce31c1c84b7f83737a4852630a0 /testsuites/libtests/record02
parentm68k: Avoid _Addresses_Add_offset() (diff)
downloadrtems-dca618404ee61c1be8a883ddb679889dbfea284b.tar.bz2
Add low level event recording support
Add low level event recording infrastructure for system and user defined events. The infrastructure is able to record high frequency events such as * SMP lock acquire/release, * interrupt entry/exit, * thread switches, * UMA zone allocate/free, and * Ethernet packet input/output, etc. It allows post-mortem analysis in fatal error handlers, e.g. the last events are in the record buffer, the newest event overwrites the oldest event. It is possible to detect record buffer overflows for consumers that expect a continuous stream of events, e.g. to display the system state in real-time. The implementation supports high-end SMP machines (more than 1GHz processor frequency, more than four processors). Add a new API instead. The implementation uses per-processor data structures and no atomic read-modify-write operations. It is uses per-processor ring buffers to record the events. The CPU counter is used to get the time of events. It is combined with periodic uptime events to synchronize it with CLOCK_REALTIME. The existing capture engine tries to solve this problem also, but its performance is not good enough for high-end production systems. The main issues are the variable-size buffers and the use of SMP locks for synchronization. To fix this, the API would change significantly. Update #3665.
Diffstat (limited to 'testsuites/libtests/record02')
-rw-r--r--testsuites/libtests/record02/init.c132
-rw-r--r--testsuites/libtests/record02/record02.doc12
-rw-r--r--testsuites/libtests/record02/record02.scn82
3 files changed, 226 insertions, 0 deletions
diff --git a/testsuites/libtests/record02/init.c b/testsuites/libtests/record02/init.c
new file mode 100644
index 0000000000..642d3d5422
--- /dev/null
+++ b/testsuites/libtests/record02/init.c
@@ -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>
diff --git a/testsuites/libtests/record02/record02.doc b/testsuites/libtests/record02/record02.doc
new file mode 100644
index 0000000000..a34aa7e30f
--- /dev/null
+++ b/testsuites/libtests/record02/record02.doc
@@ -0,0 +1,12 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: record02
+
+directives:
+
+ - rtems_record_client_init()
+ - rtems_record_client_run()
+
+concepts:
+
+ - Simple event recording use case.
diff --git a/testsuites/libtests/record02/record02.scn b/testsuites/libtests/record02/record02.scn
new file mode 100644
index 0000000000..487c601caf
--- /dev/null
+++ b/testsuites/libtests/record02/record02.scn
@@ -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 ***