def main(): import subprocess import glob # 获取当前目录中的所有 .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 文件 # 获取用户的多行输入 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()