Changeset 1affcdf3 in mainline for uspace/app/trace/trace.c


Ignore:
Timestamp:
2011-06-10T19:33:41Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1878386
Parents:
13ecdac9 (diff), 79a141a (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

File:
1 edited

Legend:

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

    r13ecdac9 r1affcdf3  
    7272ipc_call_t thread_ipc_req[THBUF_SIZE];
    7373
    74 int phoneid;
     74async_sess_t *sess;
    7575bool abort_trace;
    7676
     
    8181
    8282static bool cev_valid;
    83 static console_event_t cev;
     83static kbd_event_t cev;
    8484
    8585void thread_trace_start(uintptr_t thread_hash);
     
    146146static int connect_task(task_id_t task_id)
    147147{
    148         int rc;
    149 
    150         rc = async_connect_kbox(task_id);
    151 
    152         if (rc == ENOTSUP) {
    153                 printf("You do not have userspace debugging support "
    154                     "compiled in the kernel.\n");
    155                 printf("Compile kernel with 'Support for userspace debuggers' "
    156                     "(CONFIG_UDEBUG) enabled.\n");
    157                 return rc;
    158         }
    159 
    160         if (rc < 0) {
     148        async_sess_t *ksess = async_connect_kbox(task_id);
     149       
     150        if (!ksess) {
     151                if (errno == ENOTSUP) {
     152                        printf("You do not have userspace debugging support "
     153                            "compiled in the kernel.\n");
     154                        printf("Compile kernel with 'Support for userspace debuggers' "
     155                            "(CONFIG_UDEBUG) enabled.\n");
     156                        return errno;
     157                }
     158               
    161159                printf("Error connecting\n");
    162                 printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc);
    163                 return rc;
    164         }
    165 
    166         phoneid = rc;
    167 
    168         rc = udebug_begin(phoneid);
     160                printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, errno);
     161                return errno;
     162        }
     163       
     164        int rc = udebug_begin(ksess);
    169165        if (rc < 0) {
    170166                printf("udebug_begin() -> %d\n", rc);
    171167                return rc;
    172168        }
    173 
    174         rc = udebug_set_evmask(phoneid, UDEBUG_EM_ALL);
     169       
     170        rc = udebug_set_evmask(ksess, UDEBUG_EM_ALL);
    175171        if (rc < 0) {
    176172                printf("udebug_set_evmask(0x%x) -> %d\n ", UDEBUG_EM_ALL, rc);
    177173                return rc;
    178174        }
    179 
     175       
     176        sess = ksess;
    180177        return 0;
    181178}
     
    188185        int i;
    189186
    190         rc = udebug_thread_read(phoneid, thread_hash_buf,
     187        rc = udebug_thread_read(sess, thread_hash_buf,
    191188                THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed);
    192189        if (rc < 0) {
     
    314311
    315312        memset(&call, 0, sizeof(call));
    316         rc = udebug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args));
     313        rc = udebug_mem_read(sess, &call.args, sc_args[1], sizeof(call.args));
    317314
    318315        if (rc >= 0) {
     
    325322        ipc_call_t question, reply;
    326323        int rc;
    327         int phoneidx;
    328 
    329 //      printf("sc_ipc_call_sync_fast()\n");
    330         phoneidx = sc_args[0];
     324        int phoneid;
     325
     326        phoneid = sc_args[0];
    331327
    332328        IPC_SET_IMETHOD(question, sc_args[1]);
     
    337333        IPC_SET_ARG5(question, 0);
    338334
    339 //      printf("memset\n");
    340335        memset(&reply, 0, sizeof(reply));
    341 //      printf("udebug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n",
    342 //              phoneid, &reply.args, sc_args[5], sizeof(reply.args));
    343         rc = udebug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args));
    344 //      printf("dmr->%d\n", rc);
    345         if (rc < 0) return;
    346 
    347 //      printf("call ipc_call_sync\n");
    348         ipcp_call_sync(phoneidx, &question, &reply);
     336        rc = udebug_mem_read(sess, &reply.args, sc_args[5], sizeof(reply.args));
     337        if (rc < 0)
     338                return;
     339       
     340        ipcp_call_sync(phoneid, &question, &reply);
    349341}
    350342
     
    355347
    356348        memset(&question, 0, sizeof(question));
    357         rc = udebug_mem_read(phoneid, &question.args, sc_args[1],
     349        rc = udebug_mem_read(sess, &question.args, sc_args[1],
    358350            sizeof(question.args));
    359351
     
    372364
    373365        memset(&reply, 0, sizeof(reply));
    374         rc = udebug_mem_read(phoneid, &reply.args, sc_args[2],
     366        rc = udebug_mem_read(sess, &reply.args, sc_args[2],
    375367            sizeof(reply.args));
    376368
     
    391383
    392384        memset(&call, 0, sizeof(call));
    393         rc = udebug_mem_read(phoneid, &call, sc_args[0], sizeof(call));
    394 //      printf("udebug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n",
    395 //              phoneid, (int)&call, sc_args[0], sizeof(call), rc);
    396 
    397         if (rc >= 0) {
     385        rc = udebug_mem_read(sess, &call, sc_args[0], sizeof(call));
     386       
     387        if (rc >= 0)
    398388                ipcp_call_in(&call, sc_rc);
    399         }
    400389}
    401390
     
    407396
    408397        /* Read syscall arguments */
    409         rc = udebug_args_read(phoneid, thread_hash, sc_args);
    410 
    411         async_serialize_start();
    412 
    413 //      printf("[%d] ", thread_id);
     398        rc = udebug_args_read(sess, thread_hash, sc_args);
    414399
    415400        if (rc < 0) {
    416401                printf("error\n");
    417                 async_serialize_end();
    418402                return;
    419403        }
     
    432416                break;
    433417        }
    434 
    435         async_serialize_end();
    436418}
    437419
     
    444426
    445427        /* Read syscall arguments */
    446         rc = udebug_args_read(phoneid, thread_hash, sc_args);
    447 
    448         async_serialize_start();
     428        rc = udebug_args_read(sess, thread_hash, sc_args);
    449429
    450430//      printf("[%d] ", thread_id);
     
    452432        if (rc < 0) {
    453433                printf("error\n");
    454                 async_serialize_end();
    455434                return;
    456435        }
     
    481460                break;
    482461        }
    483 
    484         async_serialize_end();
    485462}
    486463
    487464static void event_thread_b(uintptr_t hash)
    488465{
    489         async_serialize_start();
    490466        printf("New thread, hash %p\n", (void *) hash);
    491         async_serialize_end();
    492 
    493467        thread_trace_start(hash);
    494468}
     
    527501
    528502                /* Run thread until an event occurs */
    529                 rc = udebug_go(phoneid, thread_hash,
     503                rc = udebug_go(sess, thread_hash,
    530504                    &ev_type, &val0, &val1);
    531505
     
    656630{
    657631        (void) arg;
    658 
     632       
     633        console_ctrl_t *console = console_init(stdin, stdout);
     634       
    659635        while (true) {
    660636                fibril_mutex_lock(&state_lock);
     
    662638                        fibril_condvar_wait(&state_cv, &state_lock);
    663639                fibril_mutex_unlock(&state_lock);
    664 
    665                 if (!console_get_event(fphone(stdin), &cev))
     640               
     641                if (!console_get_kbd_event(console, &cev))
    666642                        return -1;
    667 
     643               
    668644                fibril_mutex_lock(&state_lock);
    669645                cev_valid = true;
    670646                fibril_condvar_broadcast(&state_cv);
    671                 fibril_mutex_unlock(&state_lock);               
     647                fibril_mutex_unlock(&state_lock);
    672648        }
    673649}
     
    675651static void trace_task(task_id_t task_id)
    676652{
    677         console_event_t ev;
     653        kbd_event_t ev;
    678654        bool done;
    679655        int i;
     
    727703                case KC_P:
    728704                        printf("Pause...\n");
    729                         rc = udebug_stop(phoneid, thash);
     705                        rc = udebug_stop(sess, thash);
    730706                        if (rc != EOK)
    731707                                printf("Error: stop -> %d\n", rc);
     
    743719        printf("\nTerminate debugging session...\n");
    744720        abort_trace = true;
    745         udebug_end(phoneid);
    746         async_hangup(phoneid);
     721        udebug_end(sess);
     722        async_hangup(sess);
    747723
    748724        ipcp_cleanup();
Note: See TracChangeset for help on using the changeset viewer.