This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gdb: Disable address space randomization for a test


The gdb.opt/inline-break.exp test script relies on capturing a $pc
value in one run of GDB, then restarting GDB and placing a breakpoint
at the previously captured $pc and checking we get the expected
behaviour.

With address space randomization on then the captured $pc value is
almost never valid in the second run of GDB, and so the test fails.

Disabling address space randomization where appropriate fixes this
issue.

gdb/testsuite/ChangeLog:

	* gdb.opt/inline-break.exp: Disable address space randomization
	for the two runs where we care about addresses being consistent.
---
 gdb/testsuite/ChangeLog                |  5 +++++
 gdb/testsuite/gdb.opt/inline-break.exp | 12 ++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gdb/testsuite/gdb.opt/inline-break.exp b/gdb/testsuite/gdb.opt/inline-break.exp
index aed38ed631f..00a5467d617 100644
--- a/gdb/testsuite/gdb.opt/inline-break.exp
+++ b/gdb/testsuite/gdb.opt/inline-break.exp
@@ -264,6 +264,12 @@ set line [gdb_get_line_number "break here"]
 with_test_prefix "line number" {
     clean_restart $binfile
 
+    # At the end of this test we store a $pc value, then restart GDB,
+    # and use this $pc value to place a breakpoint.  If address space
+    # randomization is on, then the chance of this $pc value being
+    # correct in a second GDB instance is pretty small.
+    gdb_test "set disable-randomization off"
+
     if {![runto main]} {
 	untested "could not run to main"
 	continue
@@ -289,6 +295,12 @@ with_test_prefix "address" {
 
     clean_restart $binfile
 
+    # We're about to reuse the $pc value from a prevous run of GDB.
+    # Ensure address space randomization is off so that the inferior
+    # is placed at the same address as previous, and the stored $pc
+    # will still be valid.
+    gdb_test "set disable-randomization off"
+
     if {![runto main]} {
 	untested "could not run to main"
 	continue
-- 
2.14.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]