Subject: bug#63084: 30.0.50; gud: set breakpoint while program is running

From: Eli Zaretskii <[email-masked]>
Date: Fri, 05 May 2023 08:52:26 +0300

Ping!  Ken, could you please look into this, if you have time?

> Cc: [email-masked], [email-masked]
> Date: Wed, 26 Apr 2023 14:19:31 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > Cc: [email-masked]
> > Date: Wed, 26 Apr 2023 12:44:29 +0300
> > From: Eli Zaretskii <[email-masked]>
> > 
> > > From: TatriX <[email-masked]>
> > > Date: Wed, 26 Apr 2023 10:48:53 +0200
> > > Cc: [email-masked]
> > > 
> > > Oh, sorry. I tried on a different machine, and realized one have to use "run&".
> > > 
> > > So, here's what I did:
> > > 
> > > $ cat main.c
> > >     #include <stdio.h>
> > >     #include <unistd.h>
> > > 
> > >     int main(void) {
> > >         for (int i = 0; ; i++) {
> > >             printf("%d\n", i);
> > >             sleep(1);
> > >         }
> > >     }
> > > 
> > > $ gcc -g -o break main.c
> > > $ emacs -Q main.c
> > > M-x gdb RET
> > > # in *gud-break*, NOTE it's "run&"
> > > (gdb) run&
> > > # in main.c
> > > (goto-line 6)
> > > (gud-break 1) ; or C-x C-a C-b
> > > # nothing happens
> > > M-: (gud-call "break 6") RET
> > > # breakpoint is set and process execution is paused on hitting that breakpoint
> > 
> > What is the value of gdb-running and of gdb-non-stop after you "run&"
> > the program?
> 
> Ken, could you please take a look at this bug report?  AFAICT, it has
> something to do with the code you changed some 11 years ago (see
> bug#9878).
> 
> Basically, what "M-x gdb" now does is send the "-gdb-set non-stop 1"
> command, then, when we get a valid response for it, it sends the
> "-gdb-set target-async 1" command.  So far so good, but when we get
> the response for the latter, we send the "-list-target-features"
> command and expect it to report "async" as one of the features, and if
> not, we decide that non-stop mode is not supported.
> 
> My testing indicates that -list-target-features will only report
> "async" after we run the program or attach to a process.  So we are
> (almost) always disabling the non-stop mode, which doesn't seem right
> to me.
> 
> So I'm interested to know how you tested this particular addition of
> the -list-target-features command back then (if you remember).  Also,
> what happens today when you start "M-x gdb" with a modern version of
> GDB that does support target-async and non-stop mode.
> 
> The root cause that "C-x C-a C-b" doesn't work in the OP is that
> gud-break (and any other command defined via gud-def) does nothing
> when gud-running is non-nil.  This needs to be changed if we are
> running the program in the background, but the question is how to know
> that reliably, and that is related -list-target-features, among other
> things.
> 
> TIA
> 
> 
> 
>