]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdbsupport] Add gdb::{waitpid,read,write,close}
authorTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 16:44:29 +0000 (17:44 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 16:44:29 +0000 (17:44 +0100)
commit658a03e9e85698fa8815915d1a858371ea51da83
tree902c3dec08c0ece2695f535c565eefbb8da790d3
parent26522e34802f32406eb653d91a3bbb509f919b30
[gdbsupport] Add gdb::{waitpid,read,write,close}

We have gdb::handle_eintr, which allows us to rewrite:
...
  ssize_t ret;
    do
      {
        errno = 0;
        ret = ::write (pipe[1], "+", 1);
      }
    while (ret == -1 && errno == EINTR);
...
into:
...
  ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1);
...

However, the call to write got a bit mangled, requiring effort to decode it
back to its original form.

Instead, add a new function gdb::write that allows us to write:
...
  ssize_t ret = gdb::write (pipe[1], "+", 1);
...

Likewise for waitpid, read and close.

Tested on x86_64-linux.
gdb/cli/cli-cmds.c
gdb/nat/linux-waitpid.c
gdbserver/netbsd-low.cc
gdbsupport/eintr.h