tdm-gcc
tdm-gcc copied to clipboard
GDB shows error message when running in directory with non-English characters
I Installed TDM-GCC 9.10 in a directory with non-English characters. When I run GDB, it shows error messages in startup:
Python Exception <class 'UnicodeDecodeError'> 'utf-8' codec can't decode byte 0x b1 in position 3: invalid start byte: c:\TDM-GCC-64-9.2.0\gdb64\bin\gdb.exe: warning: internal error: Unhandled Python exception GNU gdb (GDB) 8.3.1
When I load an executable file and start, it shows the following message in each step or next: Python Exception <class 'NameError'> Installation error: gdb.execute_unwinders f unction is missing: Python Exception <class 'NameError'> Installation error: gdb.execute_unwinders f unction is missing:
If I rename the installation directory will full-English letters, these error message will disappear.
Although GCC and GDB have a history of not playing well with the expanded UTF character space, this looks like something that may be an easy fix. Can you try modifying gdb64\bin\gdbinit
to use a unicode string literal? (It's a text file containing Python code that GDB runs at startup.)
python
import sys
from os.path import dirname
import glob
globbed_paths = sorted(glob.glob(dirname(sys.executable) + u'\\..\\..\\share\\gcc-*\\python'), reverse=True)
for path in globbed_paths:
sys.path.insert(0, path)
try:
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers(None)
break
except ModuleNotFoundError:
sys.path.pop(0)
end
If this doesn't solve the problem, I'd like to see the output of python print(sys.path)
from a GDB terminal. Here's mine for comparison:
C:\TDM-GCC-64\bin>gdb
...
(gdb) python print(sys.path)
['C:\\TDM-GCC-64\\gdb64\\bin/../../share\\gcc-9.2.0\\python', 'c:\\tdm-gcc-64\\gdb64\\share\\gdb/python', 'C:\\TDM-GCC-64\\gdb64\\bin\\python38.zip', 'C:\\TDM-GCC-64\\gdb64\\bin\\DLLs', 'C:\\TDM-GCC-64\\gdb64\\bin\\lib', 'C:\\TDM-GCC-64\\gdb64\\bin', 'C:\\TDM-GCC-64\\gdb64\\bin\\lib\\site-packages']
I modified gdb64\bin\gdbinit as you said. But it doesn't solve the problem.
The Installation directory of TDM-GCC 9.2.0 is *d:\我的文档\GitHub\devcpp\TDM-GCC-64-9.2.0* When I run GDB, it displays at startup:
d:\我的文档\GitHub\devcpp\TDM-GCC-64-9.2.0\bin>gdb Python Exception <class 'UnicodeDecodeError'> 'utf-8' codec can't decode byte 0x ce in position 3: invalid continuation byte: d:\\GitHub\devcpp\TDM-GCC-64-9.2.0\gdb64\bin\gdb.exe: warning: internal error: U nhandled Python exception GNU gdb (GDB) 8.3.1 Copyright (C) 2019 Free Software Foundation, Inc.
Obviously, the UTF characters in the installation directory is discarded.
My current Windows locale is US English and when I put TDM-GCC-64 in a directory with the same name, 我的文档
, I get a different error.
C:\我的文档\bin>gdb
Python Exception <class 'ModuleNotFoundError'> No module named 'gdb':
C:\????\gdb64\bin\gdb.exe: warning:
Could not load the Python gdb module from `c:\mingw64tdm\gdb64\share\gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.
GNU gdb (GDB) 8.3.1
Copyright (C) 2019 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-w64-mingw32".
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".
(gdb)
This error happens regardless of the contents of gdbinit
.
64-bit TDM GDB is built with --disable-nls
, but 32-bit is built with --enable-nls
. I would hope that GDB would support UTF-8 Python paths regardless, but you might check if 32-bit GDB shows the same failure as 64-bit GDB or not. Also, I'm still curious to see your python print(sys.path)
output.
Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
d:\我的文档\GitHub\devcpp\TDM-GCC-64-9.2.0\gdb64\bin>gdb Python Exception <class 'UnicodeDecodeError'> 'utf-8' codec can't decode byte 0x ce in position 3: invalid continuation byte: d:\GitHub\devcpp\TDM-GCC-64-9.2.0\gdb64\bin\gdb.exe: warning: internal error: U nhandled Python exception GNU gdb (GDB) 8.3.1 Copyright (C) 2019 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-w64-mingw32". 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". (gdb) python print(sys.path) ['d:\我的文档\GitHub\devcpp\TDM-GCC-64-9.2.0\gdb64\bin\python38.zip', 'd: \我的文档\GitHub\devcpp\TDM-GCC-64-9.2.0\gdb64\bin\DLLs', 'd:\我的文档\ GitHub\devcpp\TDM-GCC-64-9.2.0\gdb64\bin\lib', 'd:\我的文档\GitHub\devcp p\TDM-GCC-64-9.2.0\gdb64\bin', 'd:\我的文档\GitHub\devcpp\TDM-GCC-64-9.2. 0\gdb64\bin\lib\site-packages'] (gdb)
I guess, the error doesn't lie in gdbinit
, but lies in another place with decode of dirname
.
I suggest you to check other versions. As I know, TMD-GCC 5.1.0 doesn't have such a problem. Maybe you need to check the versions between 5.1.0 and 9.2.0. (I don't know where I can download these versions, and can't help to check them.)
BTW: there is no gdb32 in TDM-GCC 9.2.0. File "gdb.exe" is the same file as "gdb64.exe".
Thanks for helping provide some output here, I appreciate it. :)
You can install gdb32 in a 64-bit or 32-bit TDM-GCC installation via the installer, if desired. Unfortunately, the installer may not let you roll back to an old version of GDB once the new version is installed. If it does, great! But it's not well supported. The latest TDM releases of GDB are based on GDB 8.3.1, and prior to that it was something in the GDB 7 series ... 7.6.1 maybe? But there are no intervening versions to check unless I build them. :)
I don't see a reliance of the TDM gdb32 or gdb64 executables on libiconv.dll, which is interesting since the GDB configuration page lists it as a requirement - https://sourceware.org/gdb/current/onlinedocs/gdb/Requirements.html . I may have to rebuild GDB and verify whether libiconv is being correctly linked.
I can add this issue to be addressed in a new TDM GDB build.
Would you please provide a download link (not the installer) of TDM-GCC 8.x or 7.x? I would like to check if these versions have the similar problem.
Previous versions of TDM GDB are here: https://sourceforge.net/projects/tdm-gcc/files/GDB/