Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: luisgpm@linux.vnet.ibm.com
Cc: Nick Roberts <nickrob@snap.net.nz>,  gdb-patches@sourceware.org
Subject: Re: linux native async mode support
Date: Wed, 19 Mar 2008 23:19:00 -0000	[thread overview]
Message-ID: <200803192318.45355.pedro@codesourcery.com> (raw)
In-Reply-To: <1205943875.32489.10.camel@gargoyle.br.ibm.com>

A Wednesday 19 March 2008 16:24:35, Luis Machado wrote:
> Hi folks,
>
> I've ran the testsuite on PPC to check for regressions due to the async
> patch. The results look good, just the expected regressions and one
> unexpected (mi2-simplerun.exp).
>

Thanks both for testing, and thanks Luis for sending me the full logs!

> mi2-simplerun.exp:
> FAIL: gdb.mi/mi2-simplerun.exp: continue to end (1)
>
> Nick, i still can reproduce the last one constantly.

> >
> > 999-exec-continue
> > 999^running
> > Hello, World!callme
> > callme
> > (gdb)
> > 999*stopped,reason="exited-normally"
> > (gdb)
> > FAIL: gdb.mi/mi2-simplerun.exp: continue to end (1)
> >

I've looked at this failure, and what happens is that
in sync mode, gdb prompts "(gdb)" immediatelly
after printing "^running", while in async mode,
"^running" is output first, and only when "run" cli command
actually completes, the "(gdb) " is output.  Like so:

mi_execute_command
 captured_mi_execute_command
  mi_execute_async_cli_command
   mi_cmd_execute
    mi_cmd_exec_run
     mi_execute_async_cli_command 
      sets up continuation for "*stopped", if async mode.
      execute_command
       (...)
        run_command_1
         target_create_inferior
         proceed
 prints ("gdb") before exiting.

later, when inferior exits, the mi_exec_async_cli_cmd_continuation is called,
which prints that part:
> > 999*stopped,reason="exited-normally"
> > (gdb)

Here's a bit of current code:

enum mi_cmd_result
mi_execute_async_cli_command (char *mi, char *args, int from_tty)
{
  struct cleanup *old_cleanups;
  char *run;
  char *async_args;

  if (target_can_async_p ())
    {
      async_args = (char *) xmalloc (strlen (args) + 2);
      make_exec_cleanup (free, async_args);
      strcpy (async_args, args);
      strcat (async_args, "&");
      run = xstrprintf ("%s %s", mi, async_args);
      make_exec_cleanup (free, run);
      add_continuation (mi_exec_async_cli_cmd_continuation, NULL);
      old_cleanups = NULL;
    }
  else
    {
      run = xstrprintf ("%s %s", mi, args);
      old_cleanups = make_cleanup (xfree, run);
    }

  if (!target_can_async_p ())
    {
      /* NOTE: For synchronous targets asynchronous behavour is faked by
         printing out the GDB prompt before we even try to execute the
         command.  */
      if (last_async_command)
	fputs_unfiltered (last_async_command, raw_stdout);
      fputs_unfiltered ("^running\n", raw_stdout);
      fputs_unfiltered ("(gdb) \n", raw_stdout);  <<<<< sync mode
                                                        prints it early.
      gdb_flush (raw_stdout);
    }
  else
    {
      /* FIXME: cagney/1999-11-29: Printing this message before
         calling execute_command is wrong.  It should only be printed
         once gdb has confirmed that it really has managed to send a
         run command to the target.  */
      if (last_async_command)
	fputs_unfiltered (last_async_command, raw_stdout);
      fputs_unfiltered ("^running\n", raw_stdout);  <<<<< async mode
                                                   defers the "(gdb)" printing
    }

  execute_command ( /*ui */ run, 0 /*from_tty */ );

  (...)
}

So, -exec-run, in async mode, is turned into CLI's "run &", which ends
up in run_command_1.  At the end of it, after calling target_create_inferior
and friends, we do proceed.  So at this point the inferior as already started
running, and we haven't printed "(gdb)" yet.  We'll only print *after*
creating the inferior and proceed'ing.  There you have the difference to sync
mode.  It's really a timing issue, and that's why I can't reproduce -- it
is timing/host sensitive.  So this means this problem isn't related to my
patch, but it's a general async issue, that may be visible too in
"target async" connected to a gdbserver for example.  Although
since we're running over a slower link there, nobody was probably seeing
it.  I don't know enough MI to say if this is according to the spec
or not, but it feels like a testsuite deficiency, is it not?

-- 
Pedro Alves


  reply	other threads:[~2008-03-19 23:19 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14  8:11 Pedro Alves
2008-03-14 21:17 ` Daniel Jacobowitz
2008-03-17 16:05   ` Pedro Alves
2008-03-17 22:05     ` Daniel Jacobowitz
2008-03-18 23:27       ` Pedro Alves
2008-03-18 23:58         ` Daniel Jacobowitz
2008-03-21 15:55         ` Daniel Jacobowitz
2008-03-21 17:19           ` Pedro Alves
2008-03-28 14:48             ` Maciej W. Rozycki
2008-03-28 16:07               ` Pedro Alves
2008-03-28 16:13                 ` Daniel Jacobowitz
2008-03-28 16:40                   ` Pedro Alves
2008-03-18  0:06     ` Nick Roberts
2008-03-18 23:28       ` Pedro Alves
2008-03-19  3:59         ` Nick Roberts
2008-03-19 16:25           ` Luis Machado
2008-03-19 23:19             ` Pedro Alves [this message]
2008-03-19 23:26               ` Pedro Alves
2008-03-20  1:58               ` Nick Roberts
2008-03-21 15:47                 ` Daniel Jacobowitz
2008-03-21 15:49       ` Daniel Jacobowitz
2008-03-21 23:02         ` Nick Roberts
2008-03-22  1:25           ` Daniel Jacobowitz
2008-03-22 22:06             ` Nick Roberts
2008-04-01 14:00               ` Daniel Jacobowitz
2008-04-01 15:17               ` Vladimir Prus
2008-04-01 20:09                 ` Nick Roberts
2008-04-04 12:34                   ` Vladimir Prus
2008-04-05 17:20                     ` Nick Roberts
2008-04-05 22:07                       ` Vladimir Prus
2008-04-07  0:06                         ` Nick Roberts
2008-04-07  2:33                         ` Nick Roberts
2008-03-18  2:47     ` Nick Roberts
2008-03-14 23:10 ` Nick Roberts
2008-03-15  1:58   ` Pedro Alves
2008-03-15  3:11     ` Daniel Jacobowitz
2008-03-17 23:41     ` Nick Roberts

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=200803192318.45355.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luisgpm@linux.vnet.ibm.com \
    --cc=nickrob@snap.net.nz \
    /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