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

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