Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb --tui is unable to display borders with proper lines when PuTTY terminal is set to use UTF-8

Issue

I log into a remote CentOS system using PuTTY and do my development using g++ and gdb. My PuTTY is set to interpret terminal output as UTF-8 and render it accordingly. This setting is configured as shown below.

enter image description here

While debugging with gdb --tui I observe that the borders around the source code pane is not drawn properly with lines. It looks like a terminal character encoding issue.

The terminal is able to display Unicode characters correctly. Here are some example outputs:

[root@gel ~]# python -c "print u'\u2665'"
♥
[root@gel ~]# printf "\xe2\x99\xa5\n"
♥

Here are my terminal settings:

[root@gel ~]# echo $LANG
en_US.UTF-8
[root@gel ~]# echo $LC_CTYPE

[root@gel ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
[root@gel ~]# echo $TERM
xterm

However, when I launch gdb -tui the

   lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
   x                                                                           x
   x                                                                           x
   x                                                                           x
   x                                                                           x
   x                                                                           x
   x                                                                           x
   x             [ No Source Available ]                                       x
   x                                                                           x
   x                                                                           x
   x                                                                           x
   x                                                                           x
   x                                                                           x
   x                                                                           x
   mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
None No process In:                                           Line: ??   PC: ??
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 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-redhat-linux-gnu".
---Type <return> to continue, or q <return> to quit---

You can see that the border around the source code pane is drawn with q's, and x's.

Question

How can I resolve this issue such that gdb -tui output draws the borders with proper lines?

Workaround

Right now, I am working around the issue by configuring PuTTY to interpret the terminal data as ISO-8859-1 as shown below. With this setting the terminal output looks like the following.

enter image description here

[root@gel ~]# python -c "print u'\u2665'"
â¥
[root@gel ~]# printf "\xe2\x99\xa5\n"
â¥

With this setting gdb --tui output looks proper.

   ┌───────────────────────────────────────────────────────────────────────────┐
   │                                                                           │
   │                                                                           │
   │                                                                           │
   │                                                                           │
   │                                                                           │
   │                                                                           │
   │             [ No Source Available ]                                       │
   │                                                                           │
   │                                                                           │
   │                                                                           │
   │                                                                           │
   │                                                                           │
   │                                                                           │
   └───────────────────────────────────────────────────────────────────────────┘
None No process In:                                           Line: ??   PC: ??
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 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-redhat-linux-gnu".
---Type <return> to continue, or q <return> to quit---
like image 269
Lone Learner Avatar asked Apr 03 '14 15:04

Lone Learner


2 Answers

According to this answer (linked in @jpe's comment), the problem is that "some terminal emulators (e.g. Putty) do not respect the ACS control sequences when they are in UTF-8 mode". This suggests two possible solutions:

  1. Take PuTTY out of UTF-8 mode. This seems to be the effect of your workaround.

  2. Stop GDB from using ACS control sequences. According to the documentation, this can be done with the command set tui border-kind ascii. The documentation fails to note that this command must be given before entering TUI mode.

like image 186
ShadSterling Avatar answered Nov 17 '22 18:11

ShadSterling


In recent version of Putty there is an option Enable VT100 line drawing even in UTF-8 mode which does the trick:

Enable VT100 line drawing

like image 1
Denis Kruchkov Avatar answered Nov 17 '22 17:11

Denis Kruchkov