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

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