~ubuntu-branches/ubuntu/lucid/skyeye/lucid-proposed

« back to all changes in this revision

Viewing changes to utils/debugger/gdb_tracepoint.c

  • Committer: Bazaar Package Importer
  • Author(s): Yu Guanghui
  • Date: 2007-08-07 13:25:49 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20070807132549-96159k1obat1fxr0
Tags: 1.2.3-1
* New upstream release
* Added NO_BFD=1, don't require libbfd now. (Closes:Bug#423933) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        debugger.h - necessary definition for skyeye debugger
 
3
        Copyright (C) 2003 Skyeye Develop Group
 
4
        for help please send mail to <skyeye-developer@lists.sf.linuxforum.net>
 
5
 
 
6
        This program is free software; you can redistribute it and/or modify
 
7
        it under the terms of the GNU General Public License as published by
 
8
        the Free Software Foundation; either version 2 of the License, or
 
9
        (at your option) any later version.
 
10
 
 
11
        This program is distributed in the hope that it will be useful,
 
12
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
        GNU General Public License for more details.
 
15
 
 
16
        You should have received a copy of the GNU General Public License
 
17
        along with this program; if not, write to the Free Software
 
18
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
*/
 
20
 
 
21
#include "skyeye2gdb.h" 
 
22
#include <stdio.h>
 
23
#include <stdlib.h>
 
24
#include <string.h>
 
25
 
 
26
extern void fetch_inferior_registers (int regno, unsigned char *memory);
 
27
extern register_defs_t *current_reg_type;
 
28
 
 
29
int add_tracepoint (unsigned int tp_number,unsigned int tp_address)
 
30
{
 
31
    if (skyeye_ice.num_tps<MAX_TRACEPOINTS)
 
32
    { 
 
33
        skyeye_ice.tps[skyeye_ice.num_tps].tp_address=tp_address;
 
34
        skyeye_ice.tps[skyeye_ice.num_tps].number=tp_number;     
 
35
        set_tracepoint_status(skyeye_ice.num_tps, TRACEPOINT_DISABLED);
 
36
        skyeye_ice.tps[skyeye_ice.num_tps].pass_count=0;
 
37
        skyeye_ice.tps[skyeye_ice.num_tps].remaining_pass=0;
 
38
        skyeye_ice.tps[skyeye_ice.num_tps].remaining_step=0;
 
39
        skyeye_ice.num_tps++;
 
40
        return(skyeye_ice.num_tps-1);
 
41
    } 
 
42
    else 
 
43
    { 
 
44
        return (-1);
 
45
    } 
 
46
}
 
47
 
 
48
int find_tp_id (unsigned int tp_number,unsigned int tp_address)
 
49
{
 
50
    int i;
 
51
    for (i=0;i<skyeye_ice.num_tps;i++)
 
52
    { 
 
53
        if ((skyeye_ice.tps[i].number==tp_number)&&(skyeye_ice.tps[i].tp_address==tp_address))
 
54
            return(i);
 
55
    } 
 
56
    return(-1);
 
57
}
 
58
 
 
59
 
 
60
void set_tracepoint_status(int tp_id, tracepoint_status status)
 
61
{
 
62
    skyeye_ice.tps[tp_id].status=status;
 
63
}
 
64
 
 
65
tracepoint_status get_tracepoint_status(int tp_id)
 
66
{
 
67
    return (skyeye_ice.tps[tp_id].status);
 
68
}
 
69
 
 
70
void set_tracepoint_address(int tp_id, unsigned int address )
 
71
{
 
72
    skyeye_ice.tps[tp_id].tp_address=address;
 
73
}
 
74
 
 
75
unsigned int get_tracepoint_address(int tp_id)
 
76
{
 
77
    return (skyeye_ice.tps[tp_id].tp_address);
 
78
}
 
79
 
 
80
void set_tracepoint_number(int tp_id, unsigned int number )
 
81
{
 
82
    skyeye_ice.tps[tp_id].number=number;
 
83
}
 
84
 
 
85
unsigned int get_tracepoint_number(int tp_id)
 
