Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Wu Zhou <woodzltc@cn.ibm.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFC] Decimal Floating Point support for GDB (Part 1: patch)
Date: Sun, 02 Oct 2005 21:00:00 -0000	[thread overview]
Message-ID: <20051002205724.GB31820@nevyn.them.org> (raw)
In-Reply-To: <Pine.LNX.4.63.0509281204560.1231@linux.site>

On Wed, Sep 28, 2005 at 12:42:36PM +0800, Wu Zhou wrote:
> This patch is intended to add decimal floating point (DFP) support into
> GDB.  It currently supports the printing and setting of DFP.  And also 
> support displaying the dfp types in function argument and backtrace.  
> If you think that any other features are also desired, please let me know.  
> I will try to see whether it can also be supported.

I'm afraid I am not very happy with this approach :-(

	* c-exp.y (parse_number): Parse the decimal floating point, which 
	has a suffix ('df', 'dd' or 'dl') and return STRING here.

This certainly isn't right.  It produces several problems:

(gdb) p 1.2df
evaluation of this expression requires the target program to be active

[Side effect of string handling]

...

(gdb) p 1.2df
$1 = "1.2"

(gdb) p $1[1]
$2 = 46 '.'

(gdb) p (1.2df)
A syntax error in expression, near `'.

If we have a GDB type system representation for decimal floats, the C
parser should use it, and for lexing purposes it should probably be a
FLOAT.

I'm not familiar with the proposed C language changes, but GDB should
plan to support them properly; the same set of implicit or invalid
conversions, supported operations, et cetera.  We certainly don't need
to implement all that; the C interpreter is pretty casual.  But let's
consider them at least.  And maybe issue intelligent error messages.

> 	* dfp.h: New header file for decimal floating point support in GDB.
> 	main functions is decimal_from_string and decimal_to_string.
> 	* dfp.c: New source file for decimal floating point support in GDB.
> 	Implement decimal_from_string and decimal_to_strin.

The decNumber library is going to be (or already is) contributed to the
FSF and GPL-licensed. In that case, perhaps we can move it to the top
level of the repository, and use it to implement support in GDB.  The
alternative is adding a lot of sensitive numeric code to GDB that the
GDB developers won't know much about.

> 	* valops.c (value_set_dfp): New function, calling decimal_from_string
> 	to set the value of decimal floating point types.

This is wrong for a couple of reasons.  I think you're doing this to
avoid the cast to arg1's type in evaluate_subexp_standard; but in the
process you've ignored "noside" and binop_user_defined_p (assuming
eventual C++ support), and you're assuming that fromval is a string.
Which means that 'dfp_var1 = dfp_var2' is going to crash.  And
'dfp_var1 = "1.2"' would probably work, which is unlikely to be what
you wanted.

I recommend representing decimal floating point numbers in GDB as
decimal floating point numbers, not as strings.  Then it will be pretty
clear where in e.g. valarith.c to handle it.  Or, initially, reject it.

Oh, and in a couple of places your code says:

+    Contributed by Cygnus Support, using pieces from other GDB modules.

which is not true since you're contributing it :-)

-- 
Daniel Jacobowitz
CodeSourcery, LLC


  parent reply	other threads:[~2005-10-02 21:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-28  4:40 Wu Zhou
2005-09-28 18:40 ` Eli Zaretskii
2005-09-29  2:12   ` Wu Zhou
2005-09-29  3:34     ` Eli Zaretskii
2005-10-02 21:00 ` Daniel Jacobowitz [this message]
2005-10-03 15:38   ` [RFC] Decimal Floating Point support for GDB (Part 1: patch)(a sidebar) Paul Gilliam
2005-10-03 15:41     ` Daniel Jacobowitz
2005-10-09  4:06       ` Wu Zhou
2005-10-09  5:23   ` [RFC] Decimal Floating Point support for GDB (Part 1: patch) Wu Zhou
2005-10-09 20:08     ` Daniel Jacobowitz
2005-10-12 14:42       ` Wu Zhou
2005-10-12 14:49         ` Daniel Jacobowitz
2005-10-18 10:02           ` [RFC] Decimal Floating Point support for GDB (Part 1: patch - Rewrited) Wu Zhou
2005-09-29  5:14 [RFC] Decimal Floating Point support for GDB (Part 1: patch) Wu Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051002205724.GB31820@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=woodzltc@cn.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox