请用的i386 linux 下gcc版本比较新的朋友帮我作个测试

6 views
Skip to first unread message

Hui Zhu

unread,
Jun 6, 2010, 11:21:49 AM6/6/10
to hell...@googlegroups.com
/*
请用的i386 linux 下gcc版本比较新的朋友帮我作个测试
附件中这个程序 编译 然后在cool的最后2条指令用一下GDB的BT命令 看2行的结果是否有不同
例如:
gcc -g 7.c
gdb ./a.out
start
(gdb) start
Temporary breakpoint 1, main () at 7.c:15
15 d = cool ();
(gdb) s
During symbol reading, incomplete CFI data; unspecified registers
(e.g., eax) at 0x80483d1.
cool () at 7.c:8
8 return c;
(gdb) s
9 }
(gdb) set disassemble-next-line on
(gdb) si
0x080483ca 9 }
0x080483c8 <cool+20>: 89 c8 mov %ecx,%eax
=> 0x080483ca <cool+22>: c9 leave
0x080483cb <cool+23>: c2 04 00 ret $0x4
(gdb) bt
#0 0x080483ca in cool () at 7.c:9
#1 0x080483df in main () at 7.c:15
(gdb) si
0x080483cb in cool () at 7.c:9
9 }
0x080483c8 <cool+20>: 89 c8 mov %ecx,%eax
0x080483ca <cool+22>: c9 leave
=> 0x080483cb <cool+23>: c2 04 00 ret $0x4
(gdb) bt
#0 0x080483cb in cool () at 7.c:9
#1 0xf7e89b56 in __libc_start_main () from /lib32/libc.so.6
#2 0x08048321 in _start () at ../sysdeps/i386/elf/start.S:119

这里的不同是因为gcc 在生成dwarf2调试信息的时候 最后给了一个错误的寄存器号码 我记得去年讨论过这个问题 而且已经在gcc中修正了
但是我现在用了下我的gcc好像amd64是没问题的 但是i386是错的 所以希望英雄们帮我测下 多谢
*/

struct ty { int a; int b;};

struct ty
cool ()
{
struct ty c;

return c;
}
int
main()
{
struct ty d;

d = cool ();

return 0;
}

Eric Fisher

unread,
Jun 6, 2010, 9:06:30 PM6/6/10
to hell...@googlegroups.com
我机器上是用的gcc version 4.5.0 20100131 (experimental) (GCC) ,测试如下:

(gdb) start
Temporary breakpoint 1 at 0x8048374: file 7.c, line 15.
Starting program: /home/eric/temp/a.out
[Thread debugging using libthread_db enabled]

Temporary breakpoint 1, main () at 7.c:15
15 d = cool ();
(gdb) s

cool () at 7.c:8
8 return c;
(gdb) s
9 }
(gdb) set disassemble-next-line on
(gdb) si

0x0804836a 9 }
0x0804836a <cool+22>: c9 leave
0x0804836b <cool+23>: c2 04 00 ret $0x4
(gdb) bt
#0 0x0804836a in cool () at 7.c:9
#1 0x0804837f in main () at 7.c:15
(gdb) si
0x0804836b 9 }
0x0804836b <cool+23>: c2 04 00 ret $0x4
(gdb) bt
#0 0x0804836b in cool () at 7.c:9
#1 0x0804837f in main () at 7.c:15

> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的"HelloGcc Workshop"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 hell...@googlegroups.com
> 要取消订阅此网上论坛,请发送电子邮件至 hellogcc+u...@googlegroups.com
> 若有更多问题,请通过 http://groups.google.com/group/hellogcc?hl=zh-CN 访问此网上论坛。
>
>

Hui Zhu

unread,
Jun 6, 2010, 9:53:08 PM6/6/10
to hell...@googlegroups.com
多谢渔夫

2010/6/7 Eric Fisher <joefo...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages