Sfoglia il codice sorgente

[add] gdb脚本

rtthread_coredump
huangyulong 1 anno fa
parent
commit
6ba88f1e1c
1 ha cambiato i file con 41 aggiunte e 0 eliminazioni
  1. 41
    0
      EWARM/stm32_broad_mini/Exe/gbd.py

+ 41
- 0
EWARM/stm32_broad_mini/Exe/gbd.py Vedi File

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

Loading…
Annulla
Salva