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

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