| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- def main():
- import subprocess
- import glob
- import sys # Import sys to access command line arguments
-
- # 获取当前目录中的所有 .out 文件
- out_files = glob.glob('*.out')
-
- if not out_files:
- out_files = glob.glob('*.elf')
-
- if not out_files:
- print("No .out files found in the current directory.")
- return
- elif len(out_files) > 1:
- print("Multiple .out files found. Using the first one found.")
-
- out_file = out_files[0] # 使用找到的第一个 .out 文件
-
- # 检查是否已提供 dump.txt 作为第一个参数
- if len(sys.argv) > 1 and sys.argv[1] == 'dump.txt':
- print("Using provided dump.txt file.")
- else:
- # 获取用户的多行输入
- print("Enter the input for mcu_coredump.exe (Ctrl-Z then Enter to finish):")
- user_input = []
- while True:
- try:
- line = input()
- except EOFError:
- break
- user_input.append(line)
-
- # 将输入写入文件
- with open('dump.txt', 'w') as file:
- file.write('\n'.join(user_input))
-
- # 运行 mcu_coredump.exe
- subprocess.run(['mcu_coredump.exe', 'dump.txt', 'core'])
-
- # 运行 GDB
- print(f"Running GDB to analyze the core dump using {out_file}...")
- subprocess.run(['arm-none-eabi-gdb.exe', out_file, 'core'])
-
- if __name__ == "__main__":
- main()
|