🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #8849

Problem with gdb and structures on the stack

#8849
From: Mark Phaneuf
Date: Thu, 17 Sep 1992 19:50
67 lines
2333 bytes
/*
 * The program executes correctly but if a breakpoint is set within the routine
 * 'compute_bandwidth' and the variable 'drops' is examined, the high 32 bits of
 * drops is displayed incorrectly.  If the addresses of the variables on the
 * stack are displayed, 'secs' starts 4 bytes after the beginning of 'drops'
 * although 'drops' is an 8 bytes quantity 'sizeof(drops)'.
 *
 * GDB version: 4.4
 * Machine type: Sun SparcStation 1
 * Compiler version: cc (SunOS version 4.1.1)
 * Compiler command: cc -o a a.c
 */

/*
 *	Copyright (C) 1992,   Matrix Computer Systems, Inc.
 *			      Nashua, NH
 */

#include <stdio.h>
#include <sys/types.h>

typedef struct {
	unsigned long hi;
	unsigned long lo;
}      counter64_t;

static counter64_t __tmp_dc;
static double float_2_to_32 = (double) 0x10 * (double) 0x10000000;

#define D_ASSIGN_C(dc, c) ((dc).hi = 0, (dc).lo = (c))
#define D_2FLOAT(dc) ((double) ((dc).hi > 0 ? ((dc).hi) * float_2_to_32 : 0.0) + \
		      ((double) (dc).lo))

float
compute_bandwidth(overhead, speed, octets, packets, drops, secs)
float overhead;
float speed;
counter64_t octets;
counter64_t packets;
counter64_t drops;
u_long secs;

{
	printf("Drops = %f\n", D_2FLOAT(drops));
	return (1.0);
}

main()
{
	float overhead;
	float speed;
	counter64_t octets;
	counter64_t packets;
	counter64_t drops;
	u_long secs;
	float result;

	overhead = 12.0;
	speed = 1250000.0;
	D_ASSIGN_C(octets, 1000000);
	D_ASSIGN_C(packets, 500);
	D_ASSIGN_C(drops, 225);
	secs = 5;

	result = compute_bandwidth(overhead, speed, octets, packets, drops, secs);
	printf("Result = %f\n", result);
}
Technical Details
Message-ID: <9209171950.AA04671@nce3.metrix.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!spool.mu.edu!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!ames!purdue!sample.eng.ohio-state.edu!cis.ohio-state.edu!metrix.COM!mark

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5053,255fd532275eedbb,start
X-Google-Attributes: gidf5053,public
X-Google-ArrivalTime: 1992-09-18 04:58:28 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!spool.mu.edu!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!ames!purdue!sample.eng.ohio-state.edu!cis.ohio-state.edu!metrix.COM!mark
From: mark@metrix.COM (Mark Phaneuf)
Newsgroups: gnu.gdb.bug
Subject: Problem with gdb and structures on the stack
Message-ID: <9209171950.AA04671@nce3.metrix.com>
Date: 17 Sep 92 19:50:48 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 67
Approved: bug-gdb@prep.ai.mit.edu