public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* tdep/2075: incorrect return value when bool functions are printed on amd64
@ 2006-01-27 21:48 larue
  0 siblings, 0 replies; 2+ messages in thread
From: larue @ 2006-01-27 21:48 UTC (permalink / raw)
  To: gdb-gnats


>Number:         2075
>Category:       tdep
>Synopsis:       incorrect return value when bool functions are printed on amd64
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 27 21:48:01 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Woody LaRue
>Release:        gdb-6.3
>Organization:
>Environment:
amd64 / linux
>Description:
printing a function that returns a bool value always returns false.

>How-To-Repeat:
cat test.cpp
bool test()
{
  return true;
}

main(int, char**)
{
while(1);
}
sdvopt05{larue 60}:!g++
g++ -g test.cpp
sdvopt05{larue 61}:gdb a.out
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or 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.
This GDB was configured as "x86_64-linux-gnu"...Using host libthread_db library "/lib64/tls/libthread_db.so.1".

(gdb) run
Starting program: /home/larue/a.out 

Interrupt


Program received signal SIGINT, Interrupt.
main () at test.cpp:8
8       while(1);
(gdb) print test()
$1 = false
(gdb) 
>Fix:
I have a fix to the function amd64_classify function (add TYPE_CODE_BOOL to the test clause)

static void
amd64_classify (struct type *type, enum amd64_reg_class class[2])
{
  enum type_code code = TYPE_CODE (type);
  int len = TYPE_LENGTH (type);

  class[0] = class[1] = AMD64_NO_CLASS;

  /* Arguments of types (signed and unsigned) _Bool, char, short, int,
     long, long long, and pointers are in the INTEGER class.  Similarly,
     range types, used by languages such as Ada, are also in the INTEGER
     class.  */

 /* Adding TYPE_CODE_BOOL to the following test. Without this printing a boolean 
    valued function is incorrectly returning false.

    larue@cadence.com 1/27/06  */
  if ((code == TYPE_CODE_INT || code == TYPE_CODE_ENUM
       || code == TYPE_CODE_RANGE
       || code == TYPE_CODE_PTR || code == TYPE_CODE_REF || TYPE_CODE_BOOL)
/* ADD BOOLEAN TO CLAUSE */
      && (len == 1 || len == 2 || len == 4 || len == 8))
    class[0] = AMD64_INTEGER;

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: tdep/2075: incorrect return value when bool functions are printed on amd64
@ 2006-01-30  8:27 kettenis
  0 siblings, 0 replies; 2+ messages in thread
From: kettenis @ 2006-01-30  8:27 UTC (permalink / raw)
  To: gdb-prs, larue, nobody

Synopsis: incorrect return value when bool functions are printed on amd64

State-Changed-From-To: open->closed
State-Changed-By: kettenis
State-Changed-When: Mon Jan 30 08:27:30 2006
State-Changed-Why:
    fixed

http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=2075


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-30  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-27 21:48 tdep/2075: incorrect return value when bool functions are printed on amd64 larue
2006-01-30  8:27 kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).