86
{
 
87
    return (skyeye_ice.tps[tp_id].number);
 
88
}
 
89
 
 
90
void set_tracepoint_pass_count(int tp_id, unsigned int pass_count )
 
91
{
 
92
    skyeye_ice.tps[tp_id].pass_count=pass_count;
 
93
}
 
94
 
 
95
unsigned int get_tracepoint_pass_count(int tp_id)
 
96
{
 
97
    return (skyeye_ice.tps[tp_id].pass_count);
 
98
}
 
99
 
 
100
void set_tracepoint_remaining_pass(int tp_id, unsigned int remaining_pass )
 
101
{
 
102
    skyeye_ice.tps[tp_id].remaining_pass=remaining_pass;
 
103
}
 
104
 
 
105
unsigned int get_tracepoint_remaining_pass(int tp_id)
 
106
{
 
107
    return (skyeye_ice.tps[tp_id].remaining_pass);
 
108
}
 
109
 
 
110
void set_tracepoint_remaining_step(int tp_id, unsigned int remaining_step )
 
111
{
 
112
    skyeye_ice.tps[tp_id].remaining_step=remaining_step;
 
113
}
 
114
 
 
115
unsigned int get_tracepoint_remaining_step(int tp_id)
 
116
{
 
117
    return (skyeye_ice.tps[tp_id].remaining_step);
 
118
}
 
119
 
 
120
void populate_default_action(action * current_action)
 
121
{
 
122
    current_action->type=ACTION_UNASSIGNED;
 
123
    current_action->sibling=NULL;
 
124
    current_action->child=NULL;
 
125
}
 
126
 
 
127
 
 
128
 
 
129
action* prepare_action(int tp_id, action *parent_action)
 
130
{
 
131
    action * current;
 
132
    if (parent_action==NULL) //we are not in a while-stepping case 
 
133
    { 
 
134
        if(skyeye_ice.tps[tp_id].actions ==NULL)
 
135
        { 
 
136
            skyeye_ice.tps[tp_id].actions=(action *)malloc(sizeof(action));
 
137
            populate_default_action(skyeye_ice.tps[tp_id].actions);
 
138
            return(skyeye_ice.tps[tp_id].actions);
 
139
        }  
 
140
        else  
 
141
        { 
 
142
            current =skyeye_ice.tps[tp_id].actions;
 
143
        }  
 
144
    } 
 
145
    else 
 
146
    { 
 
147
        if(parent_action->child ==NULL)
 
148
        { 
 
149
            parent_action->child=(action *)malloc(sizeof(action));
 
150
            populate_default_action(parent_action->child);
 
151
            return(parent_action->child);
 
152
        }  
 
153
        else 
 
154
        { 
 
155
            current =parent_action->child;
 
156
        } 
 
157
    } 
 
158
    while (current->sibling!=NULL)
 
159
    { 
 
160
        current=current->sibling;
 
161
    } 
 
162
    current->sibling=(action *)malloc(sizeof(action));
 
163
    populate_default_action(current->sibling);
 
164
    return(current->sibling);
 
165
}
 
166
 
 
167
 
 
168
 
 
169
 
 
170
void set_action_type (action *action_p, action_type type)
 
171
{
 
172
    action_p->type=type;
 
173
}
 
174
 
 
175
action_type get_action_type (action *action_p)
 
176
{
 
177
    return (action_p->type);
 
178
}
 
179
 
 
180
void set_action_data_type(action *action_p, collect_action_type type )
 
181
{
 
182
    action_p->action_data.ca.type=type;
 
183
}
 
184
 
 
185
collect_action_type get_action_data_type(action *action_p)
 
186
{
 
187
    return (action_p->action_data.ca.type);
 
188
}
 
189
 
 
190
void set_wa_step_count (action *action_p, unsigned int step_count)
 
191
{
 
192
    action_p->action_data.wa.step_count=step_count;
 
193
}
 
194
 
 
195
unsigned int get_wa_step_count (action *action_p)
 
196
{
 
197
    return (action_p->action_data.wa.step_count);
 
198
}
 
