Hi,
I am trying to use gdb on an Itanium server with HP-UX B.11.23 O/S. Just got installed today. I am trying out the simplest program to get familiar with gdb but the print/inspect, x, display, info locals, etc. do not seem to be working properly. Can anybody tell me why?
Here is what I get:
First here is the program:
==========================
$ cat -n test.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <dirent.h>
5 #include <signal.h>
6
7 int main()
8 {
9 char input[80];
10 int i;
11 char var0[] = "A";
12 signed char var1[] = "A";
13
14
15 printf("Enter a string: \n");
16 fgets( input, 256, stdin );
17
18 for ( i = 0; i < 256; i++ )
19 {
20 printf("i has value %d\n",i);
21 if ( input[i] == '\n' )
22 {
23 input[i] = '\0';
24 break;
25 }
26 }
27
28 printf("The value is %s\n",input);
29 printf("var0 is %s\n",var0);
30 printf("var1 is %s\n",var1);
31
32 }
compiled with debugging info as follows:
$ gcc -g3 test.c
gdb session
===========
(notice printf shows i is incrementing but the gdb print command always shows the same value)
$ gdb a.out
HP gdb 5.6.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.6.0 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
(gdb) break 20
Breakpoint 1 at 0x4000a60:0: file test.c, line 20 from /home/chlee/proc_/hold_/a.out.
(gdb) run
Starting program: /home/chlee/proc_/hold_/a.out
Enter a string:
1234567890 abcdefg
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) print /fd i
$1 = 0
(gdb) x /fs input
0x20000000777ff1bc: "wNh "
(gdb) x /fs var0
0x20000000777ff20c: "wz\036\220 "
(gdb) x /fs var1
0x20000000777ff20e: "\036\220 "
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) c
Continuing.
i has value 0
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) c
Continuing.
i has value 1
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) c
Continuing.
i has value 2
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) print i
$2 = 0
(gdb) c
Continuing.
i has value 3
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) print i
$3 = 0
(gdb) c
Continuing.
i has value 4
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) c
Continuing.
i has value 5
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) c
Continuing.
i has value 6
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) print i
$4 = 0
(gdb) c 20
Will ignore next 19 crossings of breakpoint 1. Continuing.
i has value 7
i has value 8
i has value 9
i has value 10
i has value 11
i has value 12
i has value 13
i has value 14
i has value 15
i has value 16
i has value 17
i has value 18
The value is 1234567890 abcdefg
var0 is A
var1 is A
Program exited with code 012.
(gdb)
(P.S. I also tried compiling with
gcc -otest -g3 test.c
and calling gdb with
gdb test
but still no luck)
Thanks for any help you can provide!
-cl
I am trying to use gdb on an Itanium server with HP-UX B.11.23 O/S. Just got installed today. I am trying out the simplest program to get familiar with gdb but the print/inspect, x, display, info locals, etc. do not seem to be working properly. Can anybody tell me why?
Here is what I get:
First here is the program:
==========================
$ cat -n test.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <dirent.h>
5 #include <signal.h>
6
7 int main()
8 {
9 char input[80];
10 int i;
11 char var0[] = "A";
12 signed char var1[] = "A";
13
14
15 printf("Enter a string: \n");
16 fgets( input, 256, stdin );
17
18 for ( i = 0; i < 256; i++ )
19 {
20 printf("i has value %d\n",i);
21 if ( input[i] == '\n' )
22 {
23 input[i] = '\0';
24 break;
25 }
26 }
27
28 printf("The value is %s\n",input);
29 printf("var0 is %s\n",var0);
30 printf("var1 is %s\n",var1);
31
32 }
compiled with debugging info as follows:
$ gcc -g3 test.c
gdb session
===========
(notice printf shows i is incrementing but the gdb print command always shows the same value)
$ gdb a.out
HP gdb 5.6.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.6.0 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
(gdb) break 20
Breakpoint 1 at 0x4000a60:0: file test.c, line 20 from /home/chlee/proc_/hold_/a.out.
(gdb) run
Starting program: /home/chlee/proc_/hold_/a.out
Enter a string:
1234567890 abcdefg
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) print /fd i
$1 = 0
(gdb) x /fs input
0x20000000777ff1bc: "wNh "
(gdb) x /fs var0
0x20000000777ff20c: "wz\036\220 "
(gdb) x /fs var1
0x20000000777ff20e: "\036\220 "
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) c
Continuing.
i has value 0
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) c
Continuing.
i has value 1
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) c
Continuing.
i has value 2
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) print i
$2 = 0
(gdb) c
Continuing.
i has value 3
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) print i
$3 = 0
(gdb) c
Continuing.
i has value 4
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) c
Continuing.
i has value 5
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) c
Continuing.
i has value 6
Breakpoint 1, main () at test.c:20
20 printf("i has value %d\n",i);
(gdb) info locals
input = "wNh \000\000\000\177\377\362l \000\000\000\177\377\362L \000\000\000\177\377\362\240\000\000\000\000\000\000\
i = 0
var0 = "wz"
var1 = "\036\220"
(gdb) print i
$4 = 0
(gdb) c 20
Will ignore next 19 crossings of breakpoint 1. Continuing.
i has value 7
i has value 8
i has value 9
i has value 10
i has value 11
i has value 12
i has value 13
i has value 14
i has value 15
i has value 16
i has value 17
i has value 18
The value is 1234567890 abcdefg
var0 is A
var1 is A
Program exited with code 012.
(gdb)
(P.S. I also tried compiling with
gcc -otest -g3 test.c
and calling gdb with
gdb test
but still no luck)
Thanks for any help you can provide!
-cl