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

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