Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: Pedro Alves <palves@redhat.com>
Cc: "Gary Benson" <gbenson@redhat.com>,
	gdb-patches@sourceware.org,
	"Joel Brobecker" <brobecker@adacore.com>,
	"Doug Evans" <dje@google.com>,
	"Jan Kratochvil" <jan.kratochvil@redhat.com>,
	"André Pönitz" <apoenitz@t-online.de>,
	"Paul Koning" <Paul_Koning@dell.com>
Subject: Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:"
Date: Thu, 20 Aug 2015 18:23:00 -0000	[thread overview]
Message-ID: <55D61AA2.5000502@codesourcery.com> (raw)
In-Reply-To: <55D607B8.70103@redhat.com>

On 08/20/2015 11:00 AM, Pedro Alves wrote:
> On 08/20/2015 04:51 PM, Pedro Alves wrote:
>
>> I don't see a quick, easy and good way around waiting for the whole file to read.
>> Having GDB handle ctrl-c differently while it is handling internal events
>> is already a source of trouble, and the fix always seemed to me to be to make ctrl-c
>> work like what is happening here.  Specifically, I mean that e.g., say that the
>> user sets a conditional breakpoint that is evaluated on gdb's side, and then the
>> target stops for that conditional breakpoint, gdb evaluates the expression,
>> and then resumes the target again, on and on.  If the user presses ctrl-c just
>> while the conditional breakpoint's expression is being evaluated, and something along
>> that code path called target_terminal_ours (thus pulling input/ctrl-c to the
>> regular "Quit" SIGINT handler), gdb behaves differently (shows a "Quit" and the
>> debug session ends up likely broken) from when the ctrl-c is pressed while the target
>> is really running.  I'd argue that the ctrl-c in both cases should be passed
>> down all the way to the target the same way, and that any internal stop and
>> breakpoint condition evaluation is magic that should be hidden.  Just like
>> what is happening here with file reading.
>>
>> Though having said that, it does look like even that isn't working properly,
>> as I'd expect this:
>>
>> (top-gdb) c
>> Continuing.
>> (no debugging symbols found)...done.
>>
>> Breakpoint 1, main (argc=1, argv=0x7fffffffe3d8) at ../../../src/gdb/gdbserver/server.c:3635
>> 3635    ../../../src/gdb/gdbserver/server.c: No such file or directory.
>> (gdb)
>>
>> to be slow (that is, the file reading isn't really interrupted), but then
>> the target stops with SIGINT as soon as gdb resumes it again after reading
>> the DSOs.  But it is reaching main anyway, and there's no sign
>> of "Program stopped with SIGINT"...
>>
>> Not sure where the bug is.  It may be on the gdbserver side.
>
> OK, so gdbserver receives the \003, but since the target is stopped,
> the normal packet processing loop discards the \003, as it doesn't
> look like a start of a RSP packet frame (that is, it isn't a $).
>
> I'm thinking that maybe the best way to handle this may be to still
> leave SIGINT forwarding to the target, so that in case gdb re-resumes
> the target quick enough, the ctrl-c turns into a real SIGINT on the
> target.  But then if it takes long for gdb or gdbserver or the target
> to react to the ctrl-c, then the user presses ctrl-c again, and gdb
> shows the old:
>
>    Interrupted while waiting for the program.
>    Give up (and stop debugging it)? (y or n)
>
> AFAICS, that query is never issued anywhere if the target
> is async.  And the remote target is always async nowadays.
>
> To make that query appear promptly, we'd hook it to the
> QUIT macro.  Something like this:
>
> (gdb) c
> Continuing.
> Reading symbols from target:/lib/x86_64-linux-gnu/libdl.so.2...(no debugging symbols found)...done.
> Reading symbols from target:/lib/x86_64-linux-gnu/libc.so.6...(no debugging symbols found)...done.
> ^CInterrupted while waiting for the program.
> Give up (and stop debugging it)? (y or n) y
> Quit
> (gdb)
>
> Could you try the hacky patch below just to see if it makes a
> difference to you?  It seems that GDB still doesn't react
> as soon as it could, but I'd guess that Gary's previous patch
> to add a QUIT around vFile:pread's would fix that.

Thanks!  The combination of these two patches does make GDB respond 
quickly to the second ^C and abort the file transfer.  However, both GDB 
and gdbserver seem to be left in a wonky state.  On the GDB side, I'm 
seeing:

(gdb) c
Continuing.
^C^CInterrupted while waiting for the program.
Give up (and stop debugging it)? (y or n) Interrupted while waiting for 
the program.
y
You can't do that when your target is `exec'
No registers.
(gdb)

And, meanwhile on the target, gdbserver has done this:

Process a.out created; pid = 856
Listening on port 6789
Remote debugging from host 134.86.188.141
readchar: Got EOF
Remote side has terminated connection.  GDBserver will reopen the 
connection.
/scratch/sandra/nios2-linux-trunk/src/gdb-nios2r2/gdb/gdbserver/../common/cleanups.c:265: 
A problem internal to GDBserver has been detected.
restore_my_cleanups has found a stale cleanup
Listening on port 6789

I was thinking that the "right" behavior here would be for GDB to just 
try to continue without library symbol or debug information if the file 
transfer is interrupted, but a clean shutdown with fewer confusing 
messages would be OK, too.  Especially if we've given users a hint that 
they need "set sysroot", the probable scenario is for the user to start 
over with a fresh GDB and add that command before "target remote".

-Sandra



  reply	other threads:[~2015-08-20 18:23 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-11 17:22 [PATCH 0/2] Better handling of slow remote transfers Doug Evans
2015-08-11 18:55 ` Jan Kratochvil
2015-08-11 19:44   ` Doug Evans
2015-08-11 19:59     ` Joel Brobecker
2015-08-12  9:48       ` Gary Benson
2015-08-12 10:10         ` Pedro Alves
2015-08-12 10:38           ` Gary Benson
2015-08-12 11:29             ` Pedro Alves
2015-08-12 12:32               ` Gary Benson
2015-08-12 12:51                 ` Pedro Alves
2015-08-12 13:02                   ` Gary Benson
2015-08-12 13:34                     ` Pedro Alves
2015-08-12 13:38                       ` Gary Benson
2015-08-12 13:44                         ` Gary Benson
2015-08-12 13:58                         ` Pedro Alves
2015-08-12 14:44                           ` Pedro Alves
2015-08-12 15:08                             ` Gary Benson
2015-08-12 15:31                               ` Pedro Alves
2015-08-12 15:45                                 ` Gary Benson
2015-08-12 13:29                   ` Gary Benson
2015-08-14 18:26         ` Joel Brobecker
2015-08-14 22:26           ` Sandra Loosemore
2015-08-16 18:49             ` Joel Brobecker
     [not found]               ` <20150817085310.GC25320@blade.nx>
2015-08-17 14:26                 ` Sandra Loosemore
2015-08-18  9:59                   ` Gary Benson
2015-08-18 16:52                     ` Sandra Loosemore
2015-08-19  1:27                       ` Pedro Alves
2015-08-19 10:41                         ` [PATCH] Prelimit number of bytes to read in "vFile:pread:" Gary Benson
2015-08-19 10:51                           ` Gary Benson
2015-08-19 12:00                             ` Pedro Alves
2015-08-19 16:43                             ` Sandra Loosemore
2015-08-19 17:21                               ` Gary Benson
2015-08-19 21:14                                 ` Sandra Loosemore
2015-08-20 14:48                                   ` Pedro Alves
2015-08-20 15:52                                   ` Pedro Alves
2015-08-20 17:00                                     ` Pedro Alves
2015-08-20 18:23                                       ` Sandra Loosemore [this message]
2015-08-21 14:52                                         ` [PATCH] remote: allow aborting long operations (e.g., file transfers) (Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:") Pedro Alves
2015-08-21 17:12                                           ` Sandra Loosemore
2015-08-21 17:27                                             ` Pedro Alves
2015-08-25 10:57                                               ` Pedro Alves
2015-08-25 15:36                                                 ` Pedro Alves
2015-08-25 20:19                                                   ` GDB 7.10 release tentative date: Fri Aug 28 (was: "Re: [PATCH] remote: allow aborting long operations (e.g., file transfers) (Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:")") Joel Brobecker
2015-08-24  8:45                                             ` [PATCH] remote: allow aborting long operations (e.g., file transfers) (Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:") Gary Benson
2015-08-19 11:44                           ` [PATCH] Prelimit number of bytes to read in "vFile:pread:" Pedro Alves
2015-08-19 13:07                             ` [pushed] " Gary Benson
2015-08-19 13:42                         ` [PATCH 0/2] Better handling of slow remote transfers Gary Benson
2015-08-20 14:46                           ` Pedro Alves
2015-08-20 18:01                             ` Gary Benson
2015-08-21  9:34                               ` [pushed] Add readahead cache to gdb's vFile:pread (Re: [PATCH 0/2] Better handling of slow remote transfers) Pedro Alves
2015-08-11 20:00     ` [PATCH 0/2] Better handling of slow remote transfers Jan Kratochvil
2015-08-12 10:05 ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55D61AA2.5000502@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=Paul_Koning@dell.com \
    --cc=apoenitz@t-online.de \
    --cc=brobecker@adacore.com \
    --cc=dje@google.com \
    --cc=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox