本帖最后由 kevin_ares 于 2010-7-12 11:22 编辑
#include "ctest.h"
Ctest::Ctest(void)
{
}
Ctest::~Ctest(void)
{
}
int Ctest::add(int a,int b)
{
return a+b;
}
extern "C" init()
{
Ctest test;
test.add(4,5);
}
然后在main.c里调用 init(),一切正常,怀疑编译器已经优化掉生成对象的代码了
改成
#include "ctest.h"
Ctest test;
Ctest::Ctest(void)
{
}
Ctest::~Ctest(void)
{
}
int Ctest::add(int a,int b)
{
return a+b;
}
extern "C" init()
{
test.add(4,5);
}
编译通过,用jlink调试,一开始就卡在
__use_no_semihosting_swi:
0x08000456 4770 BX lr
__sig_exit:
0x08000458 2800 CMP r0,#0x00
0x0800045A D001 BEQ 0x08000460
0x0800045C F000B828 B.W _sys_exit (0x080004B0)
0x08000460 4770 BX lr
0x08000462 0000 MOVS r0,r0
__rt_SIGRTMEM_inner:
0x08000464 2100 MOVS r1,#0x00
0x08000466 B510 PUSH {r4,lr}
0x08000468 2801 CMP r0,#0x01
0x0800046A D100 BNE 0x0800046E
0x0800046C A102 ADR r1,{pc}+4 ; @0x08000478
0x0800046E A008 ADR r0,{pc}+2 ; @0x08000490
0x08000470 F000F828 BL.W __default_signal_display (0x080004C4)
0x08000474 2001 MOVS r0,#0x01
0x08000476 BD10 POP {r4,pc}
0x08000478 203A MOVS r0,#0x3A
0x0800047A 6548 STR r0,[r1,#0x54]
0x0800047C 7061 STRB r1,[r4,#0x01]
0x0800047E 6D20 LDR r0,[r4,#0x50]
0x08000480 6D65 LDR r5,[r4,#0x54]
0x08000482 726F STRB r7,[r5,#0x09]
0x08000484 2079 MOVS r0,#0x79
0x08000486 6F63 LDR r3,[r4,#0x74]
0x08000488 7272 STRB r2,[r6,#0x09]
0x0800048A 7075 STRB r5,[r6,#0x01]
0x0800048C 6574 STR r4,[r6,#0x54]
0x0800048E 0064 LSLS r4,r4,#1
0x08000490 4953 LDR r1,[pc,#332] ; @0x080005E0
0x08000492 5247 STRH r7,[r0,r1]
0x08000494 4D54 LDR r5,[pc,#336] ; @0x080005E8
0x08000496 4D45 LDR r5,[pc,#276] ; @0x080005AC
0x08000498 203A MOVS r0,#0x3A
0x0800049A 754F STRB r7,[r1,#0x15]
0x0800049C 2074 MOVS r0,#0x74
0x0800049E 666F STR r7,[r5,#0x64]
0x080004A0 6820 LDR r0,[r4,#0x00]
0x080004A2 6165 STR r5,[r4,#0x14]
0x080004A4 2070 MOVS r0,#0x70
0x080004A6 656D STR r5,[r5,#0x54]
0x080004A8 6F6D LDR r5,[r5,#0x74]
0x080004AA 7972 LDRB r2,[r6,#0x05]
0x080004AC 0000 MOVS r0,r0
0x080004AE 0000 MOVS r0,r0
_sys_exit:
0x080004B0 4903 LDR r1,[pc,#12] ; @0x080004C0
0x080004B2 F04F0018 MOV r0,#0x18
0x080004B6 BEAB BKPT 0xAB
0x080004B8 4770 BX lr
0x080004BA 0000 MOVS r0,r0
0x080004BC FF9BFFFF DCD 0xFF9BFFFF ; ? Undefined
0x080004C0 0026 MOVS r6,r4
0x080004C2 0002 MOVS r2,r0
__default_signal_display:
0x080004C4 B570 PUSH {r4-r6,lr}
0x080004C6 4604 MOV r4,r0
0x080004C8 460D MOV r5,r1
0x080004CA 200A MOVS r0,#0x0A
0x080004CC E000 B 0x080004D0
0x080004CE 1C64 ADDS r4,r4,#1
0x080004D0 F000F811 BL.W _ttywrch (0x080004F6)
0x080004D4 B134 CBZ r4,0x080004E4
0x080004D6 7820 LDRB r0,[r4,#0x00]
0x080004D8 2800 CMP r0,#0x00
0x080004DA D1F8 BNE 0x080004CE
0x080004DC E002 B 0x080004E4
0x080004DE 1C6D ADDS r5,r5,#1
0x080004E0 F000F809 BL.W _ttywrch (0x080004F6)
0x080004E4 B115 CBZ r5,0x080004EC
0x080004E6 7828 LDRB r0,[r5,#0x00]
0x080004E8 2800 CMP r0,#0x00
0x080004EA D1F8 BNE 0x080004DE
0x080004EC E8BD4070 POP {r4-r6,lr}
0x080004F0 200A MOVS r0,#0x0A
0x080004F2 F3AF8000 NOP.W
_ttywrch:
0x080004F6 B508 PUSH {r3,lr}
0x080004F8 4669 MOV r1,sp
0x080004FA 9000 STR r0,[sp,#0x00]
0x080004FC 2003 MOVS r0,#0x03
0x080004FE BEAB BKPT 0xAB //卡在这
[/color]0x08000500 BD08 POP {r3,pc}
|
|