gdb/gdb-do-not-import-py-curses-ascii-module.patch
Andrew Burgess 08bfd0a4a7 switch rpm suggestion feature to a Python extension
This commit backports several patches from upstream GDB:

  7d21600b31f
  dd5516bf98f
  e8c3dafa5f5
  1146d27749f
  7db795bc67a
  8f6c452b5a4
  661d98a3331
  6234ba17598
  27807da5849
  7628a997f27

These commits provide a new Python API which allows users to catch the
case where GDB tries to load an objfile, but can't find any debug
information.

I've then added a new patch which uses this Python API to hook into
GDB and make suggestions about RPMs to install that could provide
missing debug information, this should replace some of the rpm
suggestion functionality that is currently implemented within GDB's
C++ code, as such I've deleted all of the code related to opening
librpm and querying the RPM database.

There is still code in GDB which will make suggestions about
installing RPMs based on the path to the build-id symlink for the
file.  This code is hit when a user tries to open a core-file and the
corresponding executable can't be found, or if a shared library
required by the core-file isn't found.

In these cases the librpm lookup would always fail anyway and we'd
just suggest that the user try to install the required package based
on the path to the build-id symlink, e.g.:

  Missing separate debuginfo for the main executable file.
  Try: yum --enablerepo='*debug*' install /usr/local/lib/debug/.build-id/bf/c9fbd13046db58c28ba332e6c991240e775c96

This should still work just as it did before.

Now GDB no longer links against librpm I'm able to remove all the
librpm related stuff from the configure scripts, which is a nice
cleanup.

There are a couple of patches:

  gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
  gdb-6.6-buildid-locate-rpm.patch

which deal exclusively with updating code (added in earlier patches)
related to the use of librpm from GDB's C++ code, these patches are
removed by this commit.  Other patches are changed either by the
removal of the librpm code, or as a consequence of that code having
been removed.

I've also taken the opportunity to fix up some of the test cases which
only exist in the Fedora tree so that they will run again.  This is
mostly just updating the tests to match upstream GDB's current
testsuite infrastructure, these are all pretty minor fixes.
2024-03-15 14:04:11 +00:00

65 lines
2.2 KiB
Diff

From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Wed, 22 Nov 2023 19:02:34 +0100
Subject: gdb-do-not-import-py-curses-ascii-module.patch
;; Backport upstream commit e8c3dafa5f5.
[gdb/python] Don't import curses.ascii module unless necessary
I ran into a failure in test-case gdb.python/py-missing-debug.exp with python
3.6, which was fixed by commit 7db795bc67a ("gdb/python: remove use of
str.isascii()").
However, I subsequently ran into a failure with python 3.11:
...
(gdb) PASS: $exp: initial checks: debug info no longer found
source py-missing-debug.py^M
Traceback (most recent call last):^M
File "py-missing-debug.py", line 17, in <module>^M
from gdb.missing_debug import MissingDebugHandler^M
File "missing_debug.py", line 21, in <module>^M
from curses.ascii import isascii, isalnum^M
File "/usr/lib64/python3.11/_import_failed/curses.py", line 16, in <module>^M
raise ImportError(f"""Module '{failed_name}' is not installed.^M
ImportError: Module 'curses' is not installed.^M
Use:^M
sudo zypper install python311-curses^M
to install it.^M
(gdb) FAIL: $exp: source python script
...
Apparently I have the curses module installed for 3.6, but not 3.11.
I could just install it, but the test-case worked fine with 3.11 before commit
7db795bc67a.
Fix this by only using the curses module when necessary, for python <= 3.7.
Tested on x86_64-linux, with both python 3.6 and 3.11.
diff --git a/gdb/python/lib/gdb/missing_debug.py b/gdb/python/lib/gdb/missing_debug.py
--- a/gdb/python/lib/gdb/missing_debug.py
+++ b/gdb/python/lib/gdb/missing_debug.py
@@ -18,8 +18,18 @@ MissingDebugHandler base class, and register_handler function.
"""
import gdb
-from curses.ascii import isascii, isalnum
-
+import sys
+if sys.version_info >= (3, 7):
+ # Functions str.isascii() and str.isalnum are available starting Python
+ # 3.7.
+ def isascii(ch):
+ return ch.isascii()
+ def isalnum(ch):
+ return ch.isalnum()
+else:
+ # Fall back to curses.ascii.isascii() and curses.ascii.isalnum() for
+ # earlier versions.
+ from curses.ascii import isascii, isalnum
def _validate_name(name):
"""Validate a missing debug handler name string.