Bug 1169495

Summary: gdb does not run under emacs gud mode
Product: [openSUSE] openSUSE Tumbleweed Reporter: Russell Sandish <hpcoder>
Component: OtherAssignee: Tom de Vries <tdevries>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: alynx.zhou, matz, pstivanin
Version: Current   
Target Milestone: ---   
Hardware: x86-64   
OS: All   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Russell Sandish 2020-04-15 03:33:36 UTC
Emacs does not correctly fire up gdb when run using its gdb command. The error message is "Error: you did not specify -i=mi on GDB’s command line!".

It turns out when running gdb with the option -i=mi, the following python errors are output on standard error:
/usr/share/gdb/python/gdb/command/prompt.py:48: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if self.value is not '':
/usr/share/gdb/python/gdb/command/prompt.py:60: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if self.value is not '':
=thread-group-added,id="i1"

The workaround is to edit /usr/share/gdb/python/gdb/command/prompt.py and replace the two instances of "is not" with "!=".

It is, I think a python 2 -> python 3 compatibility issue. != is the correct operator to use in this circumstance, but apparently "is not" worked well enough in python 2 the bug never surfaced before.

Perhaps a patch could be applied to OpenSUSE's gdb package to fix this error until it is fixed upstream.
Comment 1 Tom de Vries 2020-04-20 14:21:14 UTC
Fixed upstream by:

commit b6484282f85bf7f11451b2441599c241d302ad9d
Author: Raul Tambre <raul@tambre.ee>
Date:   Sat May 4 15:48:17 2019 -0400

    Fix incorrect use of 'is' operator for comparison in python/lib/gdb/command/prompt.py
    
    The 'is' operator is not meant to be used for comparisons. It currently working
    is an implementation detail of CPython.  CPython 3.8 has added a SyntaxWarning
    for this.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 383b353339..7eb5d9aef3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-04  Raul Tambre  <raul@tambre.ee>
+
+       * python/lib/gdb/prompt.py (_ExtendedPrompt)
+       <before_prompt_hook, get_show_string>: Fix incorrect use of 'is'
+       operator for comparison.
+
 2019-05-04  Tom Tromey  <tom@tromey.com>
 
        * psymtab.c (psymbol_name_matches, match_partial_symbol)
diff --git a/gdb/python/lib/gdb/command/prompt.py b/gdb/python/lib/gdb/command/prompt.py
index 3d662a7d3f..04b9e49c22 100644
--- a/gdb/python/lib/gdb/command/prompt.py
+++ b/gdb/python/lib/gdb/command/prompt.py
@@ -45,7 +45,7 @@ The currently defined substitutions are:
         self.hook_set = False
 
     def get_show_string (self, pvalue):
-        if self.value is not '':
+        if self.value:
            return "The extended prompt is: " + self.value
         else:
            return "The extended prompt is not set."
@@ -57,7 +57,7 @@ The currently defined substitutions are:
         return ""
 
     def before_prompt_hook(self, current):
-        if self.value is not '':
+        if self.value:
             return gdb.prompt.substitute_prompt(self.value)
         else:
             return None
Comment 3 Swamp Workflow Management 2020-04-21 15:50:05 UTC
This is an autogenerated message for OBS integration:
This bug (1169495) was mentioned in
https://build.opensuse.org/request/show/796085 Factory / gdb
Comment 6 Swamp Workflow Management 2020-05-26 13:15:39 UTC
SUSE-RU-2020:1415-1: An update that has three recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1168394,1169368,1169495
CVE References: 
Sources used:
SUSE Linux Enterprise Module for Development Tools 15-SP1 (src):    gdb-8.3.1-8.14.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 7 Swamp Workflow Management 2020-05-29 22:13:55 UTC
openSUSE-RU-2020:0740-1: An update that has three recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1168394,1169368,1169495
CVE References: 
Sources used:
openSUSE Leap 15.1 (src):    gdb-8.3.1-lp151.4.9.1
Comment 11 Russell Sandish 2021-05-31 05:33:49 UTC
This particular bug hasn't manifested for some time.
Comment 15 Swamp Workflow Management 2022-02-17 14:23:59 UTC
SUSE-RU-2022:0472-1: An update that has 13 recommended fixes and contains four features can now be installed.

Category: recommended (moderate)
Bug References: 1146167,1146475,1156284,1158539,1168394,1169368,1169495,1180786,1184214,1185638,1186040,1187044,1192285
CVE References: 
JIRA References: SLE-13656,SLE-21561,SLE-21581,SLE-7903
Sources used:
SUSE Linux Enterprise Software Development Kit 12-SP5 (src):    gdb-11.1-2.17.1
SUSE Linux Enterprise Server 12-SP5 (src):    gdb-11.1-2.17.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.