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

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