Blame SOURCES/gdb-rhbz1281351-python-unreadable-arg.patch

2c2fa1
commit c75bd3a23915c3122070a95e1974e323543ffbe4
2c2fa1
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
2c2fa1
Date:   Sun Sep 7 14:09:59 2014 +0200
2c2fa1
2c2fa1
    Fix crash on Python frame filters with unreadable arg
2c2fa1
    
2c2fa1
    https://bugzilla.redhat.com/show_bug.cgi?id=1126177
2c2fa1
    
2c2fa1
    ERROR: AddressSanitizer: SEGV on unknown address 0x000000000050 (pc 0x000000992bef sp 0x7ffff9039530 bp 0x7ffff9039540
2c2fa1
    T0)
2c2fa1
        #0 0x992bee in value_type .../gdb/value.c:925
2c2fa1
        #1 0x87c951 in py_print_single_arg python/py-framefilter.c:445
2c2fa1
        #2 0x87cfae in enumerate_args python/py-framefilter.c:596
2c2fa1
        #3 0x87e0b0 in py_print_args python/py-framefilter.c:968
2c2fa1
    
2c2fa1
    It crashes because frame_arg::val is documented it may contain NULL
2c2fa1
    (frame_arg::error is then non-NULL) but the code does not handle it.
2c2fa1
    
2c2fa1
    Another bug is that py_print_single_arg() calls goto out of its TRY_CATCH
2c2fa1
    which messes up GDB cleanup chain crashing GDB later.
2c2fa1
    
2c2fa1
    It is probably 7.7 regression (I have not verified it) due to the introduction
2c2fa1
    of Python frame filters.
2c2fa1
    
2c2fa1
    gdb/ChangeLog
2c2fa1
    
2c2fa1
    	PR python/17355
2c2fa1
    	* python/py-framefilter.c (py_print_single_arg): Handle NULL FA->VAL.
2c2fa1
    	Fix goto out of TRY_CATCH.
2c2fa1
    
2c2fa1
    gdb/testsuite/ChangeLog
2c2fa1
    
2c2fa1
    	PR python/17355
2c2fa1
    	* gdb.python/amd64-py-framefilter-invalidarg.S: New file.
2c2fa1
    	* gdb.python/py-framefilter-invalidarg-gdb.py.in: New file.
2c2fa1
    	* gdb.python/py-framefilter-invalidarg.exp: New file.
2c2fa1
    	* gdb.python/py-framefilter-invalidarg.py: New file.
2c2fa1
2c2fa1
### a/gdb/ChangeLog
2c2fa1
### b/gdb/ChangeLog
2c2fa1
## -1,3 +1,9 @@
2c2fa1
+2014-09-07  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
+
2c2fa1
+	PR python/17355
2c2fa1
+	* python/py-framefilter.c (py_print_single_arg): Handle NULL FA->VAL.
2c2fa1
+	Fix goto out of TRY_CATCH.
2c2fa1
+
2c2fa1
 2014-09-06  Doug Evans  <xdje42@gmail.com>
2c2fa1
 	    Tom Tromey  <tromey@redhat.com>
2c2fa1
 
2c2fa1
### a/gdb/testsuite/ChangeLog
2c2fa1
### b/gdb/testsuite/ChangeLog
2c2fa1
## -1,3 +1,11 @@
2c2fa1
+2014-09-07  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
+
2c2fa1
+	PR python/17355
2c2fa1
+	* gdb.python/amd64-py-framefilter-invalidarg.S: New file.
2c2fa1
+	* gdb.python/py-framefilter-invalidarg-gdb.py.in: New file.
2c2fa1
+	* gdb.python/py-framefilter-invalidarg.exp: New file.
2c2fa1
+	* gdb.python/py-framefilter-invalidarg.py: New file.
2c2fa1
+
2c2fa1
 2014-09-06  Doug Evans  <xdje42@gmail.com>
2c2fa1
 
2c2fa1
 	PR 15276
