aefb0e1
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=196439
aefb0e1
aefb0e1
aefb0e1
2006-08-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
aefb0e1
aefb0e1
        * gdb.dwarf2/dw2-stripped.exp: New file, Handle corrupted
aefb0e1
        or missing location list information.
aefb0e1
        * gdb.dwarf2/dw2-stripped.c: New file, Handle corrupted
aefb0e1
        or missing location list information.
aefb0e1
aefb0e1
aefb0e1
Index: gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
aefb0e1
===================================================================
aefb0e1
RCS file: gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
aefb0e1
diff -N gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
aefb0e1
--- /dev/null	1 Jan 1970 00:00:00 -0000
aefb0e1
+++ gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.c	26 Aug 2006 11:47:26 -0000
aefb0e1
@@ -0,0 +1,42 @@
aefb0e1
+/* This testcase is part of GDB, the GNU debugger.
aefb0e1
+
aefb0e1
+   Copyright 2004 Free Software Foundation, Inc.
aefb0e1
+
aefb0e1
+   This program is free software; you can redistribute it and/or modify
aefb0e1
+   it under the terms of the GNU General Public License as published by
aefb0e1
+   the Free Software Foundation; either version 2 of the License, or
aefb0e1
+   (at your option) any later version.
aefb0e1
+
aefb0e1
+   This program is distributed in the hope that it will be useful,
aefb0e1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
aefb0e1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
aefb0e1
+   GNU General Public License for more details.
aefb0e1
+ 
aefb0e1
+   You should have received a copy of the GNU General Public License
aefb0e1
+   along with this program; if not, write to the Free Software
aefb0e1
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
aefb0e1
+   USA.  */
aefb0e1
+
aefb0e1
+
aefb0e1
+/* The function `func1' traced into must have debug info on offset > 0;
aefb0e1
+   (DW_UNSND (attr)).  This is the reason of `func0' existence.  */
aefb0e1
+
aefb0e1
+void
aefb0e1
+func0(int a, int b)
aefb0e1
+{
aefb0e1
+}
aefb0e1
+
aefb0e1
+/* `func1' being traced into must have some arguments to dump.  */
aefb0e1
+
aefb0e1
+void
aefb0e1
+func1(int a, int b)
aefb0e1
+{
aefb0e1
+  func0 (a,b);
aefb0e1
+}
aefb0e1
+
aefb0e1
+int
aefb0e1
+main(void)
aefb0e1
+{
aefb0e1
+  func1 (1, 2);
aefb0e1
+  return 0;
aefb0e1
+}
aefb0e1
Index: gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
aefb0e1
===================================================================
aefb0e1
RCS file: gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
aefb0e1
diff -N gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
aefb0e1
--- /dev/null	1 Jan 1970 00:00:00 -0000
aefb0e1
+++ gdb-6.5/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp	26 Aug 2006 11:47:27 -0000
aefb0e1
@@ -0,0 +1,79 @@
aefb0e1
+# Copyright 2006 Free Software Foundation, Inc.
aefb0e1
+
aefb0e1
+# This program is free software; you can redistribute it and/or modify
aefb0e1
+# it under the terms of the GNU General Public License as published by
aefb0e1
+# the Free Software Foundation; either version 2 of the License, or
aefb0e1
+# (at your option) any later version.
aefb0e1
+# 
aefb0e1
+# This program is distributed in the hope that it will be useful,
aefb0e1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
aefb0e1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
aefb0e1
+# GNU General Public License for more details.
aefb0e1
+# 
aefb0e1
+# You should have received a copy of the GNU General Public License
aefb0e1
+# along with this program; if not, write to the Free Software
aefb0e1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
aefb0e1
+
aefb0e1
+# Minimal DWARF-2 unit test
aefb0e1
+
aefb0e1
+# This test can only be run on targets which support DWARF-2.
aefb0e1
+# For now pick a sampling of likely targets.
aefb0e1
+if {![istarget *-*-linux*]
aefb0e1
+    && ![istarget *-*-gnu*]
aefb0e1
+    && ![istarget *-*-elf*]
aefb0e1
+    && ![istarget *-*-openbsd*]
aefb0e1
+    && ![istarget arm-*-eabi*]
aefb0e1
+    && ![istarget powerpc-*-eabi*]} {
aefb0e1
+    return 0  
aefb0e1
+}
aefb0e1
+
aefb0e1
+set testfile "dw2-stripped"
aefb0e1
+set srcfile ${testfile}.c
aefb0e1
+set binfile ${objdir}/${subdir}/${testfile}.x
aefb0e1
+
aefb0e1
+remote_exec build "rm -f ${binfile}"
aefb0e1
+
aefb0e1
+# get the value of gcc_compiled
aefb0e1
+if [get_compiler_info ${binfile}] {
aefb0e1
+    return -1
aefb0e1
+}
aefb0e1
+
aefb0e1
+# This test can only be run on gcc as we use additional_flags=FIXME
aefb0e1
+if {$gcc_compiled == 0} {
aefb0e1
+    return 0
aefb0e1
+}
aefb0e1
+
aefb0e1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
aefb0e1
+    return -1
aefb0e1
+}
aefb0e1
+
aefb0e1
+remote_exec build "objcopy -R .debug_loc ${binfile}"
aefb0e1
+set strip_output [remote_exec build "objdump -h ${binfile}"]
aefb0e1
+
aefb0e1
+set test "stripping test file preservation"
aefb0e1
+if [ regexp ".debug_info " $strip_output]  {
aefb0e1
+    pass "$test (.debug_info preserved)"
aefb0e1
+} else {
aefb0e1
+    fail "$test (.debug_info got also stripped)"
aefb0e1
+}
aefb0e1
+
aefb0e1
+set test "stripping test file functionality"
aefb0e1
+if [ regexp ".debug_loc " $strip_output]  {
aefb0e1
+    fail "$test (.debug_loc still present)"
aefb0e1
+} else {
aefb0e1
+    pass "$test (.debug_loc stripped)"
aefb0e1
+}
aefb0e1
+
aefb0e1
+gdb_exit
aefb0e1
+gdb_start
aefb0e1
+gdb_reinitialize_dir $srcdir/$subdir
aefb0e1
+gdb_load ${binfile}
aefb0e1
+
aefb0e1
+# For C programs, "start" should stop in main().
aefb0e1
+
aefb0e1
+gdb_test "start" \
aefb0e1
+         ".*main \\(\\) at .*" \
aefb0e1
+         "start"
aefb0e1
+gdb_test "step" \
aefb0e1
+         "func.* \\(.*\\) at .*" \
aefb0e1
+         "step"