diff options
-rw-r--r-- | include/dlt/dlt_user.h | 10 | ||||
-rw-r--r-- | include/dlt/dlt_user_macros.h | 8 | ||||
-rw-r--r-- | src/lib/dlt_user.c | 32 |
3 files changed, 43 insertions, 7 deletions
diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h index 326a733..a151e95 100644 --- a/include/dlt/dlt_user.h +++ b/include/dlt/dlt_user.h @@ -333,6 +333,16 @@ DltReturnValue dlt_user_log_write_uint32_formatted(DltContextData *log, uint32_t DltReturnValue dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t data, DltFormatType type); /** + * Write a pointer value architecture independent. + * dlt_user_log_write_start has to be called before adding any attributes to the log message. + * Finish sending log message by calling dlt_user_log_write_finish. + * @param log pointer to an object containing information about logging context data + * @param data void* parameter written into log message. + * @return Value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_ptr(DltContextData *log, void *data); + +/** * Write a int parameter into a DLT log message. * dlt_user_log_write_start has to be called before adding any attributes to the log message. * Finish sending log message by calling dlt_user_log_write_finish. diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h index e1e9104..e1968a2 100644 --- a/include/dlt/dlt_user_macros.h +++ b/include/dlt/dlt_user_macros.h @@ -331,13 +331,7 @@ * Architecture independent macro to print pointers */ #define DLT_PTR(PTR_VAR) \ - do { \ - if (sizeof(void *) < 8) { \ - DLT_HEX32((uintptr_t)PTR_VAR); \ - } else { \ - DLT_HEX64((uintptr_t)PTR_VAR); \ - } \ - } while(0) + (void)dlt_user_log_write_ptr(&log_local, PTR_VAR) /** * Trace network message diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 9870cf2..b3ee5da 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -1963,6 +1963,38 @@ DltReturnValue dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t return DLT_RETURN_OK; } +DltReturnValue dlt_user_log_write_ptr(DltContextData *log, void *data) +{ + if (log == NULL) + { + return DLT_RETURN_WRONG_PARAMETER; + } + + if (!dlt_user_initialised) + { + dlt_vlog(LOG_WARNING, "%user_initialised false\n", __FUNCTION__); + return DLT_RETURN_ERROR; + } + + switch(sizeof(void *)) + { + case 4: + return dlt_user_log_write_uint32_formatted(log, + (uintptr_t)data, + DLT_FORMAT_HEX32); + break; + case 8: + return dlt_user_log_write_uint64_formatted(log, + (uintptr_t)data, + DLT_FORMAT_HEX64); + break; + default: + ; /* skip */ + } + + return DLT_RETURN_OK; +} + DltReturnValue dlt_user_log_write_int(DltContextData *log, int data) { if (log == NULL) |