Changes in / [2314381:bb0d3d24] in mainline


Ignore:
Files:
7 added
25 deleted
35 edited

Legend:

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

    r2314381 rbb0d3d24  
    2727 */
    2828
    29 /** @addtogroup generic
     29/** @addtogroup generic 
    3030 * @{
    3131 */
     
    8383UDEBUG_M_ARGS_READ,
    8484
    85 /** Read thread's userspace register state (istate_t).
    86  *
    87  * - ARG2 - thread identification
    88  * - ARG3 - destination address in the caller's address space
    89  *
    90  * or, on error, retval will be
    91  * - ENOENT - thread does not exist
    92  * - EBUSY - register state not available
    93  */
    94 UDEBUG_M_REGS_READ,
    95 
    9685/** Read the list of the debugged tasks's threads.
    9786 *
     
    10796 */
    10897UDEBUG_M_THREAD_READ,
    109 
    110 /** Read the name of the debugged task.
    111  *
    112  * - ARG2 - destination address in the caller's address space
    113  * - ARG3 - size of receiving buffer in bytes
    114  *
    115  * The kernel fills the buffer with a non-terminated string.
    116  *
    117  * - ARG2 - number of bytes that were actually copied
    118  * - ARG3 - number of bytes of the complete data
    119  *
    120  */
    121 UDEBUG_M_NAME_READ,
    12298
    12399/** Read the list of the debugged task's address space areas.
     
    146122} udebug_method_t;
    147123
    148 
     124                               
    149125typedef enum {
    150126        UDEBUG_EVENT_FINISHED = 1,      /**< Debuging session has finished */
     
    242218
    243219int udebug_task_cleanup(struct task *ta);
    244 void udebug_thread_fault(void);
    245220
    246221#endif
  • kernel/generic/include/udebug/udebug_ops.h

    r2314381 rbb0d3d24  
    4747int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
    4848    size_t *needed);
    49 int udebug_name_read(char **data, size_t *data_size);
    5049int udebug_args_read(thread_t *t, void **buffer);
    51 
    52 int udebug_regs_read(thread_t *t, void **buffer);
    5350
    5451int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer);
  • kernel/generic/src/interrupt/interrupt.c

    r2314381 rbb0d3d24  
    134134        printf("\n");
    135135
    136         /*
    137          * Userspace can subscribe for FAULT events to take action
    138          * whenever a thread faults. (E.g. take a dump, run a debugger).
    139          * The notification is always available, but unless Udebug is enabled,
    140          * that's all you get.
    141          */
    142136        if (event_is_subscribed(EVENT_FAULT)) {
    143                 /* Notify the subscriber that a fault occurred. */
    144137                event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
    145138                    UPPER32(TASK->taskid), (unative_t) THREAD);
     139        }
    146140
    147141#ifdef CONFIG_UDEBUG
    148                 /* Wait for a debugging session. */
    149                 udebug_thread_fault();
    150 #endif
    151         }
     142        /* Wait until a debugger attends to us. */
     143        mutex_lock(&THREAD->udebug.lock);
     144        while (!THREAD->udebug.active)
     145                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
     146        mutex_unlock(&THREAD->udebug.lock);
     147
     148        udebug_stoppable_begin();
     149        udebug_stoppable_end();
     150
     151        /* Make sure the debugging session is over before proceeding. */
     152        mutex_lock(&THREAD->udebug.lock);
     153        while (THREAD->udebug.active)
     154                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
     155        mutex_unlock(&THREAD->udebug.lock);
     156#endif
    152157
    153158        task_kill(task->taskid);
  • kernel/generic/src/udebug/udebug.c

    r2314381 rbb0d3d24  
    460460}
    461461
    462 /** Wait for debugger to handle a fault in this thread.
    463  *
    464  * When a thread faults and someone is subscribed to the FAULT kernel event,
    465  * this function is called to wait for a debugging session to give userspace
    466  * a chance to examine the faulting thead/task. When the debugging session
    467  * is over, this function returns (so that thread/task cleanup can continue).
    468  */
    469 void udebug_thread_fault(void)
    470 {
    471         udebug_stoppable_begin();
    472 
    473         /* Wait until a debugger attends to us. */
    474         mutex_lock(&THREAD->udebug.lock);
    475         while (!THREAD->udebug.active)
    476                 condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    477         mutex_unlock(&THREAD->udebug.lock);
    478 
    479         /* Make sure the debugging session is over before proceeding. */
    480         mutex_lock(&THREAD->udebug.lock);
    481         while (THREAD->udebug.active)
    482                 condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    483         mutex_unlock(&THREAD->udebug.lock);
    484 
    485         udebug_stoppable_end();
    486 }
    487462
    488463/** @}
  • kernel/generic/src/udebug/udebug_ipc.c

    r2314381 rbb0d3d24  
    202202}
    203203
    204 /** Process a NAME_READ call.
    205  *
    206  * Returns a string containing the name of the task.
    207  *
    208  * @param call  The call structure.
    209  */
    210 static void udebug_receive_name_read(call_t *call)
    211 {
    212         unative_t uspace_addr;
    213         unative_t to_copy;
    214         size_t data_size;
    215         size_t buf_size;
    216         void *data;
    217 
    218         uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
    219         buf_size = IPC_GET_ARG3(call->data);    /* Dest. buffer size */
    220 
    221         /*
    222          * Read task name.
    223          */
    224         udebug_name_read((char **) &data, &data_size);
    225 
    226         /* Copy MAX(buf_size, data_size) bytes */
    227 
    228         if (buf_size > data_size)
    229                 to_copy = data_size;
    230         else
    231                 to_copy = buf_size;
    232 
    233         /*
    234          * Make use of call->buffer to transfer data to caller's userspace
    235          */
    236 
    237         IPC_SET_RETVAL(call->data, 0);
    238         /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
    239            same code in process_answer() can be used
    240            (no way to distinguish method in answer) */
    241         IPC_SET_ARG1(call->data, uspace_addr);
    242         IPC_SET_ARG2(call->data, to_copy);
    243 
    244         IPC_SET_ARG3(call->data, data_size);
    245         call->buffer = data;
    246 
    247         ipc_answer(&TASK->kb.box, call);
    248 }
    249 
    250204/** Process an AREAS_READ call.
    251205 *
     
    333287        ipc_answer(&TASK->kb.box, call);
    334288}
    335 
    336 /** Receive a REGS_READ call.
    337  *
    338  * Reads the thread's register state (istate structure).
    339  */
    340 static void udebug_receive_regs_read(call_t *call)
    341 {
    342         thread_t *t;
    343         unative_t uspace_addr;
    344         unative_t to_copy;
    345         void *buffer;
    346         int rc;
    347 
    348         t = (thread_t *) IPC_GET_ARG2(call->data);
    349 
    350         rc = udebug_regs_read(t, &buffer);
    351         if (rc < 0) {
    352                 IPC_SET_RETVAL(call->data, rc);
    353                 ipc_answer(&TASK->kb.box, call);
    354                 return;
    355         }
    356 
    357         /*
    358          * Make use of call->buffer to transfer data to caller's userspace
    359          */
    360 
    361         uspace_addr = IPC_GET_ARG3(call->data);
    362         to_copy = sizeof(istate_t);
    363 
    364         IPC_SET_RETVAL(call->data, 0);
    365         /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
    366            same code in process_answer() can be used
    367            (no way to distinguish method in answer) */
    368         IPC_SET_ARG1(call->data, uspace_addr);
    369         IPC_SET_ARG2(call->data, to_copy);
    370 
    371         call->buffer = buffer;
    372 
    373         ipc_answer(&TASK->kb.box, call);
    374 }
    375 
    376289
    377290/** Process an MEM_READ call.
     
    455368                udebug_receive_thread_read(call);
    456369                break;
    457         case UDEBUG_M_NAME_READ:
    458                 udebug_receive_name_read(call);
    459                 break;
    460370        case UDEBUG_M_AREAS_READ:
    461371                udebug_receive_areas_read(call);
     
    464374                udebug_receive_args_read(call);
    465375                break;
    466         case UDEBUG_M_REGS_READ:
    467                 udebug_receive_regs_read(call);
    468                 break;
    469376        case UDEBUG_M_MEM_READ:
    470377                udebug_receive_mem_read(call);
  • kernel/generic/src/udebug/udebug_ops.c

    r2314381 rbb0d3d24  
    4646#include <errno.h>
    4747#include <print.h>
    48 #include <string.h>
    4948#include <syscall/copy.h>
    5049#include <ipc/ipc.h>
     
    440439}
    441440
    442 /** Read task name.
    443  *
    444  * Returns task name as non-terminated string in a newly allocated buffer.
    445  * Also returns the size of the data.
    446  *
    447  * @param data          Place to store pointer to newly allocated block.
    448  * @param data_size     Place to store size of the data.
    449  *
    450  * @returns             EOK.
    451  */
    452 int udebug_name_read(char **data, size_t *data_size)
    453 {
    454         size_t name_size;
    455 
    456         name_size = str_size(TASK->name) + 1;
    457         *data = malloc(name_size, 0);
    458         *data_size = name_size;
    459 
    460         memcpy(*data, TASK->name, name_size);
    461 
    462         return 0;
    463 }
    464 
    465441/** Read the arguments of a system call.
    466442 *
     
    473449 * this function will fail with an EINVAL error code.
    474450 *
    475  * @param t             Thread where call arguments are to be read.
    476  * @param buffer        Place to store pointer to new buffer.
    477  * @return              EOK on success, ENOENT if @a t is invalid, EINVAL
    478  *                      if thread state is not valid for this operation.
     451 * @param buffer        The buffer for storing thread hashes.
    479452 */
    480453int udebug_args_read(thread_t *t, void **buffer)
     
    508481}
    509482
    510 /** Read the register state of the thread.
    511  *
    512  * The contents of the thread's istate structure are copied to a newly
    513  * allocated buffer and a pointer to it is written to @a buffer. The size of
    514  * the buffer will be sizeof(istate_t).
    515  *
    516  * Currently register state cannot be read if the thread is inside a system
    517  * call (as opposed to an exception). This is an implementation limit.
    518  *
    519  * @param t             Thread whose state is to be read.
    520  * @param buffer        Place to store pointer to new buffer.
    521  * @return              EOK on success, ENOENT if @a t is invalid, EINVAL
    522  *                      if thread is not in valid state, EBUSY if istate
    523  *                      is not available.
    524  */
    525 int udebug_regs_read(thread_t *t, void **buffer)
    526 {
    527         istate_t *state, *state_buf;
    528         int rc;
    529 
    530         /* Prepare a buffer to hold the data. */
    531         state_buf = malloc(sizeof(istate_t), 0);
    532 
    533         /* On success, this will lock t->udebug.lock */
    534         rc = _thread_op_begin(t, false);
    535         if (rc != EOK) {
    536                 return rc;
    537         }
    538 
    539         state = t->udebug.uspace_state;
    540         if (state == NULL) {
    541                 _thread_op_end(t);
    542                 return EBUSY;
    543         }
    544 
    545         /* Copy to the allocated buffer */
    546         memcpy(state_buf, state, sizeof(istate_t));
    547 
    548         _thread_op_end(t);
    549 
    550         *buffer = (void *) state_buf;
    551         return 0;
    552 }
    553 
    554483/** Read the memory of the debugged task.
    555484 *
  • uspace/app/taskdump/Makefile

    r2314381 rbb0d3d24  
    2929USPACE_PREFIX = ../..
    3030LIBS = $(LIBC_PREFIX)/libc.a
    31 EXTRA_CFLAGS = -Iinclude
    3231
    3332OUTPUT = taskdump
    3433
    3534SOURCES = \
    36         taskdump.c \
    37         symtab.c
     35        taskdump.c
    3836
    3937include ../Makefile.common
  • uspace/app/taskdump/taskdump.c

    r2314381 rbb0d3d24  
    4141#include <task.h>
    4242#include <kernel/mm/as.h>
    43 #include <libarch/istate.h>
    4443#include <macros.h>
    4544#include <assert.h>
    4645#include <bool.h>
    4746
    48 #include <symtab.h>
    49 #include <stacktrace.h>
    50 
    5147#define LINE_BYTES 16
    5248
     
    5753static task_id_t task_id;
    5854static bool dump_memory;
    59 static char *app_name;
    60 static symtab_t *app_symtab;
    6155
    6256static int connect_task(task_id_t task_id);
    6357static int parse_args(int argc, char *argv[]);
    64 static void print_syntax(void);
     58static void print_syntax();
    6559static int threads_dump(void);
    66 static int thread_dump(uintptr_t thash);
    6760static int areas_dump(void);
    6861static int area_dump(as_area_info_t *area);
    6962static void hex_dump(uintptr_t addr, void *buffer, size_t size);
    70 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);
    71 
    72 static void autoload_syms(void);
    73 static char *get_app_task_name(void);
    74 static char *fmt_sym_address(uintptr_t addr);
    7563
    7664int main(int argc, char *argv[])
     
    9785        }
    9886
    99         app_name = get_app_task_name();
    100         app_symtab = NULL;
    101 
    102         printf("Dumping task '%s' (task ID %lld).\n", app_name, task_id);
    103         autoload_syms();
    104         putchar('\n');
     87        printf("Dumping task %lld.\n\n", task_id);
    10588
    10689        rc = threads_dump();
     
    199182}
    200183
    201 static void print_syntax(void)
     184static void print_syntax()
    202185{
    203186        printf("Syntax: taskdump [-m] -t <task_id>\n");
     
    246229        for (i = 0; i < n_threads; i++) {
    247230                printf(" [%d] hash: 0x%lx\n", 1+i, thash_buf[i]);
    248 
    249                 thread_dump(thash_buf[i]);
    250231        }
    251232        putchar('\n');
     
    310291}
    311292
    312 static int thread_dump(uintptr_t thash)
    313 {
    314         istate_t istate;
    315         uintptr_t pc, fp, nfp;
    316         stacktrace_t st;
    317         char *sym_pc;
    318         int rc;
    319 
    320         rc = udebug_regs_read(phoneid, thash, &istate);
    321         if (rc < 0) {
    322                 printf("Failed reading registers (%d).\n", rc);
    323                 return EIO;
    324         }
    325 
    326         pc = istate_get_pc(&istate);
    327         fp = istate_get_fp(&istate);
    328 
    329         printf("Thread 0x%lx crashed at PC 0x%lx. FP 0x%lx\n", thash, pc, fp);
    330 
    331         st.op_arg = NULL;
    332         st.read_uintptr = td_read_uintptr;
    333 
    334         while (stacktrace_fp_valid(&st, fp)) {
    335                 sym_pc = fmt_sym_address(pc);
    336                 printf("  %p: %s()\n", fp, sym_pc);
    337                 free(sym_pc);
    338 
    339                 rc = stacktrace_ra_get(&st, fp, &pc);
    340                 if (rc != EOK)
    341                         return rc;
    342 
    343                 rc = stacktrace_fp_prev(&st, fp, &nfp);
    344                 if (rc != EOK)
    345                         return rc;
    346 
    347                 fp = nfp;
    348         }
    349 
    350         return EOK;
    351 }
    352 
    353293static int area_dump(as_area_info_t *area)
    354294{
     
    410350}
    411351
    412 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value)
    413 {
    414         uintptr_t data;
    415         int rc;
    416 
    417         (void) arg;
    418 
    419         rc = udebug_mem_read(phoneid, &data, addr, sizeof(data));
    420         if (rc < 0) {
    421                 printf("Warning: udebug_mem_read() failed.\n");
    422                 return rc;
    423         }
    424 
    425         *value = data;
    426         return EOK;
    427 }
    428 
    429 /** Attempt to find the right executable file and load the symbol table. */
    430 static void autoload_syms(void)
    431 {
    432         char *file_name;
    433         int rc;
    434 
    435         assert(app_name != NULL);
    436         assert(app_symtab == NULL);
    437 
    438         rc = asprintf(&file_name, "/app/%s", app_name);
    439         if (rc < 0) {
    440                 printf("Memory allocation failure.\n");
    441                 exit(1);
    442         }
    443 
    444         rc = symtab_load(file_name, &app_symtab);
    445         if (rc == EOK) {
    446                 printf("Loaded symbol table from %s\n", file_name);
    447                 free(file_name);
    448                 return;
    449         }
    450 
    451         free(file_name);
    452 
    453         rc = asprintf(&file_name, "/srv/%s", app_name);
    454         if (rc < 0) {
    455                 printf("Memory allocation failure.\n");
    456                 exit(1);
    457         }
    458 
    459         rc = symtab_load("/srv/xyz", &app_symtab);
    460         if (rc == EOK) {
    461                 printf("Loaded symbol table from %s\n", file_name);
    462                 free(file_name);
    463                 return;
    464         }
    465 
    466         free(file_name);
    467         printf("Failed autoloading symbol table.\n");
    468 }
    469 
    470 static char *get_app_task_name(void)
    471 {
    472         char dummy_buf;
    473         size_t copied, needed, name_size;
    474         char *name;
    475         int rc;
    476 
    477         rc = udebug_name_read(phoneid, &dummy_buf, 0, &copied, &needed);
    478         if (rc < 0)
    479                 return NULL;
    480 
    481         name_size = needed;
    482         name = malloc(name_size + 1);
    483         rc = udebug_name_read(phoneid, name, name_size, &copied, &needed);
    484         if (rc < 0) {
    485                 free(name);
    486                 return NULL;
    487         }
    488 
    489         assert(copied == name_size);
    490         assert(copied == needed);
    491         name[copied] = '\0';
    492 
    493         return name;
    494 }
    495 
    496 /** Format address in symbolic form.
    497  *
    498  * Formats address as <symbol_name>+<offset> (<address>), if possible,
    499  * otherwise as <address>.
    500  *
    501  * @param addr  Address to format.
    502  * @return      Newly allocated string, address in symbolic form.
    503  */
    504 static char *fmt_sym_address(uintptr_t addr)
    505 {
    506         char *name;
    507         size_t offs;
    508         int rc;
    509         char *str;
    510 
    511         if (app_symtab != NULL) {
    512                 rc = symtab_addr_to_name(app_symtab, addr, &name, &offs);
    513         } else {
    514                 rc = ENOTSUP;
    515         }
    516 
    517         if (rc == EOK) {
    518                 rc = asprintf(&str, "(%p) %s+%p", addr, name, offs);
    519         } else {
    520                 rc = asprintf(&str, "%p", addr);
    521         }
    522 
    523         if (rc < 0) {
    524                 printf("Memory allocation error.\n");
    525                 exit(1);
    526         }
    527 
    528         return str;
    529 }
    530 
    531352/** @}
    532353 */
  • uspace/lib/libc/arch/amd64/Makefile.inc

    r2314381 rbb0d3d24  
    3737        arch/$(UARCH)/src/fibril.S \
    3838        arch/$(UARCH)/src/tls.c \
    39         arch/$(UARCH)/src/stacktrace.c \
    40         arch/$(UARCH)/src/stacktrace_asm.S
     39        arch/$(UARCH)/src/stacktrace.S
    4140
    4241GCC_CFLAGS += -fno-omit-frame-pointer
  • uspace/lib/libc/arch/amd64/include/types.h

    r2314381 rbb0d3d24  
    3636#define LIBC_amd64_TYPES_H_
    3737
    38 #define __64_BITS__
    39 
    4038typedef unsigned long long sysarg_t;
    4139
  • uspace/lib/libc/arch/arm32/Makefile.inc

    r2314381 rbb0d3d24  
    3838        arch/$(UARCH)/src/tls.c \
    3939        arch/$(UARCH)/src/eabi.S \
    40         arch/$(UARCH)/src/stacktrace.c \
    41         arch/$(UARCH)/src/stacktrace_asm.S
     40        arch/$(UARCH)/src/stacktrace.S
    4241
    4342GCC_CFLAGS += -ffixed-r9 -mtp=soft -mapcs-frame -fno-omit-frame-pointer
  • uspace/lib/libc/arch/arm32/include/types.h

    r2314381 rbb0d3d24  
    3737#define LIBC_arm32_TYPES_H_
    3838
    39 #define __32_BITS__
    40 
    4139typedef unsigned int sysarg_t;
    4240
  • uspace/lib/libc/arch/ia32/Makefile.inc

    r2314381 rbb0d3d24  
    3838        arch/$(UARCH)/src/tls.c \
    3939        arch/$(UARCH)/src/setjmp.S \
    40         arch/$(UARCH)/src/stacktrace.c \
    41         arch/$(UARCH)/src/stacktrace_asm.S
     40        arch/$(UARCH)/src/stacktrace.S
    4241
    4342GCC_CFLAGS += -march=pentium
  • uspace/lib/libc/arch/ia32/include/types.h

    r2314381 rbb0d3d24  
    3636#define LIBC_ia32_TYPES_H_
    3737
    38 #define __32_BITS__
    39 
    4038typedef unsigned int sysarg_t;
    4139
  • uspace/lib/libc/arch/ia64/Makefile.inc

    r2314381 rbb0d3d24  
    3737        arch/$(UARCH)/src/tls.c \
    3838        arch/$(UARCH)/src/ddi.c \
    39         arch/$(UARCH)/src/stacktrace.c \
    40         arch/$(UARCH)/src/stacktrace_asm.S
     39        arch/$(UARCH)/src/stacktrace.S
    4140
    4241GCC_CFLAGS += -fno-unwind-tables
  • uspace/lib/libc/arch/ia64/include/types.h

    r2314381 rbb0d3d24  
    3636#define LIBC_ia64_TYPES_H_
    3737
    38 #define __64_BITS__
    39 
    4038typedef unsigned long long sysarg_t;
    4139
  • uspace/lib/libc/arch/mips32/Makefile.inc

    r2314381 rbb0d3d24  
    3636        arch/$(UARCH)/src/fibril.S \
    3737        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/stacktrace.c \
    39         arch/$(UARCH)/src/stacktrace_asm.S
     38        arch/$(UARCH)/src/stacktrace.S
    4039
    4140GCC_CFLAGS += -mips3
  • uspace/lib/libc/arch/mips32/include/types.h

    r2314381 rbb0d3d24  
    3737#define LIBC_mips32_TYPES_H_
    3838
    39 #define __32_BITS__
    40 
    4139typedef unsigned int sysarg_t;
    4240
  • uspace/lib/libc/arch/mips32eb/Makefile.inc

    r2314381 rbb0d3d24  
    3636        arch/$(UARCH)/src/fibril.S \
    3737        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/stacktrace.c \
    39         arch/$(UARCH)/src/stacktrace_asm.S
     38        arch/$(UARCH)/src/stacktrace.S
    4039
    4140GCC_CFLAGS += -mips3
  • uspace/lib/libc/arch/ppc32/Makefile.inc

    r2314381 rbb0d3d24  
    3636        arch/$(UARCH)/src/fibril.S \
    3737        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/stacktrace.c \
    39         arch/$(UARCH)/src/stacktrace_asm.S
     38        arch/$(UARCH)/src/stacktrace.S
    4039
    4140GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
  • uspace/lib/libc/arch/ppc32/include/types.h

    r2314381 rbb0d3d24  
    3636#define LIBC_ppc32_TYPES_H_
    3737
    38 #define __32_BITS__
    39 
    4038typedef unsigned int sysarg_t;
    4139
  • uspace/lib/libc/arch/sparc64/Makefile.inc

    r2314381 rbb0d3d24  
    3535ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \
    3636        arch/$(UARCH)/src/tls.c \
    37         arch/$(UARCH)/src/stacktrace.c \
    38         arch/$(UARCH)/src/stacktrace_asm.S
     37        arch/$(UARCH)/src/stacktrace.S
    3938
    4039GCC_CFLAGS += -mcpu=ultrasparc -m64
  • uspace/lib/libc/arch/sparc64/include/types.h

    r2314381 rbb0d3d24  
    3636#define LIBC_sparc64_TYPES_H_
    3737
    38 #define __64_BITS__
    39 
    4038typedef unsigned long sysarg_t;
    4139
  • uspace/lib/libc/generic/stacktrace.c

    r2314381 rbb0d3d24  
    11/*
    22 * Copyright (c) 2009 Jakub Jermar
    3  * Copyright (c) 2010 Jiri Svoboda
    43 * All rights reserved.
    54 *
     
    3736#include <stdio.h>
    3837#include <sys/types.h>
    39 #include <errno.h>
    4038
    41 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
    42 
    43 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
     39void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc)
    4440{
    45         stacktrace_t st;
    46         uintptr_t nfp;
    47 
    48         st.op_arg = NULL;
    49         st.read_uintptr = stacktrace_read_uintptr;
    50 
    51         while (stacktrace_fp_valid(&st, fp)) {
     41        while (frame_pointer_validate(fp)) {
    5242                printf("%p: %p()\n", fp, pc);
    53                 (void) stacktrace_ra_get(&st, fp, &pc);
    54                 (void) stacktrace_fp_prev(&st, fp, &nfp);
    55                 fp = nfp;
     43                pc = return_address_get(fp);
     44                fp = frame_pointer_prev(fp);
    5645        }
    5746}
    5847
    59 void stacktrace_print(void)
     48void stack_trace(void)
    6049{
    61         stacktrace_prepare();
    62         stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get());
     50        stack_trace_fp_pc(frame_pointer_get(), program_counter_get());
    6351        /*
    6452         * Prevent the tail call optimization of the previous call by
    6553         * making it a non-tail call.
    6654         */
    67         (void) stacktrace_fp_get();
    68 }
    69 
    70 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data)
    71 {
    72         (void) arg;
    73         *data = *((uintptr_t *) addr);
    74         return EOK;
     55        (void) frame_pointer_get();
    7556}
    7657
  • uspace/lib/libc/generic/udebug.c

    r2314381 rbb0d3d24  
    6969}
    7070
    71 int udebug_name_read(int phoneid, void *buffer, size_t n,
    72         size_t *copied, size_t *needed)
    73 {
    74         ipcarg_t a_copied, a_needed;
    75         int rc;
    76 
    77         rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_NAME_READ,
    78                 (sysarg_t)buffer, n, NULL, &a_copied, &a_needed);
    79 
    80         *copied = (size_t)a_copied;
    81         *needed = (size_t)a_needed;
    82 
    83         return rc;
    84 }
    85 
    8671int udebug_areas_read(int phoneid, void *buffer, size_t n,
    8772        size_t *copied, size_t *needed)
     
    9984}
    10085
     86
    10187int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n)
    10288{
     
    10894{
    10995        return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_ARGS_READ,
    110             tid, (sysarg_t)buffer);
    111 }
    112 
    113 int udebug_regs_read(int phoneid, thash_t tid, void *buffer)
    114 {
    115         return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_REGS_READ,
    11696            tid, (sysarg_t)buffer);
    11797}
  • uspace/lib/libc/include/stacktrace.h

    r2314381 rbb0d3d24  
    11/*
    22 * Copyright (c) 2009 Jakub Jermar
    3  * Copyright (c) 2010 Jiri Svoboda
    43 * All rights reserved.
    54 *
     
    4039#include <bool.h>
    4140
    42 typedef struct {
    43         void *op_arg;
    44         int (*read_uintptr)(void *, uintptr_t, uintptr_t *);
    45 } stacktrace_t;
    46 
    47 extern void stacktrace_print(void);
    48 extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t);
     41extern void stack_trace(void);
     42extern void stack_trace_fp_pc(uintptr_t, uintptr_t);
    4943
    5044/*
    5145 * The following interface is to be implemented by each architecture.
    5246 */
    53 extern bool stacktrace_fp_valid(stacktrace_t *, uintptr_t);
    54 extern int stacktrace_fp_prev(stacktrace_t *, uintptr_t, uintptr_t *);
    55 extern int stacktrace_ra_get(stacktrace_t *, uintptr_t, uintptr_t *);
    56 
    57 extern void stacktrace_prepare(void);
    58 extern uintptr_t stacktrace_fp_get(void);
    59 extern uintptr_t stacktrace_pc_get();
     47extern bool frame_pointer_validate(uintptr_t);
     48extern uintptr_t frame_pointer_get(void);
     49extern uintptr_t frame_pointer_prev(uintptr_t);
     50extern uintptr_t return_address_get(uintptr_t);
     51extern uintptr_t program_counter_get();
    6052
    6153#endif
  • uspace/lib/libc/include/stdlib.h

    r2314381 rbb0d3d24  
    4242#define abort() \
    4343        do { \
    44                 stacktrace_print(); \
     44                stack_trace(); \
    4545                _exit(1); \
    4646        } while (0)
  • uspace/lib/libc/include/udebug.h

    r2314381 rbb0d3d24  
    4747int udebug_thread_read(int phoneid, void *buffer, size_t n,
    4848        size_t *copied, size_t *needed);
    49 int udebug_name_read(int phoneid, void *buffer, size_t n,
    50         size_t *copied, size_t *needed);
    5149int udebug_areas_read(int phoneid, void *buffer, size_t n,
    5250        size_t *copied, size_t *needed);
    5351int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n);
    5452int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer);
    55 int udebug_regs_read(int phoneid, thash_t tid, void *buffer);
    5653int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type,
    5754        sysarg_t *val0, sysarg_t *val1);
  • uspace/srv/loader/arch/amd64/Makefile.inc

    r2314381 rbb0d3d24  
    2727#
    2828
     29EXTRA_CFLAGS = -D__64_BITS__
    2930ARCH_SOURCES := arch/$(UARCH)/amd64.s
  • uspace/srv/loader/arch/arm32/Makefile.inc

    r2314381 rbb0d3d24  
    2727#
    2828
     29EXTRA_CFLAGS = -D__32_BITS__
    2930ARCH_SOURCES := arch/$(UARCH)/arm32.s
  • uspace/srv/loader/arch/ia32/Makefile.inc

    r2314381 rbb0d3d24  
    2727#
    2828
     29EXTRA_CFLAGS = -D__32_BITS__
    2930ARCH_SOURCES := arch/$(UARCH)/ia32.s
  • uspace/srv/loader/arch/ia64/Makefile.inc

    r2314381 rbb0d3d24  
    2727#
    2828
     29EXTRA_CFLAGS = -D__64_BITS__
    2930ARCH_SOURCES := arch/$(UARCH)/ia64.s
    3031AFLAGS += -xexplicit
  • uspace/srv/loader/arch/mips32/Makefile.inc

    r2314381 rbb0d3d24  
    2727#
    2828
     29EXTRA_CFLAGS = -D__32_BITS__
    2930ARCH_SOURCES := arch/$(UARCH)/mips32.s
  • uspace/srv/loader/arch/ppc32/Makefile.inc

    r2314381 rbb0d3d24  
    2727#
    2828
     29EXTRA_CFLAGS = -D__32_BITS__
    2930ARCH_SOURCES := arch/$(UARCH)/ppc32.s
  • uspace/srv/loader/arch/sparc64/Makefile.inc

    r2314381 rbb0d3d24  
    2727#
    2828
     29EXTRA_CFLAGS = -D__64_BITS__
    2930ARCH_SOURCES := arch/$(UARCH)/sparc64.s
Note: See TracChangeset for help on using the changeset viewer.