Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskdump/taskdump.c

    r1d6dd2a r9af1c61  
    4848#include <macros.h>
    4949#include <assert.h>
    50 #include <str.h>
    5150
    5251#include <symtab.h>
     
    6463static symtab_t *app_symtab;
    6564
    66 static errno_t connect_task(task_id_t task_id);
     65static int connect_task(task_id_t task_id);
    6766static int parse_args(int argc, char *argv[]);
    6867static void print_syntax(void);
    69 static errno_t threads_dump(void);
    70 static errno_t thread_dump(uintptr_t thash);
    71 static errno_t areas_dump(void);
    72 static errno_t td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);
     68static int threads_dump(void);
     69static int thread_dump(uintptr_t thash);
     70static int areas_dump(void);
     71static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);
    7372
    7473static void autoload_syms(void);
     
    8483int main(int argc, char *argv[])
    8584{
    86         errno_t rc;
     85        int rc;
    8786
    8887        printf("Task Dump Utility\n");
     
    9392
    9493        rc = connect_task(task_id);
    95         if (rc != EOK) {
     94        if (rc < 0) {
    9695                printf("Failed connecting to task %" PRIu64 ".\n", task_id);
    9796                return 1;
     
    106105
    107106        rc = threads_dump();
    108         if (rc != EOK)
     107        if (rc < 0)
    109108                printf("Failed dumping threads.\n");
    110109
    111110        rc = areas_dump();
    112         if (rc != EOK)
     111        if (rc < 0)
    113112                printf("Failed dumping address space areas.\n");
    114113
    115114        rc = fibrils_dump(app_symtab, sess);
    116         if (rc != EOK)
     115        if (rc < 0)
    117116                printf("Failed dumping fibrils.\n");
    118117
     
    123122}
    124123
    125 static errno_t connect_task(task_id_t task_id)
     124static int connect_task(task_id_t task_id)
    126125{
    127126        async_sess_t *ksess = async_connect_kbox(task_id);
     
    141140        }
    142141       
    143         errno_t rc = udebug_begin(ksess);
    144         if (rc != EOK) {
    145                 printf("udebug_begin() -> %s\n", str_error_name(rc));
     142        int rc = udebug_begin(ksess);
     143        if (rc < 0) {
     144                printf("udebug_begin() -> %d\n", rc);
    146145                return rc;
    147146        }
     
    211210}
    212211
    213 static errno_t threads_dump(void)
     212static int threads_dump(void)
    214213{
    215214        uintptr_t *thash_buf;
     
    220219        size_t needed;
    221220        size_t i;
    222         errno_t rc;
     221        int rc;
    223222
    224223        /* TODO: See why NULL does not work. */
    225224        rc = udebug_thread_read(sess, &dummy_buf, 0, &copied, &needed);
    226         if (rc != EOK) {
    227                 printf("udebug_thread_read() -> %s\n", str_error_name(rc));
     225        if (rc < 0) {
     226                printf("udebug_thread_read() -> %d\n", rc);
    228227                return rc;
    229228        }
     
    238237
    239238        rc = udebug_thread_read(sess, thash_buf, buf_size, &copied, &needed);
    240         if (rc != EOK) {
    241                 printf("udebug_thread_read() -> %s\n", str_error_name(rc));
     239        if (rc < 0) {
     240                printf("udebug_thread_read() -> %d\n", rc);
    242241                return rc;
    243242        }
     
    261260}
    262261
    263 static errno_t areas_dump(void)
     262static int areas_dump(void)
    264263{
    265264        as_area_info_t *ainfo_buf;
     
    270269        size_t needed;
    271270        size_t i;
    272         errno_t rc;
     271        int rc;
    273272
    274273        rc = udebug_areas_read(sess, &dummy_buf, 0, &copied, &needed);
    275         if (rc != EOK) {
    276                 printf("udebug_areas_read() -> %s\n", str_error_name(rc));
     274        if (rc < 0) {
     275                printf("udebug_areas_read() -> %d\n", rc);
    277276                return rc;
    278277        }
     
    282281
    283282        rc = udebug_areas_read(sess, ainfo_buf, buf_size, &copied, &needed);
    284         if (rc != EOK) {
    285                 printf("udebug_areas_read() -> %s\n", str_error_name(rc));
     283        if (rc < 0) {
     284                printf("udebug_areas_read() -> %d\n", rc);
    286285                return rc;
    287286        }
     
    321320}
    322321
    323 errno_t td_stacktrace(uintptr_t fp, uintptr_t pc)
     322int td_stacktrace(uintptr_t fp, uintptr_t pc)
    324323{
    325324        uintptr_t nfp;
    326325        stacktrace_t st;
    327326        char *sym_pc;
    328         errno_t rc;
     327        int rc;
    329328
    330329        st.op_arg = NULL;
     
    350349}
    351350
    352 static errno_t thread_dump(uintptr_t thash)
     351static int thread_dump(uintptr_t thash)
    353352{
    354353        istate_t istate;
    355354        uintptr_t pc, fp;
    356355        char *sym_pc;
    357         errno_t rc;
     356        int rc;
    358357
    359358        rc = udebug_regs_read(sess, thash, &istate);
    360         if (rc != EOK) {
    361                 printf("Failed reading registers: %s.\n", str_error_name(rc));
     359        if (rc < 0) {
     360                printf("Failed reading registers (%d).\n", rc);
    362361                return EIO;
    363362        }
     
    379378}
    380379
    381 static errno_t td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value)
     380static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value)
    382381{
    383382        uintptr_t data;
    384         errno_t rc;
     383        int rc;
    385384
    386385        (void) arg;
    387386
    388387        rc = udebug_mem_read(sess, &data, addr, sizeof(data));
    389         if (rc != EOK) {
     388        if (rc < 0) {
    390389                printf("Warning: udebug_mem_read() failed.\n");
    391390                return rc;
     
    400399{
    401400        char *file_name;
    402         errno_t rc;
    403         int ret;
     401        int rc;
    404402
    405403        assert(app_name != NULL);
    406404        assert(app_symtab == NULL);
    407405
    408         ret = asprintf(&file_name, "/app/%s", app_name);
    409         if (ret < 0) {
     406        rc = asprintf(&file_name, "/app/%s", app_name);
     407        if (rc < 0) {
    410408                printf("Memory allocation failure.\n");
    411409                exit(1);
     
    421419        free(file_name);
    422420
    423         ret = asprintf(&file_name, "/srv/%s", app_name);
    424         if (ret < 0) {
     421        rc = asprintf(&file_name, "/srv/%s", app_name);
     422        if (rc < 0) {
    425423                printf("Memory allocation failure.\n");
    426424                exit(1);
     
    434432        }
    435433
    436         ret = asprintf(&file_name, "/drv/%s/%s", app_name, app_name);
    437         if (ret < 0) {
     434        rc = asprintf(&file_name, "/drv/%s/%s", app_name, app_name);
     435        if (rc < 0) {
    438436                printf("Memory allocation failure.\n");
    439437                exit(1);
     
    456454        size_t copied, needed, name_size;
    457455        char *name;
    458         errno_t rc;
     456        int rc;
    459457
    460458        rc = udebug_name_read(sess, &dummy_buf, 0, &copied, &needed);
    461         if (rc != EOK)
     459        if (rc < 0)
    462460                return NULL;
    463461
     
    465463        name = malloc(name_size + 1);
    466464        rc = udebug_name_read(sess, name, name_size, &copied, &needed);
    467         if (rc != EOK) {
     465        if (rc < 0) {
    468466                free(name);
    469467                return NULL;
     
    489487        char *name;
    490488        size_t offs;
    491         errno_t rc;
    492         int ret;
     489        int rc;
    493490        char *str;
    494491
     
    500497
    501498        if (rc == EOK) {
    502                 ret = asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs);
     499                rc = asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs);
    503500        } else {
    504                 ret = asprintf(&str, "%p", (void *) addr);
    505         }
    506 
    507         if (ret < 0) {
     501                rc = asprintf(&str, "%p", (void *) addr);
     502        }
     503
     504        if (rc < 0) {
    508505                printf("Memory allocation error.\n");
    509506                exit(1);
Note: See TracChangeset for help on using the changeset viewer.