199
 
 
200
void set_wa_remaining_steps (action *action_p, unsigned int remaining_steps)
 
201
{
 
202
    action_p->action_data.wa.remaining_steps=remaining_steps;
 
203
}
 
204
 
 
205
void set_rc_action_mask( action *action_p, unsigned int mask)
 
206
{
 
207
    action_p->action_data.ca.description.rc.mask=mask;
 
208
}
 
209
 
 
210
void set_mc_action_base_reg(action *action_p, unsigned int base_reg)
 
211
{
 
212
    action_p->action_data.ca.description.mc.base_reg=base_reg;
 
213
}
 
214
 
 
215
void set_mc_action_offset(action *action_p, unsigned int offset)
 
216
{
 
217
    action_p->action_data.ca.description.mc.offset=offset;
 
218
}
 
219
 
 
220
void set_mc_action_length(action *action_p, unsigned int length)
 
221
{
 
222
    action_p->action_data.ca.description.mc.length=length;
 
223
}
 
224
 
 
225
void delete_action (action * current_action)
 
226
{
 
227
    //post fix iteration in a binary tree 
 
228
    if (current_action->sibling!=NULL)
 
229
    { 
 
230
        delete_action(current_action->sibling);
 
231
        current_action->sibling=NULL;
 
232
    } 
 
233
    if (current_action->child!=NULL)
 
234
    { 
 
235
        delete_action(current_action->child);
 
236
        current_action->child=NULL;
 
237
    } 
 
238
    if ((current_action->sibling==NULL)&&(current_action->child==NULL))
 
239
    { 
 
240
        free(current_action);
 
241
    } 
 
242
     
 
243
}
 
244
 
 
245
 
 
246
void clear_ro_regions(void)
 
247
{
 
248
    ro_region * previous_ro_region ,*next_ro_region;
 
249
     
 
250
    if (skyeye_ice.ro_region_head!=NULL)
 
251
    { 
 
252
        next_ro_region = skyeye_ice.ro_region_head;
 
253
        while(next_ro_region!=NULL)
 
254
        { 
 
255
            previous_ro_region=next_ro_region;
 
256
            next_ro_region=next_ro_region->next;
 
257
            free(previous_ro_region);
 
258
        } 
 
259
        skyeye_ice.ro_region_head=NULL;   
 
260
    }   
 
261
}
 
262
 
 
263
 
 
264
int is_in_ro_region(unsigned int addr, int length)
 
265
{
 
266
    ro_region *current_ro_region;
 
267
    if (skyeye_ice.ro_region_head==NULL)
 
268
    { 
 
269
        return 0;
 
270
    } 
 
271
    current_ro_region=skyeye_ice.ro_region_head;
 
272
    while(current_ro_region!=NULL)
 
273
    { 
 
274
        if ((current_ro_region->start <=addr)&&(current_ro_region->end >=addr+length))
 
275
        { 
 
276
            return (1);
 
277
        } 
 
278
        current_ro_region=current_ro_region->next;
 
279
    } 
 
280
    return (0);       
 
281
}
 
282
 
 
283
 
 
284
 
 
285
void add_ro_region(unsigned int start, unsigned int end)
 
286
{
 
287
    ro_region *current_ro_region;
 
288
    if (skyeye_ice.ro_region_head!=NULL)
 
289
    { 
 
290
        current_ro_region=skyeye_ice.ro_region_head;
 
291
        while(current_ro_region->next !=NULL)
 
292
        { 
 
293
            current_ro_region=current_ro_region->next;
 
294
        } 
 
295
        current_ro_region->next=(ro_region *)malloc (sizeof(ro_region));
 
296
        current_ro_region=current_ro_region->next;
 
297
    } 
 
298
    else 
 
299
    { 
 
300
        skyeye_ice.ro_region_head=(ro_region *)malloc (sizeof(ro_region));
 
301
        current_ro_region=skyeye_ice.ro_region_head;
 
302
    } 
 
303
    current_ro_region->start=start;
 
304
    current_ro_region->end=end;
 
305
    current_ro_region->next=NULL;
 
306
}
 
