1From 9bbc991a927722439cad38c892fc9f57207089d3 Mon Sep 17 00:00:00 2001
2From: Liwei Song <liwei.song@windriver.com>
3Date: Mon, 24 May 2021 08:27:28 +0000
4Subject: [PATCH] sleepgraph.py: parse unfished cpu exec line
5
6exist the below case in ftrace file:
7sleepgraph-6508    [003] .... 18197.824037: tracing_mark_write: ps - xxx..., lock_torture_wr-94 169,lock_torture_wr-95 143,lock_tort
8sleepgraph-6508    [003] .... 18197.824043: tracing_mark_write: ure_wr-96 189,lock_torture_wr-97 174,lock_torture_wr-98 160,lock_torture_st-99 1
9
10lock_torture_wr-96 was split to different line due to limited buffer
11size(1k) set in kernel, check this case and re-parse the unfinished
12line.
13
14Upstream-Status: [Submitted: https://github.com/intel/pm-graph/pull/20]
15
16Signed-off-by: Liwei Song <liwei.song@windriver.com>
17---
18 sleepgraph.py | 17 +++++++++++++++--
19 1 file changed, 15 insertions(+), 2 deletions(-)
20
21diff --git a/sleepgraph.py b/sleepgraph.py
22index e340d5b3f03b..38b4439db8eb 100755
23--- a/sleepgraph.py
24+++ b/sleepgraph.py
25@@ -3365,8 +3365,21 @@ def parseTraceLog(live=False):
26 					val = ps.split()
27 					if not val:
28 						continue
29-					name = val[0].replace('--', '-')
30-					proclist[name] = int(val[1])
31+					if not len(val) < 2:
32+						name = val[0].replace('--', '-')
33+						proclist[name] = int(val[1])
34+					else:
35+						proclist = dict()
36+						nextline = next(tf)
37+						mcont = re.match(tp.ftrace_line_fmt, nextline)
38+						n = m.group('ps') + mcont.group('msg').split(': ')[1]
39+						for pscont in n.split(','):
40+							val = pscont.split()
41+							if not val:
42+								continue
43+							if not len(val) < 2:
44+								name = val[0].replace('--', '-')
45+								proclist[name] = int(val[1])
46 				data.pstl[t.time] = proclist
47 				continue
48 		# find the end of resume
49--
502.29.2
51
52