* [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available
@ 2014-10-16 6:29 Yao Qi
2014-10-16 17:48 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Yao Qi @ 2014-10-16 6:29 UTC (permalink / raw)
To: gdb-patches
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
Re-run argv0-symlink.exp, scm-value.exp, and py-value.exp on x86-linux
(both native and gdbserver) and arm-none-eabi. No fail on x86-linux,
and argv0-symlink.exp is skipped on arm-none-eabi target.
gdb/testsuite:
2014-10-16 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Skip it if gdb_has_argv0 return
false.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
---
gdb/testsuite/gdb.base/argv0-symlink.exp | 5 ++
gdb/testsuite/gdb.guile/scm-value.exp | 5 +-
gdb/testsuite/gdb.python/py-value.exp | 5 +-
gdb/testsuite/lib/gdb.exp | 79 ++++++++++++++++++++++++++++++++
4 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp
index d849b4c..183fd70 100644
--- a/gdb/testsuite/gdb.base/argv0-symlink.exp
+++ b/gdb/testsuite/gdb.base/argv0-symlink.exp
@@ -13,6 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+if { ![gdb_has_argv0] } {
+ unsupported "Can't get argv\[0\]."
+ return
+}
+
standard_testfile
if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp
index ae80d1b..2b49134 100644
--- a/gdb/testsuite/gdb.guile/scm-value.exp
+++ b/gdb/testsuite/gdb.guile/scm-value.exp
@@ -20,6 +20,8 @@ load_lib gdb-guile.exp
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
# Build inferior to language specification.
# LANG is one of "c" or "c++".
proc build_inferior {exefile lang} {
@@ -86,7 +88,8 @@ proc test_value_in_inferior {} {
"set arg0"
# Check that the dereferenced value is sane.
- if { ! [target_info exists noargs] } {
+ global has_argv0
+ if { $has_argv0 } {
gdb_test "gu (print arg0)" \
"0x.*$testfile\"" "verify dereferenced value"
}
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 0d18bef..afa55a5 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -20,6 +20,8 @@ load_lib gdb-python.exp
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
# Build inferior to language specification.
# LANG is one of "c" or "c++".
proc build_inferior {exefile lang} {
@@ -221,7 +223,8 @@ proc test_value_in_inferior {} {
gdb_py_test_silent_cmd "python arg0 = argv.dereference ()" "dereference value" 1
# Check that the dereferenced value is sane
- if { ! [target_info exists noargs] } {
+ global has_argv0
+ if { $has_argv0 } {
gdb_test "python print (arg0)" "0x.*$testfile\"" "verify dereferenced value"
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7b2a402..dd525dc 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4227,6 +4227,85 @@ gdb_caching_proc gdb_skip_xml_test {
return $xml_missing
}
+# Return true if argv[0] is available.
+
+gdb_caching_proc gdb_has_argv0 {
+ set result 0
+
+ # Set up, compile, and execute a test program to check whether
+ # argv[0] is available.
+ set src [standard_temp_file has_argv0[pid].c]
+ set exe [standard_temp_file has_argv0[pid].x]
+
+ gdb_produce_source $src {
+ int main (int argc, char **argv) {
+ return 0;
+ }
+ }
+
+ gdb_compile $src $exe executable {debug}
+
+ # Helper proc.
+ proc gdb_has_argv0_1 { exe } {
+ global srcdir subdir
+ global gdb_prompt hex decimal
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load "$exe"
+
+ # Set breakpoint on main.
+ send_gdb "break main\n"
+ gdb_expect {
+ -re "Breakpoint.*${gdb_prompt} $" {
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+
+ # Run to main.
+ gdb_run_cmd
+ gdb_expect {
+ -re "Breakpoint.*${gdb_prompt} $" {
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+
+ # Check whether argc is 1.
+ send_gdb "p argc\n"
+ gdb_expect {
+ -re " = 1\r\n${gdb_prompt} $" {
+
+ send_gdb "p argv\[0\]\n"
+ gdb_expect {
+ -re " = $hex \".*$exe\"\r\n${gdb_prompt} $" {
+ return 1
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+ return 0
+ }
+
+ set result [gdb_has_argv0_1 $exe]
+
+ gdb_exit
+ file delete $src
+ file delete $exe
+
+ return $result
+}
+
# Note: the procedure gdb_gnu_strip_debug will produce an executable called
# ${binfile}.dbglnk, which is just like the executable ($binfile) but without
# the debuginfo. Instead $binfile has a .gnu_debuglink section which contains
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available
2014-10-16 6:29 [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available Yao Qi
@ 2014-10-16 17:48 ` Pedro Alves
2014-10-17 7:24 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2014-10-16 17:48 UTC (permalink / raw)
To: Yao Qi, gdb-patches
On 10/16/2014 07:25 AM, Yao Qi wrote:
>
> When the program is running with gdbserver, argv[1] to argv[N] aren't
> available, but argv[0] is. Fortunately, argv0-symlink.exp only
> requires argv[0]. argv0-symlink.exp can be run with gdbserver board
> file, as what we do now.
>
> What we need to check is whether argv[0] is available, so I add a new
> proc gdb_has_argv0 to do so by starting a program, and check
> argc/argv[0] to see whether argv[0] is available.
Sounds good.
> --- a/gdb/testsuite/gdb.base/argv0-symlink.exp
> +++ b/gdb/testsuite/gdb.base/argv0-symlink.exp
> @@ -13,6 +13,11 @@
> # You should have received a copy of the GNU General Public License
> # along with this program. If not, see <http://www.gnu.org/licenses/>.
>
> +if { ![gdb_has_argv0] } {
> + unsupported "Can't get argv\[0\]."
> + return
> +}
> +
I think we shouldn't skip the whole test though; only the
printing argv[0] test. The test file also makes sure
that "info inferiors" shows the symlink name, not the target
of the symlink, and that is host-dependent, not target
dependent. See git 4856b6bc.
>
> # Check that the dereferenced value is sane
> - if { ! [target_info exists noargs] } {
> + global has_argv0
> + if { $has_argv0 } {
> gdb_test "python print (arg0)" "0x.*$testfile\"" "verify dereferenced value"
> }
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 7b2a402..dd525dc 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -4227,6 +4227,85 @@ gdb_caching_proc gdb_skip_xml_test {
> return $xml_missing
> }
>
> +# Return true if argv[0] is available.
> +
> +gdb_caching_proc gdb_has_argv0 {
> + set result 0
> +
> + # Set up, compile, and execute a test program to check whether
> + # argv[0] is available.
> + set src [standard_temp_file has_argv0[pid].c]
> + set exe [standard_temp_file has_argv0[pid].x]
> +
> + gdb_produce_source $src {
> + int main (int argc, char **argv) {
> + return 0;
> + }
> + }
> +
> + gdb_compile $src $exe executable {debug}
> +
> + # Helper proc.
> + proc gdb_has_argv0_1 { exe } {
> + global srcdir subdir
> + global gdb_prompt hex decimal
> +
> + gdb_exit
> + gdb_start
> + gdb_reinitialize_dir $srcdir/$subdir
> + gdb_load "$exe"
> +
> + # Set breakpoint on main.
> + send_gdb "break main\n"
> + gdb_expect {
> + -re "Breakpoint.*${gdb_prompt} $" {
> + }
> + -re "${gdb_prompt} $" {
> + return 0
> + }
> + }
> +
> + # Run to main.
> + gdb_run_cmd
> + gdb_expect {
> + -re "Breakpoint.*${gdb_prompt} $" {
> + }
> + -re "${gdb_prompt} $" {
> + return 0
> + }
> + }
> +
> + # Check whether argc is 1.
> + send_gdb "p argc\n"
> + gdb_expect {
> + -re " = 1\r\n${gdb_prompt} $" {
> +
> + send_gdb "p argv\[0\]\n"
> + gdb_expect {
> + -re " = $hex \".*$exe\"\r\n${gdb_prompt} $" {
I suspect this may break if remote (host|target) testing,
and not sharing the filesystem between build/host/target.
Isn't $exe here a full path on the build?
> + return 1
> + }
> + -re "${gdb_prompt} $" {
> + return 0
> + }
> + }
> + }
> + -re "${gdb_prompt} $" {
> + return 0
> + }
> + }
> + return 0
> + }
> +
I think these gdb_expect's should be gdb_test_multiple's instead.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available
2014-10-16 17:48 ` Pedro Alves
@ 2014-10-17 7:24 ` Yao Qi
2014-10-17 11:15 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Yao Qi @ 2014-10-17 7:24 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Pedro Alves <palves@redhat.com> writes:
> I think we shouldn't skip the whole test though; only the
> printing argv[0] test. The test file also makes sure
> that "info inferiors" shows the symlink name, not the target
> of the symlink, and that is host-dependent, not target
> dependent. See git 4856b6bc.
Yeah, we can wrap the test on argv[0] with if { $has_argv0 } {...}. See
below in the updated patch.
>> +
>> + send_gdb "p argv\[0\]\n"
>> + gdb_expect {
>> + -re " = $hex \".*$exe\"\r\n${gdb_prompt} $" {
>
> I suspect this may break if remote (host|target) testing,
> and not sharing the filesystem between build/host/target.
> Isn't $exe here a full path on the build?
>
$exe can be a full path, and can be a base name too. It depends on proc
standard_temp_file. You are right that it is a mistake to use the build
file path on host. I change it to
".*[file tail $exe]\"\r\n${gdb_prompt} $"
>> + return 1
>> + }
>> + -re "${gdb_prompt} $" {
>> + return 0
>> + }
>> + }
>> + }
>> + -re "${gdb_prompt} $" {
>> + return 0
>> + }
>> + }
>> + return 0
>> + }
>> +
>
> I think these gdb_expect's should be gdb_test_multiple's instead.
Fixed.
--
Yao (齐尧)
Subject: [PATCH] Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-17 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp
index d849b4c..cda2128 100644
--- a/gdb/testsuite/gdb.base/argv0-symlink.exp
+++ b/gdb/testsuite/gdb.base/argv0-symlink.exp
@@ -15,6 +15,8 @@
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
return -1
}
@@ -39,7 +41,9 @@ if ![runto_main] {
gdb_test_no_output "set print repeats 10000"
gdb_test_no_output "set print elements 10000"
-gdb_test {print argv[0]} "/$filelink\"" $test
+if { $has_argv0 } {
+ gdb_test {print argv[0]} "/$filelink\"" $test
+}
# For a link named /PATH/TO/DIR/LINK, we want to check the output
# against "/DIR/LINK", but computed in a way that doesn't make
@@ -73,9 +77,12 @@ if ![runto_main] {
gdb_test_no_output "set print repeats 10000"
gdb_test_no_output "set print elements 10000"
-# gdbserver does not have this issue.
-if ![is_remote target] {
- setup_kfail "*-*-*" gdb/15934
+if { $has_argv0 } {
+ # gdbserver does not have this issue.
+ if ![is_remote target] {
+ setup_kfail "*-*-*" gdb/15934
+ }
+ gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
}
-gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
+
gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors"
diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp
index ae80d1b..2b49134 100644
--- a/gdb/testsuite/gdb.guile/scm-value.exp
+++ b/gdb/testsuite/gdb.guile/scm-value.exp
@@ -20,6 +20,8 @@ load_lib gdb-guile.exp
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
# Build inferior to language specification.
# LANG is one of "c" or "c++".
proc build_inferior {exefile lang} {
@@ -86,7 +88,8 @@ proc test_value_in_inferior {} {
"set arg0"
# Check that the dereferenced value is sane.
- if { ! [target_info exists noargs] } {
+ global has_argv0
+ if { $has_argv0 } {
gdb_test "gu (print arg0)" \
"0x.*$testfile\"" "verify dereferenced value"
}
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 0d18bef..afa55a5 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -20,6 +20,8 @@ load_lib gdb-python.exp
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
# Build inferior to language specification.
# LANG is one of "c" or "c++".
proc build_inferior {exefile lang} {
@@ -221,7 +223,8 @@ proc test_value_in_inferior {} {
gdb_py_test_silent_cmd "python arg0 = argv.dereference ()" "dereference value" 1
# Check that the dereferenced value is sane
- if { ! [target_info exists noargs] } {
+ global has_argv0
+ if { $has_argv0 } {
gdb_test "python print (arg0)" "0x.*$testfile\"" "verify dereferenced value"
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7b2a402..53a7b1f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4227,6 +4227,82 @@ gdb_caching_proc gdb_skip_xml_test {
return $xml_missing
}
+# Return true if argv[0] is available.
+
+gdb_caching_proc gdb_has_argv0 {
+ set result 0
+
+ # Set up, compile, and execute a test program to check whether
+ # argv[0] is available.
+ set src [standard_temp_file has_argv0[pid].c]
+ set exe [standard_temp_file has_argv0[pid].x]
+
+ gdb_produce_source $src {
+ int main (int argc, char **argv) {
+ return 0;
+ }
+ }
+
+ gdb_compile $src $exe executable {debug}
+
+ # Helper proc.
+ proc gdb_has_argv0_1 { exe } {
+ global srcdir subdir
+ global gdb_prompt hex decimal
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load "$exe"
+
+ # Set breakpoint on main.
+ gdb_test_multiple "break main" "break main" {
+ -re "Breakpoint.*${gdb_prompt} $" {
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+
+ # Run to main.
+ gdb_run_cmd
+ gdb_test_multiple "" "run to main" {
+ -re "Breakpoint.*${gdb_prompt} $" {
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+
+ # Check whether argc is 1.
+ gdb_test_multiple "p argc" "p argc" {
+ -re " = 1\r\n${gdb_prompt} $" {
+
+ gdb_test_multiple "p argv\[0\]" "p argv\[0\]" {
+ -re " = $hex \".*[file tail $exe]\"\r\n${gdb_prompt} $" {
+ return 1
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+ return 0
+ }
+
+ set result [gdb_has_argv0_1 $exe]
+
+ gdb_exit
+ file delete $src
+ file delete $exe
+
+ return $result
+}
+
# Note: the procedure gdb_gnu_strip_debug will produce an executable called
# ${binfile}.dbglnk, which is just like the executable ($binfile) but without
# the debuginfo. Instead $binfile has a .gnu_debuglink section which contains
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available
2014-10-17 7:24 ` Yao Qi
@ 2014-10-17 11:15 ` Pedro Alves
2014-10-17 13:20 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2014-10-17 11:15 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 10/17/2014 08:20 AM, Yao Qi wrote:
>>> >> +
>>> >> + send_gdb "p argv\[0\]\n"
>>> >> + gdb_expect {
>>> >> + -re " = $hex \".*$exe\"\r\n${gdb_prompt} $" {
>> >
>> > I suspect this may break if remote (host|target) testing,
>> > and not sharing the filesystem between build/host/target.
>> > Isn't $exe here a full path on the build?
>> >
> $exe can be a full path, and can be a base name too. It depends on proc
> standard_temp_file. You are right that it is a mistake to use the build
> file path on host. I change it to
>
> ".*[file tail $exe]\"\r\n${gdb_prompt} $"
OK. So I'm somewhat worried about silently reducing coverage due to
some problem here, either now, or in the future.
So how about instead of silently skipping the tests, call
unsupported, like:
global has_argv0
set test "verify dereferenced value"
if { $has_argv0 } {
gdb_test "python print (arg0)" "0x.*$testfile\"" $test
} else {
unsupported $test
}
etc.
> +gdb_caching_proc gdb_has_argv0 {
> + set result 0
...
> + # Helper proc.
> + proc gdb_has_argv0_1 { exe } {
...
> + set result [gdb_has_argv0_1 $exe]
And then in addition, add an assert here for the main OSs
we support, like so:
if { !$result
&& ([istarget *-*-linux*]
|| [istarget *-*-gnu*]
|| [istarget *-*-cygwin*]
|| [istarget *-*-mingw*]
|| [istarget *-*-darwin*]
|| [istarget *-*-bsd*]
|| [istarget *-*-solaris*]
|| [istarget *-*-msdosdjgpp*]
|| [istarget *-*-go32*]
|| [istarget *-*-aix*]
|| [istarget *-*-hpux*]) } {
fail "argv[0] should be available on this target"
}
> + # Helper proc.
> + proc gdb_has_argv0_1 { exe } {
> + global srcdir subdir
> + global gdb_prompt hex decimal
> +
> + gdb_exit
> + gdb_start
> + gdb_reinitialize_dir $srcdir/$subdir
> + gdb_load "$exe"
BTW, use clean_restart here? (if so, I think 'global srcdir subdir'
becomes unnecessary too)
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available
2014-10-17 11:15 ` Pedro Alves
@ 2014-10-17 13:20 ` Yao Qi
2014-10-17 13:27 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Yao Qi @ 2014-10-17 13:20 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Pedro Alves <palves@redhat.com> writes:
> So how about instead of silently skipping the tests, call
> unsupported, like:
>
> global has_argv0
> set test "verify dereferenced value"
> if { $has_argv0 } {
> gdb_test "python print (arg0)" "0x.*$testfile\"" $test
> } else {
> unsupported $test
> }
>
OK, fixed in the updated patch.
> etc.
>
>> +gdb_caching_proc gdb_has_argv0 {
>> + set result 0
> ...
>> + # Helper proc.
>> + proc gdb_has_argv0_1 { exe } {
> ...
>> + set result [gdb_has_argv0_1 $exe]
>
> And then in addition, add an assert here for the main OSs
> we support, like so:
>
> if { !$result
> && ([istarget *-*-linux*]
> || [istarget *-*-gnu*]
> || [istarget *-*-cygwin*]
> || [istarget *-*-mingw*]
> || [istarget *-*-darwin*]
> || [istarget *-*-bsd*]
> || [istarget *-*-solaris*]
> || [istarget *-*-msdosdjgpp*]
> || [istarget *-*-go32*]
> || [istarget *-*-aix*]
> || [istarget *-*-hpux*]) } {
> fail "argv[0] should be available on this target"
> }
>
OK, I list all OSes GDB supports (extracted from configure.tgt and configure.ac).
>> + # Helper proc.
>> + proc gdb_has_argv0_1 { exe } {
>> + global srcdir subdir
>> + global gdb_prompt hex decimal
>> +
>> + gdb_exit
>> + gdb_start
>> + gdb_reinitialize_dir $srcdir/$subdir
>> + gdb_load "$exe"
>
> BTW, use clean_restart here? (if so, I think 'global srcdir subdir'
> becomes unnecessary too)
Unfortunately we can't. clean_restart loads file from $objdir/$subdir,
but $exe is in $objdir or $objdir/temp.
--
Yao (齐尧)
Subject: [PATCH] Skip testing argv[0] on target argv[0] isn't available
I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name
print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name
My first thought is to check [target_info exists noargs], and skip the
test if it returns true. However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.
When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is. Fortunately, argv0-symlink.exp only
requires argv[0]. argv0-symlink.exp can be run with gdbserver board
file, as what we do now.
What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.
Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver. This patch fixed it too.
gdb/testsuite:
2014-10-17 Yao Qi <yao@codesourcery.com>
* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.
diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp
index d849b4c..cd459bb 100644
--- a/gdb/testsuite/gdb.base/argv0-symlink.exp
+++ b/gdb/testsuite/gdb.base/argv0-symlink.exp
@@ -15,6 +15,8 @@
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
return -1
}
@@ -39,7 +41,11 @@ if ![runto_main] {
gdb_test_no_output "set print repeats 10000"
gdb_test_no_output "set print elements 10000"
-gdb_test {print argv[0]} "/$filelink\"" $test
+if { $has_argv0 } {
+ gdb_test {print argv[0]} "/$filelink\"" $test
+} else {
+ unsupported $test
+}
# For a link named /PATH/TO/DIR/LINK, we want to check the output
# against "/DIR/LINK", but computed in a way that doesn't make
@@ -73,9 +79,14 @@ if ![runto_main] {
gdb_test_no_output "set print repeats 10000"
gdb_test_no_output "set print elements 10000"
-# gdbserver does not have this issue.
-if ![is_remote target] {
- setup_kfail "*-*-*" gdb/15934
+if { $has_argv0 } {
+ # gdbserver does not have this issue.
+ if ![is_remote target] {
+ setup_kfail "*-*-*" gdb/15934
+ }
+ gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
+} else {
+ unsupported $test
}
-gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
+
gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors"
diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp
index ae80d1b..033633c 100644
--- a/gdb/testsuite/gdb.guile/scm-value.exp
+++ b/gdb/testsuite/gdb.guile/scm-value.exp
@@ -20,6 +20,8 @@ load_lib gdb-guile.exp
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
# Build inferior to language specification.
# LANG is one of "c" or "c++".
proc build_inferior {exefile lang} {
@@ -86,9 +88,12 @@ proc test_value_in_inferior {} {
"set arg0"
# Check that the dereferenced value is sane.
- if { ! [target_info exists noargs] } {
- gdb_test "gu (print arg0)" \
- "0x.*$testfile\"" "verify dereferenced value"
+ global has_argv0
+ set test "verify dereferenced value"
+ if { $has_argv0 } {
+ gdb_test "gu (print arg0)" "0x.*$testfile\"" $test
+ } else {
+ unsupported $test
}
# Smoke-test value-optimized-out?.
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 0d18bef..0e1534a 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -20,6 +20,8 @@ load_lib gdb-python.exp
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
# Build inferior to language specification.
# LANG is one of "c" or "c++".
proc build_inferior {exefile lang} {
@@ -221,8 +223,12 @@ proc test_value_in_inferior {} {
gdb_py_test_silent_cmd "python arg0 = argv.dereference ()" "dereference value" 1
# Check that the dereferenced value is sane
- if { ! [target_info exists noargs] } {
- gdb_test "python print (arg0)" "0x.*$testfile\"" "verify dereferenced value"
+ global has_argv0
+ set test "verify dereferenced value"
+ if { $has_argv0 } {
+ gdb_test "python print (arg0)" "0x.*$testfile\"" $test
+ } else {
+ unsupported $test
}
# Smoke-test is_optimized_out attribute
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7b2a402..37e701c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4227,6 +4227,104 @@ gdb_caching_proc gdb_skip_xml_test {
return $xml_missing
}
+# Return true if argv[0] is available.
+
+gdb_caching_proc gdb_has_argv0 {
+ set result 0
+
+ # Set up, compile, and execute a test program to check whether
+ # argv[0] is available.
+ set src [standard_temp_file has_argv0[pid].c]
+ set exe [standard_temp_file has_argv0[pid].x]
+
+ gdb_produce_source $src {
+ int main (int argc, char **argv) {
+ return 0;
+ }
+ }
+
+ gdb_compile $src $exe executable {debug}
+
+ # Helper proc.
+ proc gdb_has_argv0_1 { exe } {
+ global srcdir subdir
+ global gdb_prompt hex
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load "$exe"
+
+ # Set breakpoint on main.
+ gdb_test_multiple "break main" "break main" {
+ -re "Breakpoint.*${gdb_prompt} $" {
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+
+ # Run to main.
+ gdb_run_cmd
+ gdb_test_multiple "" "run to main" {
+ -re "Breakpoint.*${gdb_prompt} $" {
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+
+ # Check whether argc is 1.
+ gdb_test_multiple "p argc" "p argc" {
+ -re " = 1\r\n${gdb_prompt} $" {
+
+ gdb_test_multiple "p argv\[0\]" "p argv\[0\]" {
+ -re " = $hex \".*[file tail $exe]\"\r\n${gdb_prompt} $" {
+ return 1
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+ }
+ -re "${gdb_prompt} $" {
+ return 0
+ }
+ }
+ return 0
+ }
+
+ set result [gdb_has_argv0_1 $exe]
+
+ gdb_exit
+ file delete $src
+ file delete $exe
+
+ if { !$result
+ && ([istarget *-*-linux*]
+ || [istarget *-*-freebsd*] || [istarget *-*-kfreebsd*]
+ || [istarget *-*-netbsd*] || [istarget *-*-knetbsd*]
+ || [istarget *-*-openbsd*]
+ || [istarget *-*-darwin*]
+ || [istarget *-*-solaris*]
+ || [istarget *-*-aix*]
+ || [istarget *-*-gnu*]
+ || [istarget *-*-cygwin*] || [istarget *-*-mingw32*]
+ || [istarget *-*-*djgpp*] || [istarget *-*-go32*]
+ || [istarget *-wince-pe] || [istarget *-*-mingw32ce*]
+ || [istarget *-*-symbianelf*]
+ || [istarget *-*-osf*]
+ || [istarget *-*-hpux*]
+ || [istarget *-*-dicos*]
+ || [istarget *-*-nto*]
+ || [istarget *-*-*vms*]
+ || [istarget *-*-lynx*178]) } {
+ fail "argv\[0\] should be available on this target"
+ }
+
+ return $result
+}
+
# Note: the procedure gdb_gnu_strip_debug will produce an executable called
# ${binfile}.dbglnk, which is just like the executable ($binfile) but without
# the debuginfo. Instead $binfile has a .gnu_debuglink section which contains
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available
2014-10-17 13:20 ` Yao Qi
@ 2014-10-17 13:27 ` Pedro Alves
2014-10-18 13:03 ` Yao Qi
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2014-10-17 13:27 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 10/17/2014 02:16 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
>> So how about instead of silently skipping the tests, call
>> unsupported, like:
>>
>> global has_argv0
>> set test "verify dereferenced value"
>> if { $has_argv0 } {
>> gdb_test "python print (arg0)" "0x.*$testfile\"" $test
>> } else {
>> unsupported $test
>> }
>>
>
> OK, fixed in the updated patch.
>
>> etc.
>>
>>> +gdb_caching_proc gdb_has_argv0 {
>>> + set result 0
>> ...
>>> + # Helper proc.
>>> + proc gdb_has_argv0_1 { exe } {
>> ...
>>> + set result [gdb_has_argv0_1 $exe]
>>
>> And then in addition, add an assert here for the main OSs
>> we support, like so:
>>
>> if { !$result
>> && ([istarget *-*-linux*]
>> || [istarget *-*-gnu*]
>> || [istarget *-*-cygwin*]
>> || [istarget *-*-mingw*]
>> || [istarget *-*-darwin*]
>> || [istarget *-*-bsd*]
>> || [istarget *-*-solaris*]
>> || [istarget *-*-msdosdjgpp*]
>> || [istarget *-*-go32*]
>> || [istarget *-*-aix*]
>> || [istarget *-*-hpux*]) } {
>> fail "argv[0] should be available on this target"
>> }
>>
>
> OK, I list all OSes GDB supports (extracted from configure.tgt and configure.ac).
>
>>> + # Helper proc.
>>> + proc gdb_has_argv0_1 { exe } {
>>> + global srcdir subdir
>>> + global gdb_prompt hex decimal
>>> +
>>> + gdb_exit
>>> + gdb_start
>>> + gdb_reinitialize_dir $srcdir/$subdir
>>> + gdb_load "$exe"
>>
>> BTW, use clean_restart here? (if so, I think 'global srcdir subdir'
>> becomes unnecessary too)
>
> Unfortunately we can't. clean_restart loads file from $objdir/$subdir,
> but $exe is in $objdir or $objdir/temp.
>
OK. This version looks good to me.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-18 13:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-16 6:29 [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available Yao Qi
2014-10-16 17:48 ` Pedro Alves
2014-10-17 7:24 ` Yao Qi
2014-10-17 11:15 ` Pedro Alves
2014-10-17 13:20 ` Yao Qi
2014-10-17 13:27 ` Pedro Alves
2014-10-18 13:03 ` Yao Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox