Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
f134ebb2 1d8365a5

+90 -2
+88
tools/bootconfig/scripts/bconf2ftrace.sh
··· 94 94 xbc_get_val $2 | while read field; do echo -n "$field; "; done 95 95 } 96 96 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 + 97 183 setup_event() { # prefix group event [instance] 98 184 branch=$1.$2.$3 99 185 if [ "$4" ]; then ··· 206 120 207 121 set_value_of ${branch}.filter ${eventdir}/filter 208 122 set_array_of ${branch}.actions ${eventdir}/trigger 123 + 124 + setup_histograms ${branch}.hist ${eventdir}/trigger 209 125 210 126 if xbc_has_key ${branch}.enable; then 211 127 run_cmd "echo 1 > ${eventdir}/enable"
+2 -2
tools/bootconfig/scripts/xbc.sh
··· 49 49 grep -q "^$1" $XBC_TMPFILE 50 50 } 51 51 52 - xbc_subkeys() { # prefix-key depth 52 + xbc_subkeys() { # prefix-key depth [subkey-pattern] 53 53 __keys=`echo $1 | sed "s/\./ /g"` 54 54 __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 56 56 }