gdb 调试内嵌汇编c程序时,好象不能单步显示执行结果
时间:2007-04-09 来源:tthacker
今天调试了一个内嵌汇编c程序,好郁闷,用gdb跟踪了一中午,始终没有结果,单步执行,直接执行到汇编后面的程序语句了,好奇怪。在cu发贴没人鸟我,上完课后,又仔细的看了代码,原来有一条汇编语句让我搞错了,
在编译执行,程序可以得到正确的结果,但是gdb跟踪还是老问题:
Administrator@wzt-u44op82g4jw ~/asm
$ gcc -o 4 4.c -g
Administrator@wzt-u44op82g4jw ~/asm
$ gdb 4
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Publi
welcome to change it and/or distribute copies of it un
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show w
This GDB was configured as "i686-pc-cygwin"...
(gdb) l
1 int main(void)
2 {
3 int m,n,sum = 0;
4
5 scanf("%d%d",&m,&n);
6 if ( m != 0 && n != 0 ) {
7 /*
8 while(m != 0) {
9 if ( m & 1 )
10 sum += n;
(gdb)
11 m = m >> 1;
12 n = n << 1;
13 }
14 */
15 __asm__("movl $0,%%eax\n"
16 "1:\tcmpl $0,%1\n\t"
17 "je 3f\n\t"
18 "testl $1,%1\n\t"
19 "jz 2f\n\t"
20 "addl %2,%0\n"
(gdb) b 15
Breakpoint 1 at 0x4010a8: file 4.c, line 15.
(gdb) r
Starting program: /home/Administrator/asm/4.exe
1 4
Breakpoint 1, main () at 4.c:15
15 __asm__("movl $0,%%eax\n"
(gdb) n
29 printf("%d * %d = %d\n",m,n,sum);
(gdb) n
1 * 4 = 4
31 return 0;
(gdb) n
32 }
难道gdb不能单步跟踪内嵌汇编吗?后来又查下gcc手册,也没看到类似的调试选项。如果哪位兄弟知道的话,告诉我啊。。。
在编译执行,程序可以得到正确的结果,但是gdb跟踪还是老问题:
Administrator@wzt-u44op82g4jw ~/asm
$ gcc -o 4 4.c -g
Administrator@wzt-u44op82g4jw ~/asm
$ gdb 4
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Publi
welcome to change it and/or distribute copies of it un
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show w
This GDB was configured as "i686-pc-cygwin"...
(gdb) l
1 int main(void)
2 {
3 int m,n,sum = 0;
4
5 scanf("%d%d",&m,&n);
6 if ( m != 0 && n != 0 ) {
7 /*
8 while(m != 0) {
9 if ( m & 1 )
10 sum += n;
(gdb)
11 m = m >> 1;
12 n = n << 1;
13 }
14 */
15 __asm__("movl $0,%%eax\n"
16 "1:\tcmpl $0,%1\n\t"
17 "je 3f\n\t"
18 "testl $1,%1\n\t"
19 "jz 2f\n\t"
20 "addl %2,%0\n"
(gdb) b 15
Breakpoint 1 at 0x4010a8: file 4.c, line 15.
(gdb) r
Starting program: /home/Administrator/asm/4.exe
1 4
Breakpoint 1, main () at 4.c:15
15 __asm__("movl $0,%%eax\n"
(gdb) n
29 printf("%d * %d = %d\n",m,n,sum);
(gdb) n
1 * 4 = 4
31 return 0;
(gdb) n
32 }
难道gdb不能单步跟踪内嵌汇编吗?后来又查下gcc手册,也没看到类似的调试选项。如果哪位兄弟知道的话,告诉我啊。。。
相关阅读 更多 +