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

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