Blame SOURCES/gdb-rhbz1325795-framefilters-test.patch

0b42f8
--- /dev/null	2016-04-19 22:52:19.405224269 +0200
0b42f8
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-thread.exp	2016-04-19 23:22:10.655271756 +0200
0b42f8
@@ -0,0 +1,54 @@
0b42f8
+# Copyright (C) 2016 Free Software Foundation, Inc.
0b42f8
+
0b42f8
+# This program is free software; you can redistribute it and/or modify
0b42f8
+# it under the terms of the GNU General Public License as published by
0b42f8
+# the Free Software Foundation; either version 3 of the License, or
0b42f8
+# (at your option) any later version.
0b42f8
+#
0b42f8
+# This program is distributed in the hope that it will be useful,
0b42f8
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0b42f8
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0b42f8
+# GNU General Public License for more details.
0b42f8
+#
0b42f8
+# You should have received a copy of the GNU General Public License
0b42f8
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
0b42f8
+
0b42f8
+load_lib gdb-python.exp
0b42f8
+
0b42f8
+standard_testfile
0b42f8
+
0b42f8
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug pthreads}]} {
0b42f8
+    return -1
0b42f8
+}
0b42f8
+
0b42f8
+# Skip all tests if Python scripting is not enabled.
0b42f8
+if { [skip_python_tests] } { continue }
0b42f8
+
0b42f8
+if ![runto_main] then {
0b42f8
+    return
0b42f8
+}
0b42f8
+gdb_test_no_output "set python print-stack full" \
0b42f8
+    "Set python print-stack to full"
0b42f8
+
0b42f8
+# Load global frame-filters
0b42f8
+set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
0b42f8
+gdb_test_no_output "python execfile ('${remote_python_file}')" \
0b42f8
+    "Load python file"
0b42f8
+
0b42f8
+gdb_breakpoint [gdb_get_line_number "Backtrace end breakpoint"]
0b42f8
+gdb_continue_to_breakpoint "Backtrace end breakpoint"
0b42f8
+
0b42f8
+# #2  0x00007ffff75f228d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113^M
0b42f8
+gdb_test "bt no-filters" " in (\\.?_*clone|thread_start) \[^\r\n\]*" "bt no-filters"
0b42f8
+
0b42f8
+# #2  0x00007ffff75f228d in 941595343737041 () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113^M
0b42f8
+# vs.
0b42f8
+# #2  0x00007ffff75f228d in 941595343737041Traceback (most recent call last):
0b42f8
+#   File "/home/jkratoch/redhat/rhel/gdb/rhel-7.3/gdb-7.6.1/gdb/testsuite/../data-directory/python/gdb/FrameDecorator.py", line 145, in frame_args
0b42f8
+#     return self._base.frame_args()
0b42f8
+#   File "/home/jkratoch/redhat/rhel/gdb/rhel-7.3/gdb-7.6.1/gdb/testsuite/../data-directory/python/gdb/FrameDecorator.py", line 152, in frame_args
0b42f8
+#     return args.fetch_frame_args()
0b42f8
+#   File "/home/jkratoch/redhat/rhel/gdb/rhel-7.3/gdb-7.6.1/gdb/testsuite/../data-directory/python/gdb/FrameDecorator.py", line 276, in fetch_frame_args
0b42f8
+#     block = self.frame.block()
0b42f8
+# RuntimeError: Cannot locate object file for block.
0b42f8
+gdb_test "bt" " in \[0-9\]+ \[^\r\n\]*" "bt with filters"
0b42f8
--- /dev/null	2016-04-19 22:52:19.405224269 +0200
0b42f8
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-thread.c	2016-04-18 22:44:07.096613437 +0200
0b42f8
@@ -0,0 +1,39 @@
0b42f8
+/* This testcase is part of GDB, the GNU debugger.
0b42f8
+
0b42f8
+   Copyright 2016 Free Software Foundation, Inc.
0b42f8
+
0b42f8
+   This program is free software; you can redistribute it and/or modify
0b42f8
+   it under the terms of the GNU General Public License as published by
0b42f8
+   the Free Software Foundation; either version 3 of the License, or
0b42f8
+   (at your option) any later version.
0b42f8
+
0b42f8
+   This program is distributed in the hope that it will be useful,
0b42f8
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
0b42f8
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0b42f8
+   GNU General Public License for more details.
0b42f8
+
0b42f8
+   You should have received a copy of the GNU General Public License
0b42f8
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
0b42f8
+
0b42f8
+#include <pthread.h>
0b42f8
+#include <assert.h>
0b42f8
+
0b42f8
+static void *
0b42f8
+start (void *arg)
0b42f8
+{
0b42f8
+  return; /* Backtrace end breakpoint */
0b42f8
+}
0b42f8
+
0b42f8
+int
0b42f8
+main (void)
0b42f8
+{
0b42f8
+  pthread_t thread1;
0b42f8
+  int i;
0b42f8
+
0b42f8
+  i = pthread_create (&thread1, NULL, start, NULL);
0b42f8
+  assert (i == 0);
0b42f8
+  i = pthread_join (thread1, NULL);
0b42f8
+  assert (i == 0);
0b42f8
+
0b42f8
+  return 0;
0b42f8
+}
0b42f8
--- /dev/null	2016-04-19 22:52:19.405224269 +0200
0b42f8
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-thread.py	2016-04-19 23:14:03.273994063 +0200
0b42f8
@@ -0,0 +1,56 @@
0b42f8
+# Copyright (C) 2016 Free Software Foundation, Inc.
0b42f8
+
0b42f8
+# This program is free software; you can redistribute it and/or modify
0b42f8
+# it under the terms of the GNU General Public License as published by
0b42f8
+# the Free Software Foundation; either version 3 of the License, or
0b42f8
+# (at your option) any later version.
0b42f8
+#
0b42f8
+# This program is distributed in the hope that it will be useful,
0b42f8
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0b42f8
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0b42f8
+# GNU General Public License for more details.
0b42f8
+#
0b42f8
+# You should have received a copy of the GNU General Public License
0b42f8
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
0b42f8
+
0b42f8
+# This file is part of the GDB testsuite.  It tests Python-based
0b42f8
+# frame-filters.
0b42f8
+
0b42f8
+# This test is specifically crafted for RH BZ 1197665.
0b42f8
+
0b42f8
+import gdb
0b42f8
+import itertools
0b42f8
+from gdb.FrameDecorator import FrameDecorator
0b42f8
+import copy
0b42f8
+
0b42f8
+class Reverse_Function (FrameDecorator):
0b42f8
+
0b42f8
+    def __init__(self, fobj):
0b42f8
+        super(Reverse_Function, self).__init__(fobj)
0b42f8
+        self.fobj = fobj
0b42f8
+
0b42f8
+    def function (self):
0b42f8
+        # This function call should not fail.
0b42f8
+        gdb.target_charset ()
0b42f8
+
0b42f8
+        fname = str (self.fobj.function())
0b42f8
+        if (fname == None or fname == ""):
0b42f8
+            return None
0b42f8
+        else:
0b42f8
+            fname = fname[::-1]
0b42f8
+        return fname
0b42f8
+
0b42f8
+class FrameFilter ():
0b42f8
+
0b42f8
+    def __init__ (self):
0b42f8
+        self.name = "Reverse"
0b42f8
+        self.priority = 100
0b42f8
+        self.enabled = True
0b42f8
+        gdb.frame_filters [self.name] = self
0b42f8
+
0b42f8
+    def filter (self, frame_iter):
0b42f8
+        frame_iter = itertools.imap (Reverse_Function,
0b42f8
+                                     frame_iter)
0b42f8
+        return frame_iter
0b42f8
+
0b42f8
+FrameFilter()