[gdb/f14] Register all available PythonGDB commands (BZ 752095). Backport fix for crash in cp_scan_for_anonymo

Jan Kratochvil jankratochvil at fedoraproject.org
Thu Nov 10 01:45:54 UTC 2011


commit d44fa831fe885129a094e719a036b5536ed47805
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date:   Thu Nov 10 02:45:45 2011 +0100

    Register all available PythonGDB commands (BZ 752095).
    Backport fix for crash in cp_scan_for_anonymous_namespace
    (Aleksandar Ristovski, BZ 750341).

 gdb-anon-namespace-crash.patch |   79 +++++++++++++++++++++++++
 gdb-python-load-commands.patch |  123 ++++++++++++++++++++++++++++++++++++++++
 gdb.spec                       |   16 +++++-
 3 files changed, 217 insertions(+), 1 deletions(-)
---
diff --git a/gdb-anon-namespace-crash.patch b/gdb-anon-namespace-crash.patch
new file mode 100644
index 0000000..473f3bf
--- /dev/null
+++ b/gdb-anon-namespace-crash.patch
@@ -0,0 +1,79 @@
+Fix for https://bugzilla.redhat.com/show_bug.cgi?id=750341
+http://sourceware.org/ml/gdb-patches/2011-10/msg00570.html
+
+
+http://sourceware.org/ml/gdb-cvs/2011-10/msg00154.html
+
+### src/gdb/ChangeLog	2011/10/20 13:34:13	1.13446
+### src/gdb/ChangeLog	2011/10/20 20:06:11	1.13447
+## -1,3 +1,15 @@
++2011-10-20  Aleksandar Ristovski  <aristovski at qnx.com>
++
++	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function
++	arguments by adding OBJFILE.  Instead of getting objfile from
++	symbol's symtab, use new argument OBJFILE.
++	* cp-support.h (cp_scan_for_anonymous_namespaces): Changed function
++	arguments by adding OBJFILE.
++	* gdb/dwarf2read.c (new_symbol_full): Change call to
++	cp_scan_for_anonymous_namespaces to match new signature.
++	* gdb/stabsread.c (define_symbol): Change call to
++	cp_scan_for_anonymous_namespaces to match new signature.
++
+ 2011-10-20  Phil Muldoon  <pmuldoon at redhat.com>
+ 
+         PR python/13308
+--- src/gdb/cp-namespace.c	2011/06/29 22:05:15	1.54
++++ src/gdb/cp-namespace.c	2011/10/20 20:06:13	1.55
+@@ -75,7 +75,8 @@ static void maintenance_cplus_namespace 
+ #define ANONYMOUS_NAMESPACE_LEN 21
+ 
+ void
+-cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
++cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
++				  struct objfile *const objfile)
+ {
+   if (SYMBOL_DEMANGLED_NAME (symbol) != NULL)
+     {
+@@ -114,7 +115,7 @@ cp_scan_for_anonymous_namespaces (const 
+ 		 namespace given by the previous component if there is
+ 		 one, or to the global namespace if there isn't.  */
+ 	      cp_add_using_directive (dest, src, NULL, NULL,
+-	                              &SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack);
++	                              &objfile->objfile_obstack);
+ 	    }
+ 	  /* The "+ 2" is for the "::".  */
+ 	  previous_component = next_component + 2;
+--- src/gdb/cp-support.h	2011/08/18 16:17:38	1.45
++++ src/gdb/cp-support.h	2011/10/20 20:06:13	1.46
+@@ -197,7 +197,8 @@
+ 				const char *processing_current_prefix,
+ 				int processing_has_namespace_info);
+ 
+-extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol);
++extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
++					      struct objfile *objfile);
+ 
+ extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
+ 						 const struct block *block,
+--- src/gdb/dwarf2read.c	2011/10/20 01:11:34	1.576
++++ src/gdb/dwarf2read.c	2011/10/20 20:06:13	1.577
+@@ -11992,7 +11992,7 @@
+ 	 namespaces based on the demangled name.  */
+       if (!processing_has_namespace_info
+ 	  && cu->language == language_cplus)
+-	cp_scan_for_anonymous_namespaces (sym);
++	cp_scan_for_anonymous_namespaces (sym, objfile);
+     }
+   return (sym);
+ }
+--- src/gdb/stabsread.c	2011/05/18 16:30:36	1.138
++++ src/gdb/stabsread.c	2011/10/20 20:06:14	1.139
+@@ -712,7 +712,7 @@ define_symbol (CORE_ADDR valu, char *str
+ 	  memcpy (name, string, p - string);
+ 	  name[p - string] = '\0';
+ 	  new_name = cp_canonicalize_string (name);
+-	  cp_scan_for_anonymous_namespaces (sym);
++	  cp_scan_for_anonymous_namespaces (sym, objfile);
+ 	}
+       if (new_name != NULL)
+ 	{
diff --git a/gdb-python-load-commands.patch b/gdb-python-load-commands.patch
new file mode 100644
index 0000000..9077310
--- /dev/null
+++ b/gdb-python-load-commands.patch
@@ -0,0 +1,123 @@
+commit 6e962026419305ae6c540eb01a735cf7c2685c20
+Author: pmuldoon <pmuldoon>
+Date:   Tue Aug 9 12:45:39 2011 +0000
+
+    2011-08-09  Phil Muldoon  <pmuldoon at redhat.com>
+    
+    	* python/lib/gdb/__init__.py: Auto-load files in command and
+    	function directories.
+    	* python/python.c (finish_python_initialization): Use
+    	os.path.join.
+    	* python/lib/gdb/command/pretty_printers.py: Self register
+    	command.
+    	* NEWS: Document auto-loading.
+    
+    2011-08-09  Phil Muldoon  <pmuldoon at redhat.com>
+    
+    	* gdb.texinfo (Python): Document command and function
+    	auto-loading.
+
+[ Backport for F-14.
+  Drop python/python.c changes.
+  Make explicit `import os'.
+  Ignore: register_pretty_printer_commands()
+    - Required for
+	[RFA, doc RFA]: New printing module and info/disable/enable commands
+	http://sourceware.org/ml/gdb-patches/2010-11/msg00001.html
+      	87c4cdd048cfaef8db45587bc58f06df97e992b9
+      which is not present in F-14.
+]
+
+### a/gdb/ChangeLog
+### b/gdb/ChangeLog
+## -1,3 +1,13 @@
++2011-08-09  Phil Muldoon  <pmuldoon at redhat.com>
++
++	* python/lib/gdb/__init__.py: Auto-load files in command and
++	function directories.
++	* python/python.c (finish_python_initialization): Use
++	os.path.join.
++	* python/lib/gdb/command/pretty_printers.py: Self register
++	command.
++	* NEWS: Document auto-loading.
++
+ 2011-08-08  Jan Kratochvil  <jan.kratochvil at redhat.com>
+ 
+ 	* dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_STACK>
+### a/gdb/doc/ChangeLog
+### b/gdb/doc/ChangeLog
+## -1,3 +1,8 @@
++2011-08-09  Phil Muldoon  <pmuldoon at redhat.com>
++
++	* gdb.texinfo (Python): Document command and function
++	auto-loading.
++
+ 2011-07-26  Jan Kratochvil  <jan.kratochvil at redhat.com>
+ 	    Eli Zaretskii  <eliz at gnu.org>
+ 
+--- ./gdb/NEWS	2011-11-10 01:05:53.963411574 +0100
++++ ./gdb/NEWS	2011-11-10 01:09:26.457874127 +0100
+@@ -1,6 +1,13 @@
+ 		What has changed in GDB?
+ 	     (Organized release by release)
+ 
++*** Changes after GDB 7.2
++
++** Python commands and convenience-functions located in
++  'data-directory'/python/gdb/command and
++  'data-directory'/python/gdb/function are now automatically loaded
++   on GDB start-up.
++
+ *** Changes since GDB 7.2
+ 
+ * GDB now supports thread debugging of core dumps on GNU/Linux.
+--- ./gdb/doc/gdb.texinfo	2011-11-10 01:05:53.811411957 +0100
++++ ./gdb/doc/gdb.texinfo	2011-11-10 01:06:47.029277357 +0100
+@@ -20389,6 +20389,12 @@ the data directory as determined at @val
+ is automatically added to the Python Search Path in order to allow
+ the Python interpreter to locate all scripts installed at this location.
+ 
++Additionally, @value{GDBN} commands and convenience functions which
++are written in Python and are located in the
++ at file{@var{data-directory}/python/gdb/command} or
++ at file{@var{data-directory}/python/gdb/function} directories are
++automatically imported when @value{GDBN} starts.
++
+ @menu
+ * Python Commands::             Accessing Python from @value{GDBN}.
+ * Python API::                  Accessing @value{GDBN} from Python.
+--- ./gdb/python/lib/gdb/__init__.py	2011-11-10 01:05:53.528412675 +0100
++++ ./gdb/python/lib/gdb/__init__.py	2011-11-10 01:08:24.443030975 +0100
+@@ -15,5 +15,30 @@
+ # You should have received a copy of the GNU General Public License
+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ 
+-# Load the require command by default.
+-import gdb.command.require
++import traceback
++import os
++
++# Auto-load all functions/commands.
++
++# Modules to auto-load, and the paths where those modules exist.
++
++module_dict = {
++  'gdb.function': os.path.join(gdb.PYTHONDIR, 'gdb', 'function'),
++  'gdb.command': os.path.join(gdb.PYTHONDIR, 'gdb', 'command')
++}
++
++# Iterate the dictionary, collating the Python files in each module
++# path.  Construct the module name, and import.
++
++for module, location in module_dict.iteritems():
++  if os.path.exists(location):
++     py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py',
++                       os.listdir(location))
++
++     for py_file in py_files:
++       # Construct from foo.py, gdb.module.foo
++       py_file = module + '.' + py_file[:-3]
++       try:
++         exec('import ' + py_file)
++       except:
++         print >> sys.stderr, traceback.format_exc()
diff --git a/gdb.spec b/gdb.spec
index 7fa9175..8827dca 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -27,7 +27,7 @@ Version: 7.2
 
 # The release always contains a leading reserved number, start it at 1.
 # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 51%{?_with_upstream:.upstream}%{dist}
+Release: 52%{?_with_upstream:.upstream}%{dist}
 
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
 Group: Development/Debuggers
@@ -750,6 +750,13 @@ Patch575: gdb-vla-gc-disable.patch
 # [ifunc] Fix ppc64 function descriptors compatibility.
 Patch578: gdb-ifunc-ppc64.patch
 
+# Register all available PythonGDB commands (BZ 752095).
+Patch635: gdb-python-load-commands.patch
+
+# Backport fix for crash in cp_scan_for_anonymous_namespace
+# (Aleksandar Ristovski, BZ 750341).
+Patch636: gdb-anon-namespace-crash.patch
+
 BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
 Requires: readline%{?_isa}
 BuildRequires: readline-devel%{?_isa}
@@ -1071,6 +1078,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
 %patch574 -p1
 %patch575 -p1
 %patch578 -p1
+%patch635 -p1
+%patch636 -p1
 
 %patch390 -p1
 %patch393 -p1
@@ -1468,6 +1477,11 @@ fi
 %endif
 
 %changelog
+* Thu Nov 10 2011 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-52.fc14
+- Register all available PythonGDB commands (BZ 752095).
+- Backport fix for crash in cp_scan_for_anonymous_namespace
+  (Aleksandar Ristovski, BZ 750341).
+
 * Tue Mar 29 2011 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-51.fc14
 - Fix occasional crash on `print errno' with no -pthread and no -g3 (BZ 690908).
 


More information about the scm-commits mailing list