#!/bin/bash # (c) 2014, Sasha Levin #set -x if [[ $# < 2 ]]; then echo "Usage:" echo " $0 [vmlinux] [base path] [modules path]" exit 1 fi vmlinux=$1 basepath=$2 modpath=$3 declare -A cache declare -A modcache parse_symbol() { # The structure of symbol at this point is: # ([name]+[offset]/[total length]) # # For example: # do_basic_setup+0x9c/0xbf if [[ $module == "" ]] ; then local objfile=$vmlinux elif [[ "${modcache[$module]+isset}" == "isset" ]]; then local objfile=${modcache[$module]} else [[ $modpath == "" ]] && return local objfile=$(find "$modpath" -name $module.ko -print -quit) [[ $objfile == "" ]] && return modcache[$module]=$objfile fi # Remove the englobing parenthesis symbol=${symbol#\(} symbol=${symbol%\)} # Strip the symbol name so that we could look it up local name=${symbol%+*} # Use 'nm vmlinux' to figure out the base address of said symbol. # It's actually faster to call it every time than to load it # all into bash. if [[ "${cache[$module,$name]+isset}" == "isset" ]]; then local base_addr=${cache[$module,$name]} else local base_addr=$(nm "$objfile" | grep -i ' t ' | awk "/ $name\$/ {print \$1}" | head -n1) cache[$module,$name]="$base_addr" fi # Let's start doing the math to get the exact address into the # symbol. First, strip out the symbol total length. local expr=${symbol%/*} # Now, replace the symbol name with the base address we found # before. expr=${expr/$name/0x$base_addr} # Evaluate it to find the actual address expr=$((expr)) local address=$(printf "%x\n" "$expr") # Pass it to addr2line to get filename and line number # Could get more than one result if [[ "${cache[$module,$address]+isset}" == "isset" ]]; then local code=${cache[$module,$address]} else local code=$(addr2line -i -e "$objfile" "$address") cache[$module,$address]=$code fi # addr2line doesn't return a proper error code if it fails, so # we detect it using the value it prints so that we could preserve # the offset/size into the function and bail out if [[ $code == "??:0" ]]; then return fi # Strip out the base of the path code=${code//$basepath/""} # In the case of inlines, move everything to same line code=${code//$'\n'/' '} # Replace old address with pretty line numbers symbol="$name ($code)" } decode_code() { local scripts=`dirname "${BASH_SOURCE[0]}"` echo "$1" | $scripts/decodecode } handle_line() { local words # Tokenize read -a words <<<"$1" # Remove hex numbers. Do it ourselves until it happens in the # kernel # We need to know the index of the last element before we # remove elements because arrays are sparse local last=$(( ${#words[@]} - 1 )) for i in "${!words[@]}"; do # Remove the address if [[ ${words[$i]} =~ \[\<([^]]+)\>\] ]]; then unset words[$i] fi # Format timestamps with tabs if [[ ${words[$i]} == \[ && ${words[$i+1]} == *\] ]]; then unset words[$i] words[$i+1]=$(printf "[%13s\n" "${words[$i+1]}") fi done if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then module=${words[$last]} module=${module#\[} module=${module%\]} symbol=${words[$last-1]} unset words[$last-1] else # The symbol is the last element, process it symbol=${words[$last]} module= fi unset words[$last] parse_symbol # modifies $symbol # Add up the line number to the symbol echo "${words[@]}" "$symbol $module" } while read line; do # Let's see if we have an address in the line if [[ $line =~ \[\<([^]]+)\>\] ]] || [[ $line =~ [^+\ ]+\+0x[0-9a-f]+/0x[0-9a-f]+ ]]; then # Translate address to line numbers handle_line "$line" # Is it a code line? elif [[ $line == *Code:* ]]; then decode_code "$line" else # Nothing special in this line, show it as is echo "$line" fi done 7space:mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-03 13:46:38 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-03 13:46:38 -0800
commit3f67790d2b7e322bcf363ec717085dd78c3ea7cd (patch)
tree7be20232078a2e801ed93bcdb72f0d955dd9836f /drivers/usb/misc/rio500.c
parentcd44691f7177b2c1e1509d1a17d9b198ebaa34eb (diff)
parent206c4720092d2a24bfefc041b377e889a220ffbf (diff)
Merge tag 'regulator-fix-v4.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "Three changes here: two run of the mill driver specific fixes and a change from Mark Rutland which reverts some new device specific ACPI binding code which was added during the merge window as there are concerns about this sending the wrong signal about usage of regulators in ACPI systems" * tag 'regulator-fix-v4.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: fixed: Revert support for ACPI interface regulator: axp20x: AXP806: Fix dcdcb being set instead of dcdce regulator: twl6030: fix range comparison, allowing vsel = 59
Diffstat (limited to 'drivers/usb/misc/rio500.c')