From: Waldemar Kozaczuk <[email protected]>
Committer: Waldemar Kozaczuk <[email protected]>
Branch: master

scripts: tweak loader.py to load libstdc++.so.*-gdb.py on Ubuntu 22.04

On newest version of Ubuntu, the location of the python script 
libstdc++.so.*-gdb.py
has moved to a subdirectory under /usr/share/gcc/python. This patch
tweaks the relevant logic to try this new place if the /usr/share/gcc-*/python
does not work.

Signed-off-by: Waldemar Kozaczuk <[email protected]>

---
diff --git a/scripts/loader.py b/scripts/loader.py
--- a/scripts/loader.py
+++ b/scripts/loader.py
@@ -1191,24 +1191,18 @@ def setup_libstdcxx():
     # "libstdc++.so.6.0.20" shared object is loaded into the debugger.
     # But because OSv is statically linked, we miss that auto-loading, so we
     #  need to look for, and run, this script explicitly.
-    sys.path += [glob('/usr/share/gcc-*/python')[0]]
+    gcc_python_dirs = glob('/usr/share/gcc-*/python')
+    if len(gcc_python_dirs) == 0: #If the above does not work try different 
place
+        gcc_python_dirs = glob('/usr/share/gcc/python')
+    if len(gcc_python_dirs) == 0:
+       print("!!! Could not locate the libstdc++.so.6.0.20-gdb.py")
+       return
+    sys.path += [gcc_python_dirs[0]]
     for base, dirnames, filenames in os.walk(gdb.PYTHONDIR + '/../auto-load'):
         for filename in fnmatch.filter(filenames, 'libstdc++.so.*-gdb.py'):
             script = os.path.join(base, filename)
             exec(compile(open(script).read(), script, 'exec'))
             return
-    # The following commented code is similar, but takes the python script
-    # from external/ instead of the one installed on the system. This might
-    # be useful if "make build_env=external" was used. However, there's a
-    # snag - the Python script we have in external/ might not be compatible
-    # with the version of Python installed on the system (there's right now
-    # a transition between Python 2 and Python 3 making things difficult).
-    #gcc = external + '/gcc.bin'
-    #sys.path += [gcc + '/usr/share/gdb/auto-load/usr/lib64',
-    #             glob(gcc + '/usr/share/gcc-*/python')[0],
-    #             ]
-    #main = glob(gcc + 
'/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.*.py')[0]
-    #exec(compile(open(main).read(), main, 'exec'))
 
 def sig_to_string(sig):
     '''Convert a tracepoing signature to a string'''

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/0000000000000be6ef05deeb41d0%40google.com.

Reply via email to