From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7584 invoked by alias); 10 Feb 2012 18:14:09 -0000 Received: (qmail 7574 invoked by uid 22791); 10 Feb 2012 18:14:07 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Feb 2012 18:13:53 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1AIDroJ004916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 10 Feb 2012 13:13:53 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1AIDpss014480; Fri, 10 Feb 2012 13:13:52 -0500 Message-ID: <4F355E5F.7010900@redhat.com> Date: Fri, 10 Feb 2012 18:14:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120131 Thunderbird/10.0 MIME-Version: 1.0 To: Pedro Alves CC: GDB Patches Subject: Re: Make remote attach/detach output be like native target's output References: <4F3532CD.1060400@redhat.com> In-Reply-To: <4F3532CD.1060400@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00209.txt.bz2 On 02/10/2012 03:07 PM, Pedro Alves wrote: > This make the output remote targets' output for attach/detach be like > all the native targets'. It is gratuitously different currently, which causes > a bunch of failures in tests that do "attach"/"detach", with the extended-remote > board. > > Before: > > (gdb) attach 18131 > Attached to process 18131 > Reading symbols from /lib64/libc.so.6...Reading symbols from /usr/lib/debug/lib64/libc-2.14.90.so.debug...done. > done. > Loaded symbols for /lib64/libc.so.6 > Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib64/ld-2.14.90.so.debug...done. > done. > Loaded symbols for /lib64/ld-linux-x86-64.so.2 > During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x339e6bbcdd. > 0x000000339e6bbcd0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82 > 82 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) > (gdb) detach > Detached from remote process 18131. > > After: > > (gdb) attach 18131 > Attaching to program: /bin/sleep, process 18131 > Reading symbols from /lib64/libc.so.6...Reading symbols from /usr/lib/debug/lib64/libc-2.14.90.so.debug...done. > done. > Loaded symbols for /lib64/libc.so.6 > Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib64/ld-2.14.90.so.debug...done. > done. > Loaded symbols for /lib64/ld-linux-x86-64.so.2 > During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x339e6bbcdd. > 0x000000339e6bbcd0 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82 > 82 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS) > (gdb) detach > Detaching from program: /bin/sleep, process 18131 > > > I don't suppose there are objections? > > The idea is that in theory, remote debugging should be indistinguishable > from native debugging, appart from performance, obviously. I forgot that the gdb.server/ tests only run when we test the native debugger. gdb.server/ext-attach.exp needed adjustment to the new output. Here's the updated patch. gdb/ 2012-02-10 Pedro Alves * remote.c (remote_detach_1, extended_remote_attach_1): Tweak output to be like native targets'. (remote_pid_to_str): Special case the null ptid. gdb/testsuite/ 2012-02-10 Pedro Alves Support extended-remote. Avoid cascading timeouts. * gdb.base/attach.exp (do_attach_tests): Add expected output for the extended-remote target. If attaching with no file fails, load the file manually. * gdb.server/ext-attach.exp: Adjust expected attach/detach output. --- gdb/testsuite/gdb.server/ext-attach.exp | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 3187ac0..14c343b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4205,6 +4205,16 @@ remote_detach_1 (char *args, int from_tty, int extended) if (!target_has_execution) error (_("No process to detach from.")); + if (from_tty) + { + char *exec_file = get_exec_file (0); + if (exec_file == NULL) + exec_file = ""; + printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file, + target_pid_to_str (pid_to_ptid (pid))); + gdb_flush (gdb_stdout); + } + /* Tell the remote target to detach. */ if (remote_multi_process_p (rs)) sprintf (rs->buf, "D;%x", pid); @@ -4221,19 +4231,8 @@ remote_detach_1 (char *args, int from_tty, int extended) else error (_("Can't detach process.")); - if (from_tty) - { - if (remote_multi_process_p (rs)) - printf_filtered (_("Detached from remote %s.\n"), - target_pid_to_str (pid_to_ptid (pid))); - else - { - if (extended) - puts_filtered (_("Detached from remote process.\n")); - else - puts_filtered (_("Ending remote debugging.\n")); - } - } + if (from_tty && !extended) + puts_filtered (_("Ending remote debugging.\n")); discard_pending_stop_replies (pid); target_mourn_inferior (); @@ -4286,6 +4285,20 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty) if (remote_protocol_packets[PACKET_vAttach].support == PACKET_DISABLE) error (_("This target does not support attaching to a process")); + if (from_tty) + { + char *exec_file = get_exec_file (0); + + if (exec_file) + printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file, + target_pid_to_str (pid_to_ptid (pid))); + else + printf_unfiltered (_("Attaching to %s\n"), + target_pid_to_str (pid_to_ptid (pid))); + + gdb_flush (gdb_stdout); + } + sprintf (rs->buf, "vAttach;%x", pid); putpkt (rs->buf); getpkt (&rs->buf, &rs->buf_size, 0); @@ -4293,10 +4306,6 @@ extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty) if (packet_ok (rs->buf, &remote_protocol_packets[PACKET_vAttach]) == PACKET_OK) { - if (from_tty) - printf_unfiltered (_("Attached to %s\n"), - target_pid_to_str (pid_to_ptid (pid))); - if (!non_stop) { /* Save the reply for later. */ @@ -8823,7 +8832,9 @@ remote_pid_to_str (struct target_ops *ops, ptid_t ptid) static char buf[64]; struct remote_state *rs = get_remote_state (); - if (ptid_is_pid (ptid)) + if (ptid_equal (ptid, null_ptid)) + return normal_pid_to_str (ptid); + else if (ptid_is_pid (ptid)) { /* Printing an inferior target id. */ diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index 87a22de..ff1b6bc 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -160,6 +160,10 @@ proc do_attach_tests {} { # Response expected on Cygwin pass "$test" } + -re "Attaching to.*, process $boguspid.*failed.*$gdb_prompt $" { + # Response expected on the extended-remote target. + pass "$test" + } } # Verify that we can attach to the process by first giving its @@ -224,7 +228,8 @@ proc do_attach_tests {} { # Verify that we can attach to the process just by giving the # process ID. - set test "set file, before attach2" + set test "attach2, with no file" + set found_exec_file 0 gdb_test_multiple "attach $testpid" "$test" { -re "Attaching to process $testpid.*Load new symbol table from \"$escapedbinfile\.exe\".*y or n. $" { # On Cygwin, the DLL's symbol tables are loaded prior to the @@ -233,9 +238,25 @@ proc do_attach_tests {} { # executable. gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \ "$test (reset file)" + + set found_exec_file 1 } -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $" { pass "$test" + set found_exec_file 1 + } + } + + if {$found_exec_file == 0} { + set test "load file manually, after attach2" + gdb_test_multiple "file $binfile" "$test" { + -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $" { + gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \ + "$test (re-read)" + } + -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" { + pass "$test" + } } } diff --git a/gdb/testsuite/gdb.server/ext-attach.exp b/gdb/testsuite/gdb.server/ext-attach.exp index edf08fd..d9c7c0c 100644 --- a/gdb/testsuite/gdb.server/ext-attach.exp +++ b/gdb/testsuite/gdb.server/ext-attach.exp @@ -57,14 +57,16 @@ if { [istarget "*-*-cygwin*"] } { set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] } -gdb_test "attach $testpid" "Attached to.*" \ +gdb_test "attach $testpid" \ + "Attaching to program: .*, process $testpid.*(in|at).*" \ "attach to remote program 1" gdb_test "backtrace" ".*main.*" "backtrace 1" -gdb_test "detach" "Detached from remote process.*\\." +gdb_test "detach" "Detaching from program.*process.*" gdb_test "backtrace" "No stack\\." "backtrace with no program" -gdb_test "attach $testpid" "Attached to.*" \ +gdb_test "attach $testpid" \ + "Attaching to program: .*, process $testpid.*(in|at).*" \ "attach to remote program 2" gdb_test "backtrace" ".*main.*" "backtrace 2"