[1/1] Fix internal warning when "gdb -p xxx" (test)

Message ID 532A5D89.1060108@mentor.com
State Committed
Headers

Commit Message

Hui Zhu March 20, 2014, 3:16 a.m. UTC
  On 03/19/14 18:28, Pedro Alves wrote:
> On 03/19/2014 04:03 AM, Hui Zhu wrote:
>
>> +    eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS --pid=$testpid"
>> +    expect {
>> +	-re "Reading symbols from.*$gdb_prompt $" {
>> +            pass "starting with --pid=$testpid"
>
> Don't add the $testpid to the PASS/FAIL line, as it'll change between
> testsuite runs, making gdb.sum diffs harder.
>
>> +	}
>> +	timeout 	{ fail "(timeout) starting with --pid=$testpid" }
>
> Instead of repeating the text, write:
>
>      set test "starting with --pid"
>      expect {
> 	-re "Reading symbols from.*$gdb_prompt $" {
>              pass "$test"
> 	}
> 	timeout {
>              fail "$test (timeout)"
> 	}
>      }
>
> Otherwise OK.
>
> Thanks!
>

Make a new version according to your comments.
Please help me review it.

Thanks,
Hui

2014-03-20  Hui Zhu  <hui@codesourcery.com>

	* gdb.base/attach.exp (do_command_attach_tests): New.
  

Comments

Pedro Alves March 20, 2014, 11:03 a.m. UTC | #1
On 03/20/2014 03:16 AM, Hui Zhu wrote:

> +    expect {
> +	-re "Reading symbols from.*$gdb_prompt $" {
> +            pass "$test"
> +	}
> +	timeout {
> +	    fail "$test (timeout)"

Something odd with indentation here.

Otherwise OK.  Please push.

Thanks,
  
Hui Zhu March 21, 2014, 3:27 a.m. UTC | #2
On 03/20/14 19:03, Pedro Alves wrote:
> On 03/20/2014 03:16 AM, Hui Zhu wrote:
>
>> +    expect {
>> +	-re "Reading symbols from.*$gdb_prompt $" {
>> +            pass "$test"
>> +	}
>> +	timeout {
>> +	    fail "$test (timeout)"
>
> Something odd with indentation here.

Change 8 blank to a tab.

>
> Otherwise OK.  Please push.
>
> Thanks,
>

Thanks for your help.

Committed to
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ccdd1909ad5299cf0753aaa113928a41f8f27391

Best,
Hui
  

Patch

--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -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