aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-10-06 12:57:39 +0100
committerPedro Alves <palves@redhat.com>2016-10-06 12:57:39 +0100
commite027976f02ce8ed4cf0da79238226c03a640f2b3 (patch)
tree5136432064454b0b458ab2e0ff16e6b5a7ac0cb0 /gdb
parente40b2941d81f6499b81834eb0e22b2ab3e25a3f4 (diff)
downloadgdb-e027976f02ce8ed4cf0da79238226c03a640f2b3.zip
gdb-e027976f02ce8ed4cf0da79238226c03a640f2b3.tar.gz
gdb-e027976f02ce8ed4cf0da79238226c03a640f2b3.tar.bz2
Fix a few gdb.base/jit-simple.exp problems
I noticed that we sometimes get this: (gdb) print &__jit_debug_descriptor $1 = (struct jit_descriptor *) 0x601040 <__jit_debug_descriptor> (gdb) PASS: gdb.base/jit-simple.exp: blah 1 [...] (gdb) run [...] Starting program: build/gdb/testsuite/outputs/gdb.base/jit-simple/jit-simple Unsupported JIT protocol version 4 in descriptor (expected 1) Breakpoint 2, main () at src/gdb/testsuite/gdb.base/jit-simple.c:36 36 return 0; (gdb) print &__jit_debug_descriptor $2 = (struct jit_descriptor *) 0x601040 <__jit_debug_descriptor> (gdb) PASS: gdb.base/jit-simple.exp: blah 1 All tests PASSed, but note the "Unsupported JIT protocol version 4" message. Also notice that "__jit_debug_descriptor" has the same address before and after the rerun, while the test is built in a way that should make that address change between runs. The test doesn't catch any of this because it doesn't compare before/after addresses. And then notice the "blah 1" test messages. "blah" is clearly a WIP message, but it should be at least "blah 2" the second time. :-) The reason this sometimes happens is that the test recompiles the program and expects gdb to reload it automaticallyt on "run". However, if the original program and the new recompilation happen to be in the same second, then gdb does not realize that the binary needs to be reloaded. (This is an old problem out of scope of this series.) If that happens, then GDB ends up using the wrong symbols for the program that it spawns, reads the JIT descriptor out of the wrong address, finds garbage, and prints that "unsupported version" notice. Fix that in the same way gdb.base/reread.exp handles it -- by sleeping one second before recompiling. gdb/testsuite/ChangeLog: 2016-10-06 Pedro Alves <palves@redhat.com> * gdb.base/jit-simple.exp (top level) Delete get_compiler_info call. (jit_run): Delete. (jit_test_reread): Use with_test_prefix. Reload the main binary explicitly. Compare the before/after addresses of the JIT descriptor.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.base/jit-simple.exp54
2 files changed, 33 insertions, 30 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 97a587a..8467082 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2016-10-06 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/jit-simple.exp (top level) Delete get_compiler_info
+ call.
+ (jit_run): Delete.
+ (jit_test_reread): Use with_test_prefix. Reload the main binary
+ explicitly. Compare the before/after addresses of the JIT
+ descriptor.
+
2016-10-03 Antoine Tremblay <antoine.tremblay@ericsson.com>
2016-10-03 Simon Marchi <simon.marchi@ericsson.com>
diff --git a/gdb/testsuite/gdb.base/jit-simple.exp b/gdb/testsuite/gdb.base/jit-simple.exp
index ad99c30..6fe6011 100644
--- a/gdb/testsuite/gdb.base/jit-simple.exp
+++ b/gdb/testsuite/gdb.base/jit-simple.exp
@@ -18,16 +18,6 @@ if {[skip_shlib_tests]} {
return -1
}
-if {[get_compiler_info]} {
- warning "Could not get compiler info"
- untested jit-simple.exp
- return 1
-}
-
-#
-# test running programs
-#
-
standard_testfile
if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
@@ -35,39 +25,43 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
return -1
}
-# A helper for jit_test_reread that invokes gdb_run_cmd.
-proc jit_run {msg} {
- global decimal gdb_prompt
-
- gdb_run_cmd
- gdb_test "" "Inferior .* exited.*" $msg
-}
-
# Test re-running an inferior with a JIT descriptor, where the JIT
# descriptor changes address between runs.
# http://sourceware.org/bugzilla/show_bug.cgi?id=13431
proc jit_test_reread {} {
global testfile binfile subdir srcfile srcdir
+ global hex
- clean_restart $testfile
+ with_test_prefix "initial run" {
+ clean_restart $testfile
- # jit_run "initial run"
- runto_main
-
- gdb_test "print &__jit_debug_descriptor" "= .*" "blah 1"
+ runto_main
- gdb_rename_execfile $binfile ${binfile}x
+ set addr_before [get_hexadecimal_valueof "&__jit_debug_descriptor" 0 \
+ "get address of __jit_debug_descriptor"]
+ }
- if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DSPACER}] != "" } {
- fail "recompile $srcfile"
- } else {
- pass "recompile $srcfile"
+ with_test_prefix "second run" {
+ # Ensure that the new executable is at least one second newer
+ # than the old. If the recompilation happens in the same
+ # second, gdb might not reload the executable automatically.
+ sleep 1
- # jit_run "second run"
+ gdb_rename_execfile $binfile ${binfile}x
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DSPACER}] != "" } {
+ fail "recompile"
+ return
+ } else {
+ pass "recompile"
+ }
runto_main
- gdb_test "print &__jit_debug_descriptor" "= .*" "blah 1"
+
+ set addr_after [get_hexadecimal_valueof "&__jit_debug_descriptor" 0 \
+ "get address of __jit_debug_descriptor"]
}
+
+ gdb_assert {$addr_before != $addr_after} "address changed"
}
jit_test_reread