├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.xml └── src └── EspStackTraceDecoder.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | install: ant 5 | notifications: 6 | on_success: never 7 | on_failure: always 8 | 9 | deploy: 10 | provider: releases 11 | api_key: 12 | secure: bd5qiGc/WtBkX9bIe4e9gKpMWq2ovxhEjgFhRQGEONw0+dJ/obYQRiP2VTzxVTY1CjPChJjKwyADUEqUQOSGTmUKK1mWZ+C4wi3Kb8cd3L4FEFO0ZzawbUnpVDYTW36lBtvqOZmagd8UMxk7CJKBjZSACiPfnzmT6k8WZtvEGVq2P/pAAD8eMpl1s/k6hFL37z+ZZqiEiXvQ/QfpLnkdC5y4Bd4Er5A0oX5h0ogndTinKmOv0em2AEbzAqMh82T2V2KRHzvCI97p6MWn9ybEg8CIMyI+OpPHs6lwJASgv0LfHC5+UD6XdOrlwrGzn9rXqGXZUtZRxL7OkgfVAqH3xl9Y3AccjLAF9fnw++2USHF+hRBm6B7P1WLtkW8By50mXxlqXZNkkvK/JK2Dt3fyawD1kcMuojfcm7FnnpyvY6eODoWlOw/cPTc+08LETtDbN1D1YpDhO963h2jqQjLLqrQ7RWKJeANf+x4WEhb1pr7VcHfpFQ7vBym2WCVf8pJVdSQ002Yhk3CYqw0kXzqWEY8xq1BVrwSk5S6jVpHfzJdyMs3aD/Bgav+wuN5frc+MTNaxj9ZudMs3Dw/nxaICTd9cW9+QqXL0NGJT0jgZ2urxbJZ/40Q+UKu3Jd/TRbHt85W2ul1G3sl9IRkVN6cUd8XfldLQrnj8gMzQ6fgOBrM= 13 | file: build/release/EspStackTraceDecoder.jar 14 | skip_cleanup: true 15 | on: 16 | repo: littleyoda/EspStackTraceDecoder 17 | tags: off 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Sven 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Command-line Decoder for Strack Trace from ESP8266 2 | 3 | based on the work from https://github.com/me-no-dev/EspExceptionDecoder, 4 | I rewrote the decoder completely for command-line usage. 5 | 6 | 7 | # Status [![Build Status](https://travis-ci.org/littleyoda/EspStackTraceDecoder.svg?branch=master)](https://travis-ci.org/littleyoda/EspStackTraceDecoder) 8 | - works for me (I'm using Eclipse for ESP8266) 9 | - not much tested 10 | - no good error handling 11 | - no documentation 12 | 13 | 14 | ## Usage 15 | 16 | Download the jar: https://github.com/littleyoda/EspStrackTraceDecoder/releases/latest 17 | 18 | java -jar EspStackTraceDecoder.jar \ \ \ 19 | 20 | For a program created within eclipse, I use the following command-line: 21 | java -jar EspStackTraceDecoder.jar /home/XXXX/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-addr2line /home/XXXX/project/Release/project.elf /tmp/dump.txt 22 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/EspStackTraceDecoder.java: -------------------------------------------------------------------------------- 1 | import java.io.BufferedReader; 2 | import java.io.File; 3 | import java.io.IOException; 4 | import java.io.InputStreamReader; 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.regex.Matcher; 10 | import java.util.regex.Pattern; 11 | 12 | 13 | public class EspStackTraceDecoder { 14 | File tool; 15 | File elf; 16 | 17 | private static String[] exceptions = { 18 | "Illegal instruction", 19 | "SYSCALL instruction", 20 | "InstructionFetchError: Processor internal physical address or data error during instruction fetch", 21 | "LoadStoreError: Processor internal physical address or data error during load or store", 22 | "Level1Interrupt: Level-1 interrupt as indicated by set level-1 bits in the INTERRUPT register", 23 | "Alloca: MOVSP instruction, if caller's registers are not in the register file", 24 | "IntegerDivideByZero: QUOS, QUOU, REMS, or REMU divisor operand is zero", 25 | "reserved", 26 | "Privileged: Attempt to execute a privileged operation when CRING ? 0", 27 | "LoadStoreAlignmentCause: Load or store to an unaligned address", 28 | "reserved", 29 | "reserved", 30 | "InstrPIFDataError: PIF data error during instruction fetch", 31 | "LoadStorePIFDataError: Synchronous PIF data error during LoadStore access", 32 | "InstrPIFAddrError: PIF address error during instruction fetch", 33 | "LoadStorePIFAddrError: Synchronous PIF address error during LoadStore access", 34 | "InstTLBMiss: Error during Instruction TLB refill", 35 | "InstTLBMultiHit: Multiple instruction TLB entries matched", 36 | "InstFetchPrivilege: An instruction fetch referenced a virtual address at a ring level less than CRING", 37 | "reserved", 38 | "InstFetchProhibited: An instruction fetch referenced a page mapped with an attribute that does not permit instruction fetch", 39 | "reserved", 40 | "reserved", 41 | "reserved", 42 | "LoadStoreTLBMiss: Error during TLB refill for a load or store", 43 | "LoadStoreTLBMultiHit: Multiple TLB entries matched for a load or store", 44 | "LoadStorePrivilege: A load or store referenced a virtual address at a ring level less than CRING", 45 | "reserved", 46 | "LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads", 47 | "StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores" 48 | }; 49 | 50 | 51 | private String[] analyseStracktrace(String content){ 52 | Pattern p = Pattern.compile("40[0-2][0-9a-f]{5}\\b"); 53 | List list = new ArrayList(); 54 | list.add(tool.getAbsolutePath()); 55 | list.add("-aipfC"); 56 | list.add("-e"); 57 | list.add(elf.getAbsolutePath()); 58 | Matcher m = p.matcher(content); 59 | while(m.find()) { 60 | list.add(m.group()); 61 | } 62 | if (list.size() == 4) { 63 | return null; 64 | } 65 | return list.toArray(new String[list.size()]); 66 | } 67 | 68 | private String analyseException(String content){ 69 | Pattern p = Pattern.compile("Exception \\(([0-9]*)\\):"); 70 | Matcher m = p.matcher(content); 71 | String description = "Exception Cause: "; 72 | if (!m.find()) { 73 | description += "Not found"; 74 | } else { 75 | int nummer = Integer.parseInt(m.group(1)); 76 | description += m.group(1) + " "; 77 | if (nummer >= 0 && nummer < exceptions.length) { 78 | description += " [" + exceptions[nummer] + "]"; 79 | } else { 80 | description += " [Unknown]"; 81 | } 82 | } 83 | return description; 84 | } 85 | 86 | 87 | public static void main(String[] args) throws IOException, InterruptedException{ 88 | if (args.length == 0) { 89 | usage(); 90 | System.exit(1); 91 | } 92 | EspStackTraceDecoder esp = new EspStackTraceDecoder(); 93 | esp.elf = new File(args[1]); 94 | esp.tool = new File(args[0]); 95 | String content = ""; 96 | if (args.length > 2) { 97 | content = new String(Files.readAllBytes(Paths.get(args[2]))); 98 | } else { 99 | String line = null; 100 | while ((line = System.console().readLine()) != null) { 101 | content = content + line + "\n"; 102 | } 103 | } 104 | System.out.println(esp.analyseException(content)); 105 | System.out.println(); 106 | String[] commands = esp.analyseStracktrace(content); 107 | if (commands == null) { 108 | System.out.println("No Addresse found in Stracktrace!"); 109 | System.exit(1); 110 | } 111 | 112 | ProcessBuilder ps=new ProcessBuilder(commands); 113 | ps.redirectErrorStream(true); 114 | Process pr = ps.start(); 115 | 116 | BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream())); 117 | String line; 118 | while ((line = in.readLine()) != null) { 119 | System.out.println(line); 120 | } 121 | pr.waitFor(); 122 | in.close(); 123 | } 124 | 125 | private static void usage() { 126 | System.out.println("Usage:"); 127 | System.out.println("java -jar EspEception "); 128 | } 129 | } 130 | --------------------------------------------------------------------------------