aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Tardy <tardyp@gmail.com>2011-02-28 16:59:51 +0100
committerPierre Tardy <tardyp@gmail.com>2011-02-28 16:59:51 +0100
commitaad4800e0df93e82a34a2d5e7fd826dc8739527a (patch)
tree8bbaf81ed8a2ec10ca0b460ea61880568822f76f
parentd1361e05977f70f815ff4807c754c181b1c47086 (diff)
linenumbers: simplify the linenumber tracking system
The old system was too complex, and did not actually worked.. the "Get Trace Text" functionnality now works correctly Signed-off-by: Pierre Tardy <tardyp@gmail.com>
-rw-r--r--timechart/model.py33
-rw-r--r--timechart/plugins/cpuidle.py3
-rw-r--r--timechart/plugins/menu_select.py2
-rw-r--r--timechart/plugins/runtime_pm.py2
4 files changed, 11 insertions, 29 deletions
diff --git a/timechart/model.py b/timechart/model.py
index c3e5c20..b959997 100644
--- a/timechart/model.py
+++ b/timechart/model.py
@@ -27,7 +27,6 @@ class tcGeneric(HasTraits):
name = String
start_ts = CArray
end_ts = CArray
- linenumbers = CArray
types = CArray
has_comments = Bool(True)
total_time = Property(Int)
@@ -199,17 +198,10 @@ class tcProject(HasTraits):
def get_selection_text(self,start,end):
low_line = -1
high_line = -1
- for tc in self.processes:
- low_i = searchsorted(tc.end_ts,start)
- high_i = searchsorted(tc.start_ts,end)
- if low_i < len(tc.linenumbers):
- ll = tc.linenumbers[low_i]
- if low_line==-1 or low_line > ll:
- low_line = ll
- if high_i < len(tc.linenumbers):
- hl = tc.linenumbers[high_i]
- if high_line==-1 or high_line > hl:
- high_line = hl
+ low_i = searchsorted(self.timestamps,start)
+ high_i = searchsorted(self.timestamps,end)
+ low_line = self.linenumbers[low_i]
+ high_line = self.linenumbers[high_i]
return self.get_partial_text(self.filename, low_line, high_line)
######### generic parsing part ##########
@@ -217,7 +209,7 @@ class tcProject(HasTraits):
def generic_find_process(self,pid,comm,ptype):
if self.tmp_process.has_key((pid,comm)):
return self.tmp_process[(pid,comm)]
- tmp = {'type':ptype,'comm':comm,'pid':pid,'start_ts':[],'end_ts':[],'types':[],'cpus':[],'comments':[],'linenumbers':[]}
+ tmp = {'type':ptype,'comm':comm,'pid':pid,'start_ts':[],'end_ts':[],'types':[],'cpus':[],'comments':[]}
if not (pid==0 and comm =="swapper"):
self.tmp_process[(pid,comm)] = tmp
return tmp
@@ -240,7 +232,6 @@ class tcProject(HasTraits):
p['start_ts'].append(int(event.timestamp))
p['types'].append(colors.get_color_id("waiting_for_cpu"))
p['cpus'].append(event.common_cpu)
- p['linenumbers'].append(event.linenumber)
p_stack.append(process)
else:
self.cur_process[event.common_cpu] = [process]
@@ -248,7 +239,6 @@ class tcProject(HasTraits):
process['start_ts'].append(event.timestamp)
process['types'].append(colors.get_color_id("running"))
process['cpus'].append(event.common_cpu)
- process['linenumbers'].append(event.linenumber)
def generic_process_end(self,process,event, build_p_stack=True):
@@ -282,7 +272,6 @@ class tcProject(HasTraits):
p['start_ts'].append(event.timestamp)
p['types'].append(colors.get_color_id("running"))
p['cpus'].append(event.common_cpu)
- p['linenumbers'].append(event.linenumber)
def do_event_sched_switch(self,event):
prev = self.generic_find_process(event.prev_pid,event.prev_comm,"user_process")
@@ -294,7 +283,6 @@ class tcProject(HasTraits):
prev['start_ts'].append(event.timestamp)
prev['types'].append(colors.get_color_id("waiting_for_cpu"))
prev['cpus'].append(event.common_cpu)
- prev['linenumbers'].append(event.linenumber)
self.generic_process_start(next,event)
@@ -355,6 +343,8 @@ class tcProject(HasTraits):
self.tmp_c_states = []
self.tmp_p_states = []
self.tmp_process = {}
+ self.timestamps = []
+ self.linenumbers = []
self.cur_process_by_pid = {}
self.wake_events = []
self.cur_process = [None]*20
@@ -390,7 +380,6 @@ class tcProject(HasTraits):
t.start_ts = numpy.array(tc['start_ts'])
t.end_ts = numpy.array(tc['end_ts'])
t.types = numpy.array(tc['types'])
- t.linenumbers = numpy.array(tc['linenumbers'])
c_states.append(t)
i+=1
self.c_states=c_states
@@ -401,7 +390,6 @@ class tcProject(HasTraits):
t.start_ts = numpy.array(tc['start_ts'])
t.end_ts = numpy.array(tc['end_ts'])
t.types = numpy.array(tc['types'])
- t.linenumbers = numpy.array(tc['linenumbers'])
i+=1
p_states.append(t)
self.wake_events = numpy.array(self.wake_events,dtype=[('waker',tuple),('wakee',tuple),('time','uint64')])
@@ -426,7 +414,6 @@ class tcProject(HasTraits):
t.types = numpy.array(tc['types'])
t.cpus = numpy.array(tc['cpus'])
t.comments = tc['comments'] #numpy.array(tc['comments'])
- t.linenumbers = numpy.array(tc['linenumbers'])
t.process_type = tc["type"]
processes.append(t)
def cmp_process(x,y):
@@ -455,12 +442,14 @@ class tcProject(HasTraits):
def ensure_cpu_allocated(self,cpu):
# ensure we have enough per_cpu p/c_states timecharts
while len(self.tmp_c_states)<=cpu:
- self.tmp_c_states.append({'start_ts':[],'end_ts':[],'types':[],'linenumbers':[]})
+ self.tmp_c_states.append({'start_ts':[],'end_ts':[],'types':[]})
while len(self.tmp_p_states)<=cpu:
- self.tmp_p_states.append({'start_ts':[],'end_ts':[],'types':[],'linenumbers':[]})
+ self.tmp_p_states.append({'start_ts':[],'end_ts':[],'types':[]})
def handle_trace_event(self,event):
callback = "do_event_"+event.event
+ self.linenumbers.append(event.linenumber)
+ self.timestamps.append(event.timestamp)
if event.event=='function':
callback = "do_event_"+event.callee
if self.plugin_methods.has_key(callback):
diff --git a/timechart/plugins/cpuidle.py b/timechart/plugins/cpuidle.py
index 5564d15..bfddc13 100644
--- a/timechart/plugins/cpuidle.py
+++ b/timechart/plugins/cpuidle.py
@@ -38,7 +38,6 @@ S0i1 #0022ff
print "warning: missed cpu_idle end: wont warn anymore!"
tc['start_ts'].append(event.timestamp)
tc['types'].append(colors.get_color_id(c_state_table[int(event.state)]))
- tc['linenumbers'].append(event.linenumber)
else :
if len(tc['start_ts'])>len(tc['end_ts']):
tc['end_ts'].append(event.timestamp)
@@ -57,7 +56,6 @@ S0i1 #0022ff
print "warning: missed power_end: wont warn anymore!"
tc['start_ts'].append(event.timestamp)
tc['types'].append(colors.get_color_id(c_state_table[int(event.state)]))
- tc['linenumbers'].append(event.linenumber)
@staticmethod
def do_event_power_end(self,event):
@@ -73,7 +71,6 @@ S0i1 #0022ff
if event.type==2:# p_state
tc = self.tmp_p_states[event.common_cpu]
tc['start_ts'].append(event.timestamp)
- tc['linenumbers'].append(event.linenumber)
tc['types'].append(event.state)
plugin_register(cpu_idle)
diff --git a/timechart/plugins/menu_select.py b/timechart/plugins/menu_select.py
index 1863ffb..4518a10 100644
--- a/timechart/plugins/menu_select.py
+++ b/timechart/plugins/menu_select.py
@@ -32,14 +32,12 @@ menu_select #ee0000
p['end_ts'].append(int(event.timestamp+event.predicted))
p['types'].append(colors.get_color_id("menu_select"))
p['cpus'].append(event.common_cpu)
- p['linenumbers'].append(event.linenumber)
p = p2
p['start_ts'].append(int(event.timestamp))
p['end_ts'].append(int(event.timestamp+event.expected))
p['types'].append(colors.get_color_id("menu_select"))
p['cpus'].append(event.common_cpu)
- p['linenumbers'].append(event.linenumber)
plugin_register(menu_select)
menu_select_patch="""
diff --git a/timechart/plugins/runtime_pm.py b/timechart/plugins/runtime_pm.py
index f4826bb..60b7d09 100644
--- a/timechart/plugins/runtime_pm.py
+++ b/timechart/plugins/runtime_pm.py
@@ -41,7 +41,6 @@ rpm_active #ee0000
p['start_ts'].append(int(event.timestamp))
p['types'].append(colors.get_color_id("rpm_%s"%(event.status.lower())))
p['cpus'].append(event.common_cpu)
- p['linenumbers'].append(event.linenumber)
@staticmethod
def do_event_runtime_pm_usage(proj, event):
@@ -57,6 +56,5 @@ rpm_active #ee0000
usagecolor = 6
p['types'].append(colors.get_color_id("rpm_usage=%d"%(usagecolor)))
p['cpus'].append(event.common_cpu)
- p['linenumbers'].append(event.linenumber)
plugin_register(runtime_pm)