2c2fa1
Index: gdb-7.6.1/gdb/python/py-framefilter.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/python/py-framefilter.c	2015-11-27 18:06:21.901228682 +0100
2c2fa1
+++ gdb-7.6.1/gdb/python/py-framefilter.c	2015-11-27 18:06:22.445231731 +0100
2c2fa1
@@ -365,9 +365,12 @@
2c2fa1
 {
2c2fa1
   struct value *val;
2c2fa1
   volatile struct gdb_exception except;
2c2fa1
+  enum py_bt_status retval = PY_BT_OK;
2c2fa1
 
2c2fa1
   if (fa != NULL)
2c2fa1
     {
2c2fa1
+      if (fa->val == NULL && fa->error == NULL)
2c2fa1
+	return PY_BT_OK;
2c2fa1
       language = language_def (SYMBOL_LANGUAGE (fa->sym));
2c2fa1
       val = fa->val;
2c2fa1
     }
2c2fa1
@@ -433,16 +436,18 @@
2c2fa1
       /* For MI print the type, but only for simple values.  This seems
2c2fa1
 	 weird, but this is how MI choose to format the various output
2c2fa1
 	 types.  */
2c2fa1
-      if (args_type == MI_PRINT_SIMPLE_VALUES)
2c2fa1
+      if (args_type == MI_PRINT_SIMPLE_VALUES && val != NULL)
2c2fa1
 	{
2c2fa1
 	  if (py_print_type (out, val) == PY_BT_ERROR)
2c2fa1
 	    {
2c2fa1
+	      retval = PY_BT_ERROR;
2c2fa1
 	      do_cleanups (cleanups);
2c2fa1
-	      goto error;
2c2fa1
+	      continue;
2c2fa1
 	    }
2c2fa1
 	}
2c2fa1
 
2c2fa1
-      annotate_arg_value (value_type (val));
2c2fa1
+      if (val != NULL)
2c2fa1
+	annotate_arg_value (value_type (val));
2c2fa1
 
2c2fa1
       /* If the output is to the CLI, and the user option "set print
2c2fa1
 	 frame-arguments" is set to none, just output "...".  */
2c2fa1
@@ -454,27 +459,25 @@
2c2fa1
 	     for the case of MI_PRINT_NO_VALUES.  */
2c2fa1
 	  if (args_type != NO_VALUES)
2c2fa1
 	    {
2c2fa1
-	      if (py_print_value (out, val, opts, 0, args_type, language)
2c2fa1
-		  == PY_BT_ERROR)
2c2fa1
+	      if (val == NULL)
2c2fa1
 		{
2c2fa1
-		  do_cleanups (cleanups);
2c2fa1
-		  goto error;
2c2fa1
+		  gdb_assert (fa != NULL && fa->error != NULL);
2c2fa1
+		  ui_out_field_fmt (out, "value",
2c2fa1
+				    _("<error reading variable: %s>"),
2c2fa1
+				    fa->error);
2c2fa1
 		}
2c2fa1
+	      else if (py_print_value (out, val, opts, 0, args_type, language)
2c2fa1
+		       == PY_BT_ERROR)
2c2fa1
+		retval = PY_BT_ERROR;
2c2fa1
 	    }
2c2fa1
 	}
2c2fa1
 
2c2fa1
       do_cleanups (cleanups);
2c2fa1
     }
2c2fa1
   if (except.reason < 0)
2c2fa1
-    {
2c2fa1
-      gdbpy_convert_exception (except);
2c2fa1
-      goto error;
2c2fa1
-    }
2c2fa1
-
2c2fa1
-  return PY_BT_OK;
2c2fa1
+    gdbpy_convert_exception (except);
2c2fa1
 
2c2fa1
- error:
2c2fa1
-  return PY_BT_ERROR;
2c2fa1
+  return retval;
2c2fa1
 }
2c2fa1
 
