[gdb/f16] Python command/function auto-loading (Phil Muldoon, BZ 730976). Work around PR libc/13097 "linux-vds

Jan Kratochvil jankratochvil at fedoraproject.org
Tue Aug 16 14:21:23 UTC 2011


commit c6934442a96f5e62d0ab415bec67289c05d1dee5
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date:   Tue Aug 16 16:21:06 2011 +0200

    Python command/function auto-loading (Phil Muldoon, BZ 730976).
    Work around PR libc/13097 "linux-vdso.so.1" warning message.
    [TUI] Fix stepi on stripped code.
    Add BuildRequires: systemtap-sdt-devel for archer-sergiodj-stap-patch-split.

 gdb-glibc-vdso-workaround.patch |   30 ++++++++++
 gdb-tui-strip-stepi.patch       |   73 +++++++++++++++++++++++
 gdb-upstream.patch              |  121 +++++++++++++++++++++++++++++++++++++++
 gdb.spec                        |   18 ++++++-
 4 files changed, 241 insertions(+), 1 deletions(-)
---
diff --git a/gdb-glibc-vdso-workaround.patch b/gdb-glibc-vdso-workaround.patch
new file mode 100644
index 0000000..48646d7
--- /dev/null
+++ b/gdb-glibc-vdso-workaround.patch
@@ -0,0 +1,30 @@
+http://sourceware.org/ml/gdb-patches/2011-08/msg00331.html
+Subject: [RFC] Work around PR libc/13097 "linux-vdso.so.1" #2
+
+Hi,
+
+missed the x86_64-m32 case:
+
+gdb/
+2011-08-16  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	Work around PR libc/13097.
+	* solib.c (update_solib_list): Ignore "linux-vdso.so.1".
+
+--- a/gdb/solib.c
++++ b/gdb/solib.c
+@@ -783,8 +783,11 @@ update_solib_list (int from_tty, struct target_ops *target)
+ 
+ 	  TRY_CATCH (e, RETURN_MASK_ERROR)
+ 	    {
+-	      /* Fill in the rest of the `struct so_list' node.  */
+-	      if (!solib_map_sections (i))
++	      /* Fill in the rest of the `struct so_list' node.
++		 Work around PR libc/13097.  */
++	      if (!solib_map_sections (i)
++		  && strcmp (i->so_original_name, "linux-vdso.so.1") != 0
++		  && strcmp (i->so_original_name, "linux-gate.so.1") != 0)
+ 		{
+ 		  not_found++;
+ 		  if (not_found_filename == NULL)
+
diff --git a/gdb-tui-strip-stepi.patch b/gdb-tui-strip-stepi.patch
new file mode 100644
index 0000000..c4bdcb0
--- /dev/null
+++ b/gdb-tui-strip-stepi.patch
@@ -0,0 +1,73 @@
+http://sourceware.org/ml/gdb-patches/2011-08/msg00283.html
+Subject: [patch] TUI: Permit stepi on stripped code
+
+Hi,
+
+nick <cinolt> on #gdb at freenode complained one cannot stepi on stripped binary.
+
+echo -e '#include<unistd.h>\nint main(void){return alarm(0);}'|gcc -Wall -s -x c -;./gdbtui ./a.out -nx -ex 'layout asm' -ex 'b alarm' -ex r -ex fini
+will:
+	0x7ffff7ae25c0 <alarm>          mov    $0x25,%eax
+	-------------------------------------------------
+	(gdb) p/x $pc
+	$1 = 0x4004d2
+	(gdb) stepi
+	No function contains program counter for selected frame.
+	(gdb) p/x $pc
+	$2 = 0x4004d2
+
+That is the window still displays stale content, stepi does not work at all.
+
+#0  throw_verror (error=GENERIC_ERROR, fmt=0xe73d20 "No function contains program counter for selected frame.", ap=0x7fffdbd3b0a8) at exceptions.c:400
+#1  in error (string=0xe73d20 "No function contains program counter for selected frame.") at utils.c:780
+#2  in tui_show_frame_info (fi=0x3eca1e0) at ./tui/tui-stack.c:383
+#3  in tui_selected_frame_level_changed_hook (level=0) at ./tui/tui-hooks.c:218
+#4  in select_frame (fi=0x3eca1e0) at frame.c:1396
+#5  in restore_selected_frame (a_frame_id=..., frame_level=0) at thread.c:1049
+#6  in do_restore_current_thread_cleanup (arg=0x456dca0) at thread.c:1116
+#7  in do_my_cleanups (pmy_chain=0x1c865f0, old_chain=0x456de90) at utils.c:515
+#8  in do_cleanups (old_chain=0x456de90) at utils.c:497
+#9  in insert_breakpoint_locations () at breakpoint.c:2021
+#10 in insert_breakpoints () at breakpoint.c:1919
+#11 in proceed (addr=18446744073709551615, siggnal=TARGET_SIGNAL_DEFAULT, step=1) at infrun.c:2156
+#12 in step_once (skip_subroutines=0, single_inst=1, count=1, thread=-1) at infcmd.c:1068
+#13 in step_1 (skip_subroutines=0, single_inst=1, count_string=0x0) at infcmd.c:903
+#14 in stepi_command (count_string=0x0, from_tty=1) at infcmd.c:839
+
+With the fix stepi works and the window correctly displays:
+	0x4004d2        pop    %rbp                
+	-------------------------------------------------
+
+I haven't found any TUI testsuite.
+
+I will check it in (after regression testing(?)) in some time.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2011-08-14  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	Fix TUI stepi on code without symbols.
+	* tui/tui-stack.c (tui_show_frame_info): Remove error, set LOW for
+	current PC instead.
+
+--- a/gdb/tui/tui-stack.c
++++ b/gdb/tui/tui-stack.c
+@@ -380,8 +380,11 @@ tui_show_frame_info (struct frame_info *fi)
+ 	    {
+ 	      if (find_pc_partial_function (get_frame_pc (fi), (char **) NULL,
+ 					    &low, (CORE_ADDR) 0) == 0)
+-		error (_("No function contains program "
+-			 "counter for selected frame."));
++		{
++		  /* There is no symbol available for current PC.  There is no
++		     safe way how to "disassemble backwards".  */
++		  low = get_frame_pc (fi);
++		}
+ 	      else
+ 		low = tui_get_low_disassembly_address (get_frame_arch (fi),
+ 						       low, get_frame_pc (fi));
+
diff --git a/gdb-upstream.patch b/gdb-upstream.patch
index b380c2f..c1500cc 100644
--- a/gdb-upstream.patch
+++ b/gdb-upstream.patch
@@ -1215,3 +1215,124 @@ Date:   Tue Jul 26 14:28:23 2011 +0000
  # Ada (GNAT) tests.
  #
  # Simple test.
+
+
+
+http://sourceware.org/ml/gdb-cvs/2011-08/msg00047.html
+
+### src/gdb/ChangeLog	2011/08/08 21:41:12	1.13259
+### src/gdb/ChangeLog	2011/08/09 12:45:39	1.13260
+## -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>
+--- src/gdb/NEWS	2011/07/26 20:57:53	1.446
++++ src/gdb/NEWS	2011/08/09 12:45:39	1.447
+@@ -23,6 +23,11 @@
+   ** A prompt subsitution hook (prompt_hook) is now available to the
+      Python API.
+ 
++  ** 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.
++
+ * libthread-db-search-path now supports two special values: $sdir and $pdir.
+   $sdir specifies the default system locations of shared libraries.
+   $pdir specifies the directory where the libpthread used by the application
+### src/gdb/doc/ChangeLog	2011/07/26 16:59:23	1.1202
+### src/gdb/doc/ChangeLog	2011/08/09 12:45:39	1.1203
+## -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>
+ 
+--- src/gdb/doc/gdb.texinfo	2011/07/26 20:57:54	1.851
++++ src/gdb/doc/gdb.texinfo	2011/08/09 12:45:39	1.852
+@@ -20845,6 +20845,12 @@
+ 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.
+--- src/gdb/python/python.c	2011/07/22 09:22:50	1.68
++++ src/gdb/python/python.c	2011/08/09 12:45:40	1.69
+@@ -1302,13 +1302,13 @@
+   sys.path.insert (0, gdb.PYTHONDIR)\n\
+ \n\
+   # Tell python where to find submodules of gdb.\n\
+-  gdb.__path__ = [gdb.PYTHONDIR + '/gdb']\n\
++  gdb.__path__ = [os.path.join (gdb.PYTHONDIR, 'gdb')]\n\
+ \n\
+   # The gdb module is implemented in C rather than in Python.  As a result,\n\
+   # the associated __init.py__ script is not not executed by default when\n\
+   # the gdb module gets imported.  Execute that script manually if it\n\
+   # exists.\n\
+-  ipy = gdb.PYTHONDIR + '/gdb/__init__.py'\n\
++  ipy = os.path.join (gdb.PYTHONDIR, 'gdb', '__init__.py')\n\
+   if os.path.exists (ipy):\n\
+     execfile (ipy)\n\
+ \n\
+--- src/gdb/python/lib/gdb/__init__.py	2011/01/01 15:33:26	1.3
++++ src/gdb/python/lib/gdb/__init__.py	2011/08/09 12:45:40	1.4
+@@ -13,6 +13,29 @@
+ # You should have received a copy of the GNU General Public License
+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ 
+-import gdb.command.pretty_printers
++import traceback
+ 
+-gdb.command.pretty_printers.register_pretty_printer_commands()
++# 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()
+--- src/gdb/python/lib/gdb/command/pretty_printers.py	2011/01/01 15:33:27	1.4
++++ src/gdb/python/lib/gdb/command/pretty_printers.py	2011/08/09 12:45:40	1.5
+@@ -368,3 +368,5 @@
+     InfoPrettyPrinter()
+     EnablePrettyPrinter()
+     DisablePrettyPrinter()
++
++register_pretty_printer_commands()
diff --git a/gdb.spec b/gdb.spec
index 2c15a06..4a1f20f 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -27,7 +27,7 @@ Version: 7.3.50.20110722
 
 # 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: 5%{?_with_upstream:.upstream}%{?dist}
+Release: 6%{?_with_upstream:.upstream}%{?dist}
 
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
 Group: Development/Debuggers
@@ -537,6 +537,12 @@ Patch617: gdb-dlopen-skip_inline_frames-perf.patch
 Patch618: gdb-dlopen-stap-probe.patch
 Patch619: gdb-dlopen-stap-probe-test.patch
 
+# Work around PR libc/13097 "linux-vdso.so.1" warning message.
+Patch627: gdb-glibc-vdso-workaround.patch
+
+# [TUI] Fix stepi on stripped code.
+Patch628: gdb-tui-strip-stepi.patch
+
 BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
 # --without-system-readline
 # Requires: readline%{?_isa}
@@ -589,6 +595,8 @@ BuildRequires: texinfo-tex
 BuildRequires: sharutils dejagnu
 # gcc-objc++ is not covered by the GDB testsuite.
 BuildRequires: gcc gcc-c++ gcc-gfortran gcc-java gcc-objc
+# archer-sergiodj-stap-patch-split
+BuildRequires: systemtap-sdt-devel
 # Copied from prelink-0.4.2-3.fc13.
 %ifarch %{ix86} alpha sparc sparcv9 sparc64 s390 s390x x86_64 ppc ppc64
 # Prelink is broken on sparcv9/sparc64.
@@ -801,6 +809,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
 %patch617 -p1
 %patch618 -p1
 %patch619 -p1
+%patch627 -p1
+%patch628 -p1
 
 %patch393 -p1
 %patch335 -p1
@@ -1223,6 +1233,12 @@ fi
 %{_infodir}/gdb.info*
 
 %changelog
+* Tue Aug 16 2011 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.3.50.20110722-6.fc16
+- Python command/function auto-loading (Phil Muldoon, BZ 730976).
+- Work around PR libc/13097 "linux-vdso.so.1" warning message.
+- [TUI] Fix stepi on stripped code.
+- Add BuildRequires: systemtap-sdt-devel for archer-sergiodj-stap-patch-split.
+
 * Wed Aug 10 2011 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.3.50.20110722-5.fc16
 - Fix dlopen of libpthread.so, patched glibc required (Gary Benson, BZ 669432).
 


More information about the scm-commits mailing list