//************************************************************************** | |
//* | |
//* Copyright (c) 2016 ZTE Corporation. | |
//* | |
//************************************************************************** | |
// geanfeng | |
//************************************************************************** | |
//* ½Å±¾½âÎöÇøÓò | |
//************************************************************************** | |
//¶¨Òå¾Ö²¿±äÁ¿ | |
local &os_time0 &os_time1 &os_time2 &os_time3 &os_time4 &os_time5 &os_time6 &os_time7 | |
local &os_time_cnt &os_next_time | |
local &os_swap_last &os_swap_cnt &os_swap_next | |
local &os_irq_start_last &os_irq_start_cnt &os_irq_start_next | |
local &os_irq_end_last &os_irq_end_cnt &os_irq_end_next | |
//for linux | |
local &os_softirq_start_last &os_softirq_start_cnt &os_softirq_start_next | |
local &os_softirq_end_last &os_softirq_end_cnt &os_softirq_end_next | |
local &os_timer_start_last &os_timer_start_cnt &os_timer_start_next | |
local &os_timer_end_last &os_timer_end_cnt &os_timer_end_next | |
local &os_irq_enable &os_softirq_enable &os_timer_enable | |
&os_irq_enable=1 | |
&os_softirq_enable=0 | |
&os_timer_enable=0 | |
//for tos | |
local &os_dsr_start_last &os_dsr_start_cnt &os_dsr_start_next | |
local &os_dsr_end_last &os_dsr_end_cnt &os_dsr_end_next | |
&os_dsr_enable=0 | |
//´´½¨Ò»¸ö´°¿Ú£» | |
&width=20. | |
&nameWidth=20. | |
&fileColumns=200. | |
&fileLines=500. | |
area.create trace &fileColumns &fileLines | |
area.clear trace | |
area.select trace | |
//´ò¿ªÎļþ£» | |
&dir=os.pwd()+"\log" | |
if !os.dir(&dir) | |
( | |
mkdir &dir | |
) | |
&file="&dir\result.txt" | |
area.open trace &file | |
area.view trace | |
//Èç¹ûT32ÔÚÔËÐÐÒª¶Ïס£» | |
if run() | |
( | |
break | |
) | |
if symbol.exist(init_task) | |
( | |
gosub LinuxTrace | |
) | |
if symbol.exist(tos_except) | |
( | |
gosub TosTrace | |
) | |
area.close trace | |
ENDDO | |
//****ÔËÐнáÊø***** | |
//*****************º¯Êý¶¨Òå********************** | |
; --------------------------------------------------------- | |
LinuxTrace: | |
local &result | |
if v.value(g_os_ddr_swapin_statistic)==0 | |
( | |
RETURN | |
) | |
&os_swap_last=v.value(g_os_ddr_swapin_statistic->index) | |
&os_swap_cnt=v.value(sizeof(g_os_ddr_swapin_statistic->statistics)/sizeof(g_os_ddr_swapin_statistic->statistics[0])) | |
&os_swap_next=&os_swap_last | |
if &os_irq_enable==1 | |
( | |
&os_irq_start_last=v.value(g_os_ddr_irq_start_statistic->index) | |
&os_irq_start_cnt=v.value(sizeof(g_os_ddr_irq_start_statistic->statistics)/sizeof(g_os_ddr_irq_start_statistic->statistics[0])) | |
&os_irq_start_next=&os_irq_start_last | |
&os_irq_end_last=v.value(g_os_ddr_irq_end_statistic->index) | |
&os_irq_end_cnt=v.value(sizeof(g_os_ddr_irq_end_statistic->statistics)/sizeof(g_os_ddr_irq_end_statistic->statistics[0])) | |
&os_irq_end_next=&os_irq_end_last | |
) | |
else | |
( | |
&os_irq_start_next=-1 | |
&os_irq_end_next=-1 | |
) | |
if &os_softirq_enable==1 | |
( | |
&os_softirq_start_last=v.value(g_os_ddr_softirq_start_statistic->index) | |
&os_softirq_start_cnt=v.value(sizeof(g_os_ddr_softirq_start_statistic->statistics)/sizeof(g_os_ddr_softirq_start_statistic->statistics[0])) | |
&os_softirq_start_next=&os_softirq_start_last | |
&os_softirq_end_last=v.value(g_os_ddr_softirq_end_statistic->index) | |
&os_softirq_end_cnt=v.value(sizeof(g_os_ddr_softirq_end_statistic->statistics)/sizeof(g_os_ddr_softirq_end_statistic->statistics[0])) | |
&os_softirq_end_next=&os_softirq_end_last | |
) | |
else | |
( | |
&os_softirq_start_next=-1 | |
&os_softirq_end_next=-1 | |
) | |
if &os_timer_enable==1 | |
( | |
&os_timer_start_last=v.value(g_os_ddr_timer_start_statistic->index) | |
&os_timer_start_cnt=v.value(sizeof(g_os_ddr_timer_start_statistic->statistics)/sizeof(g_os_ddr_timer_start_statistic->statistics[0])) | |
&os_timer_start_next=&os_timer_start_last | |
&os_timer_end_last=v.value(g_os_ddr_timer_end_statistic->index) | |
&os_timer_end_cnt=v.value(sizeof(g_os_ddr_timer_end_statistic->statistics)/sizeof(g_os_ddr_timer_end_statistic->statistics[0])) | |
&os_timer_end_next=&os_timer_end_last | |
) | |
else | |
( | |
&os_timer_start_next=-1 | |
&os_timer_end_next=-1 | |
) | |
//³õʼ»¯timeÊýÖµ | |
if &os_swap_next==-1 | |
( | |
&os_time0=-1 | |
) | |
else | |
( | |
&os_time0=v.value(g_os_ddr_swapin_statistic->statistics[&os_swap_next].data2) | |
) | |
if &os_irq_start_next==-1 | |
( | |
&os_time1=-1 | |
) | |
else | |
( | |
&os_time1=v.value(g_os_ddr_irq_start_statistic->statistics[&os_irq_start_next].data2) | |
) | |
if &os_irq_end_next==-1 | |
( | |
&os_time2=-1 | |
) | |
else | |
( | |
&os_time2=v.value(g_os_ddr_irq_end_statistic->statistics[&os_irq_end_next].data2) | |
) | |
if &os_softirq_start_next==-1 | |
( | |
&os_time3=-1 | |
) | |
else | |
( | |
&os_time3=v.value(g_os_ddr_softirq_start_statistic->statistics[&os_softirq_start_next].data2) | |
) | |
if &os_softirq_end_next==-1 | |
( | |
&os_time4=-1 | |
) | |
else | |
( | |
&os_time4=v.value(g_os_ddr_softirq_end_statistic->statistics[&os_softirq_end_next].data2) | |
) | |
if &os_timer_start_next==-1 | |
( | |
&os_time5=-1 | |
) | |
else | |
( | |
&os_time5=v.value(g_os_ddr_timer_start_statistic->statistics[&os_timer_start_next].data2) | |
) | |
if &os_timer_end_next==-1 | |
( | |
&os_time6=-1 | |
) | |
else | |
( | |
&os_time6=v.value(g_os_ddr_timer_end_statistic->statistics[&os_timer_end_next].data2) | |
) | |
&os_time_cnt=7. | |
&os_next_time=0. | |
print format.string("Name",32,' ')+" "+"Index"+" "+"Time"+" "+"Exce" | |
&result=0 | |
while &result==0 | |
( | |
gosub LinuxPrintNextLine | |
if ((&os_swap_next==-1)&&(&os_irq_start_next==-1)&&(&os_irq_end_next==-1)&&(&os_softirq_start_next==-1)&&(&os_softirq_end_next==-1)&&(&os_timer_start_next==-1)&&(&os_timer_end_next==-1)) | |
( | |
print "END" | |
&result=-1 | |
) | |
) | |
RETURN | |
; --------------------------------------------------------- | |
LinuxPrintNextLine: | |
local &time &str &line_index | |
gosub GetMinTimeIndex &os_time_cnt | |
ENTRY &index | |
if &index==0 | |
( | |
local &task &addr | |
&task=v.value(g_os_ddr_swapin_statistic->statistics[&os_swap_next].data1) | |
&addr=v.value(&((struct task_struct*)&task)->comm) | |
&str="THREAD: "+data.string(D:&addr) | |
&line_index=&os_swap_next | |
&time=&os_time0 | |
gosub GetNextIndex &os_swap_cnt &os_swap_last &os_swap_next | |
ENTRY &os_swap_next | |
if &os_swap_next==-1 | |
( | |
&os_time0=-1 | |
) | |
else | |
( | |
&os_time0=v.value(g_os_ddr_swapin_statistic->statistics[&os_swap_next].data2) | |
) | |
) | |
else if &index==1 | |
( | |
local &irq &addr | |
&irq=v.value(g_os_ddr_irq_start_statistic->statistics[&os_irq_start_next].data1) | |
&addr=v.value(irq_desc[&irq].action->name) | |
&str="IRQSTA: "+data.string(D:&addr)+" S" | |
&line_index=&os_irq_start_next | |
&time=&os_time1 | |
gosub GetNextIndex &os_irq_start_cnt &os_irq_start_last &os_irq_start_next | |
ENTRY &os_irq_start_next | |
if &os_irq_start_next==-1 | |
( | |
&os_time1=-1 | |
) | |
else | |
( | |
&os_time1=v.value(g_os_ddr_irq_start_statistic->statistics[&os_irq_start_next].data2) | |
) | |
) | |
else if &index==2 | |
( | |
local &irq &addr | |
&irq=v.value(g_os_ddr_irq_end_statistic->statistics[&os_irq_end_next].data1) | |
&addr=v.value(irq_desc[&irq].action->name) | |
&str="IRQEND: "+data.string(D:&addr)+" E" | |
&line_index=&os_irq_end_next | |
&time=&os_time2 | |
gosub GetNextIndex &os_irq_end_cnt &os_irq_end_last &os_irq_end_next | |
ENTRY &os_irq_end_next | |
if &os_irq_end_next==-1 | |
( | |
&os_time2=-1 | |
) | |
else | |
( | |
&os_time2=v.value(g_os_ddr_irq_end_statistic->statistics[&os_irq_end_next].data2) | |
) | |
) | |
else if &index==3 | |
( | |
local &vec &func | |
&time=v.value(g_os_ddr_softirq_start_statistic->statistics[&os_softirq_start_next].data2) | |
&vec=v.value(g_os_ddr_softirq_start_statistic->statistics[&os_softirq_start_next].data1) | |
&func=v.value(softirq_vec[&vec].action) | |
&str="SIRQS: "+symbol.function(P:&func)+" S" | |
&line_index=&os_softirq_start_next | |
&time=&os_time3 | |
gosub GetNextIndex &os_softirq_start_cnt &os_softirq_start_last &os_softirq_start_next | |
ENTRY &os_softirq_start_next | |
if &os_softirq_start_next==-1 | |
( | |
&os_time3=-1 | |
) | |
else | |
( | |
&os_time3=v.value(g_os_ddr_softirq_start_statistic->statistics[&os_softirq_start_next].data2) | |
) | |
) | |
else if &index==4 | |
( | |
local &vec &func | |
&time=v.value(g_os_ddr_softirq_end_statistic->statistics[&os_softirq_end_next].data2) | |
&vec=v.value(g_os_ddr_softirq_end_statistic->statistics[&os_softirq_end_next].data1) | |
&func=v.value(softirq_vec[&vec].action) | |
&str="SIRQE: "+symbol.function(P:&func)+" E" | |
&line_index=&os_softirq_end_next | |
&time=&os_time4 | |
gosub GetNextIndex &os_softirq_end_cnt &os_softirq_end_last &os_softirq_end_next | |
ENTRY &os_softirq_end_next | |
if &os_softirq_end_next==-1 | |
( | |
&os_time4=-1 | |
) | |
else | |
( | |
&os_time4=v.value(g_os_ddr_softirq_end_statistic->statistics[&os_softirq_end_next].data2) | |
) | |
) | |
else if &index==5 | |
( | |
local &func | |
&time=v.value(g_os_ddr_timer_start_statistic->statistics[&os_timer_start_next].data2) | |
&func=v.value(g_os_ddr_timer_start_statistic->statistics[&os_timer_start_next].data1) | |
&str="TIMERS: "+symbol.function(P:&func)+" S" | |
&line_index=&os_timer_start_next | |
&time=&os_time5 | |
gosub GetNextIndex &os_timer_start_cnt &os_timer_start_last &os_timer_start_next | |
ENTRY &os_timer_start_next | |
if &os_timer_start_next==-1 | |
( | |
&os_time5=-1 | |
) | |
else | |
( | |
&os_time5=v.value(g_os_ddr_timer_start_statistic->statistics[&os_timer_start_next].data2) | |
) | |
) | |
else if &index==6 | |
( | |
local &func | |
&time=v.value(g_os_ddr_timer_end_statistic->statistics[&os_timer_end_next].data2) | |
&func=v.value(g_os_ddr_timer_end_statistic->statistics[&os_timer_end_next].data1) | |
&str="TIMERE: "+symbol.function(P:&func)+" E" | |
&line_index=&os_timer_end_next | |
&time=&os_time6 | |
gosub GetNextIndex &os_timer_end_cnt &os_timer_end_last &os_timer_end_next | |
ENTRY &os_timer_end_next | |
if &os_timer_end_next==-1 | |
( | |
&os_time6=-1 | |
) | |
else | |
( | |
&os_time6=v.value(g_os_ddr_timer_end_statistic->statistics[&os_timer_end_next].data2) | |
) | |
) | |
else | |
( | |
print "Unknown Type" | |
) | |
gosub GetMinTime &os_time_cnt | |
ENTRY &os_next_time | |
print format.string("&str",32,' ')+" "+format.DecimalU(8,&line_index)+" "+format.DecimalU(1,&time)+" "+format.DecimalU(1,&os_next_time-&time) | |
RETURN | |
; --------------------------------------------------------- | |
GetNextIndex: | |
ENTRY &cnt &last_index &cur_index | |
local &index | |
if !((&cur_index>=0.)&&(&cur_index<&cnt)) | |
( | |
RETURN -1 | |
) | |
&index=&cur_index+1 | |
if &index>=&cnt | |
( | |
&index=0 | |
) | |
if &index==&last_index | |
( | |
&index=-1 | |
) | |
RETURN &index | |
; --------------------------------------------------------- | |
GetMinTimeIndex: | |
ENTRY &cnt | |
local &i &min_index &min_val | |
local &value &index | |
&i=0. | |
&min_index=0. | |
&min_val=0xFFFFFFFF | |
while &i<&cnt | |
( | |
&index=string.cut("&i",-1) | |
&&value=&os_time&index | |
if (&value!=-1)&&(&min_val>=&value) | |
( | |
&min_val=&value | |
&min_index=&i | |
) | |
&i=&i+1 | |
) | |
RETURN &min_index | |
; --------------------------------------------------------- | |
GetMinTime: | |
ENTRY &cnt | |
local &i &min_index &min_val | |
local &value &index | |
&i=0. | |
&min_index=0. | |
&min_val=0xFFFFFFFF | |
while &i<&cnt | |
( | |
&index=string.cut("&i",-1) | |
&&value=&os_time&index | |
if (&value!=-1)&&(&min_val>=&value) | |
( | |
&min_val=&value | |
&min_index=&i | |
) | |
&i=&i+1 | |
) | |
RETURN &min_val | |
; --------------------------------------------------------- | |
TosPrintNextLine: | |
local &time &str &line_index | |
gosub GetMinTimeIndex &os_time_cnt | |
ENTRY &index | |
if &index==0 | |
( | |
local &task &addr | |
&task=v.value(g_os_ddr_swapin_statistic->statistics[&os_swap_next].data1) | |
&addr=v.value(&((Cyg_Thread*)&task)->thread_name) | |
&str="THREAD: "+data.string(D:&addr) | |
&line_index=&os_swap_next | |
&time=&os_time0 | |
gosub GetNextIndex &os_swap_cnt &os_swap_last &os_swap_next | |
ENTRY &os_swap_next | |
if &os_swap_next==-1 | |
( | |
&os_time0=-1 | |
) | |
else | |
( | |
&os_time0=v.value(g_os_ddr_swapin_statistic->statistics[&os_swap_next].data2) | |
) | |
) | |
else if &index==1 | |
( | |
local &irq &addr | |
&irq=v.value(g_os_ddr_irq_start_statistic->statistics[&os_irq_start_next].data1) | |
&str="IRQSTA: "+format.DecimalU(1,&irq)+" S" | |
&line_index=&os_irq_start_next | |
&time=&os_time1 | |
gosub GetNextIndex &os_irq_start_cnt &os_irq_start_last &os_irq_start_next | |
ENTRY &os_irq_start_next | |
if &os_irq_start_next==-1 | |
( | |
&os_time1=-1 | |
) | |
else | |
( | |
&os_time1=v.value(g_os_ddr_irq_start_statistic->statistics[&os_irq_start_next].data2) | |
) | |
) | |
else if &index==2 | |
( | |
local &irq &addr | |
&irq=v.value(g_os_ddr_irq_end_statistic->statistics[&os_irq_end_next].data1) | |
&str="IRQEND: "+format.DecimalU(1,&irq)+" E" | |
&line_index=&os_irq_end_next | |
&time=&os_time2 | |
gosub GetNextIndex &os_irq_end_cnt &os_irq_end_last &os_irq_end_next | |
ENTRY &os_irq_end_next | |
if &os_irq_end_next==-1 | |
( | |
&os_time2=-1 | |
) | |
else | |
( | |
&os_time2=v.value(g_os_ddr_irq_end_statistic->statistics[&os_irq_end_next].data2) | |
) | |
) | |
else if &index==3 | |
( | |
local &dsr &addr | |
&dsr=v.value(g_os_ddr_dsr_start_statistic->statistics[&os_dsr_start_next].data1) | |
&str="DSRSTA: "+format.DecimalU(1,&dsr)+" S" | |
&line_index=&os_dsr_start_next | |
&time=&os_time3 | |
gosub GetNextIndex &os_dsr_start_cnt &os_dsr_start_last &os_dsr_start_next | |
ENTRY &os_dsr_start_next | |
if &os_dsr_start_next==-1 | |
( | |
&os_time3=-1 | |
) | |
else | |
( | |
&os_time3=v.value(g_os_ddr_dsr_start_statistic->statistics[&os_dsr_start_next].data2) | |
) | |
) | |
else if &index==4 | |
( | |
local &dsr &addr | |
&dsr=v.value(g_os_ddr_dsr_end_statistic->statistics[&os_dsr_end_next].data1) | |
&str="DSREND: "+format.DecimalU(1,&dsr)+" E" | |
&line_index=&os_dsr_end_next | |
&time=&os_time4 | |
gosub GetNextIndex &os_dsr_end_cnt &os_dsr_end_last &os_dsr_end_next | |
ENTRY &os_dsr_end_next | |
if &os_dsr_end_next==-1 | |
( | |
&os_time4=-1 | |
) | |
else | |
( | |
&os_time4=v.value(g_os_ddr_dsr_end_statistic->statistics[&os_dsr_end_next].data2) | |
) | |
) | |
else | |
( | |
print "Unknown Type" | |
) | |
gosub GetMinTime &os_time_cnt | |
ENTRY &os_next_time | |
print format.string("&str",32,' ')+" "+format.DecimalU(8,&line_index)+" "+format.DecimalU(1,&time)+" "+format.DecimalU(1,&os_next_time-&time) | |
RETURN | |
; --------------------------------------------------------- | |
TosTrace: | |
local &result | |
if v.value(g_os_ddr_swapin_statistic)==0 | |
( | |
RETURN | |
) | |
&os_swap_last=v.value(g_os_ddr_swapin_statistic->index) | |
&os_swap_cnt=v.value(sizeof(g_os_ddr_swapin_statistic->statistics)/sizeof(g_os_ddr_swapin_statistic->statistics[0])) | |
&os_swap_next=&os_swap_last | |
if &os_irq_enable==1 | |
( | |
&os_irq_start_last=v.value(g_os_ddr_irq_start_statistic->index) | |
&os_irq_start_cnt=v.value(sizeof(g_os_ddr_irq_start_statistic->statistics)/sizeof(g_os_ddr_irq_start_statistic->statistics[0])) | |
&os_irq_start_next=&os_irq_start_last | |
&os_irq_end_last=v.value(g_os_ddr_irq_end_statistic->index) | |
&os_irq_end_cnt=v.value(sizeof(g_os_ddr_irq_end_statistic->statistics)/sizeof(g_os_ddr_irq_end_statistic->statistics[0])) | |
&os_irq_end_next=&os_irq_end_last | |
) | |
else | |
( | |
&os_irq_start_next=-1 | |
&os_irq_end_next=-1 | |
) | |
if &os_dsr_enable==1 | |
( | |
&os_dsr_start_last=v.value(g_os_ddr_dsr_start_statistic->index) | |
&os_dsr_start_cnt=v.value(sizeof(g_os_ddr_dsr_start_statistic->statistics)/sizeof(g_os_ddr_dsr_start_statistic->statistics[0])) | |
&os_dsr_start_next=&os_dsr_start_last | |
&os_dsr_end_last=v.value(g_os_ddr_dsr_end_statistic->index) | |
&os_dsr_end_cnt=v.value(sizeof(g_os_ddr_dsr_end_statistic->statistics)/sizeof(g_os_ddr_dsr_end_statistic->statistics[0])) | |
&os_dsr_end_next=&os_dsr_end_last | |
) | |
else | |
( | |
&os_dsr_start_next=-1 | |
&os_dsr_end_next=-1 | |
) | |
if &os_swap_next==-1 | |
( | |
&os_time0=-1 | |
) | |
else | |
( | |
&os_time0=v.value(g_os_ddr_swapin_statistic->statistics[&os_swap_next].data2) | |
) | |
if &os_irq_start_next==-1 | |
( | |
&os_time1=-1 | |
) | |
else | |
( | |
&os_time1=v.value(g_os_ddr_irq_start_statistic->statistics[&os_irq_start_next].data2) | |
) | |
if &os_irq_end_next==-1 | |
( | |
&os_time2=-1 | |
) | |
else | |
( | |
&os_time2=v.value(g_os_ddr_irq_end_statistic->statistics[&os_irq_end_next].data2) | |
) | |
if &os_dsr_start_next==-1 | |
( | |
&os_time3=-1 | |
) | |
else | |
( | |
&os_time3=v.value(g_os_ddr_dsr_start_statistic->statistics[&os_dsr_start_next].data2) | |
) | |
if &os_dsr_end_next==-1 | |
( | |
&os_time4=-1 | |
) | |
else | |
( | |
&os_time4=v.value(g_os_ddr_dsr_end_statistic->statistics[&os_dsr_end_next].data2) | |
) | |
&os_time_cnt=5. | |
&os_next_time=0. | |
print format.string("Name",32,' ')+" "+"Index"+" "+"Time"+" "+"Exce" | |
&result=0 | |
while &result==0 | |
( | |
gosub TosPrintNextLine | |
if ((&os_swap_next==-1)&&(&os_irq_start_next==-1)&&(&os_irq_end_next==-1)&&(&os_dsr_start_next==-1)&&(&os_dsr_end_next==-1)) | |
( | |
print "END" | |
&result=-1 | |
) | |
) | |
RETURN |