- 论坛徽章:
- 0
|
确是跟线程的实现有关系. 我想g++会在unwind代码中生成~myTest()调用. pthread_exit()函数执行时没有与之协调, 从而没有调用到~myTest().
下面是g++在我的机器上生成的sendMsgs()汇编代码了.
- .globl _Z8sendMsgsPv
- .type _Z8sendMsgsPv,@function
- _Z8sendMsgsPv:
- .LFB1703:
- pushq %rbp
- .LCFI5:
- movq %rsp, %rbp
- .LCFI6:
- pushq %rbx
- .LCFI7:
- subq $1048632, %rsp
- .LCFI8:
- movq %rdi, -24(%rbp)
- movl $.LC3, %esi
- movl $_ZSt4cout, %edi
- .LEHB0:
- call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
- movq %rax, %rdi
- movl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
- call _ZNSolsEPFRSoS_E
- leaq -48(%rbp), %rdi
- call _ZN6myTestC1Ev
- .LEHE0:
- leaq -1048624(%rbp), %rdi
- movl $1048576, %edx
- movl $0, %esi
- call memset
- leaq -1048624(%rbp), %rdi
- movl $1048575, %edx
- movl $97, %esi
- call memset
- .LEHB1:
- call _Z11writeStatusv
- movl $.LC4, %esi
- movl $_ZSt4cout, %edi
- call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
- movq %rax, %rdi
- movl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
- call _ZNSolsEPFRSoS_E
- movl $0, %edi
- call pthread_exit
- .LEHE1:
- .L9:
- movq %rax, -1048632(%rbp)
- movq -1048632(%rbp), %rbx
- leaq -48(%rbp), %rdi
- call _ZN6myTestD1Ev
- movq %rbx, -1048632(%rbp)
- movq -1048632(%rbp), %rdi
- .LEHB2:
- call _Unwind_Resume
- .LEHE2:
- .LFE1703:
- .Lfe3:
- .size _Z8sendMsgsPv,.Lfe3-_Z8sendMsgsPv
- .section .gcc_except_table,"a",@progbits
复制代码
我google了一下, 有人说绝对不要用pthread_exit(), 用return. 就是因为某些系统会有类似你的问提.
[ 本帖最后由 Alligator27 于 2005-12-23 23:22 编辑 ] |
|