forked from Imagelibrary/rtems
record: Dump only once in fatal handling
This commit is contained in:
committed by
Chris Johns
parent
e72ee949a0
commit
0f2721c832
@@ -1,7 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 embedded brains GmbH & Co. KG
|
* Copyright (C) 2020, 2024 embedded brains GmbH & Co. KG
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -30,7 +30,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/recorddump.h>
|
#include <rtems/recorddump.h>
|
||||||
|
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/bspIo.h>
|
||||||
|
#include <rtems/score/isrlock.h>
|
||||||
|
#include <rtems/score/smpimpl.h>
|
||||||
|
|
||||||
|
#if ISR_LOCK_NEEDS_OBJECT
|
||||||
|
static ISR_lock_Control _Record_Dump_base64_lock =
|
||||||
|
ISR_LOCK_INITIALIZER( "Record Dump base64" );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static bool _Record_Dump_base64_done;
|
||||||
|
|
||||||
void _Record_Fatal_dump_base64(
|
void _Record_Fatal_dump_base64(
|
||||||
Internal_errors_Source source,
|
Internal_errors_Source source,
|
||||||
@@ -38,13 +48,36 @@ void _Record_Fatal_dump_base64(
|
|||||||
Internal_errors_t code
|
Internal_errors_t code
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
ISR_lock_Context lock_context;
|
||||||
|
|
||||||
rtems_record_produce_2(
|
rtems_record_produce_2(
|
||||||
RTEMS_RECORD_FATAL_SOURCE,
|
RTEMS_RECORD_FATAL_SOURCE,
|
||||||
source,
|
source,
|
||||||
RTEMS_RECORD_FATAL_CODE,
|
RTEMS_RECORD_FATAL_CODE,
|
||||||
code
|
code
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if defined(RTEMS_SMP)
|
||||||
|
if (
|
||||||
|
source == RTEMS_FATAL_SOURCE_SMP &&
|
||||||
|
code == SMP_FATAL_SHUTDOWN_RESPONSE
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Request other online processors to shutdown to stop event generation */
|
||||||
|
_SMP_Request_shutdown();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_ISR_lock_Acquire( &_Record_Dump_base64_lock, &lock_context );
|
||||||
|
|
||||||
|
if ( !_Record_Dump_base64_done ) {
|
||||||
|
_Record_Dump_base64_done = true;
|
||||||
|
|
||||||
printk( "\n*** BEGIN OF RECORDS BASE64 ***\n" );
|
printk( "\n*** BEGIN OF RECORDS BASE64 ***\n" );
|
||||||
rtems_record_dump_base64( rtems_put_char, NULL );
|
rtems_record_dump_base64( rtems_put_char, NULL );
|
||||||
printk( "\n*** END OF RECORDS BASE64 ***\n" );
|
printk( "\n*** END OF RECORDS BASE64 ***\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ISR_lock_Release( &_Record_Dump_base64_lock, &lock_context );
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 embedded brains GmbH & Co. KG
|
* Copyright (C) 2020, 2024 embedded brains GmbH & Co. KG
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -30,9 +30,19 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/recorddump.h>
|
#include <rtems/recorddump.h>
|
||||||
#include <rtems/bspIo.h>
|
|
||||||
|
|
||||||
static rtems_record_dump_base64_zlib_context context;
|
#include <rtems/bspIo.h>
|
||||||
|
#include <rtems/score/isrlock.h>
|
||||||
|
#include <rtems/score/smpimpl.h>
|
||||||
|
|
||||||
|
#if ISR_LOCK_NEEDS_OBJECT
|
||||||
|
static ISR_lock_Control _Record_Dump_base64_zlib_lock =
|
||||||
|
ISR_LOCK_INITIALIZER( "Record Dump base64 zlib" );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static bool _Record_Dump_base64_zlib_done;
|
||||||
|
|
||||||
|
static rtems_record_dump_base64_zlib_context _Record_Dump_base64_zlib_context;
|
||||||
|
|
||||||
void _Record_Fatal_dump_base64_zlib(
|
void _Record_Fatal_dump_base64_zlib(
|
||||||
Internal_errors_Source source,
|
Internal_errors_Source source,
|
||||||
@@ -40,13 +50,40 @@ void _Record_Fatal_dump_base64_zlib(
|
|||||||
Internal_errors_t code
|
Internal_errors_t code
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
ISR_lock_Context lock_context;
|
||||||
|
|
||||||
rtems_record_produce_2(
|
rtems_record_produce_2(
|
||||||
RTEMS_RECORD_FATAL_SOURCE,
|
RTEMS_RECORD_FATAL_SOURCE,
|
||||||
source,
|
source,
|
||||||
RTEMS_RECORD_FATAL_CODE,
|
RTEMS_RECORD_FATAL_CODE,
|
||||||
code
|
code
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if defined(RTEMS_SMP)
|
||||||
|
if (
|
||||||
|
source == RTEMS_FATAL_SOURCE_SMP &&
|
||||||
|
code == SMP_FATAL_SHUTDOWN_RESPONSE
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Request other online processors to shutdown to stop event generation */
|
||||||
|
_SMP_Request_shutdown();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_ISR_lock_Acquire( &_Record_Dump_base64_zlib_lock, &lock_context );
|
||||||
|
|
||||||
|
if ( !_Record_Dump_base64_zlib_done ) {
|
||||||
|
_Record_Dump_base64_zlib_done = true;
|
||||||
|
|
||||||
printk( "\n*** BEGIN OF RECORDS BASE64 ZLIB ***\n" );
|
printk( "\n*** BEGIN OF RECORDS BASE64 ZLIB ***\n" );
|
||||||
rtems_record_dump_zlib_base64( &context, rtems_put_char, NULL );
|
rtems_record_dump_zlib_base64(
|
||||||
|
&_Record_Dump_base64_zlib_context,
|
||||||
|
rtems_put_char,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
printk( "\n*** END OF RECORDS BASE64 ZLIB ***\n" );
|
printk( "\n*** END OF RECORDS BASE64 ZLIB ***\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ISR_lock_Release( &_Record_Dump_base64_zlib_lock, &lock_context );
|
||||||
|
}
|
||||||
|
|||||||
@@ -80,14 +80,18 @@ static rtems_record_client_status client_handler(
|
|||||||
return RTEMS_RECORD_CLIENT_SUCCESS;
|
return RTEMS_RECORD_CLIENT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generate_events(void)
|
static void wait(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint32_t level;
|
|
||||||
|
|
||||||
for (i = 0; i < 10; ++i) {
|
for (i = 0; i < 10; ++i) {
|
||||||
rtems_task_wake_after(1);
|
rtems_task_wake_after(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void generate_events(void)
|
||||||
|
{
|
||||||
|
uint32_t level;
|
||||||
|
|
||||||
rtems_record_line();
|
rtems_record_line();
|
||||||
rtems_record_line_2(RTEMS_RECORD_USER_0, 0);
|
rtems_record_line_2(RTEMS_RECORD_USER_0, 0);
|
||||||
@@ -187,6 +191,7 @@ static void Init(rtems_task_argument arg)
|
|||||||
TEST_BEGIN();
|
TEST_BEGIN();
|
||||||
ctx = &test_instance;
|
ctx = &test_instance;
|
||||||
|
|
||||||
|
wait();
|
||||||
generate_events();
|
generate_events();
|
||||||
|
|
||||||
cs = rtems_record_client_init(&ctx->client, client_handler, NULL);
|
cs = rtems_record_client_init(&ctx->client, client_handler, NULL);
|
||||||
@@ -203,11 +208,9 @@ static void Init(rtems_task_argument arg)
|
|||||||
|
|
||||||
rtems_record_client_destroy(&ctx->client);
|
rtems_record_client_destroy(&ctx->client);
|
||||||
|
|
||||||
|
wait();
|
||||||
generate_events();
|
generate_events();
|
||||||
|
rtems_fatal( RTEMS_FATAL_SOURCE_EXIT, 0 );
|
||||||
_Record_Fatal_dump_base64(RTEMS_FATAL_SOURCE_APPLICATION, false, 123);
|
|
||||||
|
|
||||||
generate_events();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fatal_extension(
|
static void fatal_extension(
|
||||||
@@ -216,6 +219,8 @@ static void fatal_extension(
|
|||||||
rtems_fatal_code code
|
rtems_fatal_code code
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
generate_events();
|
||||||
|
_Record_Fatal_dump_base64(source, always_set_to_false, code);
|
||||||
TEST_END();
|
TEST_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user