This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: redirect gdbserver stderr/debug vim via gdbserver


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]