diff mbox

Fix gdb.base/attach.exp fails when gdb is configured --with-sysroot=/

Message ID 1516809167-10599-1-git-send-email-yao.qi@linaro.org
State New
Headers show

Commit Message

Yao Qi Jan. 24, 2018, 3:52 p.m. UTC
I see some test fails in gdb.base/attach.exp when gdb is configured
--with-sysroot=/.

FAIL: gdb.base/attach.exp: attach2, with no file
FAIL: gdb.base/attach.exp: load file manually, after attach2 (re-read) (got interactive prompt)
FAIL: gdb.base/attach.exp: attach when process' a.out not in cwd

If gdb is configured this way, sysroot is "/" in default, and if binfile
is a absolute path, the regexp pattern $sysroot$escapedbinfile is
incorrect.

There are different ways to fix it, but I don't want to complicate the
test, so I choose this naive way.

gdb/testsuite:

2018-01-24  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/attach.exp (do_attach_tests): Set sysroot to ".*".
---
 gdb/testsuite/gdb.base/attach.exp | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Comments

Andreas Schwab Jan. 24, 2018, 4:03 p.m. UTC | #1
On Jan 24 2018, Yao Qi <qiyaoltc@gmail.com> wrote:

> 2018-01-24  Yao Qi  <yao.qi@linaro.org>
>
> 	* gdb.base/attach.exp (do_attach_tests): Set sysroot to ".*".

.* can match newlines, better avoid that.

Andreas.
Yao Qi Jan. 24, 2018, 4:12 p.m. UTC | #2
On Wed, Jan 24, 2018 at 4:03 PM, Andreas Schwab <schwab@suse.de> wrote:
> On Jan 24 2018, Yao Qi <qiyaoltc@gmail.com> wrote:
>
>> 2018-01-24  Yao Qi  <yao.qi@linaro.org>
>>
>>       * gdb.base/attach.exp (do_attach_tests): Set sysroot to ".*".
>
> .* can match newlines, better avoid that.
>

OK, updated it to "\[^\r\n\]*".
Yao Qi Feb. 1, 2018, 2:51 p.m. UTC | #3
On Wed, Jan 24, 2018 at 4:12 PM, Yao Qi <qiyaoltc@gmail.com> wrote:
> On Wed, Jan 24, 2018 at 4:03 PM, Andreas Schwab <schwab@suse.de> wrote:
>> On Jan 24 2018, Yao Qi <qiyaoltc@gmail.com> wrote:
>>
>>> 2018-01-24  Yao Qi  <yao.qi@linaro.org>
>>>
>>>       * gdb.base/attach.exp (do_attach_tests): Set sysroot to ".*".
>>
>> .* can match newlines, better avoid that.
>>
>
> OK, updated it to "\[^\r\n\]*".
>

I pushed it in.
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index d315c27..c30e95d 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -57,15 +57,12 @@  proc do_attach_tests {} {
     # Figure out a regular expression that will match the sysroot,
     # noting that the default sysroot is "target:", and also noting
     # that GDB will strip "target:" from the start of filenames when
-    # operating on the local filesystem
-    set sysroot ""
-    set test "show sysroot"
-    gdb_test_multiple $test $test {
-	-re "The current system root is \"(.*)\"\..*${gdb_prompt} $" {
-	    set sysroot $expect_out(1,string)
-	}
-    }
-    regsub "^target:" "$sysroot" "(target:)?" sysroot
+    # operating on the local filesystem.  However the default sysroot
+    # can be set via configure option --with-sysroot, which can be "/".
+    # If $binfile is a absolute path, so pattern
+    # "$sysroot$escapedbinfile" below is wrong.  Use .* to make
+    # $sysroot simple.
+    set sysroot ".*"
 
     # Start the program running and then wait for a bit, to be sure
     # that it can be attached to.