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

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