@@ -117,57 +117,39 @@ application:
117
117
```
118
118
119
119
``` console
120
- (lldb) b DefaultExceptionHandler
121
- Breakpoint 1: where = app`DefaultExceptionHandler at lib.rs:95, address = 0x000000ec
120
+ (gdb) target remote :3333
121
+ Remote debugging using :3333
122
+ Reset () at ../rt/src/lib.rs:7
123
+ 7 pub unsafe extern "C" fn Reset() -> ! {
122
124
123
- (lldb) continue
124
- Process 1 resuming
125
- Process 1 stopped
126
- * thread #1, stop reason = breakpoint 1.1
127
- frame #0: 0x000000ec app`DefaultExceptionHandler at lib.rs:95
128
- 92
129
- 93 #[no_mangle]
130
- 94 pub extern "C" fn DefaultExceptionHandler() {
131
- -> 95 loop {}
132
- 96 }
125
+ (gdb) b DefaultExceptionHandler
126
+ Breakpoint 1 at 0xec: file ../rt/src/lib.rs, line 95.
127
+
128
+ (gdb) continue
129
+ Continuing.
130
+
131
+ Breakpoint 1, DefaultExceptionHandler ()
132
+ at ../rt/src/lib.rs:95
133
+ 95 loop {}
134
+
135
+ (gdb) list
136
+ 90 Vector { handler: SysTick },
137
+ 91 ];
138
+ 92
139
+ 93 #[no_mangle]
140
+ 94 pub extern "C" fn DefaultExceptionHandler() {
141
+ 95 loop {}
142
+ 96 }
133
143
```
134
144
135
145
And for completeness, here's the disassembly of the optimized version of the program:
136
146
137
147
``` console
138
- $ cargo objdump --bin app --release -- -d
148
+ $ cargo objdump --bin app --release -- -d -no-show-raw-insn -print-imm-hex
139
149
```
140
150
141
- > ** NOTE** ` llvm-objdump ` , which is what ` cargo-objdump ` invokes, produces
142
- > broken output for this particular file so the output below is actually the
143
- > output from ` arm-none-eabi-objdump `
144
-
145
-
146
151
``` text
147
- 00000040 <main>:
148
- 40: defe udf #254 ; 0xfe
149
- 42: defe udf #254 ; 0xfe
150
-
151
- 00000044 <Reset>:
152
- 44: f240 0100 movw r1, #0
153
- 48: f240 0000 movw r0, #0
154
- 4c: f2c2 0100 movt r1, #8192 ; 0x2000
155
- 50: f2c2 0000 movt r0, #8192 ; 0x2000
156
- 54: 1a09 subs r1, r1, r0
157
- 56: f000 f869 bl 12c <__aeabi_memclr>
158
- 5a: f240 0100 movw r1, #0
159
- 5e: f240 0000 movw r0, #0
160
- 62: f2c2 0100 movt r1, #8192 ; 0x2000
161
- 66: f2c2 0000 movt r0, #8192 ; 0x2000
162
- 6a: 1a0a subs r2, r1, r0
163
- 6c: f240 1132 movw r1, #306 ; 0x132
164
- 70: f2c0 0100 movt r1, #0
165
- 74: f000 f804 bl 80 <__aeabi_memcpy>
166
- 78: f7ff ffe2 bl 40 <main>
167
- 7c: defe udf #254 ; 0xfe
168
-
169
- 0000007e <DefaultExceptionHandler>:
170
- 7e: e7fe b.n 7e <DefaultExceptionHandler>
152
+ {{#include ../ci/exceptions/app/app.objdump:1:28}}
171
153
```
172
154
173
155
``` console
@@ -221,18 +203,28 @@ matches the name we used in `EXCEPTIONS`.
221
203
You can test it in QEMU
222
204
223
205
``` console
224
- (lldb) b HardFault
225
-
226
- (lldb) continue
227
- Process 1 resuming
228
- Process 1 stopped
229
- * thread #1, stop reason = breakpoint 1.1
230
- frame #0: 0x00000044 app`HardFault at main.rs:18
231
- 15 #[no_mangle]
232
- 16 pub extern "C" fn HardFault() -> ! {
233
- 17 // do something interesting here
234
- -> 18 loop {}
235
- 19 }
206
+ (gdb) target remote :3333
207
+ Remote debugging using :3333
208
+ Reset () at /home/japaric/rust/embedonomicon/ci/exceptions/rt/src/lib.rs:7
209
+ 7 pub unsafe extern "C" fn Reset() -> ! {
210
+
211
+ (gdb) b HardFault
212
+ Breakpoint 1 at 0x44: file src/main.rs, line 18.
213
+
214
+ (gdb) continue
215
+ Continuing.
216
+
217
+ Breakpoint 1, HardFault () at src/main.rs:18
218
+ 18 loop {}
219
+
220
+ (gdb) list
221
+ 13 }
222
+ 14
223
+ 15 #[no_mangle]
224
+ 16 pub extern "C" fn HardFault() -> ! {
225
+ 17 // do something interesting here
226
+ 18 loop {}
227
+ 19 }
236
228
```
237
229
238
230
The program now executes the user defined ` HardFault ` function instead of the
0 commit comments