Article View: gnu.gdb.bug
Article #10031GDB 3.5 bug: short returns botched if BYTES_BIG_ENDIAN (+ Sun fix)
From: Paul Eggert
Date: Tue, 16 Oct 1990 20:58
Date: Tue, 16 Oct 1990 20:58
81 lines
3383 bytes
3383 bytes
This message contains a fix for a bug I reported earlier: GDB 3.5 reports the
wrong returned value for functions that yield char or short (Sun-4, SunOS 4.1,
GCC 1.37.1). Here's an example of the bug:
57-ata% cat t.c
char p() { return 1; }
main() { return p(); }
58-ata% gdb a.out
GDB 3.5, Copyright (C) 1989 Free Software Foundation, Inc.
...
(gdb) b p
Reading in symbols for t.c...done.
Breakpoint 1 at 0x2294: file t.c, line 1.
(gdb) r
Starting program: /n/dark/u/eggert/junk/a.out
Bpt 1, p () (t.c line 1)
1 char p() { return 1; }
(gdb) fin
Run till exit from #0 p () (t.c line 1)
0x22b4 in main () (t.c line 2)
2 main() { return p(); }
Value returned is $1 = 0 '\000'
The actual value returned is 1, but GDB reports it as 0.
This bug is generic to BYTES_BIG_ENDIAN machines, but I couldn't see a simple
generic fix. The following fix is for Sun-3s and Sun-4s; the other
BYTES_BIG_ENDIAN m-xxxx.h files can be fixed similarly.
===================================================================
RCS file: RCS/m-sparc.h,v
retrieving revision 1.1
diff -c -r1.1 m-sparc.h
*** 1.1 1990/10/16 19:59:37
--- m-sparc.h 1990/10/16 20:28:50
***************
*** 260,266 ****
(VALBUF), TYPE_LENGTH(TYPE)); \
} \
else \
! bcopy (((int *)(REGBUF))+8, (VALBUF), TYPE_LENGTH (TYPE)); \
}
/* Write into appropriate registers a function return value
--- 260,268 ----
(VALBUF), TYPE_LENGTH(TYPE)); \
} \
else \
! bcopy ((char *)((int *)(REGBUF) + 8) + \
! (TYPE_LENGTH (TYPE) < 4 ? 4 - TYPE_LENGTH (TYPE) : 0), \
! VALBUF, TYPE_LENGTH (TYPE)); \
}
/* Write into appropriate registers a function return value
===================================================================
RCS file: RCS/m-sun3.h,v
retrieving revision 1.1
diff -c -r1.1 m-sun3.h
*** 1.1 1990/10/16 20:33:29
--- m-sun3.h 1990/10/16 20:33:41
***************
*** 203,209 ****
into VALBUF. */
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
! bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
/* Write into appropriate registers a function return value
of type TYPE, given in virtual format. */
--- 203,211 ----
into VALBUF. */
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
! bcopy ((char *)(REGBUF) + \
! (TYPE_LENGTH (TYPE) < 4 ? 4 - TYPE_LENGTH (TYPE) : 0), \
! VALBUF, TYPE_LENGTH (TYPE))
/* Write into appropriate registers a function return value
of type TYPE, given in virtual format. */
Technical Details
Message-ID:
<9010162058.AA16838@ata.twinsun.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!twinsun.com!eggertShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,a6b5e3368f184564,start X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 1990-10-16 13:58:16 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!twinsun.com!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: gnu.gdb.bug Subject: GDB 3.5 bug: short returns botched if BYTES_BIG_ENDIAN (+ Sun fix) Message-ID: <9010162058.AA16838@ata.twinsun.com> Date: 16 Oct 90 20:58:16 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 81 Approved: bug-gdb@prep.ai.mit.edu Posted: Tue Oct 16 21:58:16 1990