|
|

楼主 |
发表于 2005-12-13 20:20:41
|
显示全部楼层
又一新问题;请帮忙
(gdb) l
1 #include<stdio.h>
2 main()
3 {
4 char my_string[]="hello there";
5 my_print(my_string);
6 my_print2(my_string);
7 }
8
9 void my_print(char *string)
10 {
(gdb) l
11 printf("The string is %s\n",string);
12 }
13
14 void my_print2(char *string)
15 {
16 char *string2;
17 int size,i;
18 size=strlen(string);
19 string2=(char *)malloc(size+1);
20 for(i=0;i<size;i++)
(gdb) l
21 string2[size-i]=string;
22 string2[size+1]='\0';
23 printf("The string printed backward is %s\n",string2);
24 }
25
26
27
28
(gdb) break 21
Breakpoint 1 at 0x804845c: file test.c, line 21.
(gdb) run
Starting program: /root/myc/tmp/test
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0x1a3000
The string is hello there
Breakpoint 1, my_print2 (string=0xbf8fc4d4 "hello there") at test.c:21
21 string2[size-i]=string;
(gdb) watch string2[size-i]
Hardware watchpoint 2: string2[size - i]
(gdb) next
warning: Could not remove hardware watchpoint 2.
Warning:
Could not insert hardware watchpoint 2.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
(gdb) |
|