Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb@sourceware.org
Cc: "Marc Khouzam" <marc.khouzam@ericsson.com>
Subject: Re: Async mode and setting breakpoints
Date: Thu, 18 Dec 2008 16:50:00 -0000	[thread overview]
Message-ID: <200812181649.37699.pedro@codesourcery.com> (raw)
In-Reply-To: <6D19CA8D71C89C43A057926FE0D4ADAA06AA14F6@ecamlmw720.eamcs.ericsson.se>

Hi Marc,

On Thursday 18 December 2008 15:41:33, Marc Khouzam wrote:
> I'm investigating the value of using async mode without non-stop
> to decide if I should use it whenever possible for DSF-GDB.
> 
> The main advantage I was seeking was to be able to set a breakpoint
> while the target was running.  It does not work though.
> I'm guessing that while the inferior is running, it is not possible
> for GDB to plant the breakpoint (although the bp command is accepted
> without complaint).  I guess I still have to interrupt the inferior, 
> set the bp, and resume, even in async mode?

Short answer, yes, in all async capable targets currently supported by GDB
(that's linux native and remote).

This is target dependent, on two levels.

On native linux, inserting a breakpoint in all-stop,async will fail when
the target is running, because it isn't possible to patch memory when
the target is running.  GDB could be momentarily stopping an LWP of the
inferior process to do this, but it isn't.  There are some threads in
the archives about this.

The remote target is a bit more complicated.  Against remote targets, even
if the OS allows patching memory or inserting breakpoints to running
processes, due to the design of the years old standard all-stop remote
protocol, it is not possible to issue any command to the remote while
the target is running.

Inserting a breakpoint requires talking to the remote side.

In more detail, after GDB issues a resume request (vCont, s, c, etc.), the
remote side will not be ready for any other packet.  GDB can only send
an interrupt request (which is really an out of band request) in this state,
or wait for a stop reply.  If GDB did send another packet in this state, both the
stub and GDB would end up confused.  To prevent this, if this condition
is detected, GDB errors out with "Cannot execute this command while the target
is running." (remote.c:putpkt_binary).

This means that in all-stop + async + remote, any GDB command that tries
to talk to the remote side while the remote is running will error out.  Any
command that *doesn't* talk to the remote side will still work.

The non-stop version of the remote protocol removed this protocol level
limitation, mostly by making stop replies asynchronous, so the stub can
accept more commands while the target is running.  It is still dependent on
the stub/OS if it is possible to insert breakpoints or patch memory while the
target is running though.  Same in native non-stop.

-- 
Pedro Alves


      reply	other threads:[~2008-12-18 16:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-18 15:42 Marc Khouzam
2008-12-18 16:50 ` Pedro Alves [this message]

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=200812181649.37699.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb@sourceware.org \
    --cc=marc.khouzam@ericsson.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