+2014-10-18 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.
+
2014-10-17 Doug Evans <dje@google.com>
* gdb.python/py-events.exp: Update expected output for clear_objfiles
standard_testfile
+set has_argv0 [gdb_has_argv0]
+
if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
return -1
}
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
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"
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} {
"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?.
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} {
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
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