From df384518f9d95037c5c5bda83895bb26eae0c4aa Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Thu, 27 Jun 2024 14:34:58 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=20exc=5Finfo.bin=E6=96=87?= =?utf8?q?=E4=BB=B6=E8=A7=A3=E6=9E=90=E8=84=9A=E6=9C=AC=EF=BC=8C=E5=8F=AF?= =?utf8?q?=E4=BB=A5=E7=9B=B4=E6=8E=A5=E5=88=86=E6=9E=90=E6=89=8B=E8=A1=A8?= =?utf8?q?=E4=B8=AD=E4=B8=8B=E8=BD=BD=E7=9A=84=20exc=5Ftar=E6=96=87?= =?utf8?q?=E4=BB=B6=E3=80=82=20=E6=8C=87=E4=BB=A4=E5=8F=82=E8=80=83?= =?utf8?q?=E5=A6=82=E4=B8=8B=EF=BC=9A=20./tools/log=5Fparser/excdump.sh=20?= =?utf8?q?/d/logs/20240627/exc=5FV1.0.6=5F20240627=5F105411=5FCT=5F1458322?= =?utf8?q?.tar?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- tools/log_parser/dump_parser.py | 348 ++++++++++++++++++ tools/log_parser/excdump.sh | 33 ++ tools/log_parser/headers/Makefile | 17 + tools/log_parser/headers/brandy_a_freertos.h | 67 ++++ tools/log_parser/headers/brandy_a_liteos.h | 107 ++++++ tools/log_parser/headers/brandy_b.h | 25 ++ tools/log_parser/headers/common.h | 10 + tools/log_parser/headers/melody_a.h | 51 +++ tools/log_parser/headers/melody_b.h | 33 ++ .../headers/preprocess/brandy_a_freertos.h | 80 ++++ .../headers/preprocess/brandy_a_liteos.h | 91 +++++ .../log_parser/headers/preprocess/brandy_b.h | 38 ++ tools/log_parser/headers/preprocess/common.h | 12 + .../log_parser/headers/preprocess/melody_a.h | 64 ++++ .../log_parser/headers/preprocess/melody_b.h | 46 +++ 15 files changed, 1022 insertions(+) create mode 100644 tools/log_parser/dump_parser.py create mode 100644 tools/log_parser/excdump.sh create mode 100644 tools/log_parser/headers/Makefile create mode 100644 tools/log_parser/headers/brandy_a_freertos.h create mode 100644 tools/log_parser/headers/brandy_a_liteos.h create mode 100644 tools/log_parser/headers/brandy_b.h create mode 100644 tools/log_parser/headers/common.h create mode 100644 tools/log_parser/headers/melody_a.h create mode 100644 tools/log_parser/headers/melody_b.h create mode 100644 tools/log_parser/headers/preprocess/brandy_a_freertos.h create mode 100644 tools/log_parser/headers/preprocess/brandy_a_liteos.h create mode 100644 tools/log_parser/headers/preprocess/brandy_b.h create mode 100644 tools/log_parser/headers/preprocess/common.h create mode 100644 tools/log_parser/headers/preprocess/melody_a.h create mode 100644 tools/log_parser/headers/preprocess/melody_b.h diff --git a/tools/log_parser/dump_parser.py b/tools/log_parser/dump_parser.py new file mode 100644 index 000000000..d394e455b --- /dev/null +++ b/tools/log_parser/dump_parser.py @@ -0,0 +1,348 @@ +#!/usr/bin/python3 +# coding=utf-8 + +""" +用法: python3 dump_parser.py -d DEFINE -s STRUCT -i INPUT [-l LST] [-o OUTPUT] [-c CC] [-e {little,big}] + -d DEFINE, --define DEFINE + 包含结构体定义的 C 头文件路径 + -s STRUCT, --struct STRUCT + 要解析的结构体名 + -i INPUT, --input INPUT + 要解析的二进制文件 + -l LST, --lst LST 要解析的 lst 文件 + -o OUTPUT, --output OUTPUT + 将解析结果保存到文件中 (默认: 无) + -c CC, --cc CC 要使用的 C 语言预处理器 (默认: 不使用) + -e {little,big}, --endian {little,big} + 大小端序 (默认: little) +例如: python3 dump_parser.py -d melody.h -s exc_info_save_t -i dump.bin + +注意: 为避免平台不一致导致的解析错误, 建议头文件中声明的结构体使用 uintXX_t, intXX_t 等类型 +""" + +from enum import Enum +import sys +import ctypes +import pycparser +import pycparser.c_ast + +__version__ = "20231101" + +basic_types = { + "": ctypes.c_int, + "void": None, + "char": ctypes.c_byte, + "unsigned char": ctypes.c_ubyte, + "short": ctypes.c_short, + "unsigned short": ctypes.c_ushort, + "int": ctypes.c_int, + "unsigned int": ctypes.c_uint, + "unsigned": ctypes.c_uint, + "long": ctypes.c_long, + "unsigned long": ctypes.c_ulong, + "long long": ctypes.c_longlong, + "unsigned long long": ctypes.c_ulonglong, + "float": ctypes.c_float, + "double": ctypes.c_double, + "long double": ctypes.c_longdouble, + "_Bool": ctypes.c_bool, + "int8_t": ctypes.c_int8, + "uint8_t": ctypes.c_uint8, + "int16_t": ctypes.c_int16, + "uint16_t": ctypes.c_uint16, + "int32_t": ctypes.c_int32, + "uint32_t": ctypes.c_uint32, + "int64_t": ctypes.c_int64, + "uint64_t": ctypes.c_uint64, +} +hex_types = [ctypes.c_uint, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint32] +hex_types = [(t.__ctype_be__, t.__ctype_le__) for t in hex_types] +hex_types = [t for sublist in hex_types for t in sublist] +functions = [] # 函数名称及其地址范围(符号表) +stack_size = -1 # HACK 自动读取调用栈大小的临时解决方案 +callback = [] + +class Visitor(pycparser.c_ast.NodeVisitor): + def __init__(self, endian): + self.is_big_endian = endian == "big" + self.types = dict(basic_types) + self.id_context = {} + + def generic_visit(self, node): + raise RuntimeError(f"Unvisit AST element at {node.coord}: {node}") + + def visit_FileAST(self, node): + for c in node: + self.visit(c) + + def visit_Decl(self, node): + return self.visit(node.type) + + def visit_FuncDef(self, node): + return + + def visit_FuncDecl(self, node): + return + + def visit_Typename(self, node): + return self.visit(node.type) + + def visit_TypeDecl(self, node): + return self.visit(node.type) + + def visit_ArrayDecl(self, node): + length = self.visit(node.dim) + type = self.visit(node.type) + if length is None or length < 0: + raise RuntimeError(f"Invalid array length '{length}' at {node.dim.coord}") + if length == 0: + length = int(input(f"Input the size of array '{node.type.declname}': ")) + if type is None: + raise RuntimeError(f"Invalid array type '{type}' at {node.type.coord}") + return type * length + + def visit_PtrDecl(self, node): + pointer = self.visit(node.type) + return ctypes.POINTER(pointer) + + def visit_Typedef(self, node): + if node.name in self.types: + return + type = self.visit(node.type) + self.types[node.name] = type + + def visit_IdentifierType(self, node): + try: + if "signed" in node.names: + node.names.remove("signed") + if ("short" in node.names or "long" in node.names) and "int" in node.names: + node.names.remove("int") + name = " ".join(node.names) + return self.types[name] + except KeyError: + raise RuntimeError(f"Invalid type specifier '{name}' at {node.coord}") + + def visit_Enum(self, node): + if node.values is None: + return self.types[node.name] + enums = {} + value = -1 + for enum in node.values: + if enum.value is None: + value += 1 + else: + value = self.visit(enum.value) + self.id_context[enum.name] = enums[enum.name] = value + enum_name = node.name if node.name is not None else "enum_anon" + enum_type = type(enum_name, (ctypes.c_uint,), {"members": enums}) + self.types[enum_name] = enum_type + return enum_type + + def visit_Struct(self, node): + if node.decls is None: + return self.types[node.name] + fields = [] + for decl in node.decls: + value = self.visit(decl.type) + if value is None: + return None + if decl.bitsize is not None: + fields.append((decl.name, value, int(decl.bitsize.value))) + else: + fields.append((decl.name, value)) + struct_name = node.name if node.name is not None else "struct_anon" + struct_class = ctypes.BigEndianStructure if self.is_big_endian else ctypes.LittleEndianStructure + struct_type = type(struct_name, (struct_class,), {"_fields_": fields}) # TODO _pack_ 暂时无修改对齐的需求 + self.types[struct_name] = struct_type + return struct_type + + def visit_Union(self, node): + if node.decls is None: + return self.types[node.name] + fields = [] + for decl in node.decls: + value = self.visit(decl.type) + if value is None: + return None + fields.append((decl.name, value)) + union_name = node.name if node.name is not None else "union_anon" + union_class = ctypes.Union + if sys.version_info > (3, 11): # New in python 3.11 + union_class = ctypes.BigEndianUnion if self.is_big_endian else ctypes.LittleEndianUnion + union_type = type(union_name, (union_class,), {"_fields_": fields}) + self.types[union_name] = union_type + return union_type + + def visit_ID(self, node): + try: + return self.id_context[node.name] + except KeyError: + raise RuntimeError(f"Failed to resolve identifier '{node.name}' at {node.coord}") + + def visit_Constant(self, node): + if node.type not in ["int", "unsigned int"]: + raise RuntimeError(f"Unhandled Constant node type '{node.type}' at {node.coord}") + value = node.value.rstrip("LlUu") + if value.startswith(("0x", "0X")): + return int(value, 16) + return int(value) + +def parse_c(src, struct, cc, endian): + node = pycparser.parse_file(src, use_cpp=False) if cc is None else \ + pycparser.parse_file(src, use_cpp=True, cpp_path=cc, cpp_args=["-E"]) + v = Visitor(endian) + v.visit(node) + return v.types[struct] + +def parse_bin(struct, f): + bytearr = f.read() + obj = struct() + ctypes.memmove(ctypes.addressof(obj), bytearr, ctypes.sizeof(obj)) + return obj + +def parse_lst(f): + functions = [] + is_symbol_table = False + while True: + line = f.readline() + if not line: + break + line = line.strip() + if len(line) == 0: + continue + if not is_symbol_table: + if line == "SYMBOL TABLE:": + is_symbol_table = True + continue + if "Disassembly of section" in line: + break + item = line.split() + if item[2] != "F": + continue + addr = int(item[0], base=16) + length = int(item[4], base=16) + functions.append((addr, addr + length, item[-1])) + functions.sort(key=lambda x: x[0]) + return functions + +def find_function(start, end, addr): + if start >= end: + return "???" + mid = (start + end) // 2 + func = functions[mid] + if addr < func[0]: + return find_function(start, mid, addr) + if addr >= func[1]: + return find_function(mid + 1, end, addr) + return func[2] + +def parse_stack_arm(stack): + callback = [] + for item in stack: + callback.append(find_function(0, len(functions), item.fp)) + return callback + +def parse_stack_riscv(ra, stack): + callback = [] + callback.append(find_function(0, len(functions), ra)) + for item in stack: + callback.append(find_function(0, len(functions), item.ra)) + return callback + +def print_obj(obj, out=sys.stdout): + global stack_size + if isinstance(obj, ctypes.Structure): # 结构体 + for field in obj._fields_: + out.write("\n" if len(obj._fields_) > 2 else "\t") + name = field[0] + value = getattr(obj, name) + out.write(f"{name}:") + if isinstance(value, (int, float, bool, str)): + value = field[1](value) + if name == "stack": + stack_size = getattr(obj, "stack_size") + elif name == "backtrace": + stack_size = getattr(obj, "backtrace_size") + print_obj(value, out) + elif isinstance(obj, ctypes.Union): # 共用体 + print("\nSelect the type of this union:") + i = 1 + for field in obj._fields_: + print(f"{i}. {field[0]}") + i += 1 + num = int(input("Input number: ")) + field = obj._fields_[num - 1] + out.write("\n") + name = field[0] + value = getattr(obj, name) + out.write(f"{name}:") + if isinstance(value, (int, float, bool, str)): + value = field[1](value) + print_obj(value, out) + elif isinstance(obj, ctypes.Array): # 数组 + if obj._type_ == ctypes.c_byte: # C风格字符串 + byte_arr = bytes(obj) + byte_arr = byte_arr[0:byte_arr.find(b"\x00")] + print_obj(byte_arr.decode("utf-8", "ignore"), out) + else: + prefix = issubclass(obj._type_, ctypes.Structure) or issubclass(obj._type_, ctypes.Union) + i = 0 + for element in obj: + if stack_size >= 0 and i >= stack_size: + break + if prefix: out.write(f"\n[{i}]:") + if isinstance(element, (int, float, bool, str)): + element = obj._type_(element) + print_obj(element, out) + if stack_size >= 0 and i < len(callback): + out.write(f"\t<{callback[i]}>") + i += 1 + stack_size = -1 + elif hasattr(obj, "members"): # 枚举 + enums = [item[0] for item in obj.members.items() if item[1] == obj.value] + enum = enums[0] if len(enums) > 0 else "UNKNOWN" + out.write(f" {enum} ({hex(obj.value)})") + elif hasattr(obj, "value"): # 基本类型 + t = type(obj) + if t in hex_types: # 以十六进制显示的无符号数 + out.write(f" 0x{obj.value:08x}") + if stack_size == -1: + out.write(f" ({obj.value})") + else: + out.write(f" {obj.value}") + else: # 其它类型直接输出 + out.write(f" {obj}") + +if __name__ == "__main__": + import argparse + parser = argparse.ArgumentParser() + parser.add_argument("-d", "--define", type=str, required=True, help="C header file path") + parser.add_argument("-s", "--struct", type=str, required=True, help="The name of struct to be parsed") + parser.add_argument("-i", "--input", type=str, required=True, help="The bin file to be parsed") + parser.add_argument("-l", "--lst", type=str, help="The lst file to be parsed") + parser.add_argument("-o", "--output", type=str, help="Save the parse result into file (default: None)") + parser.add_argument("-c", "--cc", default=None, type=str, help="C preprocessor path (default: Not use)") + parser.add_argument("-e", "--endian", default="little", type=str, choices=["little", "big"], + help="Choose little or big endian (default: little)") + args = parser.parse_args() + + if args.lst: + with open(args.lst, "r", encoding="utf-8") as f: + functions = parse_lst(f) + root_struct = parse_c(args.define, args.struct, args.cc, args.endian) + with open(args.input, "rb") as f: + obj = parse_bin(root_struct, f) + if hasattr(obj, "stack") and len(functions) > 0: + if hasattr(obj, "ra"): + callback = parse_stack_riscv(obj.mepc, obj.stack) + else: + callback = parse_stack_arm(obj.stack) + if args.output is not None: + out = open(args.output, "w") + out.write("Last word info:") + print_obj(obj, out) + out.close() + else: + print("Last word info:", end="") + print_obj(obj) + print("\n========== finished! ==========") diff --git a/tools/log_parser/excdump.sh b/tools/log_parser/excdump.sh new file mode 100644 index 000000000..a1750a070 --- /dev/null +++ b/tools/log_parser/excdump.sh @@ -0,0 +1,33 @@ +#!/bin/bash +ROOTPATH=`dirname $0` +if [ -z $1 ]; then + echo "Usage: $0 [lst file]" + exit +fi + +parser_cmd=$ROOTPATH/dump_parser.py +header="brandy_a_liteos.h" +struct="exc_info_save_t" +srctarpath=$1 +srctar=`basename $srctarpath` +srcdir=`dirname $srctarpath` +version=${srctar:4:22} +mkdir -p $srcdir/bin_${srctar} +tar xf $srctarpath -C $srcdir/bin_$srctar +srcbin=`ls $srcdir/bin_$srctar/exc_*.bin` +#exc_V1.0.1_20240617_203628_CT_1718696920.tar +#/d/Snicker/release/V1.0.1_20240617_203628/bin/application.lst +releasepath=$ROOTPATH/../../release/pack_brandy_native_js/release +applst=$releasepath/$version/bin/application.lst +#echo $srctar +cp $releasepath/$version/bin/application* $srcdir/bin_$srctar/ +echo $# $srcbin $version $applst +if [ $# == 2 ]; then + extra_opt="-l $2" +else + extra_opt="-l $applst" +fi +echo python3 $parser_cmd -d $ROOTPATH/headers/preprocess/$header -s $struct -i $srcbin $extra_opt +python3 $parser_cmd -d $ROOTPATH/headers/preprocess/$header -s $struct -i $srcbin $extra_opt + + diff --git a/tools/log_parser/headers/Makefile b/tools/log_parser/headers/Makefile new file mode 100644 index 000000000..ce40d6766 --- /dev/null +++ b/tools/log_parser/headers/Makefile @@ -0,0 +1,17 @@ +CPP ?= cpp +ifeq ($(suffix $(SHELL)),.exe) + CPP := cpp + RM := del +endif +OUT_PATH := ./preprocess +HEADERS := $(addprefix $(OUT_PATH)/,$(wildcard *.h)) + +all: $(HEADERS) + +$(OUT_PATH)/%.h: %.h + $(CPP) $< > $@ + +clean: + $(RM) $(OUT_PATH)/* + +.phony: all clean diff --git a/tools/log_parser/headers/brandy_a_freertos.h b/tools/log_parser/headers/brandy_a_freertos.h new file mode 100644 index 000000000..1399ecbb6 --- /dev/null +++ b/tools/log_parser/headers/brandy_a_freertos.h @@ -0,0 +1,67 @@ +#include "common.h" + +#define SUPPORT_CALLSTACK + +#ifdef SUPPORT_CALLSTACK +typedef struct { + uint32_t ra; + uint32_t fp; +} exc_stack_info_t; +#else +typedef struct { + uint32_t sp_addr; + uint32_t sp_content; +} exc_backtrace_info_t; +#endif + +typedef struct { + char task_name[16]; + uint16_t uw_exc_type; + uint16_t ret; + uint32_t mepc; + uint32_t mstatus; + uint32_t mtval; + uint32_t mcause; +// #if CORE == WIFI +// uint32_t cxcptsc; +// #endif + uint32_t ra; + uint32_t sp; + uint32_t gp; + uint32_t tp; + uint32_t t0; + uint32_t t1; + uint32_t t2; + uint32_t s0; + uint32_t s1; + uint32_t a0; + uint32_t a1; + uint32_t a2; + uint32_t a3; + uint32_t a4; + uint32_t a5; + uint32_t a6; + uint32_t a7; + uint32_t s2; + uint32_t s3; + uint32_t s4; + uint32_t s5; + uint32_t s6; + uint32_t s7; + uint32_t s8; + uint32_t s9; + uint32_t s10; + uint32_t s11; + uint32_t t3; + uint32_t t4; + uint32_t t5; + uint32_t t6; + uint32_t reg0; + uint32_t reg1; + uint32_t reg2; + uint32_t reg3; +#ifdef SUPPORT_CALLSTACK + uint32_t stack_size; + exc_stack_info_t stack[20]; +#endif +} exc_info_save_t; diff --git a/tools/log_parser/headers/brandy_a_liteos.h b/tools/log_parser/headers/brandy_a_liteos.h new file mode 100644 index 000000000..416d9a6a2 --- /dev/null +++ b/tools/log_parser/headers/brandy_a_liteos.h @@ -0,0 +1,107 @@ +#include "common.h" + +#define SUPPORT_CALLSTACK +#define LOSCFG_EXC_SIMPLE_INFO 1 + +#ifdef SUPPORT_CALLSTACK +typedef struct { + uint32_t ra; + uint32_t fp; +} exc_stack_info_t; +#else +typedef struct { + uint32_t sp_addr; + uint32_t sp_content; +} exc_backtrace_info_t; +#endif + +typedef struct { + char task_name[16]; + uint32_t thrd_pid; + uint16_t type; + uint16_t nest_cnt; +#ifndef LOSCFG_EXC_SIMPLE_INFO + char phase[8]; +#else + uint16_t phase; + uint16_t ret; +#endif + uint32_t ccause; + uint32_t mcause; + uint32_t mtval; + uint32_t gp; + uint32_t mstatus; + uint32_t mepc; + uint32_t ra; + uint32_t sp; +#ifndef LOSCFG_EXC_SIMPLE_INFO + uint32_t tp; + uint32_t t0; + uint32_t t1; + uint32_t t2; + uint32_t s0; + uint32_t s1; + uint32_t a0; + uint32_t a1; + uint32_t a2; + uint32_t a3; + uint32_t a4; + uint32_t a5; + uint32_t a6; + uint32_t a7; + uint32_t s2; + uint32_t s3; + uint32_t s4; + uint32_t s5; + uint32_t s6; + uint32_t s7; + uint32_t s8; + uint32_t s9; + uint32_t s10; + uint32_t s11; + uint32_t t3; + uint32_t t4; + uint32_t t5; + uint32_t t6; +#else + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + uint32_t x11; + uint32_t x12; + uint32_t x13; + uint32_t x14; + uint32_t x15; + uint32_t x16; + uint32_t x17; + uint32_t x18; + uint32_t x19; + uint32_t x20; + uint32_t x21; + uint32_t x22; + uint32_t x23; + uint32_t x24; + uint32_t x25; + uint32_t x26; + uint32_t x27; + uint32_t x28; + uint32_t x29; + uint32_t x30; + uint32_t x31; +#endif + uint32_t reg0; + uint32_t reg1; + uint32_t reg2; + uint32_t reg3; +#ifdef SUPPORT_CALLSTACK + uint32_t stack_size; + exc_stack_info_t stack[20]; +#else + uint32_t backtrace_size; + exc_backtrace_info_t backtrace[20]; +#endif +} exc_info_save_t; diff --git a/tools/log_parser/headers/brandy_b.h b/tools/log_parser/headers/brandy_b.h new file mode 100644 index 000000000..7e752ec90 --- /dev/null +++ b/tools/log_parser/headers/brandy_b.h @@ -0,0 +1,25 @@ +#include "common.h" + +#define AULREG_VALUE_INDEX 13 + +typedef struct { + uint32_t v; +} reg_value_t; + +typedef struct { + // om_msg_header_stru_t msg_header; + uint32_t stack_limit; + uint32_t fault_type; + uint32_t fault_reason; + uint32_t address; + reg_value_t reg_value[AULREG_VALUE_INDEX]; + uint32_t psp_value; + uint32_t lr_value; + uint32_t pc_value; + uint32_t psps_value; + uint32_t primask_value; + uint32_t fault_mask_value; + uint32_t bserpri_value; + uint32_t control_value; + // uint8_t msg_tail; +} om_exception_info_stru_t; diff --git a/tools/log_parser/headers/common.h b/tools/log_parser/headers/common.h new file mode 100644 index 000000000..48ed2c619 --- /dev/null +++ b/tools/log_parser/headers/common.h @@ -0,0 +1,10 @@ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int int16_t; +typedef unsigned short int uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int int64_t; +typedef unsigned long int uint64_t; + +#define bool _Bool diff --git a/tools/log_parser/headers/melody_a.h b/tools/log_parser/headers/melody_a.h new file mode 100644 index 000000000..81854d487 --- /dev/null +++ b/tools/log_parser/headers/melody_a.h @@ -0,0 +1,51 @@ +#include "common.h" + +typedef struct { + uint32_t lr; + uint32_t fp; +} exc_stack_info_t; + +typedef struct { + char task_name[16]; + uint32_t task_id; + uint32_t task_stack_size; + uint32_t system_mem_addr; + char phase[22]; + uint16_t type; + uint32_t fault_addr; + uint32_t int_num_or_task_id; + uint32_t r0; + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t r4; + uint32_t r5; + uint32_t r6; + uint32_t r7; + uint32_t r8; + uint32_t r9; + uint32_t r10; + uint32_t r11; + uint32_t r12; + uint32_t pri_mask; + uint32_t sp; + uint32_t lr; + uint32_t pc; + uint32_t xpsr; + uint32_t psp; + uint32_t pri_mask_scb; + uint32_t fault_mask; + uint32_t base_pri; + uint32_t control; + uint32_t scb_icsr; + uint32_t scb_scr; + uint32_t scb_shcsr; + uint32_t scb_cfsr; + uint32_t scb_hfsr; + uint32_t scb_dfsr; + uint32_t scb_mmfar; + uint32_t scb_bfsr; + uint32_t scb_afsr; + uint32_t stack_size; + exc_stack_info_t stack[15]; +} exc_info_save_t; diff --git a/tools/log_parser/headers/melody_b.h b/tools/log_parser/headers/melody_b.h new file mode 100644 index 000000000..c3ce7eca7 --- /dev/null +++ b/tools/log_parser/headers/melody_b.h @@ -0,0 +1,33 @@ +#include "common.h" + +#define AULREG_VALUE_INDEX 13 + +typedef struct { + uint32_t v; +} reg_value_t; + +typedef struct excep_stack_info { + uint32_t lr; + uint32_t fp; +} exception_stack_info_t; + +typedef struct { + // om_msg_header_stru_t msg_header; + uint32_t stack_limit; + uint32_t fault_type; + uint32_t fault_reason; + uint32_t address; + reg_value_t reg_value[AULREG_VALUE_INDEX]; + uint32_t psp_value; + uint32_t lr_value; + uint32_t pc_value; + uint32_t psps_value; + uint32_t primask_value; + uint32_t fault_mask_value; + uint32_t bserpri_value; + uint32_t control_value; + uint32_t stack_size; + exception_stack_info_t stack[15]; + // uint8_t padding[3]; + // uint8_t msg_tail; +} om_exception_info_stru_t; diff --git a/tools/log_parser/headers/preprocess/brandy_a_freertos.h b/tools/log_parser/headers/preprocess/brandy_a_freertos.h new file mode 100644 index 000000000..ddceae52a --- /dev/null +++ b/tools/log_parser/headers/preprocess/brandy_a_freertos.h @@ -0,0 +1,80 @@ +# 1 "brandy_a_freertos.h" +# 1 "" +# 1 "" +# 1 "brandy_a_freertos.h" +# 1 "common.h" 1 +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int int16_t; +typedef unsigned short int uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int int64_t; +typedef unsigned long int uint64_t; +# 2 "brandy_a_freertos.h" 2 + + + + +typedef struct { + uint32_t ra; + uint32_t fp; +} exc_stack_info_t; + + + + + + + +typedef struct { + char task_name[16]; + uint16_t uw_exc_type; + uint16_t ret; + uint32_t mepc; + uint32_t mstatus; + uint32_t mtval; + uint32_t mcause; + + + + uint32_t ra; + uint32_t sp; + uint32_t gp; + uint32_t tp; + uint32_t t0; + uint32_t t1; + uint32_t t2; + uint32_t s0; + uint32_t s1; + uint32_t a0; + uint32_t a1; + uint32_t a2; + uint32_t a3; + uint32_t a4; + uint32_t a5; + uint32_t a6; + uint32_t a7; + uint32_t s2; + uint32_t s3; + uint32_t s4; + uint32_t s5; + uint32_t s6; + uint32_t s7; + uint32_t s8; + uint32_t s9; + uint32_t s10; + uint32_t s11; + uint32_t t3; + uint32_t t4; + uint32_t t5; + uint32_t t6; + uint32_t reg0; + uint32_t reg1; + uint32_t reg2; + uint32_t reg3; + + uint32_t stack_size; + exc_stack_info_t stack[20]; + +} exc_info_save_t; diff --git a/tools/log_parser/headers/preprocess/brandy_a_liteos.h b/tools/log_parser/headers/preprocess/brandy_a_liteos.h new file mode 100644 index 000000000..c1ecf8db4 --- /dev/null +++ b/tools/log_parser/headers/preprocess/brandy_a_liteos.h @@ -0,0 +1,91 @@ +# 1 "brandy_a_liteos.h" +# 1 "" +# 1 "" +# 1 "brandy_a_liteos.h" +# 1 "common.h" 1 +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int int16_t; +typedef unsigned short int uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int int64_t; +typedef unsigned long int uint64_t; +# 2 "brandy_a_liteos.h" 2 + + + + + +typedef struct { + uint32_t ra; + uint32_t fp; +} exc_stack_info_t; + + + + + + + +typedef struct { + char task_name[16]; + uint32_t thrd_pid; + uint16_t type; + uint16_t nest_cnt; + + + + uint16_t phase; + uint16_t ret; + + uint32_t ccause; + uint32_t mcause; + uint32_t mtval; + uint32_t gp; + uint32_t mstatus; + uint32_t mepc; + uint32_t ra; + uint32_t sp; +# 67 "brandy_a_liteos.h" + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + uint32_t x11; + uint32_t x12; + uint32_t x13; + uint32_t x14; + uint32_t x15; + uint32_t x16; + uint32_t x17; + uint32_t x18; + uint32_t x19; + uint32_t x20; + uint32_t x21; + uint32_t x22; + uint32_t x23; + uint32_t x24; + uint32_t x25; + uint32_t x26; + uint32_t x27; + uint32_t x28; + uint32_t x29; + uint32_t x30; + uint32_t x31; + + uint32_t reg0; + uint32_t reg1; + uint32_t reg2; + uint32_t reg3; + + uint32_t stack_size; + exc_stack_info_t stack[20]; + + + + +} exc_info_save_t; diff --git a/tools/log_parser/headers/preprocess/brandy_b.h b/tools/log_parser/headers/preprocess/brandy_b.h new file mode 100644 index 000000000..d253960db --- /dev/null +++ b/tools/log_parser/headers/preprocess/brandy_b.h @@ -0,0 +1,38 @@ +# 1 "brandy_b.h" +# 1 "" +# 1 "" +# 1 "brandy_b.h" +# 1 "common.h" 1 +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int int16_t; +typedef unsigned short int uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int int64_t; +typedef unsigned long int uint64_t; +# 2 "brandy_b.h" 2 + + + +typedef struct { + uint32_t v; +} reg_value_t; + +typedef struct { + + uint32_t stack_limit; + uint32_t fault_type; + uint32_t fault_reason; + uint32_t address; + reg_value_t reg_value[13]; + uint32_t psp_value; + uint32_t lr_value; + uint32_t pc_value; + uint32_t psps_value; + uint32_t primask_value; + uint32_t fault_mask_value; + uint32_t bserpri_value; + uint32_t control_value; + +} om_exception_info_stru_t; diff --git a/tools/log_parser/headers/preprocess/common.h b/tools/log_parser/headers/preprocess/common.h new file mode 100644 index 000000000..f6337c570 --- /dev/null +++ b/tools/log_parser/headers/preprocess/common.h @@ -0,0 +1,12 @@ +# 1 "common.h" +# 1 "" +# 1 "" +# 1 "common.h" +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int int16_t; +typedef unsigned short int uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int int64_t; +typedef unsigned long int uint64_t; diff --git a/tools/log_parser/headers/preprocess/melody_a.h b/tools/log_parser/headers/preprocess/melody_a.h new file mode 100644 index 000000000..c9d732d20 --- /dev/null +++ b/tools/log_parser/headers/preprocess/melody_a.h @@ -0,0 +1,64 @@ +# 1 "melody_a.h" +# 1 "" +# 1 "" +# 1 "melody_a.h" +# 1 "common.h" 1 +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int int16_t; +typedef unsigned short int uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int int64_t; +typedef unsigned long int uint64_t; +# 2 "melody_a.h" 2 + +typedef struct { + uint32_t lr; + uint32_t fp; +} exc_stack_info_t; + +typedef struct { + char task_name[16]; + uint32_t task_id; + uint32_t task_stack_size; + uint32_t system_mem_addr; + char phase[22]; + uint16_t type; + uint32_t fault_addr; + uint32_t int_num_or_task_id; + uint32_t r0; + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t r4; + uint32_t r5; + uint32_t r6; + uint32_t r7; + uint32_t r8; + uint32_t r9; + uint32_t r10; + uint32_t r11; + uint32_t r12; + uint32_t pri_mask; + uint32_t sp; + uint32_t lr; + uint32_t pc; + uint32_t xpsr; + uint32_t psp; + uint32_t pri_mask_scb; + uint32_t fault_mask; + uint32_t base_pri; + uint32_t control; + uint32_t scb_icsr; + uint32_t scb_scr; + uint32_t scb_shcsr; + uint32_t scb_cfsr; + uint32_t scb_hfsr; + uint32_t scb_dfsr; + uint32_t scb_mmfar; + uint32_t scb_bfsr; + uint32_t scb_afsr; + uint32_t stack_size; + exc_stack_info_t stack[15]; +} exc_info_save_t; diff --git a/tools/log_parser/headers/preprocess/melody_b.h b/tools/log_parser/headers/preprocess/melody_b.h new file mode 100644 index 000000000..2148160b9 --- /dev/null +++ b/tools/log_parser/headers/preprocess/melody_b.h @@ -0,0 +1,46 @@ +# 1 "melody_b.h" +# 1 "" +# 1 "" +# 1 "melody_b.h" +# 1 "common.h" 1 +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int int16_t; +typedef unsigned short int uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int int64_t; +typedef unsigned long int uint64_t; +# 2 "melody_b.h" 2 + + + +typedef struct { + uint32_t v; +} reg_value_t; + +typedef struct excep_stack_info { + uint32_t lr; + uint32_t fp; +} exception_stack_info_t; + +typedef struct { + + uint32_t stack_limit; + uint32_t fault_type; + uint32_t fault_reason; + uint32_t address; + reg_value_t reg_value[13]; + uint32_t psp_value; + uint32_t lr_value; + uint32_t pc_value; + uint32_t psps_value; + uint32_t primask_value; + uint32_t fault_mask_value; + uint32_t bserpri_value; + uint32_t control_value; + uint32_t stack_size; + exception_stack_info_t stack[15]; + + +} om_exception_info_stru_t; -- 2.17.1