307
 
 
308
void clear_collect_records(collect_record *head_record)
 
309
{
 
310
    collect_record * previous_collect_record ,*next_collect_record;
 
311
     
 
312
    if (head_record!=NULL)
 
313
    { 
 
314
        next_collect_record = head_record;
 
315
        while(next_collect_record!=NULL)
 
316
        { 
 
317
            previous_collect_record=next_collect_record;
 
318
            next_collect_record=next_collect_record->next;
 
319
            free(previous_collect_record);
 
320
        }        
 
321
    }     
 
322
}
 
323
     
 
324
 
 
325
void clear_frame_buffers(void)
 
326
{
 
327
    frame_buffer * previous_frame_buffer ,*next_frame_buffer;
 
328
     
 
329
    if (skyeye_ice.fb!=NULL)
 
330
    { 
 
331
        next_frame_buffer = skyeye_ice.fb;
 
332
        while(next_frame_buffer!=NULL)
 
333
        { 
 
334
            previous_frame_buffer=next_frame_buffer;
 
335
            next_frame_buffer=next_frame_buffer->next;
 
336
            clear_collect_records(previous_frame_buffer->head_record);
 
337
            free(previous_frame_buffer);
 
338
        } 
 
339
        skyeye_ice.fb=NULL;
 
340
        skyeye_ice.num_fb =0;
 
341
    }  
 
342
}
 
343
 
 
344
 
 
345
 
 
346
frame_buffer * add_frame_buffer ( void )
 
347
{
 
348
    frame_buffer * current_frame_buffer;
 
349
     
 
350
    current_frame_buffer = skyeye_ice.fb;
 
351
    if (skyeye_ice.fb ==NULL)
 
352
    { 
 
353
        skyeye_ice.fb= (frame_buffer *)malloc (sizeof(frame_buffer));
 
354
        current_frame_buffer=skyeye_ice.fb;
 
355
    } 
 
356
    else  
 
357
    { 
 
358
        while  (current_frame_buffer ->next !=NULL)
 
359
        { 
 
360
            current_frame_buffer = current_frame_buffer ->next;
 
361
        } 
 
362
        current_frame_buffer ->next =(frame_buffer *)malloc (sizeof(frame_buffer));
 
363
        current_frame_buffer=current_frame_buffer ->next;
 
364
    } 
 
365
    // set every thing to default 
 
366
    current_frame_buffer->tp_number=0;
 
367
    current_frame_buffer->frame_number=skyeye_ice.num_fb;
 
368
    current_frame_buffer->head_record=NULL;
 
369
    current_frame_buffer->next=NULL;
 
370
    skyeye_ice.num_fb++;
 
371
    return (current_frame_buffer);
 
372
}
 
373
 
 
374
 
 
375
void trace_fetch_registers(int regno, unsigned char *memory)
 
376
{
 
377
    collect_record *current_record;
 
378
    if(skyeye_ice.selected_fb!=NULL)
 
379
    { 
 
380
        current_record=skyeye_ice.selected_fb->head_record;
 
381
        while (current_record!=NULL)
 
382
        { 
 
383
            if (current_record->ca->type ==COLLECT_REGISTERS)
 
384
            { 
 
385
                memcpy (memory,current_record->collect_data,current_record->collect_data_length);
 
386
                return;
 
387
            } 
 
388
            else 
 
389
            { 
 
390
                current_record=current_record->next;
 
391
            }  
 
392
        } 
 
393
    }      
 
394
}
 
395
 
 
396
int trace_read (unsigned int addr, unsigned char *buffer, int size)
 
