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

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