Bug 1434601 - gdb-mi mode doesn't initialize properly
Summary: gdb-mi mode doesn't initialize properly
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: emacs
Version: 27
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Jan Synacek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-21 21:49 UTC by Ben Woodard
Modified: 2018-11-30 17:41 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-30 17:41:03 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Ben Woodard 2017-03-21 21:49:08 UTC
Description of problem:
when you try use gdb inside of emacs the mode doesn't initialize and then it becomes nearly unusable because you're left interacting with the machine interface.

Version-Release number of selected component (if applicable):
emacs-filesystem-25.2-0.1.rc2.fc26.noarch
emacs-common-25.2-0.1.rc2.fc26.x86_64
emacs-nox-25.2-0.1.rc2.fc26.x86_64


How reproducible:
always

Steps to Reproduce:
1. inside of emacs do M-x gdb
2. it will fill in a command line like: 
Run gdb (like this): gdb -i=mi /omp-test1
hit enter
3. instead of giving you a nice UI it will print something like:
Current directory is /
Error: you did not specify -i=mi on GDB's command line!
Python runtime initialized with LC_CTYPE=C (a locale with default ASCII encoding), which may cause Unicode compatibility problems. Using \
C.UTF-8, C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is recommended.
=thread-group-added,id="i1"
~"GNU gdb (GDB) Fedora 7.12.50.20170309-5.fc27\n"
~"Copyright (C) 2017 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redist\
ribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-redhat-linux-gnu\".\nType \"show configuration\" for configuration details."
~"\nFor bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\"...\n"
~"Reading symbols from /omp-test1..."
~"done.\n"
(gdb)
1^done
(gdb)
2^done
(gdb)
3^done
(gdb)
4^done
(gdb)
5^done,files=[{file="openmp.cc",fullname="/openmp.cc"},{file="/usr/include/c++/7/cstdlib",fullname="/usr/include/c++/7/cstdlib"},{file="/\
usr/include/c++/7/cmath",fullname="/usr/include/c++/7/cmath"},{file="/usr/include/c++/7/x86_64-redhat-linux/bits/c++config.h",fullname="/\
usr/include/c++/7/x86_64-redhat-linux/bits/c++config.h"},{file="/usr/lib/gcc/x86_64-redhat-linux/7/include/stddef.h",fullname="/usr/lib/g\
cc/x86_64-redhat-linux/7/include/stddef.h"},{file="/usr/include/stdlib.h",fullname="/usr/include/stdlib.h"},{file="/usr/include/math.h",f\
ullname="/usr/include/math.h"},{file="<built-in>",fullname="//<built-in>"}]
(gdb)
6^done,line="1",file="openmp.cc",fullname="/openmp.cc",macro-info="0"
(gdb)
7^done,value="(gdb) "
(gdb)
8^error,msg="No registers."
(gdb)
9^done,threads=[]
(gdb)
10^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1\
",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",co\
lhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[\
]}
(gdb)
11^done,threads=[]
(gdb)
12^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1\
",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",co\
lhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[\
]}


Additional info:

It looks to me like something is going wrong in:
(defun gdb--check-interpreter (filter proc string)
  (unless (zerop (length string))
    (remove-function (process-filter proc) #'gdb--check-interpreter)
    (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=))
      ;; Apparently we're not running with -i=mi.                                                                                         
      (let ((msg "Error: you did not specify -i=mi on GDB's command line!"))
        (message msg)
        (setq string (concat (propertize msg 'font-lock-face 'error)
                             "\n" string)))
      ;; Use the old gud-gbd filter, not because it works, but because it                                                                 
      ;; will properly display GDB's answers rather than hanging waiting for                                                              
      ;; answers that aren't coming.                                                                                                      
      (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter))
    (funcall filter proc string)))

I think that the problem is when you run emacs in a minimal container the first thing that it prints out is:

[root@1eadb6a256ad /]# gdb -i=mi omp_test1
Python runtime initialized with LC_CTYPE=C (a locale with default ASCII encoding), which may cause Unicode compatibility problems. Using C.UTF-8, C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is recommended.
=thread-group-added,id="i1"
~"GNU gdb (GDB) Fedora 7.12.50.20170309-5.fc27\n"

and that python warning before the GDB banner confuses the gdb-mi mode.

Comment 1 Ben Woodard 2017-03-21 22:13:43 UTC
If you do something like:

# export LC_CTYPE=C.UTF-8

before running emacs, then things work as they should.

I don't know how to make the gdb--check-interpreter more robust so that it ignores the python warning or I don't know how to have gdb suppress the warning when it is in the -i=mi mode. It seems to me that one or the other needs to be done.

Comment 2 Jan Kratochvil 2017-03-21 22:42:34 UTC
Maybe by an F-26 feature:
  https://fedoraproject.org/wiki/Changes/python3_c.utf-8_locale

Comment 3 Ben Woodard 2017-03-21 22:55:20 UTC
I don't think that feature will fix the problem as observed because with the patch:

$ LANG=C /usr/bin/python3 -c 'import click; cli = click.command()(lambda:None); cli()'
Python detected LC_CTYPE=C: LC_ALL & LANG coerced to C.UTF-8 (set another locale or PYTHONCOERCECLOCALE=0 to disable this locale coercion behaviour).

it still prints out the Python detected warning.

My opinion for whatever it is worth is (not much in this case):
1) The F-26 feature above should be implemented
2) Somehow gdb should suppress, delay, or wrap the Python warning when it running in -i=mi mode because machines don't know how to do deal with it.
3) The Emacs gdb-mi should be robustified to ignore the warning.

i.e. belt, suspenders, and a girdle.

Comment 4 Mark Wielaard 2017-05-17 15:03:27 UTC
This also breaks various valgrind gdbserver testcases because there is this extra "Python runtime initialized with LC_CTYPE=C (a locale with default ASCII encoding), which may cause Unicode compatibility problems. Using C.UTF-8, C.utf8, or UTF-8" line.

Comment 5 Jan Kratochvil 2017-06-16 08:48:05 UTC
I no longer have it reproducible with GDB in Rawhide; despite I am not aware of any GDB change.  Maybe Python fixed that?

Comment 6 Jan Kurik 2017-08-15 07:17:16 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

Comment 7 Ben Cotton 2018-11-27 18:37:13 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Ben Cotton 2018-11-30 17:41:03 UTC
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.