397
{
 
398
    collect_record *current_record;
 
399
    if(skyeye_ice.selected_fb!=NULL)
 
400
    { 
 
401
        current_record=skyeye_ice.selected_fb->head_record;
 
402
        while (current_record!=NULL)
 
403
        { 
 
404
            if (current_record->ca->type ==COLLECT_MEMORY)
 
405
            { 
 
406
                if ((addr >=current_record->ca->description.mc.offset)&&(addr+size<=current_record->ca->description.mc.offset+current_record->ca->description.mc.length))
 
407
                { 
 
408
                  memcpy (buffer,(current_record->collect_data)+(addr-current_record->ca->description.mc.offset),size);
 
409
                  return (size);
 
410
                } 
 
411
                else  
 
412
                { 
 
413
                    current_record=current_record->next;
 
414
                } 
 
415
            } 
 
416
            else 
 
417
            { 
 
418
                current_record=current_record->next;
 
419
            }  
 
420
        } 
 
421
    }  
 
422
    return (-1)    ;
 
423
}
 
424
     
 
425
 
 
426
int select_frame_buffer_by_fn (int *tracepoint_number,int frame_number)
 
427
{
 
428
    frame_buffer * current_fb;
 
429
    if ( frame_number >skyeye_ice.num_fb)
 
430
    { 
 
431
        //the frame couldn't be found 
 
432
        return (0);
 
433
    } 
 
434
    else 
 
435
    { 
 
436
        skyeye_ice.selected_fb=skyeye_ice.fb;
 
437
        current_fb=skyeye_ice.selected_fb;
 
438
        while (current_fb !=NULL)
 
439
        {  
 
440
            if (current_fb->frame_number==frame_number)
 
441
            { 
 
442
                skyeye_ice.selected_fb=current_fb;
 
443
                *tracepoint_number=skyeye_ice.selected_fb->tp_number;
 
444
                return(1);
 
445
            } 
 
446
            else  
 
447
            { 
 
448
                current_fb=current_fb->next;
 
449
            } 
 
450
        } 
 
451
    } 
 
452
    return (0);
 
453
}
 
454
 
 
455
int select_frame_buffer_by_tpn (int tracepoint_number, int *frame_number)
 
456
{
 
457
    frame_buffer * current_fb;
 
458
    if (skyeye_ice.selected_fb==NULL)
 
459
    { 
 
460
        skyeye_ice.selected_fb=skyeye_ice.fb;
 
461
    } 
 
462
    if (skyeye_ice.selected_fb ==NULL) return (0);
 
463
     
 
464
    current_fb=skyeye_ice.selected_fb->next;
 
465
    while (current_fb !=NULL)
 
466
    {  
 
467
        if (current_fb->tp_number==tracepoint_number)
 
468
        { 
 
469
            skyeye_ice.selected_fb=current_fb;
 
470
            *frame_number=skyeye_ice.selected_fb->frame_number;
 
471
            return(1);
 
472
        } 
 
473
        else  
 
474
        { 
 
475
            current_fb=current_fb->next;
 
476
        } 
 
477
    } 
 
478
     
 
479
    return (0);
 
480
}
 
481
 
 
482
 
 
483
void do_action (unsigned int tp_id, action * current_action, frame_buffer * record_fb)
 