2c2fa1
 /* Helper function to loop over frame arguments provided by the
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.python/amd64-py-framefilter-invalidarg.S
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.python/amd64-py-framefilter-invalidarg.S	2015-11-27 18:06:22.446231736 +0100
2c2fa1
@@ -0,0 +1,261 @@
2c2fa1
+/* This testcase is part of GDB, the GNU debugger.
2c2fa1
+
2c2fa1
+   Copyright 2014 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+   This program is free software; you can redistribute it and/or modify
2c2fa1
+   it under the terms of the GNU General Public License as published by
2c2fa1
+   the Free Software Foundation; either version 3 of the License, or
2c2fa1
+   (at your option) any later version.
2c2fa1
+
2c2fa1
+   This program is distributed in the hope that it will be useful,
2c2fa1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+   GNU General Public License for more details.
2c2fa1
+
2c2fa1
+   You should have received a copy of the GNU General Public License
2c2fa1
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2c2fa1
+
2c2fa1
+/* This file is compiled from a single line
2c2fa1
+   int main (int argc, char **argv) { return 0; }
2c2fa1
+   using -g -dA -S -O2 and patched as #if-ed below.  */
2c2fa1
+
2c2fa1
+	.file	"py-framefilter-invalidarg.c"
2c2fa1
+	.text
2c2fa1
+.Ltext0:
2c2fa1
+	.globl	main
2c2fa1
+	.type	main, @function
2c2fa1
+main:
2c2fa1
+.LFB0:
2c2fa1
+	.file 1 "py-framefilter-invalidarg.c"
2c2fa1
+	# py-framefilter-invalidarg.c:1
2c2fa1
+	.loc 1 1 0
2c2fa1
+	.cfi_startproc
2c2fa1
+# BLOCK 2 seq:0
2c2fa1
+# PRED: ENTRY (FALLTHRU)
2c2fa1
+	pushq	%rbp
2c2fa1
+	.cfi_def_cfa_offset 16
2c2fa1
+	.cfi_offset 6, -16
2c2fa1
+	movq	%rsp, %rbp
2c2fa1
+	.cfi_def_cfa_register 6
2c2fa1
+	movl	%edi, -4(%rbp)
2c2fa1
+	movq	%rsi, -16(%rbp)
2c2fa1
+	# py-framefilter-invalidarg.c:2
2c2fa1
+	.loc 1 2 0
2c2fa1
+	movl	$0, %eax
2c2fa1
+	# py-framefilter-invalidarg.c:3
2c2fa1
+	.loc 1 3 0
2c2fa1
+	popq	%rbp
2c2fa1
+	.cfi_def_cfa 7, 8
2c2fa1
+# SUCC: EXIT [100.0%] 
2c2fa1
+	ret
2c2fa1
+	.cfi_endproc
2c2fa1
+.LFE0:
2c2fa1
+	.size	main, .-main
2c2fa1
+.Letext0:
2c2fa1
+	.section	.debug_info,"",@progbits
2c2fa1
+.Ldebug_info0:
2c2fa1
+	.long	.Le - .Ls	# Length of Compilation Unit Info
2c2fa1
+.Ls:
2c2fa1
+	.value	0x4	# DWARF version number
2c2fa1
+	.long	.Ldebug_abbrev0	# Offset Into Abbrev. Section
2c2fa1
+	.byte	0x8	# Pointer Size (in bytes)
2c2fa1
+	.uleb128 0x1	# (DIE (0xb) DW_TAG_compile_unit)
2c2fa1
+	.long	.LASF3	# DW_AT_producer: "GNU C 4.9.1 20140813 (Red Hat 4.9.1-7) -mtune=generic -march=x86-64 -g"
2c2fa1
+	.byte	0x1	# DW_AT_language
2c2fa1
+	.long	.LASF4	# DW_AT_name: "py-framefilter-invalidarg.c"
2c2fa1
+	.long	.LASF5	# DW_AT_comp_dir: ""
2c2fa1
+	.quad	.Ltext0	# DW_AT_low_pc
2c2fa1
+	.quad	.Letext0-.Ltext0	# DW_AT_high_pc
2c2fa1
+	.long	.Ldebug_line0	# DW_AT_stmt_list
2c2fa1
+die2d:
2c2fa1
+	.uleb128 0x2	# (DIE (0x2d) DW_TAG_subprogram)
2c2fa1
+			# DW_AT_external
2c2fa1
+	.long	.LASF6	# DW_AT_name: "main"
2c2fa1
+	.byte	0x1	# DW_AT_decl_file (py-framefilter-invalidarg.c)
2c2fa1
+	.byte	0x1	# DW_AT_decl_line
2c2fa1
+			# DW_AT_prototyped
2c2fa1
+	.long	die6b-.Ldebug_info0	# DW_AT_type
2c2fa1
+	.quad	.LFB0	# DW_AT_low_pc
2c2fa1
+	.quad	.LFE0-.LFB0	# DW_AT_high_pc
2c2fa1
+	.uleb128 0x1	# DW_AT_frame_base
2c2fa1
+	.byte	0x9c	# DW_OP_call_frame_cfa
2c2fa1
+			# DW_AT_GNU_all_call_sites
2c2fa1
+die4e:
2c2fa1
+	.uleb128 0x3	# (DIE (0x4e) DW_TAG_formal_parameter)
2c2fa1
+	.long	.LASF0	# DW_AT_name: "argc"
2c2fa1
+	.byte	0x1	# DW_AT_decl_file (py-framefilter-invalidarg.c)
2c2fa1
+	.byte	0x1	# DW_AT_decl_line
2c2fa1
+	.long	die6b-.Ldebug_info0	# DW_AT_type
2c2fa1
+#if 0
2c2fa1
+	.uleb128 0x2	# DW_AT_location
2c2fa1
+	.byte	0x91	# DW_OP_fbreg
2c2fa1
+	.sleb128 -20
2c2fa1
+#endif
2c2fa1
+#if 0
2c2fa1
+	.uleb128 1f - 2f	# DW_AT_location
2c2fa1
+2:
2c2fa1
+	.byte	0x03	# DW_OP_addr
2c2fa1
+	.quad 0
2c2fa1
+1:
2c2fa1
+#endif
2c2fa1
+#if 1
2c2fa1
+	.uleb128 1f - 2f	# DW_AT_location
2c2fa1
+2:
2c2fa1
+	.byte	0x13	# DW_OP_drop
2c2fa1
+	.quad 0
2c2fa1
+1:
2c2fa1
+#endif
2c2fa1
+die5c:
2c2fa1
+	.uleb128 0x3	# (DIE (0x5c) DW_TAG_formal_parameter)
2c2fa1
+	.long	.LASF1	# DW_AT_name: "argv"
2c2fa1
+	.byte	0x1	# DW_AT_decl_file (py-framefilter-invalidarg.c)
2c2fa1
+	.byte	0x1	# DW_AT_decl_line
2c2fa1
+	.long	die72-.Ldebug_info0	# DW_AT_type
2c2fa1
+	.uleb128 0x2	# DW_AT_location
2c2fa1
+	.byte	0x91	# DW_OP_fbreg
2c2fa1
+	.sleb128 -32
2c2fa1
+	.byte	0	# end of children of DIE 0x2d
2c2fa1
+die6b:
2c2fa1
+	.uleb128 0x4	# (DIE (0x6b) DW_TAG_base_type)
2c2fa1
+	.byte	0x4	# DW_AT_byte_size
2c2fa1
+	.byte	0x5	# DW_AT_encoding
2c2fa1
+	.ascii "int\0"	# DW_AT_name
2c2fa1
+die72:
2c2fa1
+	.uleb128 0x5	# (DIE (0x72) DW_TAG_pointer_type)
2c2fa1
+	.byte	0x8	# DW_AT_byte_size
2c2fa1
+	.long	die78-.Ldebug_info0	# DW_AT_type
2c2fa1
+die78:
2c2fa1
+	.uleb128 0x5	# (DIE (0x78) DW_TAG_pointer_type)
2c2fa1
+	.byte	0x8	# DW_AT_byte_size
2c2fa1
+	.long	die7e-.Ldebug_info0	# DW_AT_type
2c2fa1
+die7e:
2c2fa1
+	.uleb128 0x6	# (DIE (0x7e) DW_TAG_base_type)
2c2fa1
+	.byte	0x1	# DW_AT_byte_size
2c2fa1
+	.byte	0x6	# DW_AT_encoding
2c2fa1
+	.long	.LASF2	# DW_AT_name: "char"
2c2fa1
+	.byte	0	# end of children of DIE 0xb
2c2fa1
+.Le:
2c2fa1
+	.section	.debug_abbrev,"",@progbits
2c2fa1
+.Ldebug_abbrev0:
2c2fa1
+	.uleb128 0x1	# (abbrev code)
2c2fa1
+	.uleb128 0x11	# (TAG: DW_TAG_compile_unit)
2c2fa1
+	.byte	0x1	# DW_children_yes
2c2fa1
+	.uleb128 0x25	# (DW_AT_producer)
2c2fa1
+	.uleb128 0xe	# (DW_FORM_strp)
2c2fa1
+	.uleb128 0x13	# (DW_AT_language)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x3	# (DW_AT_name)
2c2fa1
+	.uleb128 0xe	# (DW_FORM_strp)
2c2fa1
+	.uleb128 0x1b	# (DW_AT_comp_dir)
2c2fa1
+	.uleb128 0xe	# (DW_FORM_strp)
2c2fa1
+	.uleb128 0x11	# (DW_AT_low_pc)
2c2fa1
+	.uleb128 0x1	# (DW_FORM_addr)
2c2fa1
+	.uleb128 0x12	# (DW_AT_high_pc)
2c2fa1
+	.uleb128 0x7	# (DW_FORM_data8)
2c2fa1
+	.uleb128 0x10	# (DW_AT_stmt_list)
2c2fa1
+	.uleb128 0x17	# (DW_FORM_sec_offset)
2c2fa1
+	.byte	0
2c2fa1
+	.byte	0
2c2fa1
+	.uleb128 0x2	# (abbrev code)
2c2fa1
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
2c2fa1
+	.byte	0x1	# DW_children_yes
2c2fa1
+	.uleb128 0x3f	# (DW_AT_external)
2c2fa1
+	.uleb128 0x19	# (DW_FORM_flag_present)
2c2fa1
+	.uleb128 0x3	# (DW_AT_name)
2c2fa1
+	.uleb128 0xe	# (DW_FORM_strp)
2c2fa1
+	.uleb128 0x3a	# (DW_AT_decl_file)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x3b	# (DW_AT_decl_line)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x27	# (DW_AT_prototyped)
2c2fa1
+	.uleb128 0x19	# (DW_FORM_flag_present)
2c2fa1
+	.uleb128 0x49	# (DW_AT_type)
2c2fa1
+	.uleb128 0x13	# (DW_FORM_ref4)
2c2fa1
+	.uleb128 0x11	# (DW_AT_low_pc)
2c2fa1
+	.uleb128 0x1	# (DW_FORM_addr)
2c2fa1
+	.uleb128 0x12	# (DW_AT_high_pc)
2c2fa1
+	.uleb128 0x7	# (DW_FORM_data8)
2c2fa1
+	.uleb128 0x40	# (DW_AT_frame_base)
2c2fa1
+	.uleb128 0x18	# (DW_FORM_exprloc)
2c2fa1
+	.uleb128 0x2117	# (DW_AT_GNU_all_call_sites)
2c2fa1
+	.uleb128 0x19	# (DW_FORM_flag_present)
2c2fa1
+	.byte	0
2c2fa1
+	.byte	0
2c2fa1
+	.uleb128 0x3	# (abbrev code)
2c2fa1
+	.uleb128 0x5	# (TAG: DW_TAG_formal_parameter)
2c2fa1
+	.byte	0	# DW_children_no
2c2fa1
+	.uleb128 0x3	# (DW_AT_name)
2c2fa1
+	.uleb128 0xe	# (DW_FORM_strp)
2c2fa1
+	.uleb128 0x3a	# (DW_AT_decl_file)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x3b	# (DW_AT_decl_line)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x49	# (DW_AT_type)
2c2fa1
+	.uleb128 0x13	# (DW_FORM_ref4)
2c2fa1
+	.uleb128 0x2	# (DW_AT_location)
2c2fa1
+	.uleb128 0x18	# (DW_FORM_exprloc)
2c2fa1
+	.byte	0
2c2fa1
+	.byte	0
2c2fa1
+	.uleb128 0x4	# (abbrev code)
2c2fa1
+	.uleb128 0x24	# (TAG: DW_TAG_base_type)
2c2fa1
+	.byte	0	# DW_children_no
2c2fa1
+	.uleb128 0xb	# (DW_AT_byte_size)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x3e	# (DW_AT_encoding)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x3	# (DW_AT_name)
2c2fa1
+	.uleb128 0x8	# (DW_FORM_string)
2c2fa1
+	.byte	0
2c2fa1
+	.byte	0
2c2fa1
+	.uleb128 0x5	# (abbrev code)
2c2fa1
+	.uleb128 0xf	# (TAG: DW_TAG_pointer_type)
2c2fa1
+	.byte	0	# DW_children_no
2c2fa1
+	.uleb128 0xb	# (DW_AT_byte_size)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x49	# (DW_AT_type)
2c2fa1
+	.uleb128 0x13	# (DW_FORM_ref4)
2c2fa1
+	.byte	0
2c2fa1
+	.byte	0
2c2fa1
+	.uleb128 0x6	# (abbrev code)
2c2fa1
+	.uleb128 0x24	# (TAG: DW_TAG_base_type)
2c2fa1
+	.byte	0	# DW_children_no
2c2fa1
+	.uleb128 0xb	# (DW_AT_byte_size)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x3e	# (DW_AT_encoding)
2c2fa1
+	.uleb128 0xb	# (DW_FORM_data1)
2c2fa1
+	.uleb128 0x3	# (DW_AT_name)
2c2fa1
+	.uleb128 0xe	# (DW_FORM_strp)
2c2fa1
+	.byte	0
2c2fa1
+	.byte	0
2c2fa1
+	.byte	0
2c2fa1
+	.section	.debug_aranges,"",@progbits
2c2fa1
+	.long	0x2c	# Length of Address Ranges Info
2c2fa1
+	.value	0x2	# DWARF Version
2c2fa1
+	.long	.Ldebug_info0	# Offset of Compilation Unit Info
2c2fa1
+	.byte	0x8	# Size of Address
2c2fa1
+	.byte	0	# Size of Segment Descriptor
2c2fa1
+	.value	0	# Pad to 16 byte boundary
2c2fa1
+	.value	0
2c2fa1
+	.quad	.Ltext0	# Address
2c2fa1
+	.quad	.Letext0-.Ltext0	# Length
2c2fa1
+	.quad	0
2c2fa1
+	.quad	0
2c2fa1
+	.section	.debug_line,"",@progbits
2c2fa1
+.Ldebug_line0:
2c2fa1
+	.section	.debug_str,"MS",@progbits,1
2c2fa1
+.LASF1:
2c2fa1
+	.string	"argv"
2c2fa1
+.LASF4:
2c2fa1
+	.string	"py-framefilter-invalidarg.c"
2c2fa1
+.LASF5:
2c2fa1
+	.string	""
2c2fa1
+.LASF0:
2c2fa1
+	.string	"argc"
2c2fa1
+.LASF3:
2c2fa1
+	.string	"GNU C 4.9.1 20140813 (Red Hat 4.9.1-7) -mtune=generic -march=x86-64 -g"
2c2fa1
+.LASF6:
2c2fa1
+	.string	"main"
2c2fa1
+.LASF2:
2c2fa1
+	.string	"char"
2c2fa1
+	.ident	"GCC: (GNU) 4.9.1 20140813 (Red Hat 4.9.1-7)"
2c2fa1
+	.section	.note.GNU-stack,"",@progbits
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py.in
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-invalidarg-gdb.py.in	2015-11-27 18:06:22.446231736 +0100
2c2fa1
@@ -0,0 +1,48 @@
2c2fa1
+# Copyright (C) 2014 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 3 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+# This file is part of the GDB testsuite.  It tests Python-based
2c2fa1
+# frame-filters.
2c2fa1
+import gdb
2c2fa1
+import itertools
2c2fa1
+from gdb.FrameDecorator import FrameDecorator
2c2fa1
+
2c2fa1
+
2c2fa1
+class FrameObjFile ():
2c2fa1
+
2c2fa1
+    def __init__ (self):
2c2fa1
+        self.name = "Filter1"
2c2fa1
+        self.priority = 1
2c2fa1
+        self.enabled = False
2c2fa1
+        gdb.current_progspace().frame_filters ["Progspace" + self.name] = self
2c2fa1
+        gdb.current_objfile().frame_filters ["ObjectFile" + self.name] = self
2c2fa1
+
2c2fa1
+    def filter (self, frame_iter):
2c2fa1
+        return frame_iter
2c2fa1
+
2c2fa1
+class FrameObjFile2 ():
2c2fa1
+
2c2fa1
+    def __init__ (self):
2c2fa1
+        self.name = "Filter2"
2c2fa1
+        self.priority = 100
2c2fa1
+        self.enabled = True
2c2fa1
+        gdb.current_progspace().frame_filters ["Progspace" + self.name] = self
2c2fa1
+        gdb.current_objfile().frame_filters ["ObjectFile" + self.name] = self
2c2fa1
+
2c2fa1
+    def filter (self, frame_iter):
2c2fa1
+        return frame_iter
2c2fa1
+
2c2fa1
+FrameObjFile()
2c2fa1
+FrameObjFile2()
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp	2015-11-27 18:19:26.346625521 +0100
2c2fa1
@@ -0,0 +1,86 @@
2c2fa1
+# Copyright (C) 2014 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 3 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+load_lib gdb-python.exp
2c2fa1
+
2c2fa1
+standard_testfile amd64-py-framefilter-invalidarg.S
2c2fa1
+
2c2fa1
+if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
2c2fa1
+    verbose "Skipping py-framefilter-invalidarg."
2c2fa1
+    return
2c2fa1
+}
2c2fa1
+
2c2fa1
+# We cannot use prepare_for_testing as we have to set the safe-patch
2c2fa1
+# to check objfile and progspace printers.
2c2fa1
+if {[build_executable $testfile.exp $testfile $srcfile {}] == -1} {
2c2fa1
+    return -1
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Start with a fresh gdb.
2c2fa1
+gdb_exit
2c2fa1
+gdb_start
2c2fa1
+
2c2fa1
+# Skip all tests if Python scripting is not enabled.
2c2fa1
+if { [skip_python_tests] } { continue }
2c2fa1
+
2c2fa1
+### IMPORT:
2c2fa1
+# Like remote_download but provides a gdb-specific behavior.  If DEST
2c2fa1
+# is "host", and the host is not remote, and TOFILE is not specified,
2c2fa1
+# then the [file tail] of FROMFILE is passed through
2c2fa1
+# standard_output_file to compute the destination.
2c2fa1
+
2c2fa1
+proc gdb_remote_download {dest fromfile {tofile {}}} {
2c2fa1
+    if {$dest == "host" && ![is_remote host] && $tofile == ""} {
2c2fa1
+	set tofile [standard_output_file [file tail $fromfile]]
2c2fa1
+    }
2c2fa1
+
2c2fa1
+    if { $tofile == "" } {
2c2fa1
+	return [remote_download $dest $fromfile]
2c2fa1
+    } else {
2c2fa1
+	return [remote_download $dest $fromfile $tofile]
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+### IMPORT^
2c2fa1
+
2c2fa1
+# Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
2c2fa1
+# Care is taken to put it in the same directory as the binary so that
2c2fa1
+# gdb will find it.
2c2fa1
+set remote_obj_python_file \
2c2fa1
+    [remote_download \
2c2fa1
+	 host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
2c2fa1
+	 [standard_output_file ${testfile}-gdb.py]]
2c2fa1
+
2c2fa1
+gdb_reinitialize_dir $srcdir/$subdir
2c2fa1
+gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
2c2fa1
+    "set auto-load safe-path"
2c2fa1
+gdb_load ${binfile}
2c2fa1
+# Verify gdb loaded the script.
2c2fa1
+gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
2c2fa1
+    "Test auto-load had loaded python scripts"
2c2fa1
+
2c2fa1
+if ![runto_main] then {
2c2fa1
+    perror "couldn't run to breakpoint"
2c2fa1
+    return
2c2fa1
+}
2c2fa1
+gdb_test_no_output "set python print-stack full" \
2c2fa1
+    "Set python print-stack to full"
2c2fa1
+
2c2fa1
+# Load global frame-filters
2c2fa1
+set remote_python_file [gdb_remote_download host \
2c2fa1
+			    ${srcdir}/${subdir}/${testfile}.py]
2c2fa1
+gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
2c2fa1
+    "Load python file"
2c2fa1
+
2c2fa1
+gdb_test "bt" " in niam \\(argc=<error reading variable: dwarf expression stack underflow>, argv=0x\[0-9a-f\]+\\) at py-framefilter-invalidarg.c:\[0-9\]+" "bt full with filters"
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.python/py-framefilter-invalidarg.py	2015-11-27 18:06:22.447231742 +0100
2c2fa1
@@ -0,0 +1,59 @@
2c2fa1
+# Copyright (C) 2014 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 3 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+# This file is part of the GDB testsuite.  It tests Python-based
2c2fa1
+# frame-filters.
2c2fa1
+import gdb
2c2fa1
+import itertools
2c2fa1
+from gdb.FrameDecorator import FrameDecorator
2c2fa1
+import copy
2c2fa1
+
2c2fa1
+class Reverse_Function (FrameDecorator):
2c2fa1
+
2c2fa1
+    def __init__(self, fobj):
2c2fa1
+        super(Reverse_Function, self).__init__(fobj)
2c2fa1
+        self.fobj = fobj
2c2fa1
+
2c2fa1
+    def function (self):
2c2fa1
+        fname = str (self.fobj.function())
2c2fa1
+        if (fname == None or fname == ""):
2c2fa1
+            return None
2c2fa1
+        if fname == 'end_func':
2c2fa1
+            extra = self.fobj.inferior_frame().read_var('str').string()
2c2fa1
+        else:
2c2fa1
+            extra = ''
2c2fa1
+        fname = fname[::-1] + extra
2c2fa1
+        return fname
2c2fa1
+
2c2fa1
+class FrameFilter ():
2c2fa1
+
2c2fa1
+    def __init__ (self):
2c2fa1
+        self.name = "Reverse"
2c2fa1
+        self.priority = 100
2c2fa1
+        self.enabled = True
2c2fa1
+        gdb.frame_filters [self.name] = self
2c2fa1
+
2c2fa1
+    def filter (self, frame_iter):
2c2fa1
+        # Python 3.x moved the itertools.imap functionality to map(),
2c2fa1
+        # so check if it is available.
2c2fa1
+        if hasattr(itertools, "imap"):
2c2fa1
+            frame_iter = itertools.imap (Reverse_Function,
2c2fa1
+                                         frame_iter)
2c2fa1
+        else:
2c2fa1
+            frame_iter = map(Reverse_Function, frame_iter)
2c2fa1
+
2c2fa1
+        return frame_iter
2c2fa1
+
2c2fa1
+FrameFilter()