Subversion Repositories HelenOS

Rev

Rev 2942 | Rev 2947 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2942 Rev 2946
Line 103... Line 103...
103
    int num_found;
103
    int num_found;
104
 
104
 
105
    len = strlen(cmd_argv[0]);
105
    len = strlen(cmd_argv[0]);
106
    cmp_len = 1;
106
    cmp_len = 1;
107
 
107
 
-
 
108
    /* Silence warnings */
-
 
109
    num_found = 0;
-
 
110
    idx_found = 0;
-
 
111
 
108
    while (cmp_len <= len + 1) {
112
    while (cmp_len <= len + 1) {
109
 
113
 
110
        num_found = 0;
114
        num_found = 0;
111
        i = 0;
115
        i = 0;
112
        while (cmd_table[i].name != NULL) {
116
        while (cmd_table[i].name != NULL) {
Line 196... Line 200...
196
#define THASH_BUF_INIT_LENGTH 32
200
#define THASH_BUF_INIT_LENGTH 32
197
 
201
 
198
static int get_thread_list(thash_t **thash_buf_ptr, int *n)
202
static int get_thread_list(thash_t **thash_buf_ptr, int *n)
199
{
203
{
200
    int rc;
204
    int rc;
201
    int tb_copied;
205
    size_t tb_copied;
202
    int tb_needed;
206
    size_t tb_needed;
203
    int i;
207
    int i;
204
    size_t tb_size;
208
    size_t tb_size;
205
    thash_t *thash_buf;
209
    thash_t *thash_buf;
206
 
210
 
207
    tb_size = THASH_BUF_INIT_LENGTH * sizeof(thash_t);
211
    tb_size = THASH_BUF_INIT_LENGTH * sizeof(thash_t);
208
    thash_buf = malloc(tb_size);
212
    thash_buf = malloc(tb_size);
209
 
213
 
210
    rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf,
214
    rc = udebug_thread_read(app_phone, thash_buf,
211
        tb_size, &tb_copied, &tb_needed);
215
        tb_size, &tb_copied, &tb_needed);
212
    if (rc < 0) return rc;
216
    if (rc < 0) return rc;
213
 
217
 
214
    if (tb_needed > tb_size) {
218
    if (tb_needed > tb_size) {
215
        /* Larger buffer needed  */
219
        /* Larger buffer needed  */
Line 224... Line 228...
224
            exit(1);
228
            exit(1);
225
        }
229
        }
226
 
230
 
227
        /* Try again */
231
        /* Try again */
228
       
232
       
229
        rc = udebug_thread_read(app_phone, (sysarg_t)thash_buf,
233
        rc = udebug_thread_read(app_phone, thash_buf,
230
            tb_size, &tb_copied, &tb_needed);
234
            tb_size, &tb_copied, &tb_needed);
231
 
235
 
232
        if (rc < 0) return rc;
236
        if (rc < 0) return rc;
233
    }
237
    }
234
 
238
 
Line 245... Line 249...
245
    *thash_buf_ptr = thash_buf;
249
    *thash_buf_ptr = thash_buf;
246
 
250
 
247
    return 0;
251
    return 0;
248
}
252
}
249
 
253
 
250
void event_thread_b(unsigned hash)
254
static void event_thread_b(unsigned hash)
251
{
255
{
252
    async_serialize_start();
256
    async_serialize_start();
253
    cons_printf("new thread, hash 0x%x\n", hash);
257
    cons_printf("new thread, hash 0x%x\n", hash);
254
    async_serialize_end();
258
    async_serialize_end();
255
 
259
 
256
    thread_debug_start(hash);
260
    thread_debug_start(hash);
257
}
261
}
258
 
262
 
259
static unsigned buffer[1024];
-
 
260
 
-
 
261
static void debug_event(thash_t thash, udebug_event_t ev_type, sysarg_t val0)
263
static void debug_event(thash_t thash, udebug_event_t ev_type, sysarg_t val0)
262
{
264
{
263
    switch (ev_type) {
265
    switch (ev_type) {
264
    case UDEBUG_EVENT_STOP:
266
    case UDEBUG_EVENT_STOP:
265
        cons_printf("stop event\n");
267
        cons_printf("stop event\n");
Line 282... Line 284...
282
        cons_printf("unknown event type %d\n", ev_type);
284
        cons_printf("unknown event type %d\n", ev_type);
283
        break;
285
        break;
284
    }
286
    }
285
}
287
}
286
 
288
 
287
void debug_loop(void *dt_arg)
289
static int debug_loop(void *dt_arg)
288
{
290
{
289
    int rc;
291
    int rc;
290
    udebug_event_t ev_type;
292
    udebug_event_t ev_type;
291
    unsigned thread_buf_idx;
-
 
292
    unsigned val0, val1;
293
    unsigned val0, val1;
293
    dthread_t *dt;
294
    dthread_t *dt;
294
 
295
 
295
    dt = (dthread_t *)dt_arg;
296
    dt = (dthread_t *)dt_arg;
296
 
297
 
Line 307... Line 308...
307
        }
308
        }
308
        if (rc >= 0) debug_event(dt->hash, ev_type, val0);
309
        if (rc >= 0) debug_event(dt->hash, ev_type, val0);
309
    }
310
    }
310
 
311
 
311
    cons_printf("debug_loop(%d) exiting\n", dt->id);
312
    cons_printf("debug_loop(%d) exiting\n", dt->id);
-
 
313
    return 0;
312
}
314
}
313
 
315
 
314
void thread_debug_start(unsigned thash)
316
void thread_debug_start(unsigned thash)
315
{
317
{
316
    fid_t fid;
318
    fid_t fid;
Line 325... Line 327...
325
    dt->fid = fid;
327
    dt->fid = fid;
326
 
328
 
327
    fibril_add_ready(fid);
329
    fibril_add_ready(fid);
328
}
330
}
329
 
331
 
330
void debug_active_task(void)
332
static void debug_active_task(void)
331
{
333
{
332
    int taskid;
334
    int taskid;
333
    int i;
335
    int i;
334
    int rc;
336
    int rc;
335
    int c;
-
 
336
 
337
 
337
    thash_t *thash_buffer;
338
    thash_t *thash_buffer;
338
    int n_threads;
339
    int n_threads;
339
 
340
 
340
    cons_printf("Breakpoint Debugger\n");
341
    cons_printf("Breakpoint Debugger\n");