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

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