Changeset bd48f4c in mainline for kernel/generic/src/debug


Ignore:
Timestamp:
2010-07-12T10:53:30Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
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.
Message:

Merge mainline changes.

Location:
kernel/generic/src/debug
Files:
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/debug/debug.c

    rc40e6ef rbd48f4c  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    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>
    3243#include <print.h>
    33 #include <proc/thread.h>
    3444
    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)
     45void __cyg_profile_func_enter(void *fn, void *call_site)
    4346{
    44         TPRINTF("Trying to lock rwlock for writing....\n");
     47        const char *fn_sym = symtab_fmt_name_lookup((uintptr_t) fn);
    4548       
    46         rwlock_write_lock(&rwlock);
    47         rwlock_write_unlock(&rwlock);
     49        const char *call_site_sym;
     50        uintptr_t call_site_off;
    4851       
    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);
    5358}
    5459
    55 const char *test_rwlock2(void)
     60void __cyg_profile_func_exit(void *fn, void *call_site)
    5661{
    57         thread_t *thrd;
     62        const char *fn_sym = symtab_fmt_name_lookup((uintptr_t) fn);
    5863       
    59         rwlock_initialize(&rwlock);
     64        const char *call_site_sym;
     65        uintptr_t call_site_off;
    6066       
    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);
    6971        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);
    8373}
     74
     75#endif /* CONFIG_TRACE */
     76
     77/** @}
     78 */
  • kernel/generic/src/debug/panic.c

    rc40e6ef rbd48f4c  
    11/*
    2  * Copyright (c) 2006 Josef Cejka
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup genericdebug
    3030 * @{
    3131 */
     
    3333 */
    3434
    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>
    3743
    38 #include <stdint.h>
    39 #include <libarch/limits.h>
     44void panic_common(panic_category_t cat, istate_t *istate, int access,
     45    uintptr_t address, const char *fmt, ...)
     46{
     47        va_list args;
    4048
    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;
    4650
    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 ");
    5455
    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);
    6079
    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");
    6681
    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        }
    7286
    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}
    8290
    8391/** @}
  • kernel/generic/src/debug/stacktrace.c

    rc40e6ef rbd48f4c  
    3737#include <typedefs.h>
    3838#include <symtab.h>
     39#include <print.h>
    3940
    4041#define STACK_FRAMES_MAX        20
     
    5152                    ops->symbol_resolve(pc, &symbol, &offset)) {
    5253                        if (offset)
    53                                 printf("%p: %s+%p()\n", fp, symbol, offset);
     54                                printf("%p: %s+%" PRIp "()\n", fp, symbol, offset);
    5455                        else
    5556                                printf("%p: %s()\n", fp, symbol);
  • kernel/generic/src/debug/symtab.c

    rc40e6ef rbd48f4c  
    4646/** Get name of a symbol that seems most likely to correspond to address.
    4747 *
    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.
    5151 *
    5252 * @return Zero on success or negative error code, ENOENT if not found,
     
    8383/** Lookup symbol by address and format for display.
    8484 *
    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.
    8788 *
    8889 * @param addr Address.
     
    101102                return name;
    102103        case ENOENT:
    103                 return "Not found";
     104                return "unknown";
    104105        default:
    105106                return "N/A";
Note: See TracChangeset for help on using the changeset viewer.