diff --git a/core/include/debug.h b/core/include/debug.h index 30caf45eee..1f4a9a8207 100644 --- a/core/include/debug.h +++ b/core/include/debug.h @@ -14,15 +14,10 @@ * @brief Debug-header * * @details If *ENABLE_DEBUG* is defined inside an implementation file, all - * calls to ::DEBUG and ::DEBUGF* will work the same as *printf* - * and output the given information to stdout. If *ENABLE_DEBUG* - * is not defined, all calls to ::DEBUG and ::DEBUGF will be - * ignored. + * calls to ::DEBUG will work the same as *printf* and output the + * given information to stdout. If *ENABLE_DEBUG* is not defined, + * all calls to ::DEBUG will be ignored. * - * In addition to just printing the given information ::DEBUGF - * will further print extended debug information about the current - * thread and function. - * * @author Kaspar Schleiser */ @@ -40,8 +35,7 @@ extern "C" { /** * @def ENABLE_DEBUG * @brief This macro can be defined as 0 or other on a file-based level. - * If ENABLE_DEBUG is 0 @ref DEBUG() and @ref DEBUGF() will generate - * no output if not they will generate output. + * @ref DEBUG() will generate output only if ENABLE_DEBUG is non-zero. */ /** @@ -100,22 +94,8 @@ extern "C" { * @note Another name for ::DEBUG_PRINT */ #define DEBUG(...) DEBUG_PRINT(__VA_ARGS__) -/** - * @def DEBUGF - * - * @brief Print extended debug information about the current thread and - * function to stdout - */ -#define DEBUGF(...) \ - do { \ - DEBUG_PRINT("DEBUG(%s): %s:%d in %s: ", \ - sched_active_thread ? sched_active_thread->name : "NO THREAD", \ - __FILE__, __LINE__, DEBUG_FUNC); \ - DEBUG_PRINT(__VA_ARGS__); \ - } while (0) #else #define DEBUG(...) -#define DEBUGF(...) #endif /** @} */ diff --git a/core/msg.c b/core/msg.c index 123ba95cb5..14945325b6 100644 --- a/core/msg.c +++ b/core/msg.c @@ -94,17 +94,17 @@ static int _msg_send(msg_t *m, kernel_pid_t target_pid, bool block, unsigned sta } DEBUG("msg_send() %s:%i: Sending from %" PRIkernel_pid " to %" PRIkernel_pid - ". block=%i src->state=%i target->state=%i\n", __FILE__, __LINE__, - sched_active_pid, target_pid, + ". block=%i src->state=%i target->state=%i\n", RIOT_FILE_RELATIVE, + __LINE__, sched_active_pid, target_pid, block, sched_active_thread->status, target->status); if (target->status != STATUS_RECEIVE_BLOCKED) { DEBUG("msg_send() %s:%i: Target %" PRIkernel_pid " is not RECEIVE_BLOCKED.\n", - __FILE__, __LINE__, target_pid); + RIOT_FILE_RELATIVE, __LINE__, target_pid); if (queue_msg(target, m)) { DEBUG("msg_send() %s:%i: Target %" PRIkernel_pid - " has a msg_queue. Queueing message.\n", __FILE__, + " has a msg_queue. Queueing message.\n", RIOT_FILE_RELATIVE, __LINE__, target_pid); restoreIRQ(state); if (sched_active_thread->status == STATUS_REPLY_BLOCKED) { diff --git a/cpu/lm4f120/include/cpu_conf.h b/cpu/lm4f120/include/cpu_conf.h index ad3e6bfc92..b68c366e01 100644 --- a/cpu/lm4f120/include/cpu_conf.h +++ b/cpu/lm4f120/include/cpu_conf.h @@ -35,7 +35,6 @@ extern "C" { #include "hw_types.h" #include "cortex-m4-def.h" #include "stellaris_periph/cpu.h" -#include "stellaris_periph/debug.h" #include "stellaris_periph/interrupt.h" #include "stellaris_periph/sysctl.h" #include "stellaris_periph/adc.h" diff --git a/cpu/lm4f120/periph/uart.c b/cpu/lm4f120/periph/uart.c index 73accb9301..283650b50b 100644 --- a/cpu/lm4f120/periph/uart.c +++ b/cpu/lm4f120/periph/uart.c @@ -18,6 +18,7 @@ #include +#include "assert.h" #include "cpu.h" #include "sched.h" #include "thread.h" @@ -79,7 +80,7 @@ static const unsigned long g_ulUARTInt[3] = int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, uart_tx_cb_t tx_cb, void *arg) { /* Check the arguments */ - ASSERT(uart == 0); + assert(uart == 0); /* Check to make sure the UART peripheral is present */ if(!ROM_SysCtlPeripheralPresent(SYSCTL_PERIPH_UART0)){ return -1; diff --git a/cpu/lpc2387/lpc2387-adc.c b/cpu/lpc2387/lpc2387-adc.c index 75e8514bfd..169fb42865 100644 --- a/cpu/lpc2387/lpc2387-adc.c +++ b/cpu/lpc2387/lpc2387-adc.c @@ -134,7 +134,7 @@ uint16_t adc_read(uint8_t channel) } adc_data = (regVal >> 6) & 0x3FF; - DEBUG("%s, %d: %lu\n", __FILE__, __LINE__, t1); - DEBUG("%s, %d: %lu\n", __FILE__, __LINE__, t2); + DEBUG("%s, %d: %lu\n", RIOT_FILE_RELATIVE, __LINE__, t1); + DEBUG("%s, %d: %lu\n", RIOT_FILE_RELATIVE, __LINE__, t2); return (uint16_t) adc_data; /* return A/D conversion value */ } diff --git a/cpu/lpc2387/mci/lpc2387-mci.c b/cpu/lpc2387/mci/lpc2387-mci.c index 0d1fa524c9..b358b8e42b 100644 --- a/cpu/lpc2387/mci/lpc2387-mci.c +++ b/cpu/lpc2387/mci/lpc2387-mci.c @@ -558,7 +558,7 @@ DSTATUS MCI_initialize(void) do { /* Wait while card is busy state (use ACMD41 with HCS bit) */ /* This loop will take a time. Insert wai_tsk(1) here for multitask envilonment. */ if (xtimer_now() > start + 1000000/*!Timer[0]*/) { - DEBUG("%s, %d: Timeout #1\n", __FILE__, __LINE__); + DEBUG("%s, %d: Timeout #1\n", RIOT_FILE_RELATIVE, __LINE__); goto di_fail; } } @@ -579,12 +579,12 @@ DSTATUS MCI_initialize(void) } do { /* Wait while card is busy state (use ACMD41 or CMD1) */ - DEBUG("%s, %d: %lX\n", __FILE__, __LINE__, resp[0]); + DEBUG("%s, %d: %lX\n", RIOT_FILE_RELATIVE, __LINE__, resp[0]); /* This loop will take a time. Insert wai_tsk(1) here for multitask envilonment. */ if (xtimer_now() > start + 1000000/*!Timer[0]*/) { DEBUG("now: %lu, started at: %lu\n", xtimer_now(), start); - DEBUG("%s, %d: Timeout #2\n", __FILE__, __LINE__); + DEBUG("%s, %d: Timeout #2\n", RIOT_FILE_RELATIVE, __LINE__); goto di_fail; } } @@ -597,7 +597,8 @@ DSTATUS MCI_initialize(void) /*---- Card is 'ready' state ----*/ if (!send_cmd(CMD2, 0, 2, resp)) { - DEBUG("%s, %d: Failed entering ident state", __FILE__, __LINE__); + DEBUG("%s, %d: Failed entering ident state", RIOT_FILE_RELATIVE, + __LINE__); goto di_fail; /* Enter ident state */ } @@ -609,7 +610,7 @@ DSTATUS MCI_initialize(void) if (ty & CT_SDC) { /* SDC: Get generated RCA and save it */ if (!send_cmd(CMD3, 0, 1, resp)) { - DEBUG("%s, %d: Failed generating RCA\n", __FILE__, __LINE__); + DEBUG("%s, %d: Failed generating RCA\n", RIOT_FILE_RELATIVE, __LINE__); goto di_fail; } diff --git a/cpu/msp430-common/include/assert.h b/cpu/msp430-common/include/assert.h index 81bc8ec53c..eb2219d948 100644 --- a/cpu/msp430-common/include/assert.h +++ b/cpu/msp430-common/include/assert.h @@ -51,8 +51,8 @@ extern "C" { #ifndef NDEBUG # define assert(assertion) \ if (!(assertion)) { \ - printf("%s:%d: %s: Assertion '%s' failed", __FILE__, __LINE__, \ - ASSERT_FUNC, #assertion); \ + printf("%s:%d: %s: Assertion '%s' failed", RIOT_FILE_RELATIVE, \ + __LINE__, ASSERT_FUNC, #assertion); \ abort(); \ } #else diff --git a/cpu/stellaris_common/include/stellaris_periph/debug.h b/cpu/stellaris_common/include/stellaris_periph/debug.h deleted file mode 100644 index 19b36a8c9f..0000000000 --- a/cpu/stellaris_common/include/stellaris_periph/debug.h +++ /dev/null @@ -1,76 +0,0 @@ -//***************************************************************************** -// -// debug.h - Macros for assisting debug of the driver library. -// -// Copyright (c) 2006-2012 Texas Instruments Incorporated. All rights reserved. -// Software License Agreement -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 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. -// -// Neither the name of Texas Instruments Incorporated nor the names of -// its contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// 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. -// -// This is part of revision 9453 of the Stellaris Peripheral Driver Library. -// -//***************************************************************************** - -#ifndef __DEBUG_H__ -#define __DEBUG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//***************************************************************************** -// -// Prototype for the function that is called when an invalid argument is passed -// to an API. This is only used when doing a DEBUG build. -// -//***************************************************************************** -extern void __error__(char *pcFilename, unsigned long ulLine); - -//***************************************************************************** -// -// The ASSERT macro, which does the actual assertion checking. Typically, this -// will be for procedure arguments. -// -//***************************************************************************** -#ifdef DEBUG -#define ASSERT(expr) { \ - if(!(expr)) \ - { \ - __error__(__FILE__, __LINE__); \ - } \ - } -#else -#define ASSERT(expr) -#endif - -#ifdef __cplusplus -} -#endif - -#endif // __DEBUG_H__ diff --git a/sys/crypto/3des.c b/sys/crypto/3des.c index c69443af4f..beff5644dc 100644 --- a/sys/crypto/3des.c +++ b/sys/crypto/3des.c @@ -285,7 +285,8 @@ int tripledes_encrypt(const cipher_context_t *context, const uint8_t *plain, uin uint32_t work[2]; if (!key) { - DEBUGF("[ERROR] Could NOT malloc space for the des3_key_s struct.\r\n"); + DEBUG("%s:%d in %s: [ERROR] Could NOT malloc space for the des3_key_s struct.\r\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); return -1; } @@ -293,7 +294,8 @@ int tripledes_encrypt(const cipher_context_t *context, const uint8_t *plain, uin res = des3_key_setup(context->context, key); if (res < 0) { - DEBUGF("[ERROR] des3_key_setup failed with Code %i\r\n", res); + DEBUG("%s:%d in %s: [ERROR] des3_key_setup failed with Code %i\r\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC, res); free(key); return -2; } @@ -318,7 +320,8 @@ int tripledes_decrypt(const cipher_context_t *context, const uint8_t *crypt, uin uint32_t work[2]; if (!key) { - DEBUGF("[ERROR] Could NOT malloc space for the des3_key_s struct.\r\n"); + DEBUG("%s:%d in %s: [ERROR] Could NOT malloc space for the des3_key_s struct.\r\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); return -1; } @@ -326,7 +329,8 @@ int tripledes_decrypt(const cipher_context_t *context, const uint8_t *crypt, uin res = des3_key_setup(context->context, key); if (res < 0) { - DEBUGF("[ERROR] des3_key_setup failed with Code %i\r\n", res); + DEBUG("%s:%d in %s: [ERROR] des3_key_setup failed with Code %i\r\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC, res); free(key); return -2; } diff --git a/sys/crypto/twofish.c b/sys/crypto/twofish.c index ca2a57b0e1..2507ca82b9 100644 --- a/sys/crypto/twofish.c +++ b/sys/crypto/twofish.c @@ -540,8 +540,9 @@ static int twofish_setup_key(twofish_context_t *ctx, const uint8_t *key, uint8_t /* Check key length. */ if (((keylen - 16) | 16) != 16) { - DEBUGF("[ERROR] invalid key-length!\r\n"); - return -1;//GPG_ERR_INV_KEYLEN; + DEBUG("%s:%d in %s: [ERROR] invalid key-length!\r\n", RIOT_FILE_RELATIVE, + __LINE__, DEBUG_FUNC); + return -1; } @@ -660,15 +661,16 @@ int twofish_encrypt(const cipher_context_t *context, const uint8_t *in, uint8_t twofish_context_t *ctx = malloc(sizeof(twofish_context_t)); if (!ctx) { - DEBUGF("[ERROR] Could NOT malloc space for the twofish_context_t \ - struct.\r\n"); + DEBUG("%s:%d in %s: [ERROR] Could NOT malloc space for the twofish_context_t \ + struct.\r\n", RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); return -1; } res = twofish_setup_key(ctx, context->context, TWOFISH_KEY_SIZE); if (res < 0) { - DEBUGF("[ERROR] twofish_setKey failed with Code %i\r\n", res); + DEBUG("%s:%d in %s: [ERROR] twofish_setKey failed with Code %i\r\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC, res); free(ctx); return -2; } @@ -716,15 +718,16 @@ int twofish_decrypt(const cipher_context_t *context, const uint8_t *in, uint8_t twofish_context_t *ctx = malloc(sizeof(twofish_context_t)); if (!ctx) { - DEBUGF("[ERROR] Could NOT malloc space for the twofish_context_t \ - struct.\r\n"); + DEBUG("%s:%d in %s: [ERROR] Could NOT malloc space for the twofish_context_t \ + struct.\r\n", RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); return -1; } res = twofish_setup_key(ctx, context->context, TWOFISH_KEY_SIZE); if (res < 0) { - DEBUGF("[ERROR] twofish_setKey failed with Code %i\r\n", res); + DEBUG("%s:%d in %s: [ERROR] twofish_setKey failed with Code %i\r\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC, res); free(ctx); return -2; } diff --git a/sys/include/embUnit/AssertImpl.h b/sys/include/embUnit/AssertImpl.h index 2694db82cd..ca644b94a1 100644 --- a/sys/include/embUnit/AssertImpl.h +++ b/sys/include/embUnit/AssertImpl.h @@ -49,7 +49,7 @@ void assertImplementationCStr(const char *expected,const char *actual, long line __typeof__(expected_) ____expected__ = expected_; \ __typeof__(actual_) ____actual__ = actual_; \ if (stdimpl_strcmp(____expected__, ____actual__) != 0) { \ - assertImplementationCStr(____expected__, ____actual__, __LINE__, __FILE__); \ + assertImplementationCStr(____expected__, ____actual__, __LINE__, RIOT_FILE_RELATIVE); \ return; \ } \ } while (0) @@ -59,7 +59,8 @@ void assertImplementationCStr(const char *expected,const char *actual, long line long long ____expected__ = (long long) (expected_); \ long long ____actual__ = (long long) (actual_); \ if (____expected__ != ____actual__) { \ - assertImplementationLongLong(____expected__, ____actual__, __LINE__, __FILE__); \ + assertImplementationLongLong(____expected__, ____actual__, \ + __LINE__, RIOT_FILE_RELATIVE); \ return; \ } \ } while (0) @@ -91,7 +92,7 @@ void assertImplementationCStr(const char *expected,const char *actual, long line #define TEST_FAIL(message) \ do { \ - addFailure((message), __LINE__, __FILE__); \ + addFailure((message), __LINE__, RIOT_FILE_RELATIVE); \ return; \ } while (0) diff --git a/sys/net/routing/nhdp/iib_table.c b/sys/net/routing/nhdp/iib_table.c index 599d1ed183..22769eace9 100644 --- a/sys/net/routing/nhdp/iib_table.c +++ b/sys/net/routing/nhdp/iib_table.c @@ -194,7 +194,8 @@ void iib_fill_wr_addresses(kernel_pid_t if_pid, struct rfc5444_writer *wr) default: /* Should not happen */ - DEBUGF("[WARNING] Unknown link tuple status\n"); + DEBUG("%s:%d in %s: [WARNING] Unknown link tuple status\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); break; } } @@ -260,7 +261,8 @@ void iib_process_metric_msg(iib_link_set_entry_t *ls_entry, uint64_t int_time) /* NHDP_METRIC is not set properly */ (void)ls_entry; (void)int_time; - DEBUGF("[WARNING] Unknown NHDP_METRIC setting\n"); + DEBUG("%s:%d in %s: [WARNING] Unknown NHDP_METRIC setting\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); #endif } @@ -332,7 +334,8 @@ void iib_process_metric_pckt(iib_link_set_entry_t *ls_entry, uint32_t metric_out (void)ls_entry; (void)metric_out; (void)seq_no; - DEBUGF("[WARNING] Unknown NHDP_METRIC setting\n"); + DEBUG("%s:%d in %s: [WARNING] Unknown NHDP_METRIC setting\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); #endif } @@ -344,7 +347,8 @@ void iib_process_metric_refresh(void) dat_metric_refresh(); #else /* NHDP_METRIC is not set properly */ - DEBUGF("[WARNING] Unknown NHDP_METRIC setting\n"); + DEBUG("%s:%d in %s: [WARNING] Unknown NHDP_METRIC setting\n", + RIOT_FILE_RELATIVE, __LINE__, DEBUG_FUNC); #endif } diff --git a/sys/trickle/trickle.c b/sys/trickle/trickle.c index 877fe7c291..7877c6287b 100644 --- a/sys/trickle/trickle.c +++ b/sys/trickle/trickle.c @@ -37,10 +37,12 @@ void trickle_interval(trickle_t *trickle) DEBUG("TRICKLE new Interval %" PRIu32 "\n", trickle->I); if (trickle->I == 0) { - DEBUGF("[WARNING] Interval was 0\n"); + DEBUG("%s:%d in %s: [WARNING] Interval was 0\n", RIOT_FILE_RELATIVE, + __LINE__, DEBUG_FUNC); if (trickle->Imax == 0) { - DEBUGF("[WARNING] Imax == 0\n"); + DEBUG("%s:%d in %s: [WARNING] Imax == 0\n", RIOT_FILE_RELATIVE, + __LINE__, DEBUG_FUNC); } trickle->I = (trickle->Imin << trickle->Imax);