- Update to fedora rawhide @ 1672291.

- Patches updated:
  * gdb-6.6-buildid-locate-rpm-suse.patch
  * gdb-add-rpm-suggestion-script.patch

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=418
This commit is contained in:
Tom de Vries 2025-01-24 15:02:13 +00:00 committed by Git OBS Bridge
parent bd80ac8165
commit 621499e68d
3 changed files with 123 additions and 110 deletions

View File

@ -1,43 +1,43 @@
diff --git a/gdb/python/lib/gdb/command/rpm-suggestions.py b/gdb/python/lib/gdb/command/rpm-suggestions.py
index 293b1638617..463684c1462 100644
index f52b822c111..da80363ebd2 100644
--- a/gdb/python/lib/gdb/command/rpm-suggestions.py
+++ b/gdb/python/lib/gdb/command/rpm-suggestions.py
@@ -28,6 +28,8 @@ __missing_rpms = {}
# the prompt is shown.
__suggest_rpms = {}
@@ -33,6 +33,8 @@ else:
# the prompt is shown.
__suggest_rpms = {}
+__package_to_debug_package = {}
+ __package_to_debug_package = {}
+
# Lookup RPMs that might provide the debug information for FILENAME,
# which is a string containing the path to an object file GDB could
@@ -43,6 +45,7 @@ def find_suggestions(filename):
for h in mi:
# Build the debuginfo package name.
obj = h.format("%{name}-debuginfo-%{version}-%{release}.%{arch}")
+ debug_rpm_name = str(obj)
# Lookup RPMs that might provide the debug information for FILENAME,
# which is a string containing the path to an object file GDB could
@@ -48,6 +50,7 @@ else:
for h in mi:
# Build the debuginfo package name.
obj = h.format("%{name}-debuginfo-%{version}-%{release}.%{arch}")
+ debug_rpm_name = str(obj)
# Check to see if the package is installed.
mi2 = ts.dbMatch(rpm.RPMDBI_LABEL, str(obj))
@@ -52,6 +55,7 @@ def find_suggestions(filename):
# Now build the name of the package FILENAME came from.
obj = h.format("%{name}-%{version}-%{release}.%{arch}")
rpm_name = str(obj)
+ __package_to_debug_package[rpm_name] = debug_rpm_name
if not rpm_name in __missing_rpms:
__suggest_rpms[rpm_name] = True
__missing_rpms[rpm_name] = True
@@ -83,10 +87,12 @@ class RPMSuggestionHandler(gdb.missing_debug.MissingDebugHandler):
# suggests this to the user.
def before_prompt():
global __suggest_rpms
+ global __package_to_debug_package
# Check to see if the package is installed.
mi2 = ts.dbMatch(rpm.RPMDBI_LABEL, str(obj))
@@ -57,6 +60,7 @@ else:
# Now build the name of the package FILENAME came from.
obj = h.format("%{name}-%{version}-%{release}.%{arch}")
rpm_name = str(obj)
+ __package_to_debug_package[rpm_name] = debug_rpm_name
if not rpm_name in __missing_rpms:
__suggest_rpms[rpm_name] = True
__missing_rpms[rpm_name] = True
@@ -88,10 +92,12 @@ else:
# suggests this to the user.
def before_prompt():
global __suggest_rpms
+ global __package_to_debug_package
if len(__suggest_rpms) > 0:
for p in __suggest_rpms.keys():
- print("Missing debuginfo, try: dnf debuginfo-install " + p)
+ dp = __package_to_debug_package[p]
+ print("Missing separate debuginfos, use: zypper install " + dp)
__suggest_rpms = {}
if len(__suggest_rpms) > 0:
for p in __suggest_rpms.keys():
- print("Missing debuginfo, try: dnf debuginfo-install " + p)
+ dp = __package_to_debug_package[p]
+ print("Missing separate debuginfos, use: zypper install " + dp)
__suggest_rpms = {}

View File

