Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ Programming ➜ General ➜ gdb print, x, display does not work on new gdb installation (Itanium HP-UX)

gdb print, x, display does not work on new gdb installation (Itanium HP-UX)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Chlee   (1 post)  Bio
Date Wed 09 May 2007 07:52 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 09 May 2007 09:58 PM (UTC)
Message
I tried your sample program under Linux and gdb behaved in the way I would expect (that is, not like happened to you).

Maybe, contrary to the documentation, it is optimizing. Try adding -O0 to the command gcc line ( letter O followed by number zero).

Failing that, as I can't reproduce it here, I would query the HP forums, possibly posting your test case. It should work better than what you are seeing.

Maybe someone has made an alias for gcc that slips in optimization, I would check that first.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,252 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.