| #!/bin/bash | |
| # Copyright 2017 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| #### CATEGORY=Run, inspect and debug | |
| ### listen for kernel logs | |
| ## usage: fx klog [--raw] [-r | --remote-symbols] | |
| ## | |
| ## --raw do not attempt to symbolize the log | |
| ## | |
| ## This command delegates to the Zircon `loglistener` binary. | |
| ## It will listen to the device specified with `fx -t DEVICE klog` or | |
| ## `fx set-device`, otherwise one of the devices on the link-local network. | |
| set -e | |
| set -o pipefail | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? | |
| fx-config-read | |
| declare is_raw=0 | |
| declare symbolizer=( "fx-command-run" "ffx" "debug" "symbolize" ) | |
| while [[ $# -ne 0 ]]; do | |
| case "$1" in | |
| -h|--help) | |
| fx-command-help | |
| exit 0 | |
| ;; | |
| --raw) | |
| is_raw=1 | |
| ;; | |
| --remote-symbols|-r) | |
| fx-error "--remote-symbols|-r is deprecated. Remote symbolization will be tried automatically." | |
| exit 1 | |
| ;; | |
| *) | |
| fx-error Invalid syntax | |
| fx-command-help | |
| exit 1 | |
| esac | |
| shift | |
| done | |
| device="$(get-device-name)" || exit $? | |
| if (( is_raw )); then | |
| exec "${FUCHSIA_BUILD_DIR}/host-tools/loglistener" "${device}" | |
| else | |
| "${FUCHSIA_BUILD_DIR}/host-tools/loglistener" "${device}" | "${symbolizer[@]}" | |
| fi |