Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Luis Machado <lgustavo@codesourcery.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Cc: Daniel Jacobowitz <drow@false.org>,
	"Pedro Alves (palves@redhat.com)"	<palves@redhat.com>
Subject: RE: [ping] [PATCH 1/2] gdbserver: catch fetch registers error
Date: Wed, 04 Jan 2017 07:20:00 -0000	[thread overview]
Message-ID: <A78C989F6D9628469189715575E55B234003BEB5@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <d64c4dd6-e569-332b-2b44-eccd370120c5@codesourcery.com>

> -----Original Message-----
> From: Luis Machado [mailto:lgustavo@codesourcery.com]
> Sent: Tuesday, January 3, 2017 7:29 PM
> To: Metzger, Markus T <markus.t.metzger@intel.com>; gdb-
> patches@sourceware.org
> Cc: Daniel Jacobowitz <drow@false.org>; Pedro Alves (palves@redhat.com)
> <palves@redhat.com>
> Subject: Re: [ping] [PATCH 1/2] gdbserver: catch fetch registers error

Hi Luis,

Thanks for your feedback.

> >> When the PTRACE_PEEKUSER ptrace request to read registers fails, gdbserer
> >> throws
> >> an error that is caught in captured_main, where it causes a E01 error packet to
> >> be sent and gdbserer to quit (if --once was specified) or the event loop to be
> >> re-started (otherwise).
> >>
> >> We may get such ptrace errors when trying to fetch registers for an exited or
> >> running thread.  There are checks in GDB that check those conditions and
> throw
> >> meaningful error messages before we could run into the above ptrace error,
> >> e.g. thread.c:validate_registers_access.
> >>
> >> I ran into a new case and, rather than adding another call to
> >> validate_registers_access in GDB, I propose to catch the error already when
> >> handling the 'g' packet in gdbserver and reply with an error packet - assuming
> >> that gdbserver's internal state is still intact.
> >>
> >> To not replace a meaningful error message with E01, I'm trying to generate a
> >> useful error message when the error is detected and the exception is thrown.
> >>
> >> It would look like this ...
> >>
> >> gdb) PASS: gdb.btrace/enable-running.exp: continue to breakpoint: cont to 44
> >> cont&
> >> Continuing.
> >> (gdb) PASS: gdb.btrace/enable-running.exp: cont&
> >> record btrace
> >> warning: Remote failure reply: E.Selected thread is running.
> >> warning: Remote failure reply: E.Selected thread is running.
> >>
> >> ... although in this particular case, I'm going to suppress the warning.
> >>
> >> To make this look a bit nicer, we could consider stripping the "E." or the
> >> entire "Remote failure reply: E." when (re-)throwing the error inside GDB in
> >> remote.c.
[...] 
> Is this a guaranteed recoverable scenario? I've seen GDB get confused
> and mess up its internal state multiple times when it can't fetch
> something essential like memory or registers.
> 
> So, even if we handle things gracefully in gdbserver, does GDB handle
> that gracefully enough to carry on with a debugging session?

At the moment, GDBserver quits or starts over.  This is not recoverable as
GDB doesn't have a clue that GDBserver just started over.

This patch improves the situation by making GDBserver send an appropriate error
message to GDB and resume normally.  It suffices in one concrete case (see next
patch in series).  If in other cases GDB does not handle the error, I'd say we fix GDB
for those cases.

Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2017-01-04  7:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03 13:14 Metzger, Markus T
2017-01-03 18:29 ` Luis Machado
2017-01-04  7:20   ` Metzger, Markus T [this message]
2017-01-04 15:49     ` Luis Machado

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=A78C989F6D9628469189715575E55B234003BEB5@IRSMSX104.ger.corp.intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=lgustavo@codesourcery.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