summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Krummenacher <max.oss.09@gmail.com>2021-11-22 17:34:59 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-26 17:01:08 +0000
commit44a3909bf61a29d279a5a0a23d62cb9b0fdd3b52 (patch)
tree595cc1184ca7b88bd1154cd93bc9f5cb1b37a3f3
parentc67fab09fef16c092565d7be79fa8aff433af005 (diff)
downloadpoky-44a3909bf61a29d279a5a0a23d62cb9b0fdd3b52.tar.gz
perf: sort-pmuevents: allow for additional type qualifiers and storage class
With kernel 5.16 some structs in pmu-events do get a const qualifier, some a static const storage class and qualifier. The current sort-pmuevents cannot cope with that and drops all struct arrays with such additional elements. This then leads to compiler errors. Allow '^struct', '^const struct', '^static struct', '^static const struct'. (From OE-Core rev: 8406e83ade1c34d8a7d8063f2e7445aafa471721) Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xmeta/recipes-kernel/perf/perf/sort-pmuevents.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/meta/recipes-kernel/perf/perf/sort-pmuevents.py b/meta/recipes-kernel/perf/perf/sort-pmuevents.py
index 4f841eb822..09ba3328a7 100755
--- a/meta/recipes-kernel/perf/perf/sort-pmuevents.py
+++ b/meta/recipes-kernel/perf/perf/sort-pmuevents.py
@@ -33,10 +33,10 @@ if os.path.exists(outfile):
33with open(infile, 'r') as file: 33with open(infile, 'r') as file:
34 data = file.read() 34 data = file.read()
35 35
36preamble_regex = re.compile( '^(.*?)^struct', re.MULTILINE | re.DOTALL ) 36preamble_regex = re.compile( '^(.*?)^(struct|const struct|static struct|static const struct)', re.MULTILINE | re.DOTALL )
37 37
38preamble = re.search( preamble_regex, data ) 38preamble = re.search( preamble_regex, data )
39struct_block_regex = re.compile( '^struct.*?(\w+) (.*?)\[\] = {(.*?)^};', re.MULTILINE | re.DOTALL ) 39struct_block_regex = re.compile( '^(struct|const struct|static struct|static const struct).*?(\w+) (.*?)\[\] = {(.*?)^};', re.MULTILINE | re.DOTALL )
40field_regex = re.compile( '{.*?},', re.MULTILINE | re.DOTALL ) 40field_regex = re.compile( '{.*?},', re.MULTILINE | re.DOTALL )
41cpuid_regex = re.compile( '\.cpuid = (.*?),', re.MULTILINE | re.DOTALL ) 41cpuid_regex = re.compile( '\.cpuid = (.*?),', re.MULTILINE | re.DOTALL )
42name_regex = re.compile( '\.name = (.*?),', re.MULTILINE | re.DOTALL ) 42name_regex = re.compile( '\.name = (.*?),', re.MULTILINE | re.DOTALL )
@@ -45,24 +45,25 @@ name_regex = re.compile( '\.name = (.*?),', re.MULTILINE | re.DOTALL )
45# types and then their fields. 45# types and then their fields.
46entry_dict = {} 46entry_dict = {}
47for struct in re.findall( struct_block_regex, data ): 47for struct in re.findall( struct_block_regex, data ):
48 # print( "struct: %s %s" % (struct[0],struct[1]) ) 48 # print( "struct: %s %s %s" % (struct[0],struct[1],struct[2]) )
49 entry_dict[struct[1]] = {} 49 entry_dict[struct[2]] = {}
50 entry_dict[struct[1]]['type'] = struct[0] 50 entry_dict[struct[2]]['type_prefix'] = struct[0]
51 entry_dict[struct[1]]['fields'] = {} 51 entry_dict[struct[2]]['type'] = struct[1]
52 for entry in re.findall( field_regex, struct[2] ): 52 entry_dict[struct[2]]['fields'] = {}
53 for entry in re.findall( field_regex, struct[3] ):
53 #print( " entry: %s" % entry ) 54 #print( " entry: %s" % entry )
54 cpuid = re.search( cpuid_regex, entry ) 55 cpuid = re.search( cpuid_regex, entry )
55 if cpuid: 56 if cpuid:
56 #print( " cpuid found: %s" % cpuid.group(1) ) 57 #print( " cpuid found: %s" % cpuid.group(1) )
57 entry_dict[struct[1]]['fields'][cpuid.group(1)] = entry 58 entry_dict[struct[2]]['fields'][cpuid.group(1)] = entry
58 59
59 name = re.search( name_regex, entry ) 60 name = re.search( name_regex, entry )
60 if name: 61 if name:
61 #print( " name found: %s" % name.group(1) ) 62 #print( " name found: %s" % name.group(1) )
62 entry_dict[struct[1]]['fields'][name.group(1)] = entry 63 entry_dict[struct[2]]['fields'][name.group(1)] = entry
63 64
64 if not entry_dict[struct[1]]['fields']: 65 if not entry_dict[struct[2]]['fields']:
65 entry_dict[struct[1]]['fields']['0'] = entry 66 entry_dict[struct[2]]['fields']['0'] = entry
66 67
67# created ordered dictionaries from the captured values. These are ordered by 68# created ordered dictionaries from the captured values. These are ordered by
68# a sorted() iteration of the keys. We don't care about the order we read 69# a sorted() iteration of the keys. We don't care about the order we read
@@ -74,6 +75,7 @@ for struct in re.findall( struct_block_regex, data ):
74entry_dict_sorted = OrderedDict() 75entry_dict_sorted = OrderedDict()
75for i in sorted(entry_dict.keys()): 76for i in sorted(entry_dict.keys()):
76 entry_dict_sorted[i] = {} 77 entry_dict_sorted[i] = {}
78 entry_dict_sorted[i]['type_prefix'] = entry_dict[i]['type_prefix']
77 entry_dict_sorted[i]['type'] = entry_dict[i]['type'] 79 entry_dict_sorted[i]['type'] = entry_dict[i]['type']
78 entry_dict_sorted[i]['fields'] = {} 80 entry_dict_sorted[i]['fields'] = {}
79 for f in sorted(entry_dict[i]['fields'].keys()): 81 for f in sorted(entry_dict[i]['fields'].keys()):
@@ -85,7 +87,7 @@ outf = open( outfile, 'w' )
85print( preamble.group(1) ) 87print( preamble.group(1) )
86outf.write( preamble.group(1) ) 88outf.write( preamble.group(1) )
87for d in entry_dict_sorted: 89for d in entry_dict_sorted:
88 outf.write( "struct %s %s[] = {\n" % (entry_dict_sorted[d]['type'],d) ) 90 outf.write( "%s %s %s[] = {\n" % (entry_dict_sorted[d]['type_prefix'], entry_dict_sorted[d]['type'],d) )
89 for f in entry_dict_sorted[d]['fields']: 91 for f in entry_dict_sorted[d]['fields']:
90 outf.write( entry_dict_sorted[d]['fields'][f] + '\n' ) 92 outf.write( entry_dict_sorted[d]['fields'][f] + '\n' )
91 93