@ -26,7 +26,7 @@ diff --git a/gdb/python/lib/gdb/command/rpm-suggestions.py b/gdb/python/lib/gdb/
new file mode 100644
--- /dev/null
+++ b/gdb/python/lib/gdb/command/rpm-suggestions.py
@@ -0,0 +1,111 @@
@@ -0,0 +1,116 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
@ -44,100 +44,105 @@ new file mode 100644
+
+import gdb
+import gdb.missing_debug
+import rpm
+try:
+ import rpm
+except ModuleNotFoundError:
+ print(
+ "Unable to load 'rpm' module. Please install the python3-rpm package."
+ )
+else:
+ # Track all the RPMs suggested during a single debug session so we
+ # don't suggest the same RPM twice. This is only cleared when the
+ # main executable is changed.
+ __missing_rpms = {}
+
+# Track all the RPMs suggested during a single debug session so we
+# don't suggest the same RPM twice. This is only cleared when the
+# main executable is changed.
+__missing_rpms = {}
+
+# Track any missing RPMs that have been discovered since the last time
+# the prompt was displayed. RPMs in here are also present in the
+# __MISSING_RPMS dictionary, but this dictionary is cleared each time
+# the prompt is shown.
+__suggest_rpms = {}
+ # Track any missing RPMs that have been discovered since the last time
+ # the prompt was displayed. RPMs in here are also present in the
+ # __MISSING_RPMS dictionary, but this dictionary is cleared each time
+ # the prompt is shown.
+ __suggest_rpms = {}
+
+
+# Lookup RPMs that might provide the debug information for FILENAME,
+# which is a string containing the path to an object file GDB could
+# not find any debug information for.
+#
+# If a possible RPM is found then this is added to the globals
+# __MISSING_RPMS and __SUGGEST_RPMS, which are used elsewhere in this
+# script.
+def find_suggestions(filename):
+ ts = rpm.TransactionSet()
+ # Lookup RPMs that might provide the debug information for FILENAME,
+ # which is a string containing the path to an object file GDB could
+ # not find any debug information for.
+ #
+ # If a possible RPM is found then this is added to the globals
+ # __MISSING_RPMS and __SUGGEST_RPMS, which are used elsewhere in this
+ # script.
+ def find_suggestions(filename):
+ ts = rpm.TransactionSet()
+
+ mi = ts.dbMatch(rpm.RPMDBI_BASENAMES, filename)
+ for h in mi:
+ # Build the debuginfo package name.
+ obj = h.format("%{name}-debuginfo-%{version}-%{release}.%{arch}")
+ mi = ts.dbMatch(rpm.RPMDBI_BASENAMES, filename)
+ for h in mi:
+ # Build the debuginfo package name.
+ obj = h.format("%{name}-debuginfo-%{version}-%{release}.%{arch}")
+
+ # Check to see if the package is installed.
+ mi2 = ts.dbMatch(rpm.RPMDBI_LABEL, str(obj))
+ if len(mi2) > 0:
+ continue
+ # Check to see if the package is installed.
+ mi2 = ts.dbMatch(rpm.RPMDBI_LABEL, str(obj))
+ if len(mi2) > 0:
+ continue
+
+ # Now build the name of the package FILENAME came from.
+ obj = h.format("%{name}-%{version}-%{release}.%{arch}")
+ rpm_name = str(obj)
+ if not rpm_name in __missing_rpms:
+ __suggest_rpms[rpm_name] = True
+ __missing_rpms[rpm_name] = True
+ # Now build the name of the package FILENAME came from.
+ obj = h.format("%{name}-%{version}-%{release}.%{arch}")
+ rpm_name = str(obj)
+ if not rpm_name in __missing_rpms:
+ __suggest_rpms[rpm_name] = True
+ __missing_rpms[rpm_name] = True
+
+
+# A missing debug handler class. Just forwards the name of the
+# objfile for which we are missing debug information to
+# find_suggestions.
+class RPMSuggestionHandler(gdb.missing_debug.MissingDebugHandler):
+ def __init__(self):
+ super().__init__("rpm-suggestions")
+ # A missing debug handler class. Just forwards the name of the
+ # objfile for which we are missing debug information to
+ # find_suggestions.
+ class RPMSuggestionHandler(gdb.missing_debug.MissingDebugHandler):
+ def __init__(self):
+ super().__init__("rpm-suggestions")
+
+ def __call__(self, objfile):
+ # Traditionally the 'build-id-verbose' parameter is what
+ # controlled all RPM suggestion. Maybe once all the RPM
+ # suggestion is performed via Python extensions then we might
+ # consider renaming this parameter to something else, but for
+ # now, for backward compatibility, I've retained this name.
+ if gdb.parameter("build-id-verbose") > 0:
+ find_suggestions(objfile.filename)
+ return False
+ return None
+ def __call__(self, objfile):
+ # Traditionally the 'build-id-verbose' parameter is what
+ # controlled all RPM suggestion. Maybe once all the RPM
+ # suggestion is performed via Python extensions then we might
+ # consider renaming this parameter to something else, but for
+ # now, for backward compatibility, I've retained this name.
+ if gdb.parameter("build-id-verbose") > 0:
+ find_suggestions(objfile.filename)
+ return False
+ return None
+
+
+# Called before GDB displays its prompt. If the global __SUGGEST_RPMS
+# dictionary is not empty, then this hook prints treats the keys of
+# this dictionary as strings which are the names of RPMs. This hook
+# formats each RPM name into a suggested debuginfo-install command and
+# suggests this to the user.
+def before_prompt():
+ global __suggest_rpms
+ # Called before GDB displays its prompt. If the global __SUGGEST_RPMS
+ # dictionary is not empty, then this hook prints treats the keys of
+ # this dictionary as strings which are the names of RPMs. This hook
+ # formats each RPM name into a suggested debuginfo-install command and
+ # suggests this to the user.
+ def before_prompt():
+ global __suggest_rpms
+
+ if len(__suggest_rpms) > 0:
+ for p in __suggest_rpms.keys():
+ print("Missing debuginfo, try: dnf debuginfo-install " + p)
+ __suggest_rpms = {}
+ if len(__suggest_rpms) > 0:
+ for p in __suggest_rpms.keys():
+ print("Missing debuginfo, try: dnf debuginfo-install " + p)
+ __suggest_rpms = {}
+
+
+# Called when the executable within a progrm space is changed. Clear
+# the lists of RPM suggestions. We only clear the previous suggestion
+# list when the executable really changes. If the user simply
+# recompiles the executable, then we don't both clearing this list.
+def executable_changed_handler(event):
+ global __missing_rpms
+ global __suggest_rpms
+ # Called when the executable within a progrm space is changed. Clear
+ # the lists of RPM suggestions. We only clear the previous suggestion
+ # list when the executable really changes. If the user simply
+ # recompiles the executable, then we don't both clearing this list.
+ def executable_changed_handler(event):
+ global __missing_rpms
+ global __suggest_rpms
+
+ if not event.reload:
+ __missing_rpms = {}
+ __suggest_rpms = {}
+ if not event.reload:
+ __missing_rpms = {}
+ __suggest_rpms = {}
+
+
+# Attach to the required GDB events.
+gdb.events.executable_changed.connect(executable_changed_handler)
+gdb.events.before_prompt.connect(before_prompt)
+ # Attach to the required GDB events.
+ gdb.events.executable_changed.connect(executable_changed_handler)
+ gdb.events.before_prompt.connect(before_prompt)
+
+# Register the missing debug handler with GDB.
+gdb.missing_debug.register_handler(None, RPMSuggestionHandler())
+ # Register the missing debug handler with GDB.
+ gdb.missing_debug.register_handler(None, RPMSuggestionHandler())
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.py b/gdb/testsuite/gdb.python/py-missing-debug.py
--- a/gdb/testsuite/gdb.python/py-missing-debug.py
+++ b/gdb/testsuite/gdb.python/py-missing-debug.py

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Jan 24 15:00:56 UTC 2025 - Tom de Vries <tdevries@suse.com>
- Update to fedora rawhide @ 1672291.
- Patches updated:
* gdb-6.6-buildid-locate-rpm-suse.patch
* gdb-add-rpm-suggestion-script.patch
-------------------------------------------------------------------
Fri Jan 24 13:37:51 UTC 2025 - Tom de Vries <tdevries@suse.com>