Hello Colin,

I don't see the point of making an advanced disassembler out of
OpenOCD. I think the main purpose of adding the routine was to do some
spot checks during debugging. In fact, it's probably not really
necessary once gdb interface was implemented, as gdb can do
disassembly itself.
If you need to disassemble a lot of code "offline", it's much better
to use specialized tools such as objdump or IDA Pro or whatnot.

On Sun, Oct 25, 2009 at 01:36, Colin Howarth <co...@howarth.de> wrote:
> Hello all,
> I'm not entirely sure this is appropriate here, it being an OpenOCD
> developer's list and not an ARM developer's list as such :-(
> However, I was wondering how many of you actually code in ARM assembler? Do
> you avoid it wherever you can, using a "high-level" language and gcc?
> For those that do do assembly code, do you have a Good (TM) disassembler?
>
> The   armv4_5 disassemble  command is fine, in that it disassembles, but as
> I mentioned a while back, it doesn't produce what I would have written as an
> assembly code routine :-)
>
> So, I've written a quick 2-pass assembly code post-processor in Perl, and
> was wondering if anyone else had any interest in it.
> So far, it does this:
> a) identifies subroutine calls (ie. BL)
> b) identifies returns (e.g. BX R14;  LDMFD R13!, {r0, r1, r15}; )
> c) identifies labels (e.g BNE 0x00001234)
> d) identifies PC-relative addressed data
> e) locates the definition of the base register (e.g.  LDR r0, [r15, #0x18];
> ... STR r0, [r2] )
> It prints out the marked up assembly code on the second pass.
>
> Thus:
>
> 0x0000072c  0xe59f3088  LDR r3, [r15, #0x88]
> 0x00000730  0xe1540003  CMP r4, r3
> 0x00000734  0x1a000009  BNE 0x00000760
> 0x00000738  0xe3a00501  MOV r0, #0x400000
> 0x0000073c  0xe3a01001  MOV r1, #0x1
> 0x00000740  0xeb000174  BL 0x00000d18
> 0x00000744  0xe3a00501  MOV r0, #0x400000
> 0x00000748  0xe3a01000  MOV r1, #0x0
> 0x0000074c  0xeb000171  BL 0x00000d18
> 0x00000750  0xe3a02000  MOV r2, #0x0
> 0x00000754  0xe59f303c  LDR r3, [r15, #0x3c]
> 0x00000758  0xe58320ac  STR r2, [r3, #0xac]
> 0x0000075c  0xe89da810  LDMIA r13, {r4, r11, r13, r15}
> 0x00000760  0xe59f3058  LDR r3, [r15, #0x58]
> 0x00000764  0xe1540003  CMP r4, r3
> 0x00000768  0x189da810  LDMNEIA r13, {r4, r11, r13, r15}
> 0x0000076c  0xe3a00502  MOV r0, #0x800000
> 0x00000770  0xe3a01001  MOV r1, #0x1
> 0x00000774  0xeb000167  BL 0x00000d18
> 0x00000778  0xe3a00502  MOV r0, #0x800000
> 0x0000077c  0xe3a01000  MOV r1, #0x0
> 0x00000780  0xeb000164  BL 0x00000d18
> 0x00000784  0xe3a02000  MOV r2, #0x0
> 0x00000788  0xe59f3008  LDR r3, [r15, #0x8]
> 0x0000078c  0xe58320ac  STR r2, [r3, #0xac]
> 0x00000790  0xe89da810  LDMIA r13, {r4, r11, r13, r15}
> 0x00000794  0x58006000  STMPLDA r0, {r13, r14
> 0x00000798  0x5c002000  UNDEFINED INSTRUCTION
> 0x0000079c  0x58007000  STMPLDA r0, {r12, r13, r14}
>
> Becomes:
>
> 0x0000072c  0xe59f3088  LDR r3, [r15, #0x88]              ; data at
> 0x000007bc: 0x5800e000
> 0x00000730  0xe1540003  CMP r4, r3
> 0x00000734  0x1a000009  BNE 0x00000760                    ; branch to
> label_26 at: 0x00000760
> 0x00000738  0xe3a00501  MOV r0, #0x400000
> 0x0000073c  0xe3a01001  MOV r1, #0x1
> 0x00000740  0xeb000174  BL 0x00000d18                     ; call
> subroutine_7 at: 0x00000d18
> 0x00000744  0xe3a00501  MOV r0, #0x400000
> 0x00000748  0xe3a01000  MOV r1, #0x0
> 0x0000074c  0xeb000171  BL 0x00000d18                     ; call
> subroutine_7 at: 0x00000d18
> 0x00000750  0xe3a02000  MOV r2, #0x0
> 0x00000754  0xe59f303c  LDR r3, [r15, #0x3c]              ; data at
> 0x00000798: 0x5c002000
> 0x00000758  0xe58320ac  STR r2, [r3, #0xac]               ; Base defined at
> 0x00000754
> 0x0000075c  0xe89da810  LDMIA r13, {r4, r11, r13, r15}    ; Return from
> subroutine
> label_26:
> 0x00000760  0xe59f3058  LDR r3, [r15, #0x58]              ; data at
> 0x000007c0: 0x5800f000
> 0x00000764  0xe1540003  CMP r4, r3
> 0x00000768  0x189da810  LDMNEIA r13, {r4, r11, r13, r15}  ; Return from
> subroutine
> 0x0000076c  0xe3a00502  MOV r0, #0x800000
> 0x00000770  0xe3a01001  MOV r1, #0x1
> 0x00000774  0xeb000167  BL 0x00000d18                     ; call
> subroutine_7 at: 0x00000d18
> 0x00000778  0xe3a00502  MOV r0, #0x800000
> 0x0000077c  0xe3a01000  MOV r1, #0x0
> 0x00000780  0xeb000164  BL 0x00000d18                     ; call
> subroutine_7 at: 0x00000d18
> 0x00000784  0xe3a02000  MOV r2, #0x0
> 0x00000788  0xe59f3008  LDR r3, [r15, #0x8]               ; data at
> 0x00000798: 0x5c002000
> 0x0000078c  0xe58320ac  STR r2, [r3, #0xac]               ; Base defined at
> 0x00000788
> 0x00000790  0xe89da810  LDMIA r13, {r4, r11, r13, r15}    ; Return from
> subroutine
> 0x00000794  0x58006000  DATA <STMPLDA r0, {r13, r14}>
> 0x00000798  0x5c002000  DATA <UNDEFINED INSTRUCTION>
> 0x0000079c  0x58007000  DATA <STMPLDA r0, {r12, r13, r14}>
>
> Which should soon become:
>
> 0x0000072c  0xe59f3088  LDR r3, data_1 <0x5800e000 =? non_buffered APB0 +
> GPIO_PORT_P8>
> 0x00000730  0xe1540003  CMP r4, r3
> 0x00000734  0x1a000009  BNE label_26
> 0x00000738  0xe3a00501  MOV r0, #0x400000
> 0x0000073c  0xe3a01001  MOV r1, #0x1
> 0x00000740  0xeb000174  BL subroutine_7
> 0x00000744  0xe3a00501  MOV r0, #0x400000
> 0x00000748  0xe3a01000  MOV r1, #0x0
> 0x0000074c  0xeb000171  BL subroutine_7
> 0x00000750  0xe3a02000  MOV r2, #0x0
> 0x00000754  0xe59f303c  LDR r3, data_2 <0x5c002000 =? non_buffered APB1 +
> SCU>
> 0x00000758  0xe58320ac  STR r2, [NB_APB1_SCU, SCU_GPIOEMI]
> 0x0000075c  0xe89da810  LDMIA r13, {r4, r11, r13, r15}    ; Return from
> subroutine
> label_26:
> 0x00000760  0xe59f3058  LDR r3, data_3 <0x5800f000 =? non_buffered APB0 +
> GPIO_PORT_P9>
> 0x00000764  0xe1540003  CMP r4, r3
> 0x00000768  0x189da810  LDMNEIA r13, {r4, r11, r13, r15}  ; Return from
> subroutine
> 0x0000076c  0xe3a00502  MOV r0, #0x800000
> 0x00000770  0xe3a01001  MOV r1, #0x1
> 0x00000774  0xeb000167  BL subroutine_7
> 0x00000778  0xe3a00502  MOV r0, #0x800000
> 0x0000077c  0xe3a01000  MOV r1, #0x0
> 0x00000780  0xeb000164  BL subroutine_7
> 0x00000784  0xe3a02000  MOV r2, #0x0
> 0x00000788  0xe59f3008  LDR r3, data_4 <0x5c002000 =? non_buffered APB1 +
> SCU>
> 0x0000078c  0xe58320ac  STR r2, [NB_APB1_SCU, SCU_GPIOEMI]
> 0x00000790  0xe89da810  LDMIA r13, {r4, r11, r13, r15}    ; Return from
> subroutine
> 0x00000794  0x58006000  DATA <STMPLDA r0, {r13, r14}>
> 0x00000798  0x5c002000  DATA <UNDEFINED INSTRUCTION>
> 0x0000079c  0x58007000  DATA <STMPLDA r0, {r12, r13, r14}>
>
>
>
> --colin
> _______________________________________________
> Openocd-development mailing list
> Openocd-development@lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/openocd-development
>
>



-- 
WBR, Igor
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to