Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* redirect gdbserver stderr/debug vim via gdbserver
@ 2017-03-04  0:09 Matt
  2017-03-07  0:12 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Matt @ 2017-03-04  0:09 UTC (permalink / raw)
  To: gdb

Hi,

I am trying to debug a console application  (neovim) with gdbserver.
 I've tried turning off all debug info from gdbserver (via monitor set
debug/remote-debug ...), yet I still see "Detaching from process"
mixed up with the debugged CLI application. In order to make these
messages disappear, I tried redirecting gdbserver stderr (zsh) to
'temp':
$ gdbserver localhost:7777 ./build/bin/nvim toto 2>temp
on the other side (same computer) I connect with:
$ gdb ./build/bin/nvim
(gdb) target remote :7777
(gdb) c

but then nothing appears on the gdbserver terminal, i.e., I can't see
neovim interface. Why is that ?

Best regards
Matt


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: redirect gdbserver stderr/debug vim via gdbserver
  2017-03-04  0:09 redirect gdbserver stderr/debug vim via gdbserver Matt
@ 2017-03-07  0:12 ` Simon Marchi
  2017-03-07  0:18   ` Matt
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2017-03-07  0:12 UTC (permalink / raw)
  To: Matt; +Cc: gdb

On 2017-03-03 19:09, Matt wrote:
> Hi,
> 
> I am trying to debug a console application  (neovim) with gdbserver.
>  I've tried turning off all debug info from gdbserver (via monitor set
> debug/remote-debug ...), yet I still see "Detaching from process"
> mixed up with the debugged CLI application.

If it's just a cosmetic thing and want to clean up nvim's UI, you can 
type ctrl-L to make nvim redraw it.

I don't think it's possible currently to make gdbserver silent or output 
somewhere else than stderr.  The easiest workaround, if that fits your 
needs, would be to first start nvim and then attach gdbserver from 
another terminal.  e.g.:

   $ gdbserver --once --attach :1234 $(pidof nvim)

If you need to debug a problem that happens at the startup of the 
program, then it's not ideal.  You can always resort to adding a sleep 
at the beginning to give you time to attach, or a while loop on a 
volatile variable that you change from GDB to let the program run.

> In order to make these
> messages disappear, I tried redirecting gdbserver stderr (zsh) to
> 'temp':
> $ gdbserver localhost:7777 ./build/bin/nvim toto 2>temp
> on the other side (same computer) I connect with:
> $ gdb ./build/bin/nvim
> (gdb) target remote :7777
> (gdb) c
> 
> but then nothing appears on the gdbserver terminal, i.e., I can't see
> neovim interface. Why is that ?

I don't know, but I would assume that nvim inherits that redirected 
stderr, maybe that's not good.

Simon


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: redirect gdbserver stderr/debug vim via gdbserver
  2017-03-07  0:12 ` Simon Marchi
@ 2017-03-07  0:18   ` Matt
  0 siblings, 0 replies; 3+ messages in thread
From: Matt @ 2017-03-07  0:18 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb

thanks for the help.
Truth is I found a solution today. I first checked if file descriptors
were correctly passed to nvim and it seemed so.
On the gdb client, I was receiving SIGTTIN and SIGTTOU signals, which
after some research revealed to me that the nvim terminal UI was
running as a background process.
I checked gdbserver code and saw that it was correctly changing the
foreground process so the problem had to lie with nvim. Indeed it was
running the UI in another process and as such, in background.
I've added those 2 lines to neovim src/nvim/tui.c and it worked
perfectly, even when redirecting gdbserver stderr !

signal (SIGTTOU, SIG_IGN);
if (!tcsetpgrp(data->input.in_fd, getpid())) {
    perror("tcsetpgrp failed");
}

Thanks for the help

Cheers
Matt

2017-03-07 1:12 GMT+01:00 Simon Marchi <simon.marchi@polymtl.ca>:
> On 2017-03-03 19:09, Matt wrote:
>>
>> Hi,
>>
>> I am trying to debug a console application  (neovim) with gdbserver.
>>  I've tried turning off all debug info from gdbserver (via monitor set
>> debug/remote-debug ...), yet I still see "Detaching from process"
>> mixed up with the debugged CLI application.
>
>
> If it's just a cosmetic thing and want to clean up nvim's UI, you can type
> ctrl-L to make nvim redraw it.
>
> I don't think it's possible currently to make gdbserver silent or output
> somewhere else than stderr.  The easiest workaround, if that fits your
> needs, would be to first start nvim and then attach gdbserver from another
> terminal.  e.g.:
>
>   $ gdbserver --once --attach :1234 $(pidof nvim)
>
> If you need to debug a problem that happens at the startup of the program,
> then it's not ideal.  You can always resort to adding a sleep at the
> beginning to give you time to attach, or a while loop on a volatile variable
> that you change from GDB to let the program run.
>
>> In order to make these
>> messages disappear, I tried redirecting gdbserver stderr (zsh) to
>> 'temp':
>> $ gdbserver localhost:7777 ./build/bin/nvim toto 2>temp
>> on the other side (same computer) I connect with:
>> $ gdb ./build/bin/nvim
>> (gdb) target remote :7777
>> (gdb) c
>>
>> but then nothing appears on the gdbserver terminal, i.e., I can't see
>> neovim interface. Why is that ?
>
>
> I don't know, but I would assume that nvim inherits that redirected stderr,
> maybe that's not good.
>
> Simon


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-07  0:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-04  0:09 redirect gdbserver stderr/debug vim via gdbserver Matt
2017-03-07  0:12 ` Simon Marchi
2017-03-07  0:18   ` Matt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox