tmedicci commented on code in PR #13546: URL: https://github.com/apache/nuttx/pull/13546#discussion_r1768932475
########## tools/espressif/btdecode.sh: ########## @@ -0,0 +1,144 @@ +#!/usr/bin/env bash +############################################################################ +# tools/espressif/btdecode.sh +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# This script can be used to decode the backtrace that's dumped on assertions. +# +# On assertions we can find the raw backtrace dump similar to: +# ... +# sched_dumpstack: backtrace| 0: 0x400e1a2a 0x40082912 +# sched_dumpstack: backtrace| 1: 0x400e39ac 0x400ef7c3 0x400ef7fc 0x400e8116 0x400e7910 0x400e7be8 0x400e6c5c 0x400e6ad6 +# sched_dumpstack: backtrace| 1: 0x400e6a99 0x400e4005 0x400e2754 +# sched_dumpstack: backtrace| 2: 0x400f13ee 0x400e4005 0x400e2754 +# ... +# +# Copy that to a file and call this script as: +# ./tools/espressif/btdecode.sh esp32 backtrace_file +# +# The result should be similar to the following: +# 0x400e1a2a: function_name at file.c:line +# 0x40082912: function_name at file.c:line + +USAGE="USAGE: ${0} chip backtrace_file" +VALID_CHIPS=("esp32" "esp32s2" "esp32s3" "esp32c3" "esp32c6" "esp32h2") + +# Make sure we have the required argument(s) + +if [ -z "$2" ]; then + echo "No backtrace supplied!" + echo "$USAGE" + exit 1 +fi + +# Check if the chip argument is valid + +chip=$1 +if [[ ! " ${VALID_CHIPS[@]} " =~ " ${chip} " ]]; then + echo "Invalid chip specified! Valid options are: ${VALID_CHIPS[*]}" + echo "$USAGE" + exit 4 +fi + +# Set the appropriate addr2line tool based on the chip + +case $chip in Review Comment: I made it generic: if the 1st argument contains `addr2line`, it will use it as the addr2line tool. Otherwise, it'll check the `VALID_CHIPS` list to associate the chip name to its addr2line tool. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
