Changeset bd48f4c in mainline for kernel/generic/src/debug
- Timestamp:
- 2010-07-12T10:53:30Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bd11d3e
- Parents:
- c40e6ef (diff), bee2d4c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- kernel/generic/src/debug
- Files:
-
- 2 edited
- 2 moved
-
debug.c (moved) (moved from kernel/test/synch/rwlock2.c ) (2 diffs)
-
panic.c (moved) (moved from uspace/lib/c/include/limits.h ) (3 diffs)
-
stacktrace.c (modified) (2 diffs)
-
symtab.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/debug/debug.c
rc40e6ef rbd48f4c 1 1 /* 2 * Copyright (c) 20 01-2004 Jakub Jermar2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <test.h> 30 #include <arch.h> 31 #include <atomic.h> 29 /** @addtogroup genericdebug 30 * @{ 31 */ 32 33 /** 34 * @file 35 * @brief Kernel instrumentation functions. 36 */ 37 38 #ifdef CONFIG_TRACE 39 40 #include <debug.h> 41 #include <symtab.h> 42 #include <errno.h> 32 43 #include <print.h> 33 #include <proc/thread.h>34 44 35 #include <synch/rwlock.h> 36 37 #define READERS 50 38 #define WRITERS 50 39 40 static rwlock_t rwlock; 41 42 static void writer(void *arg) 45 void __cyg_profile_func_enter(void *fn, void *call_site) 43 46 { 44 TPRINTF("Trying to lock rwlock for writing....\n");47 const char *fn_sym = symtab_fmt_name_lookup((uintptr_t) fn); 45 48 46 rwlock_write_lock(&rwlock);47 rwlock_write_unlock(&rwlock);49 const char *call_site_sym; 50 uintptr_t call_site_off; 48 51 49 TPRINTF("Trying to lock rwlock for reading....\n"); 50 51 rwlock_read_lock(&rwlock); 52 rwlock_read_unlock(&rwlock); 52 if (symtab_name_lookup((uintptr_t) call_site, &call_site_sym, 53 &call_site_off) == EOK) 54 printf("%s+%" PRIp "->%s\n", call_site_sym, call_site_off, 55 fn_sym); 56 else 57 printf("->%s\n", fn_sym); 53 58 } 54 59 55 const char *test_rwlock2(void)60 void __cyg_profile_func_exit(void *fn, void *call_site) 56 61 { 57 thread_t *thrd;62 const char *fn_sym = symtab_fmt_name_lookup((uintptr_t) fn); 58 63 59 rwlock_initialize(&rwlock); 64 const char *call_site_sym; 65 uintptr_t call_site_off; 60 66 61 rwlock_read_lock(&rwlock); 62 rwlock_read_lock(&rwlock); 63 rwlock_read_lock(&rwlock); 64 rwlock_read_lock(&rwlock); 65 66 thrd = thread_create(writer, NULL, TASK, 0, "writer", false); 67 if (thrd) 68 thread_ready(thrd); 67 if (symtab_name_lookup((uintptr_t) call_site, &call_site_sym, 68 &call_site_off) == EOK) 69 printf("%s+%" PRIp "<-%s\n", call_site_sym, call_site_off, 70 fn_sym); 69 71 else 70 return "Could not create thread"; 71 72 thread_sleep(1); 73 74 rwlock_read_unlock(&rwlock); 75 rwlock_read_unlock(&rwlock); 76 rwlock_read_unlock(&rwlock); 77 rwlock_read_unlock(&rwlock); 78 79 thread_join(thrd); 80 thread_detach(thrd); 81 82 return NULL; 72 printf("<-%s\n", fn_sym); 83 73 } 74 75 #endif /* CONFIG_TRACE */ 76 77 /** @} 78 */ -
kernel/generic/src/debug/panic.c
rc40e6ef rbd48f4c 1 1 /* 2 * Copyright (c) 20 06 Josef Cejka2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc29 /** @addtogroup genericdebug 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef LIBC_LIMITS_H_ 36 #define LIBC_LIMITS_H_ 35 #include <panic.h> 36 #include <print.h> 37 #include <stacktrace.h> 38 #include <func.h> 39 #include <typedefs.h> 40 #include <mm/as.h> 41 #include <stdarg.h> 42 #include <interrupt.h> 37 43 38 #include <stdint.h> 39 #include <libarch/limits.h> 44 void panic_common(panic_category_t cat, istate_t *istate, int access, 45 uintptr_t address, const char *fmt, ...) 46 { 47 va_list args; 40 48 41 /* char */ 42 #define SCHAR_MIN MIN_INT8 43 #define SCHAR_MAX MAX_INT8 44 #define UCHAR_MIN MIN_UINT8 45 #define UCHAR_MAX MAX_UINT8 49 silent = false; 46 50 47 #ifdef __CHAR_UNSIGNED__ 48 #define CHAR_MIN UCHAR_MIN 49 #define CHAR_MAX UCHAR_MAX 50 #else 51 #define CHAR_MIN SCHAR_MIN 52 #define CHAR_MAX SCHAR_MAX 53 #endif 51 printf("\nKERNEL PANIC "); 52 if (CPU) 53 printf("ON cpu%d ", CPU->id); 54 printf("DUE TO "); 54 55 55 /* short int */ 56 #define SHRT_MIN MIN_INT16 57 #define SHRT_MAX MAX_INT16 58 #define USHRT_MIN MIN_UINT16 59 #define USHRT_MAX MAX_UINT16 56 va_start(args, fmt); 57 if (cat == PANIC_ASSERT) { 58 printf("A FAILED ASSERTION:\n"); 59 vprintf(fmt, args); 60 printf("\n"); 61 } else if (cat == PANIC_BADTRAP) { 62 printf("BAD TRAP %ld.\n", address); 63 } else if (cat == PANIC_MEMTRAP) { 64 printf("A BAD MEMORY ACCESS WHILE "); 65 if (access == PF_ACCESS_READ) 66 printf("LOADING FROM"); 67 else if (access == PF_ACCESS_WRITE) 68 printf("STORING TO"); 69 else if (access == PF_ACCESS_EXEC) 70 printf("BRANCHING TO"); 71 else 72 printf("REFERENCING"); 73 printf(" ADDRESS %p.\n", address); 74 } else { 75 printf("THE FOLLOWING REASON:\n"); 76 vprintf(fmt, args); 77 } 78 va_end(args); 60 79 61 /* int */ 62 #define INT_MIN MIN_INT32 63 #define INT_MAX MAX_INT32 64 #define UINT_MIN MIN_UINT32 65 #define UINT_MAX MAX_UINT32 80 printf("\n"); 66 81 67 /* long long int */ 68 #define LLONG_MIN MIN_INT64 69 #define LLONG_MAX MAX_INT64 70 #define ULLONG_MIN MIN_UINT64 71 #define ULLONG_MAX MAX_UINT64 82 if (istate) { 83 istate_decode(istate); 84 printf("\n"); 85 } 72 86 73 /* off64_t */ 74 #define OFF64_MIN MIN_INT64 75 #define OFF64_MAX MAX_INT64 76 77 /* aoff64_t */ 78 #define AOFF64_MIN MIN_UINT64 79 #define AOFF64_MAX MAX_UINT64 80 81 #endif 87 stack_trace(); 88 halt(); 89 } 82 90 83 91 /** @} -
kernel/generic/src/debug/stacktrace.c
rc40e6ef rbd48f4c 37 37 #include <typedefs.h> 38 38 #include <symtab.h> 39 #include <print.h> 39 40 40 41 #define STACK_FRAMES_MAX 20 … … 51 52 ops->symbol_resolve(pc, &symbol, &offset)) { 52 53 if (offset) 53 printf("%p: %s+% p()\n", fp, symbol, offset);54 printf("%p: %s+%" PRIp "()\n", fp, symbol, offset); 54 55 else 55 56 printf("%p: %s()\n", fp, symbol); -
kernel/generic/src/debug/symtab.c
rc40e6ef rbd48f4c 46 46 /** Get name of a symbol that seems most likely to correspond to address. 47 47 * 48 * @param addr Address.49 * @param name Place to store pointer to the symbol name.50 * @param offset Place to store offset from the symbol address.48 * @param addr Address. 49 * @param name Place to store pointer to the symbol name. 50 * @param offset Place to store offset from the symbol address. 51 51 * 52 52 * @return Zero on success or negative error code, ENOENT if not found, … … 83 83 /** Lookup symbol by address and format for display. 84 84 * 85 * Returns name of closest corresponding symbol, "Not found" if none exists 86 * or "N/A" if no symbol information is available. 85 * Returns name of closest corresponding symbol, 86 * "unknown" if none exists and "N/A" if no symbol 87 * information is available. 87 88 * 88 89 * @param addr Address. … … 101 102 return name; 102 103 case ENOENT: 103 return " Not found";104 return "unknown"; 104 105 default: 105 106 return "N/A";
Note:
See TracChangeset
for help on using the changeset viewer.