484
{
 
485
    int size;
 
486
    unsigned char * buffer ;
 
487
    collect_record * current_collect_record;
 
488
    unsigned int base_reg_val;
 
489
    unsigned char *registers;
 
490
     
 
491
    //point to the lase record in the frame buffer 
 
492
    if (record_fb==NULL) return;
 
493
    if (record_fb->head_record !=NULL)
 
494
    { 
 
495
        current_collect_record =record_fb->head_record;
 
496
        while (current_collect_record->next !=NULL)  
 
497
        { 
 
498
            current_collect_record = current_collect_record->next;
 
499
        } 
 
500
        current_collect_record->next = (collect_record *) malloc (sizeof (collect_record));
 
501
        current_collect_record=current_collect_record->next;
 
502
    } 
 
503
    else 
 
504
    { 
 
505
        record_fb->head_record = (collect_record *) malloc (sizeof (collect_record));
 
506
        current_collect_record=record_fb->head_record;
 
507
    } 
 
508
   
 
509
    if (current_action!=NULL)
 
510
    { 
 
511
       switch (current_action->type)
 
512
       { 
 
513
        case ACTION_COLLECT : 
 
514
            { 
 
515
                switch (current_action->action_data.ca.type)
 
516
                { 
 
517
                    case COLLECT_REGISTERS: 
 
518
                        { 
 
519
                            current_collect_record->collect_data= (char *)malloc (current_reg_type->register_bytes);
 
520
                            fetch_inferior_registers (-1, current_collect_record ->collect_data);
 
521
                            current_collect_record->collect_data_length=current_reg_type->register_bytes;
 
522
                            current_collect_record->ca=&(current_action->action_data.ca);
 
523
                            current_collect_record->next=NULL;
 
524
                        } 
 
525
                        break;
 
526
                    case COLLECT_MEMORY:  
 
527
                        { 
 
528
                              current_collect_record->collect_data= (char *)malloc(current_action->action_data.ca.description.mc.length);
 
529
                              //should be the content of basereg  
 
530
                              if (current_action->action_data.ca.description.mc.base_reg == -1)
 
531
                              { 
 
532
                                   base_reg_val=0;
 
533
                              } 
 
534
                              else 
 
535
                              { 
 
536
                                      registers = (unsigned char *)malloc(current_reg_type->register_bytes);
 
537
 
 
538
                                  fetch_inferior_registers (current_action->action_data.ca.description.mc.base_reg, registers);
 
539
                                  base_reg_val=registers[current_reg_type->register_byte (current_action->action_data.ca.description.mc.base_reg)];
 
540
                                  free (registers);
 
541
                                   
 
542
                              } 
 
543
                              current_collect_record->collect_data_length=sim_read (base_reg_val+current_action->action_data.ca.description.mc.offset, current_collect_record->collect_data, current_action->action_data.ca.description.mc.length);
 
544
                              current_collect_record->ca=&(current_action->action_data.ca);
 
545
                              current_collect_record->next=NULL;
 
546
                        } 
 
547
                        break;;
 
548
                    case COLLECT_EXPRESSION : ;
 
549
                    default : break;
 
550
                     
 
551
                } 
 
552
            } 
 
553
            break;
 
554
         
 
555
        case ACTION_WHILE :;
 
556
        default : break;
 
557
             
 
558
       } 
 
559
    }   
 
560
}
 
561
 
 
562
 
 
563
void do_action_list (unsigned int tp_id, action* actions, frame_buffer * fb)  
 
564
{
 
565
    frame_buffer *current_frame_buffer;
 
566
    action * current_action;
 
567
   
 
568
    current_frame_buffer =fb;
 
569
    current_action =actions;
 
570
    while (current_action !=NULL)
 
571
    { 
 
572
        switch (current_action->type)  
 
573
        { 
 
574
            case ACTION_COLLECT: 
 
575
                { 
 
576
                    do_action(tp_id,current_action,current_frame_buffer);
 
577
                    fprintf (stderr," tracepoint : %x, remaining pass : %x, action collect \n",skyeye_ice.tps[tp_id].number,skyeye_ice.tps[tp_id].remaining_pass);
 
578
                    current_action=current_action->sibling;
 
579
                } 
 
580
            break;
 
581
            case ACTION_WHILE: 
 
582
                { 
 
583
                    if (current_action->action_data.wa.remaining_steps !=0)
 
584
                    { 
 
585
                         set_tracepoint_status(tp_id, TRACEPOINT_STEPPING);
 
586
                         current_action->action_data.wa.remaining_steps--;
 
587
                         do_action_list(tp_id,current_action->child,current_frame_buffer);
 
588
                          
 
589
                         fprintf (stderr," tracepoint : %x, remaining pass : %x, action stepping \n",skyeye_ice.tps[tp_id].number,skyeye_ice.tps[tp_id].remaining_pass);
 
590
                        
 
591
                    } 
 
592
                    if (current_action->action_data.wa.remaining_steps ==0)
 
593
                    { 
 
594
                          set_tracepoint_status(tp_id, TRACEPOINT_ENABLED);
 
595
                          current_action->action_data.wa.remaining_steps=current_action->action_data.wa.step_count;
 
596
                          fprintf (stderr," tracepoint : %x, action stepping end \n",skyeye_ice.tps[tp_id].number);
 
597
                    } 
 
598
                    current_action=current_action->sibling;
 
599
                }  
 
600
            break;
 
601
        } 
 
602
    } 
 
603
}  
 
