-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgdb.py
More file actions
133 lines (101 loc) · 3.39 KB
/
gdb.py
File metadata and controls
133 lines (101 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/python3
import subprocess
import dataclasses
import os
@dataclasses.dataclass
class Env:
target: str
env = Env("samd51-fkuw") if os.getenv("FKUW") else Env("samd51")
print(f"Env: {env}")
class FkSegger(gdb.Command):
"Segger mode."
def __init__(self):
super(FkSegger, self).__init__(
"js", gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, True
)
def invoke(self, arg, from_tty):
if arg is None or len(arg) == 0:
print("Pass JLink port: js 2331")
return
if True:
gdb.execute(
f"add-symbol-file build/{env.target}/bootloader/fkbl.elf 0x0000"
)
gdb.execute("target extended-remote :" + arg)
gdb.execute("monitor exec SetRTTSearchRanges 0x20000000 64")
if True:
gdb.execute("b osi_hard_fault_report")
gdb.execute("b fk_debugger_break")
gdb.execute("b fk_assert")
if False:
for h in irq_handlers:
gdb.execute("b " + h)
gdb.execute("monitor reset")
# NOTE GDB is crashing with this?!
if False:
gdb.execute("continue")
class FkFixLogs(gdb.Command):
"Fix logs."
def __init__(self):
super(FkFixLogs, self).__init__(
"jfl", gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, True
)
def invoke(self, arg, from_tty):
gdb.execute("monitor exec SetRTTSearchRanges 0x20000000 64")
class FkRunHosted(gdb.Command):
"Run hosted tests."
def __init__(self):
super(FkRunHosted, self).__init__(
"jrh", gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, True
)
def invoke(self, arg, from_tty):
made = subprocess.run(["make", "amd64", "-j4"])
if made.returncode != 0:
return False
gdb.execute("run")
class FkRestart(gdb.Command):
"Restart."
def __init__(self):
super(FkRestart, self).__init__(
"rs", gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, True
)
def invoke(self, arg, from_tty):
gdb.execute("monitor reset")
# NOTE GDB is crashing with this?!
if False:
gdb.execute("continue")
class FkReloadAllAndRun(gdb.Command):
"Reload all."
def __init__(self):
super(FkReloadAllAndRun, self).__init__(
"jrar", gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, True
)
def invoke(self, arg, from_tty):
made = subprocess.run(["make", "fw", "-j4", env.target])
if made.returncode != 0:
return False
gdb.execute(f"load build/{env.target}/bootloader/fkbl-fkb.elf")
gdb.execute(f"load build/{env.target}/fk/fk-bundled-fkb.elf")
gdb.execute(f"monitor reset")
# NOTE GDB is crashing with this?!
if False:
gdb.execute("continue")
class FkReloadAll(gdb.Command):
"Reload all."
def __init__(self):
super(FkReloadAll, self).__init__(
"jra", gdb.COMMAND_SUPPORT, gdb.COMPLETE_NONE, True
)
def invoke(self, arg, from_tty):
made = subprocess.run(["make", "fw", "-j4"])
if made.returncode != 0:
return False
gdb.execute(f"load build/{env.target}/bootloader/fkbl-fkb.elf")
gdb.execute(f"load build/{env.target}/fk/fk-bundled-fkb.elf")
gdb.execute(f"monitor reset")
# FkReloadAll()
FkReloadAllAndRun()
FkSegger()
# FkRunHosted()
# FkRestart()
# FkFixLogs()