Changeset 31198c12 in mainline for kernel/generic/include/debug.h


Ignore:
Timestamp:
2010-05-21T19:04:58Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5f0e39e8
Parents:
7de7cde
Message:

get rid of get_ip() and HERE (the functionality is replaced more elegantly by program_counter_get())
don't print the "caller=%p" part on assertions, rely on the stack trace
print the stack trace also in the non-debug builds (this should be helpful when dealing with external bugreports)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/debug.h

    r7de7cde r31198c12  
    3737
    3838#include <panic.h>
    39 #include <arch/debug.h>
     39#include <symtab.h>
    4040
    4141#define CALLER  ((uintptr_t) __builtin_return_address(0))
    42 
    43 
    44 #ifndef HERE
    45 
    46 /** Current Instruction Pointer address */
    47 #define HERE ((uintptr_t *) 0)
    48 
    49 #endif /* HERE */
    50 
    5142
    5243#ifdef CONFIG_DEBUG
     
    6253 */
    6354#define ASSERT(expr) \
    64         if (!(expr)) { \
    65                 panic("Assertion failed (%s), caller=%p.", #expr, CALLER); \
    66         }
     55        do { \
     56                if (!(expr)) \
     57                        panic("Assertion failed (%s)", #expr); \
     58        } while (0)
    6759
    6860/** Debugging verbose ASSERT macro
     
    7870 */
    7971#define ASSERT_VERBOSE(expr, msg) \
    80         if (!(expr)) { \
    81                 panic("Assertion failed (%s, %s), caller=%p.", #expr, msg, CALLER); \
    82         }
     72        do { \
     73                if (!(expr)) \
     74                        panic("Assertion failed (%s, %s)", #expr, msg); \
     75        } while (0)
    8376
    8477#else /* CONFIG_DEBUG */
     
    8881
    8982#endif /* CONFIG_DEBUG */
    90 
    9183
    9284#ifdef CONFIG_LOG
     
    10092 */
    10193#define LOG(format, ...) \
    102         printf("%s() at %s:%u: " format "\n", __func__, __FILE__, \
    103             __LINE__, ##__VA_ARGS__);
     94        do { \
     95                printf("%s->%s() at %s:%u: " format "\n", symtab_fmt_name_lookup(CALLER), \
     96                    __func__, __FILE__, __LINE__, ##__VA_ARGS__); \
     97        } while (0)
    10498
    10599/** Extensive logging execute macro
     
    111105 */
    112106#define LOG_EXEC(fnc) \
    113         { \
    114                 printf("%s() at %s:%u: " #fnc "\n", __func__, __FILE__, \
    115                     __LINE__); \
     107        do { \
     108                printf("%s->%s() at %s:%u: " #fnc "\n", symtab_fmt_name_lookup(CALLER), \
     109                    __func__, __FILE__, __LINE__); \
    116110                fnc; \
    117         }
    118        
    119 #else /* CONFOG_LOG */
     111        } while (0)
     112
     113#else /* CONFIG_LOG */
    120114
    121115#define LOG(format, ...)
    122 #define LOG_EXEC(fnc) fnc
     116#define LOG_EXEC(fnc)     fnc
    123117
    124118#endif /* CONFOG_LOG */
Note: See TracChangeset for help on using the changeset viewer.