History

tools/bootconfig: Add histogram syntax support to bconf2ftrace.sh

Add histogram syntax support to bconf2ftrace.sh script. Link: https://lkml.kernel.org/r/162856128672.203126.8240335908303312607.stgit@devnote2

Masami Hiramatsu committed 5 years ago

Commit f134ebb1 parent 1d8365a2 files · +90 −2Browse files

Showing the changes to tools/bootconfig/scripts (2 of 2 files). Show all

Unified · Split

2 files
  1. tools/bootconfig/scripts/bconf2ftrace.sh +88 −0
  2. tools/bootconfig/scripts/xbc.sh +2 −2
tools/bootconfig/scripts/bconf2ftrace.sh+88−0
@@ -94,6 +94,92 @@ compose_synth() { # event_name branch · 93 unmodified lines
9494 xbc_get_val $2 | while read field; do echo -n "$field; "; done
9595 }
9696
97+print_hist_array() { # prefix key
98+ __sep="="
99+ if xbc_has_key ${1}.${2}; then
100+ echo -n ":$2"
101+ xbc_get_val ${1}.${2} | while read field; do
102+ echo -n "$__sep$field"; __sep=","
103+ done
104+ fi
105+}
106+
107+print_hist_action_array() { # prefix key
108+ __sep="("
109+ echo -n ".$2"
110+ xbc_get_val ${1}.${2} | while read field; do
111+ echo -n "$__sep$field"; __sep=","
112+ done
113+ echo -n ")"
114+}
115+
116+print_hist_one_action() { # prefix handler param
117+ echo -n ":${2}("`xbc_get_val ${1}.${3}`")"
118+ if xbc_has_key "${1}.trace"; then
119+ print_hist_action_array ${1} "trace"
120+ elif xbc_has_key "${1}.save"; then
121+ print_hist_action_array ${1} "save"
122+ elif xbc_has_key "${1}.snapshot"; then
123+ echo -n ".snapshot()"
124+ fi
125+}
126+
127+print_hist_actions() { # prefix handler param
128+ for __hdr in `xbc_subkeys ${1}.${2} 1 ".[0-9]"`; do
129+ print_hist_one_action ${1}.${2}.$__hdr ${2} ${3}
130+ done
131+ if xbc_has_key ${1}.${2}.${3} ; then
132+ print_hist_one_action ${1}.${2} ${2} ${3}
133+ fi
134+}
135+
136+print_hist_var() { # prefix varname
137+ echo -n ":${2}="`xbc_get_val ${1}.var.${2} | tr -d [:space:]`
138+}
139+
140+print_one_histogram() { # prefix
141+ echo -n "hist"
142+ print_hist_array $1 "keys"
143+ print_hist_array $1 "values"
144+ print_hist_array $1 "sort"
145+ if xbc_has_key "${1}.size"; then
146+ echo -n ":size="`xbc_get_val ${1}.size`
147+ fi
148+ if xbc_has_key "${1}.name"; then
149+ echo -n ":name="`xbc_get_val ${1}.name`
150+ fi
151+ for __var in `xbc_subkeys "${1}.var" 1`; do
152+ print_hist_var ${1} ${__var}
153+ done
154+ if xbc_has_key "${1}.pause"; then
155+ echo -n ":pause"
156+ elif xbc_has_key "${1}.continue"; then
157+ echo -n ":continue"
158+ elif xbc_has_key "${1}.clear"; then
159+ echo -n ":clear"
160+ fi
161+ print_hist_actions ${1} "onmax" "var"
162+ print_hist_actions ${1} "onchange" "var"
163+ print_hist_actions ${1} "onmatch" "event"
164+
165+ if xbc_has_key "${1}.filter"; then
166+ echo -n " if "`xbc_get_val ${1}.filter`
167+ fi
168+}
169+
170+setup_one_histogram() { # prefix trigger-file
171+ run_cmd "echo '`print_one_histogram ${1}`' >> ${2}"
172+}
173+
174+setup_histograms() { # prefix trigger-file
175+ for __hist in `xbc_subkeys ${1} 1 ".[0-9]"`; do
176+ setup_one_histogram ${1}.$__hist ${2}
177+ done
178+ if xbc_has_key ${1}.keys; then
179+ setup_one_histogram ${1} ${2}
180+ fi
181+}
182+
97183 setup_event() { # prefix group event [instance]
98184 branch=$1.$2.$3
99185 if [ "$4" ]; then
@@ -121,6 +207,8 @@ setup_event() { # prefix group event [instance] · 21 unmodified lines
121207 set_value_of ${branch}.filter ${eventdir}/filter
122208 set_array_of ${branch}.actions ${eventdir}/trigger
123209
210+ setup_histograms ${branch}.hist ${eventdir}/trigger
211+
124212 if xbc_has_key ${branch}.enable; then
125213 run_cmd "echo 1 > ${eventdir}/enable"
126214 fi
tools/bootconfig/scripts/xbc.sh+2−2
@@ -49,8 +49,8 @@ xbc_has_branch() { # prefix-key · 48 unmodified lines
4949 grep -q "^$1" $XBC_TMPFILE
5050 }
5151
52−xbc_subkeys() { # prefix-key depth
52+xbc_subkeys() { # prefix-key depth [subkey-pattern]
5353 __keys=`echo $1 | sed "s/\./ /g"`
5454 __s=`nr_args $__keys`
55− grep "^$1" $XBC_TMPFILE | cut -d= -f1| cut -d. -f$((__s + 1))-$((__s + $2)) | uniq
55+ grep "^$1$3" $XBC_TMPFILE | cut -d= -f1| cut -d. -f$((__s + 1))-$((__s + $2)) | uniq
5656 }