Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Holmes <holmes@novak.lanl.gov>
Subject: gdb problem
Date: Tue, 13 May 1997 20:10:48 -0600	[thread overview]
Message-ID: <f47df2edd0c159857195dab0f99b7327.axp-list@archive.invalid> (raw)

Hello,

I have a problem with gdb that perhaps someone can solve.  

I compiled the following code with gcc 2.7.2.1 using the -g flag

#include <stdio.h>
double f();

int	main(void)
{
double	x;

	x = f();

	printf("x = %lf\n", x);
}

double	f()
{
	return 1.0;
}

It will print the proper value , 1.0000, if I run it.  If, however,
I use gdb I can get some strange behavior.  I have a typescript at the
end of the message that shows all the gory details, but basically
what I did was put breakpoints on the "x = f();" and "printf ... " lines.
If I run to the first breakpoint, use the continue command to execute
the function and let it stop at the second breakpoint.  If I print x
I get 1, as I should.  However, if intead of using continue to get
through the function I use next I get garbage when I print x.

Any idea what might be happening?  I'm using gdb 4.16 that came from
the gdb-4.16-6.axp.rpm RPM.  I'm running it on an Alpha PC164 using
the 2.0.27 kernel.  

Thanks,
Rich

Script started on Tue May 13 19:54:26 1997
nancy 267> gdb a.out
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (alpha-unknown-linux), Copyright 1996 Free Software Foundation, Inc...
(gdb) l 1,16
1	#include <stdio.h>
2	double f();
3	
4	int	main(void)
5	{
6	double	x;
7	
8		x = f();
9	
10		printf("x = %lf\n", x);
11	}
12	
13	double	f()
14	{
15		return 1.0;
16	}
(gdb) break 8
Breakpoint 1 at 0x1200008f8: file test.c, line 8.
(gdb) break 10
Breakpoint 2 at 0x120000910: file test.c, line 10.
(gdb) r
Starting program: /home/holmes/test/a.out 

Breakpoint 1, main () at test.c:8
8		x = f();
(gdb) next
10		printf("x = %lf\n", x);
(gdb) p x
$1 = -2.8638903918474961e+250
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/holmes/test/a.out 

Breakpoint 1, main () at test.c:8
8		x = f();
(gdb) c
Continuing.

Breakpoint 2, main () at test.c:10
10		printf("x = %lf\n", x);
(gdb) p x
$2 = 1
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
nancy 268> exit

Script done on Tue May 13 19:55:42 1997

---------------------------------------
Richard Holmes
Los Alamos National Laboratory
Group XTA  
MS B220
Los Alamos, NM  87545
(505) 667-3598
holmes@lanl.gov

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

             reply	other threads:[~1997-05-14  2:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-14  2:10 Richard Holmes [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-05-14 18:58 gdb problem Richard Holmes
1997-05-14 19:09 ` Kortelainen Mika
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox