summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-10-09 19:29:10 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-10-09 19:29:10 +0000
commit3e6f69839cc2e003a3ebe3ef4ee0361fc2e0b971 (patch)
tree38fd6b8cb15b63ebac47ca9d76fb3f5b1940dea0 /gdb/testsuite/gdb.arch
parentb8cf68580fa8900f6750adc16b3454433fbdccd0 (diff)
downloadgdb-3e6f69839cc2e003a3ebe3ef4ee0361fc2e0b971.tar.gz
gdb/
Protect entry values against self tail calls. * dwarf2loc.c (VEC (CORE_ADDR), func_verify_no_selftailcall): New. (dwarf_expr_dwarf_reg_entry_value): Call func_verify_no_selftailcall. gdb/testsuite/ Protect entry values against self tail calls. * gdb.arch/amd64-entry-value.cc (self2, self): New. (main): Call self. * gdb.arch/amd64-entry-value.exp (self: breakhere, self: bt) (set debug entry-values 1, self: bt debug entry-values): New tests.
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r--gdb/testsuite/gdb.arch/amd64-entry-value.cc24
-rw-r--r--gdb/testsuite/gdb.arch/amd64-entry-value.exp13
2 files changed, 37 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.cc b/gdb/testsuite/gdb.arch/amd64-entry-value.cc
index 9e09c8a3efc..44b7564c680 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value.cc
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value.cc
@@ -91,6 +91,29 @@ amb_a (int i)
amb_b (i + 1);
}
+static void __attribute__((noinline, noclone)) self (int i);
+
+static void __attribute__((noinline, noclone))
+self2 (int i)
+{
+ self (i);
+}
+
+static void __attribute__((noinline, noclone))
+self (int i)
+{
+ if (i == 200)
+ {
+ /* GCC would inline `self' as `cmovne' without the `self2' indirect. */
+ self2 (i + 1);
+ }
+ else
+ {
+ e (v, v);
+ d (i + 2, i + 2.5);
+ }
+}
+
int
main ()
{
@@ -100,5 +123,6 @@ main ()
else
b (5, 5.25);
amb_a (100);
+ self (200);
return 0;
}
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.exp b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
index 6abc7ab9d9c..fdf8040b86a 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
@@ -73,3 +73,16 @@ gdb_continue_to_breakpoint "ambiguous: breakhere"
gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in amb_z \\(i=<optimized out>\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in amb_y \\(i=<optimized out>\\)\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in amb_x \\(i=<optimized out>\\)\[^\r\n\]*\r\n#4 +0x\[0-9a-f\]+ in amb_b \\(i=101\\)\[^\r\n\]*\r\n#5 +0x\[0-9a-f\]+ in amb_a \\(i=100\\)\[^\r\n\]*\r\n#6 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \
"ambiguous: bt"
+
+
+# Test self tail calls verification.
+# GDB should not print the real value as it is ambiguous.
+
+gdb_continue_to_breakpoint "self: breakhere"
+
+gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in self \\(i=<optimized out>\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \
+ "self: bt"
+
+gdb_test_no_output "set debug entry-values 1"
+gdb_test "bt" "DW_OP_GNU_entry_value resolving has found function \"self\\(int\\)\" at 0x\[0-9a-f\]+ can call itself via tail calls\r\n.*" \
+ "self: bt debug entry-values"