This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/17607] With some locales, entering a valid floating point number gives "Invalid number"


https://sourceware.org/bugzilla/show_bug.cgi?id=17607

--- Comment #2 from fabrizio.ge at tiscali dot it ---
This still occurs with the latest Git 8d7d784e23b5b2f8c7e28ece1bdb73b58199f16f.

To reproduce, first make sure that a locale using comma as decimal separator is
installed on the system (on Ubuntu, the relative language-pack-* must be
installed).

Add the option --with-python=/usr/bin/python3 to configure to enable Python3
support.

Build gdb and run the command

fabrizio@fabrizio-host:~/dev/binutils-gdb/gdb$ ./gdb -ex "p 1.0" -ex q
GNU gdb (GDB) 7.10.50.20160104-cvs
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Invalid number "1.0".

The problem lies in the line of 

setlocale (LC_ALL, "");

in file python/python.c, function _initialize_python(). That line (which is
protected by #ifdef IS_PY3K, and therefore is not executed in case gdb is not
compiled with Python3) resets the locales to the values specified in the
environment, while the old values of all the locales were C.

It can be worked around by explicitly setting the env var LC_NUMERIC. Example:

fabrizio@fabrizio-host:~/dev/binutils-gdb/gdb$ LC_NUMERIC=C ./gdb -ex "p 1.0"
-ex q
GNU gdb (GDB) 7.10.50.20160104-cvs
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
$1 = 1

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]