gdbtui does not give input and show cyrillic symbols

Bug #1275210 reported by Eldar Khayrullin
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gdb (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

┌──main.c────────────────────────────────────────────────────────────────────────────────┐
   │1 #include <stdio.h> │
   │2 │
   │3 int main() │
   │4 { │
   │5 printf("M-P~_M-Q~@M-PM-8M-PM-2M-PM-5M-Q~B M-P~\M-PM-8M-Q~@\n"); │
   │6 return 0; │
   │7 } │
   │8 │
   └─────────────────────────────────────────────────────────────────────────────────────┘
exec No process In: Line: ?? PC: ??
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 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-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/eldar/hello...done.
(gdb) M-Q~GM-Q~BM-PM-> M-Q~BM-PM-0M-PM-:M-PM->M-PM-5

Revision history for this message
Eldar Khayrullin (eldar) wrote :

main.c

description: updated
Revision history for this message
Matthias Klose (doko) wrote :

closing this rather old issue. sorry for not addressing this earlier. Please could you recheck with the recent 14.04 LTS or 14.10 releases and reopen the issue if the problem persists?

Changed in gdb (Ubuntu):
status: New → Invalid
Revision history for this message
Eldar Khayrullin (eldar) wrote :

Ubuntu 14.10

GNU gdb (Ubuntu 7.8-1ubuntu4) 7.8.0.20141001-cvs
Copyright (C) 2014 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-linux-gnu".

┌──main.cpp─────────────────────────────────────────────────────────────────────────────────────┐
   │1 #include <stdio.h> │
   │2 │
   │3 int main() │
   │4 { │
   │5 printf("M-P~_M-Q~@M-PM-8M-PM-2M-PM-5M-Q~B M-P~\M-PM-8M-Q~@\n"); │
   │6 return 0; │
   │7 }

Changed in gdb (Ubuntu):
status: Invalid → New
Revision history for this message
Matthias Klose (doko) wrote :

repeating the issue here is not good enough. please could you state what is supposed to be wrong, and what you would expect?

Changed in gdb (Ubuntu):
status: New → Incomplete
Revision history for this message
Eldar Khayrullin (eldar) wrote :

Must be:
#include <stdio.h>

int main()
{
 printf("Привет Мир\n");
 return 0;
}

Current:
#include <stdio.h>

int main()
{
 printf("M-P~_M-Q~@M-PM-8M-PM-2M-PM-5M-Q~B M-P~\M-PM-8M-Q~@\n");
 return 0;
}

The russian text is not displayed correctly.

Revision history for this message
Eldar Khayrullin (eldar) wrote :

$ file main.c
main.c: C source, UTF-8 Unicode text

(gdb) show charset
The host character set is "auto; currently UTF-8".
The target character set is "auto; currently UTF-8".
The target wide character set is "auto; currently UTF-32".

Enter text:
-with TUI
(gdb) M-PM-?M-Q~@M-PM-8M-PM-2M-PM-5M-Q~B // currently
-without TUI
(gdb) привет // must be

Without TUI
(gdb) list main.c:1
1 #include <stdio.h>
2
3 int main()
4 {
5 printf("Привет Мир\n"); // correctly
6 return 0;
7 }

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for gdb (Ubuntu) because there has been no activity for 60 days.]

Changed in gdb (Ubuntu):
status: Incomplete → Expired
Eldar Khayrullin (eldar)
Changed in gdb (Ubuntu):
status: Expired → New
Revision history for this message
Лъчезар Георгиев (luchezar) wrote :

I managed to build from source code a gdb which correctly shows Cyrillic characters (and probably all other UTF-8 encoded characters which the console font supports) in the source code window. But in order to write an acceptable gdb patch, I would need to study the configuration scripts, which isn't easy. So, for now, may the following information be useful to anyone who would like to build their own gdb which correctly displays UTF-8 encoded characters in the source code window.

In order to do this, gdb needs to be:

1) patched so that instead of the "ncurses" headers and library, it uses the wide-character "ncursesw", which decodes the UTF-8 encoded multi-byte characters correctly.

2) configured with --enable-tui and --with-curses switches, among the other eventually needed switches (the existing ones can be examined with the "show config" gdb command, and then applied to "configure". Sure, several needed additional packages will have to be installed, too).

To accomplish (1), I wrote the following "slow and dirty" script which changes many more occurrences of "ncurses" than necessary, but surely changes also those that really need to be changed, among them:

# Please be patient: this script is very slow!
find gdb -type f | xargs sed -si 's/ncurses/ncursesw/g'
find gdb -type f | xargs sed -si 's|ncursesw/ncursesw|ncursesw/curses|g'

It's written for the case when "sudo apt-get install gdb-source" is executed to get the current gdb source archive, which is then extracted. If extracting another archive with some other top level directory name, the "gdb" in the above script must be changed to match that name.

Hope this helps, and once again, sorry that at least at the moment I can't provide a good patch. By the way, the bug is fixed in FreeBSD-11, albeit its gdb is an older version (6.1.1). If someone could find their patch that accomplished this, that would be even more helpful. But, as I wrote, it would be a patch against version 6.1.1, so it would probably need to be edited for the newer one. Why this new release of FreeBSD uses an old gdb version? I don't know, ask them.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gdb - 8.0-0ubuntu6

---------------
gdb (8.0-0ubuntu6) artful; urgency=medium

  * Fix build dependencies for the gdb64 build.

 -- Matthias Klose <email address hidden> Fri, 01 Sep 2017 09:00:04 +0200

Changed in gdb (Ubuntu):
status: New → Fix Released
Revision history for this message
Лъчезар Георгиев (luchezar) wrote :

Thank you very much for fixing it! Unfortunately, it's back in version 9.0.90.20200105-0ubuntu1 (tested on AMD64, Ubuntu 20.04). I tried to downgrade to 8.3-0ubuntu1 and then even to 8.2.91.20190405-0ubuntu3. In both cases the bug was there. It wasn't there in 8.1-0ubuntu3.2 (Ubuntu 18.04 LTS).

Revision history for this message
Лъчезар Георгиев (luchezar) wrote :

To add some later findings, it turned out that:
(1) The bug was reintroduced in version 8.3;
(2) It affects only some CPU architectures.
I tested version "Debian 8.3.1-1" on two 64-bit machines with the same version of Debian (Sid), one with PowerPC, and the other with SPARC. The bug shows up only on the SPARC machine, not the PowerPC one. I then built the generic version 8.3.1 on a 64-bit ARM machine. The bug didn't show up there. And then I built it on a 64-bit MIPS (big endian) machine, where the bug did show up. Repeated this with version 8.3. The bug showed up again. When I built the generic version 8.2.1 on the same MIPS machine, the bug didn't show up. A "diff -u gdb-8.2.1/gdb/tui gdb-8.3/gdb/tui" shows a lot of changes made in the TUI code of version 8.3 to add some colourisation to the TUI, and the bug was probably introduced during this process. Sorry that I can't help more to isolate the bug. But it's quite strange that it manifests itself only on x86-64, SPARC and MIPS, but not on ARM and PowerPC. I suppose that because of this, it will be rather hard to pinpoint.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.