summaryrefslogtreecommitdiff
path: root/src/lib/dlt_user.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix macro code to use boolean value in while instruction (false) (#469)michael-methner2023-05-081-1/+1
| | | | | * Fix macro code to use boolean value in while instruction (false) Signed-off-by: Michael Methner <mmethner@de.adit-jv.com>
* dlt-user: fix crash with certain strings (#463)v2.18.9Alexander Mohr2023-04-171-9/+9
| | | | | | make sure that a string with exactly UINT16_MAX bytes does not overflow the dlt buffer Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* house-keeper: remove infinite wait (#438)Alexander Mohr2023-03-221-18/+44
| | | | | | | in case the house keeper thread does not start we should not wait indefinitely but abort the wait after a 10s Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* dlt-user: fix potential non closed socket in init/free (#435)Alexander Mohr2023-01-201-4/+39
| | | | | | | | | wait until the house keeper is up and running this makes sure dlt_init / dlt_free in close succession closes this thread properly. Otherwise we might keep the dlt socket open Check if the thread is running every 10ms Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* dlt-user: Fix crashes in dlt_free during dlt_init (#362)Alexander Mohr2023-01-111-83/+100
| | | | | | | | | If dlt_free is called while dlt_init is running, the dlt-user library crashes because the init and free where not thread safe. This commit introduces a new field dlt_user_initialising which will prevent entering dlt_free while dlt_init is running. Correctness is ensured by a unit test Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
* Fix for Resource and Memory Leak (#418)lti9hc2022-10-261-17/+24
| | | | | | | | | | | dlt_daemon_client.c Adding NULL check for tok dlt_daemon_offline_logstorage.c : Adding NULL check for application dlt_user.c : Fix for Memory Leak dlt-daemon.c : Fix for Resource Leak dlt_config_file_parser.c : Add termination character at the end of string dlt_offline_trace.c : Fix for Resource Leak Signed-off-by: Mvaradaraj2 manoj.varadaraj2@harman.com Co-authored-by: Le Tin <tin.le@vn.bosch.com>
* lib: Correct VARI usage in dlt_user_log_write_uint (#356)Saya Sugiura2021-12-101-14/+86
| | | | | Closes #352 Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* fix -Wformat issues reported by clang (#349)sebastienr2021-11-091-3/+3
| | | | | | | | | | | | | | * some previous dlt_vlog was using %lu specifier to display an uint64_t variable. However, this isn't portable as depending on the system you're targeting (32bits, 64bits, Linux, android, etc.), the uint64_t can be an unsigned long long. This prevents compilation on system where -Werror and -Wformat is activated coupled with a less tolerant compiler (e.g clang). Instead, PRIxN macros (e.g PRIu64 for uint64_t) are now used as specifier to ensure compatibility for each platforms * for bytes_read which is of type ssize_t, zd specifier is used as indicated in C99 standard * for st_size (from struct stat) which is of type off_t, POSIX says that it should be a signed integer. To be safe, we now use %jd specifier to ensure that it will fit correctly
* fixes compilation issue with clangSebastien RAILLET2021-10-131-2/+2
| | | | | | | * function atomic_compare_exchange_strong expect a pointer to an _Atomic type. dlt_user_initialised is now an atomic_bool * function dlt_set_filesize_max returned a DLT_LOG_ERROR which isn't a DltReturnValue. This commit replaces DLT_LOG_ERROR by DLT_RETURN_ERROR which is the expected return type Signed-off-by: Sebastien RAILLET <sebastien.raillet@marelli.com>
* lib: Fix wrong type alert from lgtmSaya Sugiura2021-10-051-2/+2
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* lib: generate dlt library internal log fileLe-Tin2021-10-051-0/+10
| | | | | | | Extern logging_mode and logging_handle variables from commom.c Reusing dlt_log_init() in cases dlt library internal log file is not opened and logging_mode is DLT_LOG_TO_FILE Signed-off-by: Le-Tin <Tin.Le@vn.bosch.com>
* dlt_user: Make dlt_init thread safeDarian Biastoch2021-10-051-5/+21
| | | | | | | | | | | | | This commit introduces the use of atomic_compare_exchange at beginning of both dlt_init functions. This function checks in an atomic way, if 'dlt_user_initialised' is 'false' (first run through dlt_init) and directly sets it 'true'. If a second thread also entered dlt-init at this point of time, its call of atomic_compare_exchange will return false and dlt_init will be immediately left due to that. This is only interesting for startup, because before each call of dlt_init, there is a check on 'dlt_user_initialised' that will fail for all later executions. Signed-off-by: Darian Biastoch <dbiastoch@de.adit-jv.com>
* lib: Add SOCK_CLOEXEC to socketSaya Sugiura2021-10-051-1/+1
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* lib: Add new interfaces with given bufferSaya Sugiura2021-10-051-30/+92
| | | | | | | | | | | | This commit adds new interfaces: - dlt_user_log_write_start_w_given_buffer(): accepts a log buffer as an input. - dlt_user_log_write_finish_w_given_buffer(): finalizes logging and send the message to corresponding output This is to reduce DLT API calls in DLT application as much as possible and avoid allocating dynamic memory within DLT library. The log buffer has to be prepared in DLT application in order to use these interfaces. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* lib: Add MaxFileSize handlingNarasimhaiah Suprathik (RBEI/ECF3)2021-10-051-6/+58
| | | | Signed-Off By: Saya Sugiura <ssugiura@jp.adit-jv.com>
* fix malformed printf format strings (#295)Radek Kaczorowski2021-10-051-9/+9
| | | Co-authored-by: Saya Sugiura <39760799+ssugiura@users.noreply.github.com>
* dlt_user: Use pthread_setname_np() if available (#326)Sebastian Lipponer2021-09-141-5/+13
| | | | | | | Use POSIX thread API to rename the housekeeper and segmented threads. The currently used prctl() function is Linux specific and in general not available on other platforms (e.g. QNX). Signed-off-by: Sebastian Lipponer <mail@sebastianlipponer.de>
* lib: Set TYLE to 1 for BOOL type (#320)TomiZet2021-08-301-2/+2
| | | According to AUTOSAR standard the TYLE for the BOOL type shall be set to 1. So I propose to initialize type_info variable for the BOOL type the same way as for uint8 type.
* dlt_user.c: fixing casting wrong typeDinh Cong Toan2021-08-061-3/+3
| | | | | | Fixing casting incorrect type Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* dlt_user: correct handling return valueDinh Cong Toan2021-06-301-14/+18
| | | | | | | | When processing dlt_user_log_send_log() function, message logs will be stored in internal buffer in error case. Then, the error value is needed to handle correctly before exiting. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* Add missing string functions (#309)Martin Willers2021-05-311-0/+24
| | | Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Make nonverbose mode non exclusive (#300)Martin Willers2021-05-171-38/+60
| | | | | | | | | | | | | | | | * Make Non-Verbose mode non-exclusive Switching to global Non-Verbose mode now does not force Verbose messages to also be sent as Non-Verbose ones anymore. That would not make any sense, because Verbose messages don't have a MessageId and thus are all getting the same MessageId of 65535. Instead, setting global "Non-Verbose" mode will allow both Verbose and Non-Verbose messages to be sent in a single session. The "Verbose-APIs" (e.g. dlt_user_log_write_start()) will then only write Verbose messages, whereas the "Non-Verbose APIs" (e.g. dlt_user_log_write_start_id()) will then only write Non-Verbose messages. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* fix bad funcion cast in dlt_user_log_out_error_handling (#294)Radek Kaczorowski2021-03-261-5/+5
| | | Co-authored-by: FIXED-TERM Kaczorowski Radoslaw (BSOT/PJ-ES21) <Fixed-Term.Radoslaw.Kaczorowski@bosch-softtec.com>
* Add verbose mode attribute handling (#292)Martin Willers2021-03-161-502/+357
| | | | | | dlt_user_log_write_*_attr() enables to writing these types, but also support adding "attributes" for them, i.e. a "name" and a "unit". Signed-off-by: Martin Willers <M.Willers@gmx.net>
* other: fix remaining conversion warningsDinh Cong Toan2021-01-061-12/+12
| | | | | | | | | | | - Converting datatype to the correct one. - As macro do not perform type-checking before, so these functions used it with different datatype could create a lot of conversion warnings. For this reason, these warnings could be consider as normal information and will not be fixed. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* library: fix conversion warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-57/+59
| | | | | | | | | | | | - Change the data type of variable 'size' in DltContextData struct (dlt_user.h.in). Variable 'size' was used repeated with function 'sizeof()' many time, so change type to 'size_t' can avoid a lot of warnings. - Adding temporary variable to calculate the datasize header (define in dlt_common.h) in 'dlt_common.c' file. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* gateway: fix compile warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-6/+6
| | | | | | | | | - Correct the data type of 'headersize' and 'datasize' variables in header 'dlt_common.h', then config those functions using this library. - Explicit the data type. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* libdlt: Use SIGUSR1 for thread on AndroidBui Nguyen Quoc Thanh2021-01-061-2/+33
| | | | | | | Since bionic does not support pthread_cancel(), try to terminate housekeeper thread via SIGUSR1. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* libdlt: Use poll to avoid CPU high loadBui Nguyen Quoc Thanh2021-01-061-29/+49
| | | | | | | | | | | | | Use timeout of polling as time for retry. In case of timeout or failure of polling, continue to close the socket. It could take some times to get the socket is shutdown So it means there could be some data available to read. Try to consume the data and poll the socket again. If read fails, time to close the socket then. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* libdlt: Flush all data in atexit_handlerSaya Sugiura2021-01-061-13/+43
| | | | | | | | | | | | | | | | | Current implementation had two issues: - Remaining data in startup_buffer wasn't able to be sent to daemon even dlt_user.timeout_at_exit_handler was set to more than 0 - Socket could be closed before all the data was sent to daemon To solve this: - dlt_unregister_app_flush_buffered_logs() won't clean appIDs if any data is remaining in startup_buffer. atexit_handler will be in charge of cleaning them - Socket won't be closed if data wasn't sent due to errno EAGAIN or EWOULDBLOCK. It retries until execution count reaches to maximum DLT_USER_MAX_RETRY_COUNT (1000 as default) Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: disable injection msg via env varBui Nguyen Quoc Thanh2021-01-061-3/+10
| | | | | | | | | | | | | | In order to disable injection message at dlt user, set DLT_DISABLE_INJECTION_MSG_AT_USER to any value. When injection message is disabled, libdlt won't poll any data from receiver. It means libdlt will ignore all data/messages from dlt-daemon. By default, variable is unset so that dlt users are able to handle data/messages from dlt-daemon. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* dlt_user: fix invalid poll timeoutAlexander Mohr2021-01-061-7/+2
| | | | | | | | | | | | | | The poll timeout was only set for fifo. TCP connections require this timeout as well. dlt_user_log_check_user_message also validated the file descriptor to be greater 0. Because 0 is a valid file descriptor this check has been changed to greater or equal 0. poll receives a timeout in milliseconds. The given paramter was in nanoseconds. An additional define takes adds the delay in miliseconds. Signed-off-by: Alexander Mohr <alexander.m.mohr@daimler.com>
* Add support for logging with VSOCK (#255)Martin Ejdestig2020-12-141-37/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
* dlt_user.c: fix the lack of DLT_NETWORK_TRACE_ENABLE definitionKHANH LUONG HONG DUY2020-08-031-0/+2
| | | | Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* network trace: Fix macro usageKHANH LUONG HONG DUY2020-07-061-1/+1
| | | | Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* libdlt: Relocate dltFifoBaseDir settingLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-3/+0
| | | | | | | Relocate the setting of dltFifoBaseDir variable from dlt_init() to dlt_check_envvar() Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* network trace: Add mqueue verificationSaya Sugiura2020-07-061-18/+29
| | | | | | | | | | There is some OS (e.g. Android) which doesn't support message queue. Since network trace uses it as IPC, we need to disable it if following calls are not available: mq_open, mq_close, mq_unlink, mq_send, mq_receive Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* relocation dlt_check_envvar() and update dlt_init() functionsLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-6/+6
| | | | Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* fix some gcc9 compiler warningsFelix Herrmann2020-07-061-31/+30
| | | | | | | | | Many stringop-truncation and stringop-overflow warnings are still there (so many). https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* Android: Enable Android buildFelix Herrmann2020-07-061-5/+31
| | | | | Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* correct errno usage in dlt_stop_threadsVo Trung Chi2020-07-061-11/+6
| | | | | | | | | | | Most pthreads functions return 0 on success, and an error number on failure. Note that the pthreads functions do not set errno. Refer to man page of pthreads for detail. So we have to use the return value as the error number instead of errno variable. Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* FIX: prevent usage of uninitialized message queue handleRudolf Svanda2020-05-181-1/+3
| | | | | | | | | Problem occurs always if application exits and dlt_user.dlt_segmented_queue_read_handle is not initialized. Warning "NWTSegmented: Error while reading queue" is printed on terminal on embedded devices. Signed-off-by: Rudolf Svanda <rudolf.svanda@globallogic.com>
* Minor optimizationMartin Willers2020-05-181-1/+1
| | | | | | | There is no need to have both an array and a pointer to it; just use the array directly. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Add functions for writing strings with known sizesMartin Willers2020-05-181-0/+16
| | | | Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Add helper function for writing strings with known sizesMartin Willers2020-05-181-3/+17
| | | | | | | | | | | This use case is common in C++ code nowadays, due to the usage of e.g. std::string_view, which does not provide a function for retrieving a null-terminated C-string, but which provides quick access to the string length via std::string_view::size(). Such use cases can now avoid an entirely unnecessary strlen() call. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* sys/poll.h: deprecate old sys/poll.h include header, now glibc/musl wants ↵Gianfranco Costamagna2020-01-271-1/+1
| | | | | | | | | poll.h being included directly. This fixes a build failure on musl systems with strict c hardening flags Signed-off-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it> Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
* dlt_user: init DltContextData before usePhong Tran2019-12-111-5/+4
| | | | | | | | for fixing the coverity warnings type Uninitialized scalar variable (UNINIT). Using uninitialized value log.use_timestamp when calling dlt_user_log_send_log. Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* Provide DLT_GET_APPID macro (#187) (#188)Vo Trung Chi2019-11-141-0/+11
| | | Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* libdlt: reattachment and improvement in dlt thread (#171)Vo Trung Chi2019-10-011-108/+59
| | | | | | | | | | | | | | | | | Improvement: housekeeper thread with poll - Change name receiver thread to housekeeper thread - Use poll() in housekeeper thread to get new received message from DLT Daemon. - Remove resend buffer inside of dlt_user_log_reattach_to_daemon() - Only try to resend buffer if fd is valid. This commit removes the event driven dlt_user_log_reattach_to_daemon() that is called e.g. by DLT_LOG. Now, only the DLT housekeeper thread handles the retrial to attach to daemon. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: Simon Herkenhoff <sherkenhoff@jp.adit-jv.com> Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* libdlt: calculate resend buffer memoryBui Nguyen Quoc Thanh2019-09-131-19/+29
| | | | | | | | | | | | | | The fix from commit 376bf6c is considered as a workaround. From now, the resend buffer size is calculated based on (dlt_user.log_buf_len + header_size) - Remove the macro DLT_USER_EXTRA_BUFF_SIZE - Use env_disable_extended_header_for_nonverbose instead of env_nonverbose_extended_header Related commit: 376bf6c Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE res… (#116) Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>