604
 
 
605
void handle_tracepoint(int tp_id)
 
606
{
 
607
    action * current_action;
 
608
    frame_buffer *current_frame_buffer;
 
609
   
 
610
    if (get_tracepoint_status(tp_id)==TRACEPOINT_STEPPING)
 
611
    { 
 
612
        //find the while stepping action 
 
613
        current_action=skyeye_ice.tps[tp_id].actions;
 
614
        while (current_action->type!=ACTION_WHILE)
 
615
        { 
 
616
            if (current_action->sibling !=NULL)
 
617
            {  
 
618
                current_action=current_action->sibling;
 
619
            }else 
 
620
            { 
 
621
                return;
 
622
            } 
 
623
        } 
 
624
        current_frame_buffer= add_frame_buffer();
 
625
        current_frame_buffer->tp_number=skyeye_ice.tps[tp_id].number;  
 
626
        //current action is a while action 
 
627
        do_action_list (tp_id,current_action,current_frame_buffer);
 
628
        return;       
 
629
    } 
 
630
    if (get_tracepoint_status(tp_id)==TRACEPOINT_ENABLED)
 
631
    {  
 
632
        if (skyeye_ice.tps[tp_id].pass_count!=0)
 
633
        { 
 
634
            if (skyeye_ice.tps[tp_id].remaining_pass!=0)
 
635
            { 
 
636
                //decrease the remaining_pass 
 
637
                skyeye_ice.tps[tp_id].remaining_pass--;
 
638
            } 
 
639
            else  
 
640
            { 
 
641
                //remaining_pass ==0, don't collect tracess 
 
642
                return;
 
643
            } 
 
644
        } 
 
645
        current_frame_buffer= add_frame_buffer();
 
646
        current_frame_buffer->tp_number=skyeye_ice.tps[tp_id].number;
 
647
        do_action_list (tp_id,skyeye_ice.tps[tp_id].actions,current_frame_buffer);
 
648
    } 
 
649
}
 
650
 
 
651
void clear_tracepoints(void)
 
652
{
 
653
    int i;
 
654
 
 
655
    skyeye_ice.num_tps=0;
 
656
 
 
657
    for (i=0;i<MAX_TRACEPOINTS;i++)
 
658
    { 
 
659
        if (skyeye_ice.tps[i].actions!=NULL)
 
660
            delete_action(skyeye_ice.tps[i].actions);
 
661
        skyeye_ice.tps[i].actions=NULL;
 
662
    } 
 
663
}
 
664
 
 
665
 
 
666
 
 
667
void init_tracepoints ()
 
668
{
 
669
    clear_tracepoints();
 
670
    skyeye_ice.tps_status=TRACE_STOPPED;
 
671
     
 
672
    clear_frame_buffers();
 
673
 
 
674
    skyeye_ice.selected_fb=NULL;
 
675
     
 
676
    clear_ro_regions();
 
677
     
 
678
    return;
 
679
}
 
680
 
 
681
void start_trace_recording ()
 
682
{
 
683
    skyeye_ice.tps_status=TRACE_STARTED;
 
684
}
 
685
 
 
686
void stop_trace_recording ()
 
687
{
 
688
    skyeye_ice.tps_status=TRACE_STOPPED;
 
689
}
 
690
 
 
691
void start_trace_focusing ()
 
692
{
 
693
    skyeye_ice.tps_status=TRACE_FOCUSING;     
 
694
}
 
695
 
 
696
void stop_trace_focusing ()
 
697
{
 
698
    skyeye_ice.tps_status=TRACE_STARTED;
 
699
    skyeye_ice.selected_fb=NULL;
 
700
}
 
701
 
 
702
trace_status get_trace_status()
 
703
{
 
704
    return(skyeye_ice.tps_status);
 
705
}
 
706