public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ciaran Woodward <ciaranwoodward@xmos.com>
To: Simon Marchi <simark@simark.ca>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH] gdb: Fix missing first breakpoint in schedule-multiple mode
Date: Tue, 26 Jul 2022 13:16:43 +0000	[thread overview]
Message-ID: <DB9PR09MB4988AB824E4A1ACB991604FCB9949@DB9PR09MB4988.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <7663ddf6-82f7-5d4f-836a-e0a93daa0f2b@simark.ca>

> Can you please provide some reproducing steps?  Some simple test
> programs along with the sequence of GDB commands to use.  This way, we'll
> be sure we look at the same problem.

Hi Simon,

Sure! The way I actually found this was when connected to a stub which
supports the multi process extensions of the remote serial protocol.
I managed to reproduce it using gdbserver on a linux system, but the
procedure is a bit more obscure:

In the case of the stub I am using, the 'processes' are actually hardware
cores, and so they already exist when you first connect to the remote.
In this reproduction, I run gdb twice - once to set up the remote state,
then a second time to connect to multiple processes at the same time, which
is what produces the issue. There may well be a simpler way to do this.

The program to reproduce is simple:

// run.c ---------------
#include <unistd.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
        printf("1\n");
        sleep(2);
        printf("2\n");
        sleep(2);
        printf("3\n");

        while (1)
        {
                sleep(1);
                printf(".");
        }
}
// end run.c -------------

And I compiled it simply with: gcc -g run.c

Then to reproduce:

Run: gdbserver --multi :2331
# leave this running

Run: gdb
target extended-remote :2331
set schedule-multiple off
add-inferior
set remote exec-file ~/test/a.out
file ~/test/a.out
start
infe 2
file ~/test/a.out
start
disconnect
q
# now we have exited this instance of gdb
# gdbserver is still running, with 2 frozen processes

Run: gdb
target extended-remote :2331
# At this point, gdb has recognised both inferiors,
# but only sets the control->stop_soon field to STOP_QUIETLY_REMOTE
# on inferior 2. (which may also be a bug - maybe should be both)
set schedule-multiple on
infe 2
file ~/test/a.out
infe 1
file ~/test/a.out
break run.c:7
break run.c:10
dis 1.2
dis 2.1
c
# At this point, GDB sets the control->stop_soon field to NO_STOP_QUIETLY
# but only on the currently selected inferior (1).
# first breakpoint hit, inferior 1
c
# second break never hit, Ctrl-c also doesn't stop.

Cheers,
Ciaran

  reply	other threads:[~2022-07-26 13:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25 16:22 Ciaran Woodward
2022-07-25 17:02 ` Simon Marchi
2022-07-26 13:16   ` Ciaran Woodward [this message]
2022-08-09 15:00 ` [PING] " Ciaran Woodward
2022-08-23 16:30 ` [PING 2][PATCH] " Ciaran Woodward
2022-08-31 10:11 ` [PING 3][PATCH] " Ciaran Woodward
2022-09-22 13:22 ` [PING 4][PATCH] " Ciaran Woodward

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=DB9PR09MB4988AB824E4A1ACB991604FCB9949@DB9PR09MB4988.eurprd09.prod.outlook.com \
    --to=ciaranwoodward@xmos.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).