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