Changeset dafa2d04 in mainline


Ignore:
Timestamp:
2010-02-06T21:36:08Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
444a54e, f27ada7
Parents:
19f24fd
Message:

Let taskdump save ELF core files. (Only memory, no register state yet.)

Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r19f24fd rdafa2d04  
    505505! [CONFIG_START_BD=y] CONFIG_MOUNT_DATA (n/y)
    506506
    507 % Verbose task dumps
    508 ! CONFIG_VERBOSE_DUMPS (n/y)
     507% Write core files
     508! CONFIG_WRITE_CORE_FILES (n/y)
  • uspace/app/taskdump/Makefile

    r19f24fd rdafa2d04  
    3434
    3535SOURCES = \
     36        elf_core.c \
    3637        taskdump.c \
    3738        symtab.c
  • uspace/app/taskdump/taskdump.c

    r19f24fd rdafa2d04  
    4040#include <udebug.h>
    4141#include <task.h>
    42 #include <kernel/mm/as.h>
     42#include <as.h>
    4343#include <sys/types.h>
    4444#include <sys/typefmt.h>
     
    4949
    5050#include <symtab.h>
     51#include <elf_core.h>
    5152#include <stacktrace.h>
    5253
     
    5859static int phoneid;
    5960static task_id_t task_id;
    60 static bool dump_memory;
     61static bool write_core_file;
     62static char *core_file_name;
    6163static char *app_name;
    6264static symtab_t *app_symtab;
     
    8082        int rc;
    8183
    82         /*
    83          * FIXME: The stdio module cannot currently detect whether we are
    84          * writing to a console or file. This workaround make file output
    85          * faster.
    86          */
    87         setvbuf(stdout, NULL, _IOFBF, 32768);
    88 
    8984        printf("Task Dump Utility\n");
    90         dump_memory = false;
     85        write_core_file = false;
    9186
    9287        if (parse_args(argc, argv) < 0)
     
    172167                                        return -1;
    173168                                }
    174                         } else if (arg[1] == 'm' && arg[2] == '\0') {
    175                                 dump_memory = true;
     169                        } else if (arg[1] == 'c' && arg[2] == '\0') {
     170                                write_core_file = true;
     171
     172                                --argc; ++argv;
     173                                core_file_name = *argv;
    176174                        } else {
    177175                                printf("Uknown option '%s'\n", arg[0]);
     
    203201static void print_syntax(void)
    204202{
    205         printf("Syntax: taskdump [-m] -t <task_id>\n");
    206         printf("\t-m\tDump memory area contents.\n");
     203        printf("Syntax: taskdump [-c <core_file>] -t <task_id>\n");
     204        printf("\t-c <core_file_id>\tName of core file to write.\n");
    207205        printf("\t-t <task_id>\tWhich task to dump.\n");
    208206}
     
    297295                    (ainfo_buf[i].flags & AS_AREA_CACHEABLE) ? 'C' : '-',
    298296                    ainfo_buf[i].start_addr, ainfo_buf[i].size);
    299 
    300                 if (dump_memory) {
    301                         putchar('\n');
    302                         area_dump(&ainfo_buf[i]);
    303                         putchar('\n');
     297        }
     298
     299        putchar('\n');
     300
     301        if (write_core_file) {
     302                printf("Writing core file '%s'\n", core_file_name);
     303                rc = elf_core_save(core_file_name, ainfo_buf, n_areas, phoneid);
     304                if (rc != EOK) {
     305                        printf("Failed writing core file.\n");
     306                        return EIO;
    304307                }
    305308        }
    306 
    307         putchar('\n');
    308309
    309310        free(ainfo_buf);
  • uspace/srv/taskmon/taskmon.c

    r19f24fd rdafa2d04  
    4949static void fault_event(ipc_callid_t callid, ipc_call_t *call)
    5050{
    51         char *argv[11];
     51        char *argv[6];
    5252        char *fname;
    5353        char *dump_fname;
     
    6666        }
    6767
    68         if (asprintf(&dump_fname, "/scratch/d" PRIuTASKID ".txt", taskid) < 0) {
     68        if (asprintf(&dump_fname, "/data/core" PRIuTASKID, taskid) < 0) {
    6969                printf("Memory allocation failed.\n");
    7070                return;
     
    7373        printf(NAME ": Task %" PRIuTASKID " fault in thread %p.\n", taskid, thread);
    7474
    75 #ifdef CONFIG_VERBOSE_DUMPS
    76         argv[0] = "/app/redir";
    77         argv[1] = "-i";
    78         argv[2] = "/readme";
    79         argv[3] = "-o";
    80         argv[4] = dump_fname;
    81         argv[5] = "--";
    82         argv[6] = "/app/taskdump";
    83         argv[7] = "-m";
    84         argv[8] = "-t";
    85         argv[9] = s_taskid;
    86         argv[10] = NULL;
     75#ifdef CONFIG_WRITE_CORE_FILES
     76        argv[0] = "/app/taskdump";
     77        argv[1] = "-c";
     78        argv[2] = dump_fname;
     79        argv[3] = "-t";
     80        argv[4] = s_taskid;
     81        argv[5] = NULL;
    8782#else
    8883        argv[0] = "/app/taskdump";
Note: See TracChangeset for help on using the changeset viewer.