Article View: gnu.gdb.bug
Article #772Bug(?) in gdb-3.1
From: Shinichirou Sugou
Date: Fri, 28 Apr 1989 07:57
Date: Fri, 28 Apr 1989 07:57
869 lines
18805 bytes
18805 bytes
Dear FSF people:
I think this is bug in gdb-3.1. My system is Sun3/60 with OS3.4, gcc-3.4, and
gdb-3.1.
Whole source program (as shar-format) is appended to the last. Please unshar
sources and type 'make' to generate executable code named 'p' (please use GNU
make if possible, also use Sun if possible because special malloc.o file
pecurial to Sun is used here).
Type
foo% gdb p
to invoke gdb-3.1.
Type
(gdb) run
to run the program 'p'.
'p' will require four integers (coordinates of a rectangle).
left top right bottom:
Type four values like these delimiting with space (value itself is not
important in this case).
1 2 3 4 <CR>
Again, 'p' will require two more integers (coordinates of a point).
h v:
Here, type Control-C to interrupt program.
The screen looks like this.
Program received signal 2, Interrupt
0x5e40 in read ()
(gdb)
Type 'bt' to examine the backtracks of entire stack.
Gdb-3.1 can't print the correct stack information.
(gdb) bt
#0 0x5e40 in read ()
#1 0x3 in ?? ()
While gdb-2.8 does without problem.
(gdb-2.8) bt
#0 0x5e40 in read ()
#1 0x3f10 in _doscan ()
#2 0x3e12 in _doscan ()
#3 0x3b4c in scanf ()
#4 0x29f4 in readPt (ptp=(struct point *) 0xefffd50) (point.c line 87)
#5 0x2762 in main () (rect.c line 239)
CAUTION: Reply-command supplied by your mail system may NOT generate
my address correctly.
Please use the following address instead.
shin%sgtp.apple.juice%lkbreth.foretune.junet@uunet.uu.net
---
Shinichirou Sugou shin%sgtp.apple.juice%lkbreth.foretune.junet@uunet.uu.net
Sources follows...
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# rect.c
# misc.c
# point.c
# rect.h
# misc.h
# point.h
# global.h
# Makefile
# dlist
# .gdbinit
# This archive created: Fri Apr 28 14:54:22 1989
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'rect.c'
then
echo shar: "will not over-write existing file 'rect.c'"
else
cat << \SHAR_EOF > 'rect.c'
#include <stdio.h>
#include "global.h"
#include "misc.h"
#include "point.h"
#include "rect.h"
static void setEmptyRect();
/**/
/* Global -top- */
/**/
bool
okRect(rp)
Rect *rp;
{
return rp != NIL && okHLoc(rp->left) && okHLoc(rp->right) && okVLoc(rp->top)
&& okVLoc(rp->bottom);
}
bool
EqualRect(ap, bp)
Rect *ap;
Rect *bp;
/* EqualRect compares the two rectangles and returns TRUE if they are equal or
FALSE if
not. The two rectangles must have identical boundary coordinates to be cons
idered
equal. */
{
assert((okRect(ap) && okRect(bp)), "invalid rect");
return ap->left == bp->left && ap->top == bp->top && ap->right == bp->right
&& ap->bottom == bp->bottom;
}
void
UnionRect(srcAp, srcBp, dstp)
Rect *srcAp;
Rect *srcBp;
Rect *dstp;
/* UnionRect calculates the smallest rectangle which encloses both input rectan
gles. It
works correctly even if one of the source rectangles is also the destination
. */
{
if (EmptyRect(srcAp) && EmptyRect(srcBp))
setEmptyRect(dstp);
else if (EmptyRect(srcAp))
copyRect(srcBp, dstp);
else if (EmptyRect(srcBp))
copyRect(srcAp, dstp);
else {
dstp->left = min(srcAp->left, srcBp->left);
dstp->right = max(srcAp->right, srcBp->right);
dstp->top = min(srcAp->top, srcBp->top);
dstp->bottom = max(srcAp->bottom, srcBp->bottom); }
}
void
copyRect(srcp, dstp)
Rect *srcp;
Rect *dstp; /* result */
/* This is not the funtion of Mac toolbox.
copyRect copies the coordinates of srcp into dstp. */
{
assert(okRect(srcp), "invalid rect");
dstp->left = srcp->left;
dstp->top = srcp->top;
dstp->right = srcp->right;
dstp->bottom = srcp->bottom;
}
bool
SectRect(srcRectAp, srcRectBp, dstRectp)
Rect *srcRectAp;
Rect *srcRectBp;
Rect *dstRectp;
/* SectRect calculates the rectangle that is the intersection of the two input
rectangles, and returns TRUE if they indeed intersect or FALSE if they do no
t.
Rectangles that "touch" at a line or a point are not considered intersecting
, because
their intersection rectangle (really, in this case, an intersection line or
point)
does not enclose any bits on the bitMap.
If the rectangles do not intersect, the destination rectangle is set to (0,0
,0,0).
SectRect works correctly even if one of the source rectangles is also the de
stination. */
{
dstRectp->left = max(srcRectAp->left, srcRectBp->left);
dstRectp->right = min(srcRectAp->right, srcRectBp->right);
dstRectp->top = max(srcRectAp->top, srcRectBp->top);
dstRectp->bottom = min(srcRectAp->bottom, srcRectBp->bottom);
if (EmptyRect(dstRectp))
setEmptyRect(dstRectp);
return !EmptyRect(dstRectp);
}
void
InsetRect(rp, dh, dv)
Rect *rp;
int dh;
int dv;
/* InsetRect shrinks or expands the rectangle. The left and right sides are mo
ved in by
the amount specified by dh; the top and bottom are moved towards the center
by the
amount specified by dv. If dh or dv is negative, the appropriate pair of si
des is
moved outwards instead of inwards. The effect is to alter the size by 2*dh
horizontally and 2*dv vertically, with the rectangle remaining centered in t
he same
place on the coordinate plane.
If the resulting width or height becomes less than 1, the rectangle is set t
o the
empty rectangle (0,0,0,0). */
{
assert(okRect(rp), "invalid rect");
rp->left += dh;
rp->right -= dh;
rp->top += dv;
rp->bottom -= dv;
if (EmptyRect(rp))
setEmptyRect(rp);
}
bool
EmptyRect(rp)
Rect *rp;
/* EmptyRect returns TRUE if the given rectangle is an empty rectangle or FALSE
if not.
A rectangle is considered empty if the bottom coordinate is equal to or less
than the
top or the right coordinate is equal to or less than the left. */
{
assert(okRect(rp), "invalid rect");
return rp->bottom <= rp->top || rp->right <= rp->left;
}
void
OffsetRect(rp, dh, dv)
Rect *rp; /* result */
int dh;
int dv;
/* OffsetRect moves the rectangle by adding dh to each horizontal coordinate an
d dv to
each vertical coordinate. If dh and dv are positive, the movement is to the
right and
down; if either is negative, the corresponding movement is in the opposite d
irection.
The rectangle retains its shape and size; it's merely moved on the coordinat
e plane.
This does not affect the screen unless you subsequently call a routine to dr
aw within
the rectangle. */
{
assert((okRect(rp) && okHLoc(dh) && okVLoc(dv)), "illegal argument");
rp->left += dh;
rp->right += dh;
rp->top += dv;
rp->bottom += dv;
}
void
SetRect(rp, left, top, right, bottom)
Rect *rp; /* result */
int left;
int top;
int right;
int bottom;
/* SetRect assigns the four boundary coordinates to the rectangle. The result
is a
rectangle with coordinates (left,top,right,bottom).
This procedure is supplied as a utility to help you shorten your program tex
t. If you
want a more readable text at the expense of length, you can assign integers
(or
points) directly into the rectangle's fields. There is not significant code
size of
execution speed advantage to either method; one's just easier to write, and
the
other's easier to read. */
{
rp->left = left;
rp->top = top;
rp->right = right;
rp->bottom = bottom;
assert(okRect(rp), "invalid rect");
}
/**/
/* Global -bottom- */
/**/
/**/
/* Private -top- */
/**/
static void
setEmptyRect(rp)
Rect *rp;
/* This is not the function of Mac toolbox.
Set the rectangle empty (0,0,0,0). */
{
/* Don't invoke okRect(rp) because setEmptyRect is sometimes called with uni
nitialized
variable. */
SetRect(rp, 0, 0, 0, 0);
}
/**/
/* Private -bottom- */
/**/
/**/
/* Debug -top- */
/**/
void
readRect(rp)
Rect *rp; /* result */
/* Debugging. */
{
xprintf("left top right bottom: ");
xscanf("%d%d%d%d", &rp->left, &rp->top, &rp->right, &rp->bottom);
assert(okRect(rp), "invalid rect");
}
void
printRect(rp)
Rect *rp;
/* Debugging. */
{
assert(okRect(rp), "invalid rect");
xprintf("(%d,%d,%d,%d)", rp->left, rp->top, rp->right, rp->bottom);
}
/**/
/* Debug -bottom- */
/**/
bool
PtInRect(ptp, rp)
Point *ptp;
Rect *rp;
/* PtInRect determines whether the pixel below and to the right of the given co
ordinate
point is enclosed in the specified rectangle, and returns TRUE if so or FALS
E if not. */
{
assert((okPt(ptp) && okRect(rp)), "invalid argument");
return rp->left <= ptp->h && ptp->h < rp->right
&& rp->top <= ptp->v && ptp->v < rp->bottom;
}
void
main()
/* PtInRect() */
{
Rect r;
Point pt;
malloc_debug(MALLOC_LEVEL);
readRect(&r);
forever() {
readPt(&pt);
xprintf("%s\n\n", PtInRect(&pt, &r) ? "within" : "no, not"); }
}
SHAR_EOF
fi
if test -f 'misc.c'
then
echo shar: "will not over-write existing file 'misc.c'"
else
cat << \SHAR_EOF > 'misc.c'
#include <stdio.h>
#include "global.h"
/**/
/* Global -top- */
/**/
void
fatal(msg)
char *msg;
/* Print error message and dumps core. */
{
xfprintf(stderr, "fatal error: %s\n", msg);
(void)abort();
}
bool
okVLoc(v)
int v;
/* Return TRUE if vertical coordinate is valid. */
{
return MIN_V <= v && v <= MAX_V;
}
bool
okHLoc(h)
int h;
/* Return TRUE if horizontal coordinate is valid. */
{
return MIN_H <= h && h <= MAX_H;
}
/**/
/* Global -bottom- */
/**/
/**/
/* Private -top- */
/**/
/**/
/* Private -bottom- */
/**/
/**/
/* Debug -top- */
/**/
/**/
/* Debug -bottom- */
/**/
SHAR_EOF
fi
if test -f 'point.c'
then
echo shar: "will not over-write existing file 'point.c'"
else
cat << \SHAR_EOF > 'point.c'
#include <stdio.h>
#include "global.h"
#include "misc.h"
#include "point.h"
/**/
/* Global -top- */
/**/
bool
okPt(ptp)
Point *ptp;
/* Return TRUE if coordinates are valid. */
{
return ptp != NIL && okHLoc(ptp->h) && okVLoc(ptp->v);
}
void
SubPt(srcPtp, dstPtp)
Point *srcPtp;
Point *dstPtp; /* result */
/* SubPt subtracts the coordinates of srcPt to the coordiantes of dstPt, and re
turn the
result in dstPt. */
{
assert((okPt(srcPtp) && okPt(dstPtp)), "invalid point");
dstPtp->h -= srcPtp->h;
dstPtp->v -= srcPtp->v;
}
void
AddPt(srcPtp, dstPtp)
Point *srcPtp;
Point *dstPtp; /* result */
/* AddPt adds the coordinates of srcPt to the coordiantes of dstPt, and return
the result
in dstPt. */
{
assert((okPt(srcPtp) && okPt(dstPtp)), "invalid point");
dstPtp->h += srcPtp->h;
dstPtp->v += srcPtp->v;
}
bool
EqualPt(ptAp, ptBp)
Point *ptAp;
Point *ptBp;
/* EqualPt compares the two points and returns TRUE if they are equal or FALSE
if not. */
{
assert((okPt(ptAp) && okPt(ptBp)), "invalid point");
return ptAp->h == ptBp->h && ptAp->v == ptBp->v;
}
void
SetPt(ptp, h, v)
Point *ptp; /* result */
int h;
int v;
/* SetPt assigns two integer coordinates to a variable of type Point*. */
{
ptp->h = h;
ptp->v = v;
assert(okPt(ptp), "invalid point");
}
/**/
/* Global -bottom- */
/**/
/**/
/* Private -top- */
/**/
/**/
/* Private -bottom- */
/**/
/**/
/* Debug -top- */
/**/
void
readPt(ptp)
Point *ptp; /* result */
/* Debugging. */
{
xprintf("h v: ");
if (scanf("%d%d", &ptp->h, &ptp->v) != 2)
fatal("scanf error");
assert(okPt(ptp), "invalid point");
}
void
printPt(ptp)
Point *ptp;
/* Debugging tool. */
{
assert(okPt(ptp), "invalid point");
fprintPt(stdout, ptp);
}
void
fprintPt(stream, ptp)
FILE *stream;
Point *ptp;
/* Debugging tool. */
{
assert(okPt(ptp), "invalid point");
(void)fprintf(stream, "(%d,%d)", ptp->h, ptp->v);
(void)fflush(stream);
}
/**/
/* Debug -bottom- */
/**/
SHAR_EOF
fi
if test -f 'rect.h'
then
echo shar: "will not over-write existing file 'rect.h'"
else
cat << \SHAR_EOF > 'rect.h'
/* Mac toolbox. */
extern void SetRect();
extern bool EmptyRect();
extern void OffsetRect();
extern void InsetRect();
extern bool SectRect();
extern void UnionRect();
extern bool EqualRect();
/* General. */
extern void copyRect();
extern bool okRect();
/* Debugging. */
extern void readRect();
SHAR_EOF
fi
if test -f 'misc.h'
then
echo shar: "will not over-write existing file 'misc.h'"
else
cat << \SHAR_EOF > 'misc.h'
extern void fatal();
extern bool okVLoc();
extern bool okHLoc();
SHAR_EOF
fi
if test -f 'point.h'
then
echo shar: "will not over-write existing file 'point.h'"
else
cat << \SHAR_EOF > 'point.h'
/* Mac toolbox. */
extern void SetPt();
extern void AddPt();
/* General. */
extern bool okPt();
/* Debugging. */
extern void fprintPt();
extern void printPt();
extern void readPt();
SHAR_EOF
fi
if test -f 'global.h'
then
echo shar: "will not over-write existing file 'global.h'"
else
cat << \SHAR_EOF > 'global.h'
#define NLN (void)printf("\n")
#define TRUE 1
#define FALSE 0
#define NIL 0
#define xprintf (void)printf
#define xfprintf (void)fprintf
#define xscanf (void)scanf
#define xfscanf (void)fscanf
#define until(A) while (!(A))
#define forever() while (TRUE)
/* Horizontal coordinates range from -32768 to +32767, and vertical coordinates
have the
same range. */
#define MAX_H 32767
#define MAX_V 32767
#define MIN_H -32768
#define MIN_V -32768
#define max(A,B) ((A)>(B) ? (A):(B))
#define min(A,B) ((A)<(B) ? (A):(B))
#ifndef NO_DEBUG
# define _assert(ex,msg) {if (!(ex)) fatal(msg);}
# define assert(ex,msg) {if (!(ex)) fatal(msg);}
#else
# define _assert(ex,msg) ;
# define assert(ex,msg) ;
#endif NDEBUG
struct point {
int h; /* Horizontal coordinate. */
int v; /* Vertical coordinate. */
};
typedef struct point Point;
struct rect {
int left;
int top;
int right;
int bottom;
};
typedef struct rect Rect;
typedef int bool;
/* UNIX library definition. */
extern int printf();
extern int fprintf();
extern int fflush();
extern int malloc_debug();
extern int scanf();
extern int abort();
SHAR_EOF
fi
if test -f 'Makefile'
then
echo shar: "will not over-write existing file 'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
#
# Makefile for Neuron-Toolbox by S.Sugou 4/27 1989
#
# 'make debug' generates debug version.
# 'make lint' invokes lint. But, you should invoke 'lint.rc' instead of 'make l
int'.
# 'make tags' creates TAGS.
# 'make clean' removes some files.
# 'make shar' creates shar file.
#
CFLAGS = $(GNU_CFLAGS) -g -DMALLOC_LEVEL=2
CPPFLAGS =
LDFLAGS =
LINTFLAGS = -abchux -DMALLOC_LEVEL
LIBS = /usr/lib/debug/malloc.o -lm -lmp
PRG = p
GNU_CFLAGS = -traditional -Wall
SUN_CFLAGS = -fswitch
#debug := CC = cc.GNU
#debug := CFLAGS = $(GNU_CFLAGS) -g -DMALLOC_LEVEL=2
#debug := CC = cc.Sun
#debug := CFLAGS = $(SUN_CFLAGS) -g -DMALLOC_LEVEL=2
SRC =\
rect.c\
misc.c\
point.c
HDR = $(SRC:.c=.h) global.h
OBJ = $(SRC:.c=.o)
LINTFILES = $(SRC:.c=.ln)
debug: $(PRG)
$(PRG): $(OBJ)
$(CC) $(CFLAGS) $(OBJ) $(LIBS) -o $(PRG)
@make lint
tags: $(SRC) Makefile
etags -et $(SRC) $(HDR) main.c dbg.c trash.c
touch tags
clean:
-\rm -f $(OBJ) $(LINTFILES) core mon.out gmon.out
dlist: $(SRC)
$(CC) -MM $(SRC) > dlist
lint: $(LINTFILES)
lint $(LINTFLAGS) $(LINTFILES)
@touch lint
shar:
shar $(SRC) $(HDR) Makefile dlist .gdbinit > shar.file
.PRECIOUS: lint tags
#
# dependency-list.
#
include dlist
#
# implict rule.
#
%:%.sh
cp $< $@
chmod +x $@
%.ln:%.c
lint $(LINTFLAGS) -i $<
SHAR_EOF
fi
if test -f 'dlist'
then
echo shar: "will not over-write existing file 'dlist'"
else
cat << \SHAR_EOF > 'dlist'
rect.o : rect.c global.h misc.h point.h rect.h
misc.o : misc.c global.h
point.o : point.c global.h misc.h point.h
SHAR_EOF
fi
if test -f '.gdbinit'
then
echo shar: "will not over-write existing file '.gdbinit'"
else
cat << \SHAR_EOF > '.gdbinit'
# Initialization for Neuron-Toolbox
unset env TERMCAP
set env TERM vt100
printf "Caution: environment TERM is set to vt100. Modify '.gdbinit' as you wi
sh.\n"
# Switch to the file 'p'
define dbgp
exec p
sym p
core
end
document dbgp
Switchs to the file 'p'. Core infomation is discarded, too.
end
# Print the next node
define nn
p $->next
end
document nn
Print the next node of linear list.
end
# Print the previous node
define pn
p $->prev
end
document pn
Print the previous node of linear list.
end
# Print the next track
define nt
p $->littleBr
end
document nt
Print the next track.
end
# Print the previous track
define pt
p $->bigBr
end
document pt
Print the previous track.
end
# Print the current node
define cn
p $
end
document cn
Print the current node of linear list.
end
# Print the content of the next node
define nc
p *$->next
end
document nc
Print the content of the next node
end
# Print the content of the previous node
define pc
p *$->prev
end
document pc
Print the content of the previous node
end
# Print the content of the current node
define cc
p *$
end
document cc
Print the content of the current node
end
# Lpr Cell and SymTable data.
define prall
set $tmp = lprCellAll()
set $tmp = lprNl(5)
set $tmp = lprSymTable()
set $tmp = lprPage()
end
document prall
Lpr Cell and SymTable data.
end
# Lpr Cell.
define prcell
set $tmp = lprCellAll()
set $tmp = lprNl(5)
end
document prcell
Lpr Cell data.
end
# Lpr Symtable.
define prsym
set $tmp = lprSymTable()
set $tmp = lprPage()
end
document prsym
Lpr all Symtable data.
end
SHAR_EOF
fi
exit 0
# End of shell archive
Technical Details
Message-ID:
<8904280757.AA03748@sgtp.apple.juice>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!rutgers!tut.cis.ohio-state.edu!sgtp.apple.juice!shinShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!rutgers!tut.cis.ohio-state.edu!sgtp.apple.juice!shin From: shin@sgtp.apple.juice (Shinichirou Sugou) Newsgroups: gnu.gdb.bug Subject: Bug(?) in gdb-3.1 Message-ID: <8904280757.AA03748@sgtp.apple.juice> Date: 28 Apr 89 07:57:57 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 869