我正在为NetBSD系统使用英特尔的ICC编译器。 我一直在与一个bug斗争,当我从核心转储中观察到来自gdb中两个不同机制的符号地址不同时,我更加惊讶。
使用“ info symbol connection_out ”和 p& connection_out 检查时,变量 connection_out 似乎具有不同的地址。
在 badf_errcnt 被优化为CPU寄存器的情况下,它是否看起来像编译器问题,被分配了一个内存位置,然后编译器在两者之间混淆了?
EDIT1 :变量 connection_out 是 static int 全局变量
gdb$ disassemble sigusr1_rt
Dump of assembler code for function sigusr1_rt:
0x01845000 <+0>: push %ebp
0x01845001 <+1>: mov %esp,%ebp
0x01845003 <+3>: sub $0x8,%esp
0x01845006 <+6>: movl $0x16c156a,0x188f05c
0x01845010 <+16>: mov %ebp,%esp
0x01845012 <+18>: pop %ebp
0x01845013 <+19>: ret
0x01845014 <+20>: lea 0x0(%esi),%esi
0x0184501a <+26>: lea 0x0(%edi),%edi
End of assembler dump.
gdb$ info symbol 0x188f05c
connection_out in section .bss of /sites/eqx/work/swcores/tripunjay/F10ACOREDIR/f10cp_sshd.login-eqx-06.6402/sshd
gdb$ p &connection_out
$10 = (int *) 0x188f048
gdb$ p/d 0x188f05c - 0x188f048
$11 = 20
gdb$ p/x 0x188f05c - 0x188f048
$12 = 0x14
gdb$ info symbol 0x188f048
badf_errcnt.5450.0.13 in section .bss of /sites/eqx/work/swcores/tripunjay/F10ACOREDIR/f10cp_sshd.login-eqx-06.6402/sshd
gdb$ p &badf_errcnt
No symbol "badf_errcnt" in current context.
gdb$ select-frame 5
gdb$ frame
Stack level 5, frame at 0xbb4aca20:
eip = 0x1846007 in wait_until_can_do_something (serverloop.c:404); saved eip 0x1846698
called by frame at 0xbb4b0af0, caller of frame at 0xbb4ac9d0
source language c.
Arglist at 0xbb4aca18, args: readsetp=0xbb4b0ab4, writesetp=0xbb4b0ab8, maxfdp=0x4, nallocp=0xbb4b0abc, max_time_milliseconds=0x0
Locals at 0xbb4aca18, Previous frame's sp is 0xbb4aca20
Saved registers:
ebx at 0xbb4aca00, ebp at 0xbb4aca18, esi at 0xbb4ac9fc, edi at 0xbb4aca04, eip at 0xbb4aca1c
readsetp = 0xbb4b0ab4
writesetp = 0xbb4b0ab8
maxfdp = 0x4
nallocp = 0xbb4b0abc
max_time_milliseconds = 0x0
badf_errcnt = <optimized out>
tv = <optimized out>
tvp = <optimized out>
client_alive_scheduled = 0x0
gdb$ p &badf_errcnt
Can't take address of "badf_errcnt" which isn't an lvalue.
答案 0 :(得分:0)
我认为编译器不会混淆,但gdb
很可能会混淆,或者至少使用太少的信息。
似乎ICC没有为gdb
提供足够的符号调试器信息,因此您没有看到任何非常有用的信息。是否使用正确的选项编译代码以在生成的二进制文件中记录调试信息? (即-g
,也许-O0
)
您是否尝试过使用idbc
(英特尔调试器)?