Skip to content

Instantly share code, notes, and snippets.

@triffid
Created November 1, 2012 12:47
Show Gist options
  • Save triffid/3993439 to your computer and use it in GitHub Desktop.
Save triffid/3993439 to your computer and use it in GitHub Desktop.
Smoothie debugging
MSD:Got CBW 0x28 with datalength 4096
MSD: Read 8 blocks from LBA 121592
MSD:LBA 121592: 0 1 2 3 4 5 6 7
MSD:LBA 121593: 0 1 2 3 4 5 6 7
MSD:LBA 121594: 0 1 2 3 4 5 6 7
MSD:LBA 121595: 0 1 2 3 4 5 6 7
MSD:LBA 121596: 0 1 2 3 4 5 6 7
MSD:LBA 121597: 0 1 2 3 4 5 6 7
MSD:LBA 121598: 0 1 2 3 4 5 6 7
MSD:LBA 121599: 0 1 2 3 4 5 6 7
MSD:In:S3,G:1
MSD:In:S4,G:0
MSD:EPOut:Read 31
��{U&&�����}��}MSD: Read 8 blocks from MSD:LBA 121792: 0 1 2 3
**Hard Fault**
Status Register: 0x40000000
Forced
**Bus Fault**
Status Register: 0x82
Fault Address: 0x100295de
Precise Data Access
$T0b0c:107c0010;0d:007e0010;0e:6dbf0100;0f:80bf0100;#99^C
triffid@jinsuul ~/Projects/Smoothie-vanilla [130] $ arm-none-eabi-gdb main.elf -ex "set target-charset ASCII" -ex "set remotelogfile mri.log" -ex "target remote /dev/arduino_A900K10V"
GNU gdb (Sourcery G++ Lite 2011.03-42) 7.2.50.20100908-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi".
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>...
Reading symbols from /home/triffid/Projects/Smoothie-vanilla/main.elf...done.
Remote debugging using /dev/arduino_A900K10V
0x0001bf80 in _free_r ()
(gdb) bt
#0 0x0001bf80 in _free_r ()
#1 0x000042d8 in _M_dispose (this=0x10001708, format=...) at /home/triffid/Projects/gcc4mbed/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/include/c++/4.5.2/bits/basic_string.h:237
#2 ~basic_string (this=0x10001708, format=...) at /home/triffid/Projects/gcc4mbed/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/include/c++/4.5.2/bits/basic_string.h:525
#3 StreamOutputPool::printf (this=0x10001708, format=...) at ./src/libs/StreamOutputPool.h:41
#4 0x0000eeb2 in USBMSD::memoryRead (this=0x100007d4) at ./src/libs/USBDevice/USBMSD/USBMSD.cpp:614
#5 0x0000f0c2 in USBMSD::USBEvent_EPIn (this=0x100007d4, bEP=<value optimized out>, bEPStatus=<value optimized out>) at ./src/libs/USBDevice/USBMSD/USBMSD.cpp:262
#6 0x000073cc in USB::USBEvent_EPIn (this=<value optimized out>, bEP=<value optimized out>, bEPStatus=<value optimized out>) at src/libs/USBDevice/USB.cpp:306
#7 0x0000e6f0 in USBHAL::usbisr (this=0x100008bc) at ./src/libs/USBDevice/USBDevice/USBHAL_LPC17.cpp:940
#8 0x0000e7be in USB_IRQHandler () at ./src/libs/USBDevice/USBDevice/USBHAL_LPC17.cpp:770
#9 <signal handler called>
#10 SerialConsole::on_main_loop (this=0x10001718, argument=0x100014f0) at ./src/modules/communication/SerialConsole.cpp:50
#11 0x00004f38 in Kernel::call_event (this=0x100014f0, id_event=0) at ./src/libs/Kernel.cpp:91
#12 0x00000000 in ?? ()
(gdb) set pagination off
(gdb) bt
#0 0x0001bf80 in _free_r ()
#1 0x000042d8 in _M_dispose (this=0x10001708, format=...) at /home/triffid/Projects/gcc4mbed/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/include/c++/4.5.2/bits/basic_string.h:237
#2 ~basic_string (this=0x10001708, format=...) at /home/triffid/Projects/gcc4mbed/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/include/c++/4.5.2/bits/basic_string.h:525
#3 StreamOutputPool::printf (this=0x10001708, format=...) at ./src/libs/StreamOutputPool.h:41
#4 0x0000eeb2 in USBMSD::memoryRead (this=0x100007d4) at ./src/libs/USBDevice/USBMSD/USBMSD.cpp:614
#5 0x0000f0c2 in USBMSD::USBEvent_EPIn (this=0x100007d4, bEP=<value optimized out>, bEPStatus=<value optimized out>) at ./src/libs/USBDevice/USBMSD/USBMSD.cpp:262
#6 0x000073cc in USB::USBEvent_EPIn (this=<value optimized out>, bEP=<value optimized out>, bEPStatus=<value optimized out>) at src/libs/USBDevice/USB.cpp:306
#7 0x0000e6f0 in USBHAL::usbisr (this=0x100008bc) at ./src/libs/USBDevice/USBDevice/USBHAL_LPC17.cpp:940
#8 0x0000e7be in USB_IRQHandler () at ./src/libs/USBDevice/USBDevice/USBHAL_LPC17.cpp:770
#9 <signal handler called>
#10 SerialConsole::on_main_loop (this=0x10001718, argument=0x100014f0) at ./src/modules/communication/SerialConsole.cpp:50
#11 0x00004f38 in Kernel::call_event (this=0x100014f0, id_event=0) at ./src/libs/Kernel.cpp:91
#12 0x00000000 in ?? ()
(gdb) list
33
34 USB u;
35
36 USBSerial usbserial(&u);
37 USBMSD msc(&u, &sd);
38
39 char buf[512];
40
41 int main() {
42 sd.disk_initialize();
(gdb) disass
Dump of assembler code for function _free_r:
0x0001bf5c <+0>: push {r3, r4, r5, r6, r7, lr}
0x0001bf5e <+2>: mov r4, r0
0x0001bf60 <+4>: mov r5, r1
0x0001bf62 <+6>: cmp r1, #0
0x0001bf64 <+8>: beq.w 0x1c0b4 <_free_r+344>
0x0001bf68 <+12>: bl 0x1ce36 <__malloc_lock>
0x0001bf6c <+16>: ldr.w r0, [r5, #-4]
0x0001bf70 <+20>: ldr r7, [pc, #324] ; (0x1c0b8 <_free_r+348>)
0x0001bf72 <+22>: bic.w r2, r0, #1
0x0001bf76 <+26>: sub.w r3, r5, #8
0x0001bf7a <+30>: adds r1, r3, r2
0x0001bf7c <+32>: ldr.w r12, [r7, #8]
=> 0x0001bf80 <+36>: ldr r6, [r1, #4]
0x0001bf82 <+38>: cmp r1, r12
0x0001bf84 <+40>: bic.w r6, r6, #3
0x0001bf88 <+44>: and.w r0, r0, #1
0x0001bf8c <+48>: bne.n 0x1bfc0 <_free_r+100>
0x0001bf8e <+50>: adds r2, r6, r2
0x0001bf90 <+52>: cbnz r0, 0x1bfa2 <_free_r+70>
0x0001bf92 <+54>: ldr.w r1, [r5, #-8]
0x0001bf96 <+58>: subs r3, r3, r1
0x0001bf98 <+60>: ldr r0, [r3, #8]
0x0001bf9a <+62>: adds r2, r2, r1
0x0001bf9c <+64>: ldr r1, [r3, #12]
0x0001bf9e <+66>: str r1, [r0, #12]
0x0001bfa0 <+68>: str r0, [r1, #8]
0x0001bfa2 <+70>: orr.w r1, r2, #1
0x0001bfa6 <+74>: str r1, [r3, #4]
0x0001bfa8 <+76>: ldr r1, [pc, #268] ; (0x1c0b8 <_free_r+348>)
0x0001bfaa <+78>: str r3, [r1, #8]
0x0001bfac <+80>: ldr r3, [pc, #268] ; (0x1c0bc <_free_r+352>)
0x0001bfae <+82>: ldr r3, [r3, #0]
0x0001bfb0 <+84>: cmp r2, r3
0x0001bfb2 <+86>: bcc.n 0x1c0aa <_free_r+334>
0x0001bfb4 <+88>: ldr r3, [pc, #264] ; (0x1c0c0 <_free_r+356>)
0x0001bfb6 <+90>: mov r0, r4
0x0001bfb8 <+92>: ldr r1, [r3, #0]
0x0001bfba <+94>: bl 0x1bec8 <_malloc_trim_r>
0x0001bfbe <+98>: b.n 0x1c0aa <_free_r+334>
0x0001bfc0 <+100>: str r6, [r1, #4]
0x0001bfc2 <+102>: cbnz r0, 0x1bfdc <_free_r+128>
0x0001bfc4 <+104>: ldr.w r5, [r5, #-8]
0x0001bfc8 <+108>: adds r7, #8
0x0001bfca <+110>: subs r3, r3, r5
0x0001bfcc <+112>: adds r2, r2, r5
0x0001bfce <+114>: ldr r5, [r3, #8]
0x0001bfd0 <+116>: cmp r5, r7
0x0001bfd2 <+118>: beq.n 0x1bfe0 <_free_r+132>
0x0001bfd4 <+120>: ldr r7, [r3, #12]
0x0001bfd6 <+122>: str r7, [r5, #12]
0x0001bfd8 <+124>: str r5, [r7, #8]
0x0001bfda <+126>: b.n 0x1bfe2 <_free_r+134>
0x0001bfdc <+128>: movs r0, #0
0x0001bfde <+130>: b.n 0x1bfe2 <_free_r+134>
0x0001bfe0 <+132>: movs r0, #1
0x0001bfe2 <+134>: adds r5, r1, r6
0x0001bfe4 <+136>: ldr r5, [r5, #4]
0x0001bfe6 <+138>: tst.w r5, #1
0x0001bfea <+142>: bne.n 0x1c00c <_free_r+176>
0x0001bfec <+144>: adds r2, r2, r6
0x0001bfee <+146>: cbnz r0, 0x1c004 <_free_r+168>
0x0001bff0 <+148>: ldr r5, [r1, #8]
0x0001bff2 <+150>: ldr r6, [pc, #208] ; (0x1c0c4 <_free_r+360>)
0x0001bff4 <+152>: cmp r5, r6
0x0001bff6 <+154>: bne.n 0x1c004 <_free_r+168>
0x0001bff8 <+156>: str r3, [r6, #12]
0x0001bffa <+158>: str r3, [r6, #8]
0x0001bffc <+160>: str r5, [r3, #12]
0x0001bffe <+162>: str r5, [r3, #8]
0x0001c000 <+164>: movs r0, #1
0x0001c002 <+166>: b.n 0x1c00c <_free_r+176>
0x0001c004 <+168>: ldr r5, [r1, #12]
0x0001c006 <+170>: ldr r1, [r1, #8]
0x0001c008 <+172>: str r5, [r1, #12]
0x0001c00a <+174>: str r1, [r5, #8]
0x0001c00c <+176>: orr.w r1, r2, #1
0x0001c010 <+180>: str r1, [r3, #4]
0x0001c012 <+182>: str r2, [r3, r2]
0x0001c014 <+184>: cmp r0, #0
0x0001c016 <+186>: bne.n 0x1c0aa <_free_r+334>
0x0001c018 <+188>: cmp.w r2, #512 ; 0x200
0x0001c01c <+192>: bcs.n 0x1c038 <_free_r+220>
0x0001c01e <+194>: lsrs r2, r2, #3
0x0001c020 <+196>: asrs r0, r2, #2
0x0001c022 <+198>: movs r5, #1
0x0001c024 <+200>: lsls.w r0, r5, r0
0x0001c028 <+204>: ldr r1, [pc, #140] ; (0x1c0b8 <_free_r+348>)
0x0001c02a <+206>: ldr r5, [r1, #4]
0x0001c02c <+208>: add.w r2, r1, r2, lsl #3
0x0001c030 <+212>: orrs r0, r5
0x0001c032 <+214>: str r0, [r1, #4]
0x0001c034 <+216>: ldr r1, [r2, #8]
0x0001c036 <+218>: b.n 0x1c0a2 <_free_r+326>
0x0001c038 <+220>: lsrs r0, r2, #9
0x0001c03a <+222>: cmp r0, #4
0x0001c03c <+224>: bhi.n 0x1c044 <_free_r+232>
0x0001c03e <+226>: lsrs r0, r2, #6
0x0001c040 <+228>: adds r0, #56 ; 0x38
0x0001c042 <+230>: b.n 0x1c072 <_free_r+278>
0x0001c044 <+232>: cmp r0, #20
0x0001c046 <+234>: bhi.n 0x1c04c <_free_r+240>
0x0001c048 <+236>: adds r0, #91 ; 0x5b
0x0001c04a <+238>: b.n 0x1c072 <_free_r+278>
0x0001c04c <+240>: cmp r0, #84 ; 0x54
0x0001c04e <+242>: bhi.n 0x1c056 <_free_r+250>
0x0001c050 <+244>: lsrs r0, r2, #12
0x0001c052 <+246>: adds r0, #110 ; 0x6e
0x0001c054 <+248>: b.n 0x1c072 <_free_r+278>
0x0001c056 <+250>: cmp.w r0, #340 ; 0x154
0x0001c05a <+254>: bhi.n 0x1c062 <_free_r+262>
0x0001c05c <+256>: lsrs r0, r2, #15
0x0001c05e <+258>: adds r0, #119 ; 0x77
0x0001c060 <+260>: b.n 0x1c072 <_free_r+278>
0x0001c062 <+262>: movw r1, #1364 ; 0x554
0x0001c066 <+266>: cmp r0, r1
0x0001c068 <+268>: bhi.n 0x1c070 <_free_r+276>
0x0001c06a <+270>: lsrs r0, r2, #18
0x0001c06c <+272>: adds r0, #124 ; 0x7c
0x0001c06e <+274>: b.n 0x1c072 <_free_r+278>
0x0001c070 <+276>: movs r0, #126 ; 0x7e
0x0001c072 <+278>: ldr r5, [pc, #68] ; (0x1c0b8 <_free_r+348>)
0x0001c074 <+280>: add.w r6, r5, r0, lsl #3
0x0001c078 <+284>: ldr r1, [r6, #8]
0x0001c07a <+286>: cmp r1, r6
0x0001c07c <+288>: bne.n 0x1c096 <_free_r+314>
0x0001c07e <+290>: movs r2, #1
0x0001c080 <+292>: asrs r0, r0, #2
0x0001c082 <+294>: lsls.w r0, r2, r0
0x0001c086 <+298>: ldr r2, [r5, #4]
0x0001c088 <+300>: orrs r0, r2
0x0001c08a <+302>: str r0, [r5, #4]
0x0001c08c <+304>: mov r2, r1
0x0001c08e <+306>: b.n 0x1c0a2 <_free_r+326>
0x0001c090 <+308>: ldr r1, [r1, #8]
0x0001c092 <+310>: cmp r1, r6
0x0001c094 <+312>: beq.n 0x1c0a0 <_free_r+324>
0x0001c096 <+314>: ldr r0, [r1, #4]
0x0001c098 <+316>: bic.w r0, r0, #3
0x0001c09c <+320>: cmp r2, r0
0x0001c09e <+322>: bcc.n 0x1c090 <_free_r+308>
0x0001c0a0 <+324>: ldr r2, [r1, #12]
0x0001c0a2 <+326>: str r2, [r3, #12]
0x0001c0a4 <+328>: str r1, [r3, #8]
0x0001c0a6 <+330>: str r3, [r2, #8]
0x0001c0a8 <+332>: str r3, [r1, #12]
0x0001c0aa <+334>: mov r0, r4
0x0001c0ac <+336>: ldmia.w sp!, {r3, r4, r5, r6, r7, lr}
0x0001c0b0 <+340>: b.w 0x1ce38 <__malloc_unlock>
0x0001c0b4 <+344>: pop {r3, r4, r5, r6, r7, pc}
0x0001c0b6 <+346>: nop
0x0001c0b8 <+348>: lsls r4, r3, #12
0x0001c0ba <+350>: asrs r0, r0, #32
0x0001c0bc <+352>: lsls r4, r4, #28
0x0001c0be <+354>: asrs r0, r0, #32
0x0001c0c0 <+356>: lsrs r4, r2, #17
0x0001c0c2 <+358>: asrs r0, r0, #32
0x0001c0c4 <+360>: lsls r4, r4, #12
0x0001c0c6 <+362>: asrs r0, r0, #32
End of assembler dump.
(gdb) set var $ptr=$sp
(gdb) while $ptr < 0x10008000
>x/4wa $ptr
>set var $ptr+=16
>end
0x10007e00: 0x10000318 0x10001708 0x1 0x6
0x10007e10: 0x10007e54 0x42d9 <StreamOutputPool::printf(std::string const, ...)+152> 0x10007c0c 0x10007e40
0x10007e20: 0x10007e54 0x27ae4 0x100007d4 0x40
0x10007e30: 0x10000c38 0x10001708 0xeeb3 <USBMSD::memoryRead()+118> 0x10007e54
0x10007e40: 0x3 0x0 0x40 0x5
0x10007e50: 0x1 0x10005024 0x10007a64 0x10007afc
0x10007e60: 0x1 0x26 0x10007ea8 0x42d9 <StreamOutputPool::printf(std::string const, ...)+152>
0x10007e70: 0x10007afc 0x10007e98 0x10007ea8 0x27c14
0x10007e80: 0x100007d4 0x100007d4 0x85 0x0
0x10007e90: 0x2 0xf0c3 <USBMSD::USBEvent_EPIn(uint8_t, uint8_t)+174> 0x10000aac 0xf547 <USBMSD::USBEvent_EPOut(uint8_t, uint8_t)+94>
0x10007ea0: 0x40 0x0 0x10007aa4 0x1f
0x10007eb0: 0x0 0x0 0x85 0x0
0x10007ec0: 0x5000c000 0x73cd <USB::USBEvent_EPIn(uint8_t, uint8_t)+44> 0x0 0x0
0x10007ed0: 0x100008bc 0xb 0x800 0xe6f1 <USBHAL::usbisr()+276>
0x10007ee0: 0x10000ab0 0x0 0x100014f0 0x0
0x10007ef0: 0x0 0x100014f0 0x269d0 <_ZL25kernel_callback_functions> 0x1
0x10007f00: 0x3996a18e 0xe7bf <USB_IRQHandler()+14> 0x10007f14 0xfffffff9
0x10007f10: 0xfffffff9 0x10001718 0x100014f0 0x27620 <_ZTV13SerialConsole+8>
0x10007f20: 0x828d <SerialConsole::on_main_loop(void*)> 0x8 0x4f39 <Kernel::call_event(unsigned int)+60> 0x828c <SerialConsole::on_main_loop(void*)>
0x10007f30: 0x1007000 0x0 0x100014f0 0x0
0x10007f40: 0x0 0x0 0x100014f0 0x269d0 <_ZL25kernel_callback_functions>
0x10007f50: 0x1 0x4f39 <Kernel::call_event(unsigned int)+60> 0x100014f0 0x0
0x10007f60: 0x10001708 0x10002ee8 0x10003070 0x10002e20
0x10007f70: 0x10003040 0x4435 <main()+340> 0x3b80000 0x0
0x10007f80: 0x3b 0x5 0x4d 0x5
0x10007f90: 0xdcfd1dad 0x10003004 0x10002edc 0x10002e14
0x10007fa0: 0x10002e14 0x2 0x100007d4 0x100008bc
0x10007fb0: 0x100000c8 0x1 0x100007c8 0x2
0x10007fc0: 0x1 0x3456abcd 0x12345678 0x0
0x10007fd0: 0xfac39112 0xdcfd1dad 0xbcb50825 0x152b5 <_start()+28>
0x10007fe0: 0x10000b2c 0x1785d <Reset_Handler+25> 0x4fff <std::vector<Module*, std::allocator<Module*> >::_M_insert_aux<Module* const&>(std::vector<Module*, std::allocator<Module*> >::iterator, Module* const&)+18> 0x240d
0x10007ff0: 0x200 0x55 0x3456abcd 0xed
(gdb) info registers
r0 0x219e3 137699
r1 0x100295da 268604890
r2 0x219e2 137698
r3 0x10007bf8 268467192
r4 0x10000228 268436008
r5 0x10007c00 268467200
r6 0x6 6
r7 0x1000031c 268436252
r8 0x100008c5 268437701
r9 0x10000aac 268438188
r10 0x85 133
r11 0x1 1
r12 0x10007c10 268467216
sp 0x10007e00 0x10007e00
lr 0x1bf6d 114541
pc 0x1bf80 0x1bf80 <_free_r+36>
xpsr 0x1000028 16777256
(gdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment