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

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