automotive-dlt
|
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <syslog.h>
#include <semaphore.h>
#include <pthread.h>
#include <sys/time.h>
#include <math.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/uio.h>
#include <limits.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdbool.h>
#include "dlt_user.h"
#include "dlt_common.h"
#include "dlt_user_shared.h"
#include "dlt_user_shared_cfg.h"
#include "dlt_user_cfg.h"
Go to the source code of this file.
Data Structures | |
struct | s_segmented_data |
Macros | |
#define | DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL) |
#define | DLT_MAX_TRACE_SEGMENT_SIZE 1024 |
#define | DLT_MESSAGE_QUEUE_NAME "/dlt_message_queue" |
#define | DLT_DELAYED_RESEND_INDICATOR_PATTERN 0xFFFF |
Variables | |
static DltUser | dlt_user |
static bool | dlt_user_initialised = false |
static int | dlt_user_freeing = 0 |
static char | dlt_user_dir [NAME_MAX+1] |
static char | dlt_daemon_fifo [NAME_MAX+1] |
static char | str [DLT_USER_BUFFER_LENGTH] |
static sem_t | dlt_mutex |
static pthread_t | dlt_receiverthread_handle |
static int | atexit_registered = 0 |
static int | atfork_registered = 0 |
pthread_mutex_t | mq_mutex |
pthread_cond_t | mq_init_condition |
Definition in file dlt_user.c.
#define DLT_DELAYED_RESEND_INDICATOR_PATTERN 0xFFFF |
Definition at line 100 of file dlt_user.c.
Referenced by dlt_user_queue_resend(), and dlt_user_trace_network_segmented_thread().
#define DLT_LOG_FATAL_RESET_TRAP | ( | LOGLEVEL | ) |
Definition at line 75 of file dlt_user.c.
Referenced by dlt_user_log_write_start_id().
#define DLT_MAX_TRACE_SEGMENT_SIZE 1024 |
Definition at line 98 of file dlt_user.c.
Referenced by dlt_user_trace_network_segmented_start(), and dlt_user_trace_network_segmented_thread_segmenter().
#define DLT_MESSAGE_QUEUE_NAME "/dlt_message_queue" |
Definition at line 99 of file dlt_user.c.
Referenced by dlt_free(), and dlt_init_message_queue().
int check_buffer | ( | void | ) |
NW Trace related
Definition at line 2501 of file dlt_user.c.
References dlt_user_check_buffer().
Referenced by dlt_user_trace_network_segmented_segment().
|
static |
Definition at line 4646 of file dlt_user.c.
References dlt_free(), dlt_log_free(), and dlt_user_initialised.
Referenced by dlt_init().
|
static |
Definition at line 4629 of file dlt_user.c.
References dlt_free(), dlt_log(), dlt_log_free(), dlt_start_threads(), DLT_USER_BUFFER_LENGTH, dlt_user_initialised, and str.
Referenced by dlt_init().
|
static |
Definition at line 4624 of file dlt_user.c.
References dlt_stop_threads().
Referenced by dlt_init().
DltReturnValue dlt_init_message_queue | ( | void | ) |
Create the message queue. It must be newly created if old one was left by a crashing process.
Definition at line 378 of file dlt_user.c.
References dlt_lock_mutex(), dlt_log(), DLT_MESSAGE_QUEUE_NAME, DLT_RETURN_ERROR, DLT_RETURN_OK, DltUser::dlt_segmented_queue_read_handle, DltUser::dlt_segmented_queue_write_handle, dlt_unlock_mutex(), dlt_vnlog(), mq_init_condition, and mq_mutex.
Referenced by dlt_user_queue_resend(), and dlt_user_trace_network_segmented().
void dlt_lock_mutex | ( | pthread_mutex_t * | mutex | ) |
Definition at line 106 of file dlt_user.c.
References dlt_log(), DLT_USER_BUFFER_LENGTH, and str.
Referenced by dlt_init_message_queue(), and dlt_user_trace_network_segmented_thread().
|
static |
Definition at line 3930 of file dlt_user.c.
References DltUser::dlt_is_file, DltUser::dlt_log_handle, DLT_LOG_MAX, DLT_RETURN_ERROR, DLT_RETURN_OK, dlt_set_id(), DLT_TRACE_STATUS_MAX, dlt_user_log_out2(), DLT_USER_MESSAGE_APP_LL_TS, dlt_user_set_userheader(), dlt_vlog(), and NULL.
Referenced by dlt_set_application_ll_ts_limit().
|
static |
Definition at line 4544 of file dlt_user.c.
References dlt_log(), dlt_receiverthread_handle, DltUser::dlt_segmented_nwt_handle, dlt_user_receiverthread_function(), dlt_user_trace_network_segmented_thread(), and NULL.
Referenced by dlt_fork_parent_fork_handler(), and dlt_init().
|
static |
Definition at line 4567 of file dlt_user.c.
References dlt_log(), dlt_receiverthread_handle, DltUser::dlt_segmented_nwt_handle, DLT_USER_BUFFER_LENGTH, NULL, and str.
Referenced by dlt_fork_pre_fork_handler(), and dlt_free().
void dlt_unlock_mutex | ( | pthread_mutex_t * | mutex | ) |
Definition at line 121 of file dlt_user.c.
Referenced by dlt_init_message_queue(), and dlt_user_trace_network_segmented_thread().
|
static |
Definition at line 596 of file dlt_user.c.
References dlt_free(), dlt_log_free(), dlt_unregister_app(), dlt_user_atexit_blow_out_user_buffer(), dlt_user_initialised, dlt_vlog(), and dlt_vnlog().
Referenced by dlt_init_common().
|
static |
Definition at line 4080 of file dlt_user.c.
References DltReceiver::buf, DltReceiver::bytesRcvd, DltUserLogLevelChangedCallback::contextID, dlt_ll_ts_type::contextID, DLT_FD_INIT, DLT_ID_SIZE, DltUser::dlt_ll_ts, DltUser::dlt_ll_ts_num_entries, dlt_log(), dlt_receiver_move_to_begin(), dlt_receiver_receive_fd(), dlt_receiver_remove(), DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_SEM_FREE, DLT_SEM_LOCK, dlt_user_check_userheader(), DltUser::dlt_user_handle, DLT_USER_MESSAGE_INJECTION, DLT_USER_MESSAGE_LOG_LEVEL, DLT_USER_MESSAGE_LOG_STATE, DltUserInjectionCallback::injection_callback, dlt_ll_ts_type::injection_table, DltUserLogLevelChangedCallback::log_level, dlt_ll_ts_type::log_level, DltUserLogLevelChangedCallback::log_level_changed_callback, dlt_ll_ts_type::log_level_changed_callback, dlt_ll_ts_type::log_level_ptr, DltUser::log_state, dlt_ll_ts_type::nrcallbacks, NULL, DltUser::receiver, DltUserInjectionCallback::service_id, DltUserLogLevelChangedCallback::trace_status, dlt_ll_ts_type::trace_status, and dlt_ll_ts_type::trace_status_ptr.
Referenced by dlt_user_receiverthread_function().
|
static |
Definition at line 3332 of file dlt_user.c.
References dlt_init(), DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, dlt_user_initialised, dlt_vlog(), DltContextData::handle, and NULL.
Referenced by dlt_register_context_ll_ts(), dlt_register_injection_callback(), dlt_register_log_level_changed_callback(), dlt_unregister_context(), dlt_user_log_reattach_to_daemon(), dlt_user_log_write_start_id(), dlt_user_trace_network_segmented_end(), dlt_user_trace_network_segmented_segment(), dlt_user_trace_network_segmented_start(), and dlt_user_trace_network_truncated().
|
static |
Definition at line 4405 of file dlt_user.c.
References DltUser::appID, DltContextData::context_description, dlt_ll_ts_type::context_description, DltContext::contextID, dlt_ll_ts_type::contextID, dlt_daemon_fifo, DltUser::dlt_ll_ts, DltUser::dlt_ll_ts_num_entries, dlt_log(), DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_SEM_FREE, DLT_SEM_LOCK, dlt_set_id(), dlt_shm_init_client(), DLT_SHM_KEY, DLT_USER_BUFFER_LENGTH, dlt_user_log_init(), DLT_USER_LOG_LEVEL_NOT_SET, dlt_user_log_resend_buffer(), dlt_user_log_send_register_application(), dlt_user_log_send_register_context(), DLT_USER_TRACE_STATUS_NOT_SET, dlt_vnlog(), DltContextData::log_level, DltContext::log_level_pos, and DltContextData::trace_status.
Referenced by dlt_forward_msg(), dlt_user_atexit_blow_out_user_buffer(), and dlt_user_log_send_log().
|
static |
Definition at line 3407 of file dlt_user.c.
References DltUser::appID, DltContextData::args_num, DltContextData::buffer, DltContext::contextID, dlt_buffer_push3(), DLT_HTOBE_16, DLT_HTYP_MSBF, DLT_HTYP_PROTOCOL_VERSION1, DLT_HTYP_UEH, DLT_HTYP_WEID, DLT_HTYP_WSID, DLT_HTYP_WTMS, DltUser::dlt_is_file, DLT_IS_HTYP_UEH, dlt_log(), DltUser::dlt_log_handle, dlt_message_init(), dlt_message_set_extraparameters(), DLT_MSIN_MSTP_SHIFT, DLT_MSIN_MTIN, DLT_MSIN_MTIN_SHIFT, DLT_MSIN_VERB, DLT_PM_AUTOMATIC, DLT_PM_FORCE_OFF, DLT_PM_FORCE_ON, DLT_RETURN_BUFFER_FULL, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_PIPE_ERROR, DLT_RETURN_PIPE_FULL, DLT_RETURN_WRONG_PARAMETER, DLT_SEM_FREE, DLT_SEM_LOCK, dlt_set_id(), dlt_set_storageheader(), dlt_shm_free_client(), dlt_shm_push(), DLT_STANDARD_HEADER_EXTRA_SIZE, DLT_TYPE_CONTROL, DLT_TYPE_LOG, DLT_TYPE_NW_TRACE, dlt_uptime(), DLT_USER_BUFFER_LENGTH, dlt_user_initialised, dlt_user_log_out2(), dlt_user_log_out3(), dlt_user_log_reattach_to_daemon(), dlt_user_log_resend_buffer(), dlt_user_log_send_overflow(), DLT_USER_MESSAGE_LOG, DLT_USER_MESSAGE_LOG_SHM, dlt_user_print_msg(), dlt_user_queue_resend(), dlt_user_set_userheader(), dlt_vlog(), dlt_vnlog(), DltUser::ecuID, DltUser::enable_local_print, sDltMessage::extendedheader, DltContextData::handle, sDltMessage::headerbuffer, sDltMessage::headerextra, sDltMessage::headersize, DltUser::local_print_mode, DltContextData::log_level, DltContext::mcnt, NULL, DltUser::overflow_counter, DltContextData::size, sDltMessage::standardheader, DltUser::startup_buffer, sDltMessage::storageheader, DltContextData::trace_status, DltUser::use_extende_header_for_non_verbose, DltUser::verbose_mode, DltUser::with_ecu_id, DltUser::with_session_id, and DltUser::with_timestamp.
Referenced by dlt_user_log_write_finish(), dlt_user_trace_network_segmented_end(), dlt_user_trace_network_segmented_segment(), dlt_user_trace_network_segmented_start(), and dlt_user_trace_network_truncated().
|
static |
Definition at line 3988 of file dlt_user.c.
References DltUser::dlt_is_file, DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, dlt_user_log_out2(), DLT_USER_MESSAGE_LOG_MODE, DLT_USER_MODE_MAX, dlt_user_set_userheader(), and dlt_vlog().
Referenced by dlt_set_log_mode().
|
static |
Definition at line 4019 of file dlt_user.c.
References DltUser::dlt_is_file, DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, dlt_user_log_out2(), DLT_USER_MESSAGE_MARKER, and dlt_user_set_userheader().
Referenced by dlt_log_marker().
|
static |
Definition at line 4486 of file dlt_user.c.
References DltUser::appID, DltUser::dlt_is_file, DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, dlt_set_id(), dlt_user_log_out2(), DLT_USER_MESSAGE_OVERFLOW, dlt_user_set_userheader(), and DltUser::overflow_counter.
Referenced by dlt_forward_msg(), dlt_user_atexit_blow_out_user_buffer(), and dlt_user_log_send_log().
|
static |
Definition at line 3705 of file dlt_user.c.
References DltUser::appID, DltUser::application_description, dlt_buffer_push3(), DltUser::dlt_is_file, dlt_log(), DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_SEM_FREE, DLT_SEM_LOCK, dlt_set_id(), dlt_user_log_out3(), DLT_USER_MESSAGE_REGISTER_APPLICATION, dlt_user_queue_resend(), dlt_user_set_userheader(), NULL, and DltUser::startup_buffer.
Referenced by dlt_register_app(), and dlt_user_log_reattach_to_daemon().
|
static |
Definition at line 3804 of file dlt_user.c.
References DltUser::appID, DltContextData::context_description, DltContext::contextID, dlt_buffer_push3(), DltUser::dlt_is_file, dlt_log(), DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, DLT_SEM_FREE, DLT_SEM_LOCK, dlt_set_id(), dlt_user_log_out3(), DLT_USER_MESSAGE_REGISTER_CONTEXT, dlt_user_queue_resend(), dlt_user_set_userheader(), DltContextData::handle, DltContextData::log_level, DltContext::log_level_pos, NULL, DltUser::startup_buffer, and DltContextData::trace_status.
Referenced by dlt_register_context_ll_ts(), and dlt_user_log_reattach_to_daemon().
|
static |
Definition at line 3773 of file dlt_user.c.
References DltUser::appID, DltUser::dlt_is_file, DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, dlt_set_id(), dlt_user_log_out2(), DLT_USER_MESSAGE_UNREGISTER_APPLICATION, and dlt_user_set_userheader().
Referenced by dlt_unregister_app().
|
static |
Definition at line 3888 of file dlt_user.c.
References DltUser::appID, DltContext::contextID, DltUser::dlt_is_file, DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, dlt_set_id(), dlt_user_log_out2(), DLT_USER_MESSAGE_UNREGISTER_CONTEXT, dlt_user_set_userheader(), DltContextData::handle, and NULL.
Referenced by dlt_unregister_context().
|
static |
Definition at line 4039 of file dlt_user.c.
References DltContextData::buffer, sDltMessage::databuffer, sDltMessage::databuffersize, sDltMessage::datasize, DLT_BETOH_16, DLT_HTOBE_16, dlt_message_get_extraparameters(), dlt_message_print_ascii(), DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, DLT_USER_TEXT_LENGTH, NULL, DltContextData::size, and sDltMessage::standardheader.
Referenced by dlt_user_log_send_log().
|
static |
Ask segmented thread to try emptying the buffer soon. This will be freed in dlt_user_trace_network_segmented_thread
Definition at line 3351 of file dlt_user.c.
References DLT_DELAYED_RESEND_INDICATOR_PATTERN, dlt_init_message_queue(), dlt_log(), DltUser::dlt_log_handle, DLT_RETURN_ERROR, DLT_RETURN_OK, DltUser::dlt_segmented_queue_write_handle, dlt_vnlog(), NULL, and s_segmented_data::payload_len.
Referenced by dlt_forward_msg(), dlt_user_log_send_log(), dlt_user_log_send_register_application(), dlt_user_log_send_register_context(), and dlt_user_trace_network_segmented_thread().
|
static |
Referenced by dlt_start_threads().
void dlt_user_receiverthread_function | ( | __attribute__((unused)) void * | ptr | ) |
Definition at line 3312 of file dlt_user.c.
References dlt_log(), DLT_RETURN_OK, dlt_user_log_check_user_message(), and DLT_USER_RECEIVE_DELAY.
DltReturnValue dlt_user_trace_network_segmented_end | ( | uint32_t | id, |
DltContext * | handle, | ||
DltNetworkTraceType | nw_trace_type | ||
) |
Definition at line 2635 of file dlt_user.c.
References DltContextData::args_num, DltUser::dlt_ll_ts, DLT_NW_TRACE_MAX, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, DLT_TRACE_STATUS_ON, DLT_TYPE_NW_TRACE, dlt_user_log_init(), dlt_user_log_send_log(), dlt_user_log_write_string(), dlt_user_log_write_uint32(), dlt_vlog(), NULL, nw_trace_type, DltContextData::size, DltContextData::trace_status, and DltContext::trace_status_ptr.
Referenced by dlt_user_trace_network_segmented_thread().
DltReturnValue dlt_user_trace_network_segmented_segment | ( | uint32_t | id, |
DltContext * | handle, | ||
DltNetworkTraceType | nw_trace_type, | ||
int | sequence, | ||
uint16_t | payload_len, | ||
void * | payload | ||
) |
Definition at line 2581 of file dlt_user.c.
References DltContextData::args_num, check_buffer(), DltUser::dlt_ll_ts, DLT_NW_TRACE_MAX, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, DLT_TRACE_STATUS_ON, DLT_TYPE_NW_TRACE, dlt_user_log_init(), dlt_user_log_resend_buffer(), dlt_user_log_send_log(), dlt_user_log_write_raw(), dlt_user_log_write_string(), dlt_user_log_write_uint16(), dlt_user_log_write_uint32(), dlt_vlog(), NULL, nw_trace_type, DltContextData::size, DltContextData::trace_status, and DltContext::trace_status_ptr.
Referenced by dlt_user_trace_network_segmented_thread_segmenter().
DltReturnValue dlt_user_trace_network_segmented_start | ( | uint32_t * | id, |
DltContext * | handle, | ||
DltNetworkTraceType | nw_trace_type, | ||
uint16_t | header_len, | ||
void * | header, | ||
uint16_t | payload_len | ||
) |
Send the start of a segment chain. Returns DLT_RETURN_ERROR on failure
Definition at line 2513 of file dlt_user.c.
References DltContextData::args_num, DltUser::dlt_ll_ts, DLT_MAX_TRACE_SEGMENT_SIZE, DLT_NW_TRACE_MAX, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_WRONG_PARAMETER, DLT_TRACE_STATUS_ON, DLT_TYPE_NW_TRACE, dlt_user_log_init(), dlt_user_log_send_log(), dlt_user_log_write_raw(), dlt_user_log_write_string(), dlt_user_log_write_uint16(), dlt_user_log_write_uint32(), dlt_vlog(), NULL, nw_trace_type, DltContextData::size, DltContextData::trace_status, and DltContext::trace_status_ptr.
Referenced by dlt_user_trace_network_segmented().
|
static |
Definition at line 2673 of file dlt_user.c.
References data, DLT_DELAYED_RESEND_INDICATOR_PATTERN, dlt_lock_mutex(), dlt_log(), DLT_RETURN_BUFFER_FULL, DLT_RETURN_ERROR, DltUser::dlt_segmented_queue_read_handle, dlt_unlock_mutex(), dlt_user_log_resend_buffer(), dlt_user_queue_resend(), dlt_user_trace_network_segmented_end(), dlt_user_trace_network_segmented_thread_segmenter(), s_segmented_data::handle, s_segmented_data::header, s_segmented_data::id, mq_init_condition, mq_mutex, NULL, s_segmented_data::nw_trace_type, s_segmented_data::payload, and s_segmented_data::payload_len.
Referenced by dlt_start_threads().
|
static |
Definition at line 2735 of file dlt_user.c.
References dlt_log(), DLT_MAX_TRACE_SEGMENT_SIZE, DLT_RETURN_BUFFER_FULL, DLT_RETURN_ERROR, dlt_user_trace_network_segmented_segment(), s_segmented_data::handle, s_segmented_data::id, NULL, s_segmented_data::nw_trace_type, s_segmented_data::payload, and s_segmented_data::payload_len.
Referenced by dlt_user_trace_network_segmented_thread().
|
static |
Definition at line 91 of file dlt_user.c.
Referenced by dlt_init_common().
|
static |
Definition at line 94 of file dlt_user.c.
Referenced by dlt_init().
|
static |
Definition at line 83 of file dlt_user.c.
Referenced by dlt_init(), and dlt_user_log_reattach_to_daemon().
|
static |
Definition at line 87 of file dlt_user.c.
Referenced by dlt_free(), and dlt_init_common().
|
static |
Definition at line 88 of file dlt_user.c.
Referenced by dlt_start_threads(), and dlt_stop_threads().
|
static |
Definition at line 78 of file dlt_user.c.
|
static |
Definition at line 82 of file dlt_user.c.
Referenced by dlt_free(), and dlt_init().
|
static |
Definition at line 80 of file dlt_user.c.
Referenced by dlt_free(), and dlt_init().
|
static |
Definition at line 79 of file dlt_user.c.
Referenced by dlt_disable_local_print(), dlt_enable_local_print(), dlt_fork_child_fork_handler(), dlt_fork_parent_fork_handler(), dlt_free(), dlt_init(), dlt_init_common(), dlt_init_file(), dlt_log_marker(), dlt_nonverbose_mode(), dlt_register_app(), dlt_register_context(), dlt_set_application_ll_ts_limit(), dlt_set_log_mode(), dlt_set_resend_timeout_atexit(), dlt_unregister_app(), dlt_use_extended_header_for_non_verbose(), dlt_user_atexit_handler(), dlt_user_log_init(), dlt_user_log_send_log(), dlt_user_log_write_bool(), dlt_user_log_write_float32(), dlt_user_log_write_float64(), dlt_user_log_write_int(), dlt_user_log_write_int16(), dlt_user_log_write_int32(), dlt_user_log_write_int64(), dlt_user_log_write_int8(), dlt_user_log_write_ptr(), dlt_user_log_write_raw_formatted(), dlt_user_log_write_string(), dlt_user_log_write_uint(), dlt_user_log_write_uint16(), dlt_user_log_write_uint16_formatted(), dlt_user_log_write_uint32(), dlt_user_log_write_uint32_formatted(), dlt_user_log_write_uint64(), dlt_user_log_write_uint64_formatted(), dlt_user_log_write_uint8(), dlt_user_log_write_uint8_formatted(), dlt_user_log_write_utf8_string(), dlt_verbose_mode(), dlt_with_ecu_id(), dlt_with_session_id(), and dlt_with_timestamp().
pthread_cond_t mq_init_condition |
Definition at line 104 of file dlt_user.c.
Referenced by dlt_free(), dlt_init(), dlt_init_message_queue(), and dlt_user_trace_network_segmented_thread().
pthread_mutex_t mq_mutex |
Definition at line 103 of file dlt_user.c.
Referenced by dlt_free(), dlt_init(), dlt_init_message_queue(), and dlt_user_trace_network_segmented_thread().
|
static |
Definition at line 85 of file dlt_user.c.
Referenced by dlt_fork_parent_fork_handler(), dlt_init_common(), dlt_lock_mutex(), and dlt_stop_threads().