break 8 为什么却停在 10呢?

软件和网站开发以及相关技术探讨
回复
vitamin
帖子: 247
注册时间: 2008-09-23 21:13
送出感谢: 0
接收感谢: 0

break 8 为什么却停在 10呢?

#1

帖子 vitamin » 2008-10-23 10:13

ellawu@ellawu-desktop:~$ gdb p3.4.debug
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
(gdb) run
Starting program: /home/ellawu/p3.4.debug
please input a character :
af
you input the character 'a'
you input the character 'b'
you input the character 'c'
you input the character 'd'
what you input is not belong to the judgement of the program
please input a character :
what you input is not belong to the judgement of the program

Program exited normally.
(gdb) file p3.4.debug
Load new symbol table from "/home/ellawu/p3.4.debug"? (y or n) y
Reading symbols from /home/ellawu/p3.4.debug...done.
(gdb) list
warning: Source file is more recent than executable.
1 #include <stdio.h>
2
3 int main(void){
4 char input;
5
6 int i;
7 for(i=0;i<2;i++){
8 printf("please input a character :\n");
9 scanf("%c",&input);
10
(gdb) list
11 switch(input){
12 case 'a':
13 printf("you input the character 'a'\n");
14 case 'b':
15 printf("you input the character 'b'\n");
16 case 'c':
17 printf("you input the character 'c'\n");
18 case 'd':
19 printf("you input the character 'd'\n");
20 default:
(gdb) list
21 printf("what you input is not belong to the judgement of the program\n");
22 }
23 }
24 return 0;
25 }
26
(gdb) list
Line number 27 out of range; p3.4.c has 26 lines.
(gdb) break 8
Breakpoint 1 at 0x80483b5: file p3.4.c, line 8.
(gdb) break 13
Breakpoint 2 at 0x80483e0: file p3.4.c, line 13.

(gdb) run
Starting program: /home/ellawu/p3.4.debug

Breakpoint 1, main () at p3.4.c:10
10
????
(gdb) watch input
Hardware watchpoint 3: input
(gdb) next
11 switch(input){
(gdb) next
please input a character :
12 case 'a':
(gdb) next
af
Hardware watchpoint 3: input

Old value = -73 '�'
New value = 97 'a'
0xb7e9f301 in _IO_vfscanf () from /lib/tls/i686/cmov/libc.so.6
(gdb)
念几句佛经就以为自己在悟道,引用几句圣经就以为自己是上帝的使者。
躲在阴暗的角落就以为看不见你那肮脏的灵魂?
游走在灰色领域就以为安然无恙?
举头三尺有神明,不是不报是时候未到。
回复

回到 “软件/网站开发”