您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

gbd.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. def main():
  2. import subprocess
  3. import glob
  4. # 获取当前目录中的所有 .out 文件
  5. out_files = glob.glob('*.out')
  6. if not out_files:
  7. out_files = glob.glob('*.elf')
  8. if not out_files:
  9. print("No .out files found in the current directory.")
  10. return
  11. elif len(out_files) > 1:
  12. print("Multiple .out files found. Using the first one found.")
  13. out_file = out_files[0] # 使用找到的第一个 .out 文件
  14. # 获取用户的多行输入
  15. print("Enter the input for mcu_coredump.exe (Ctrl-Z then Enter to finish):")
  16. user_input = []
  17. while True:
  18. try:
  19. line = input()
  20. except EOFError:
  21. break
  22. user_input.append(line)
  23. # 将输入写入文件
  24. with open('dump.txt', 'w') as file:
  25. file.write('\n'.join(user_input))
  26. # 运行 mcu_coredump.exe
  27. subprocess.run(['mcu_coredump.exe', 'dump.txt', 'core'])
  28. # 运行 GDB
  29. print(f"Running GDB to analyze the core dump using {out_file}...")
  30. subprocess.run(['arm-none-eabi-gdb.exe', out_file, 'core'])
  31. if __name__ == "__main__":
  32. main()