Fix internal warning when "gdb -p xxx"
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / attach.exp
index 4d67d51be61a738a5a76f2e9b4d53d2b550ca7e9..9714c2991ead1bacac04dc64aa16ede01d112f3f 100644 (file)
@@ -384,6 +384,51 @@ proc do_call_attach_tests {} {
     remote_exec build "kill -9 ${testpid}"
 }
 
+proc do_command_attach_tests {} {
+    global gdb_prompt
+    global binfile
+    global verbose
+    global GDB
+    global INTERNAL_GDBFLAGS
+    global GDBFLAGS
+
+    if ![isnative] then {
+       unsupported "command attach test"
+       return 0
+    }
+
+    # Start the program running and then wait for a bit, to be sure
+    # that it can be attached to.
+
+    set testpid [eval exec $binfile &]
+    exec sleep 2
+    if { [istarget "*-*-cygwin*"] } {
+       # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
+       # different due to the way fork/exec works.
+       set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
+    }
+
+    gdb_exit
+    if $verbose>1 then {
+        send_user "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS --pid=$testpid\n"
+    }
+
+    eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS --pid=$testpid"
+    set test "starting with --pid"
+    expect {
+       -re "Reading symbols from.*$gdb_prompt $" {
+           pass "$test"
+       }
+       timeout {
+           fail "$test (timeout)"
+       }
+    }
+
+    # Get rid of the process
+
+    remote_exec build "kill -9 ${testpid}"
+}
+
 
 # Start with a fresh gdb
 
@@ -404,4 +449,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 do_call_attach_tests
 
+# Test "gdb --pid"
+
+do_command_attach_tests
+
 return 0
This page took 0.035835 seconds and 4 git commands to generate.