diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-entry-value.cc | 24 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-entry-value.exp | 13 |
3 files changed, 45 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ce9800c..86fe0e9 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2011-10-09 Jan Kratochvil <jan.kratochvil@redhat.com> + 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. + +2011-10-09 Jan Kratochvil <jan.kratochvil@redhat.com> + Recognize virtual tail call frames. * gdb.arch/amd64-entry-value.cc (c, a, b, amb_z, amb_y, amb_x, amb) (amb_b, amb_a): New. diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.cc b/gdb/testsuite/gdb.arch/amd64-entry-value.cc index 9e09c8a..44b7564 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 6abc7ab..fdf8040 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" |