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

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