mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 19:09:31 +08:00
gdb::handle_eintr, remove need to specify return type
This eliminates the need to specify the return type when using handle_eintr. We let the compiler deduce it for us. Also, use lowercase for function parameter names. Uppercase should only be used on template parameters. gdb/ChangeLog: * nat/linux-waitpid.c: Include "gdbsupport/eintr.h". (my_waitpid): Use gdb::handle_eintr. gdbserver/ChangeLog: * netbsd-low.cc (netbsd_waitpid, netbsd_process_target::kill) (netbsd_qxfer_libraries_svr4): Use gdb::handle_eintr without explicit type. gdbsupport/ChangeLog: * eintr.h (handle_eintr): Replace Ret template parameter with ErrorValType. Use it as type of the failure value. Deduce the function's return type using decltype. Use lowercase for function parameter names.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2020-10-26 Pedro Alves <pedro@palves.net>
|
||||||
|
|
||||||
|
* nat/linux-waitpid.c: Include "gdbsupport/eintr.h".
|
||||||
|
(my_waitpid): Use gdb::handle_eintr.
|
||||||
|
|
||||||
2020-10-25 Simon Marchi <simon.marchi@polymtl.ca>
|
2020-10-25 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* acinclude.m4: Update ptrace.m4 path.
|
* acinclude.m4: Update ptrace.m4 path.
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "linux-nat.h"
|
#include "linux-nat.h"
|
||||||
#include "linux-waitpid.h"
|
#include "linux-waitpid.h"
|
||||||
#include "gdbsupport/gdb_wait.h"
|
#include "gdbsupport/gdb_wait.h"
|
||||||
|
#include "gdbsupport/eintr.h"
|
||||||
|
|
||||||
/* Convert wait status STATUS to a string. Used for printing debug
|
/* Convert wait status STATUS to a string. Used for printing debug
|
||||||
messages only. */
|
messages only. */
|
||||||
@ -54,13 +55,5 @@ status_to_str (int status)
|
|||||||
int
|
int
|
||||||
my_waitpid (int pid, int *status, int flags)
|
my_waitpid (int pid, int *status, int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
return gdb::handle_eintr (-1, ::waitpid, pid, status, flags);
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ret = waitpid (pid, status, flags);
|
|
||||||
}
|
|
||||||
while (ret == -1 && errno == EINTR);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2020-10-26 Pedro Alves <pedro@palves.net>
|
||||||
|
|
||||||
|
* netbsd-low.cc (netbsd_waitpid, netbsd_process_target::kill)
|
||||||
|
(netbsd_qxfer_libraries_svr4): Use gdb::handle_eintr without
|
||||||
|
explicit type.
|
||||||
|
|
||||||
2020-10-25 Simon Marchi <simon.marchi@polymtl.ca>
|
2020-10-25 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* acinclude.m4: Update ptrace.m4 path.
|
* acinclude.m4: Update ptrace.m4 path.
|
||||||
|
@ -232,7 +232,7 @@ netbsd_waitpid (ptid_t ptid, struct target_waitstatus *ourstatus,
|
|||||||
int options = (target_options & TARGET_WNOHANG) ? WNOHANG : 0;
|
int options = (target_options & TARGET_WNOHANG) ? WNOHANG : 0;
|
||||||
|
|
||||||
pid_t pid
|
pid_t pid
|
||||||
= gdb::handle_eintr<int> (-1, ::waitpid, ptid.pid (), &status, options);
|
= gdb::handle_eintr (-1, ::waitpid, ptid.pid (), &status, options);
|
||||||
|
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
perror_with_name (_("Child process unexpectedly missing"));
|
perror_with_name (_("Child process unexpectedly missing"));
|
||||||
@ -443,7 +443,7 @@ netbsd_process_target::kill (process_info *process)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
if (gdb::handle_eintr<int> (-1, ::waitpid, pid, &status, 0) == -1)
|
if (gdb::handle_eintr (-1, ::waitpid, pid, &status, 0) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
mourn (process);
|
mourn (process);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1136,15 +1136,15 @@ netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex,
|
|||||||
static bool
|
static bool
|
||||||
elf_64_file_p (const char *file)
|
elf_64_file_p (const char *file)
|
||||||
{
|
{
|
||||||
int fd = gdb::handle_eintr<int> (-1, ::open, file, O_RDONLY);
|
int fd = gdb::handle_eintr (-1, ::open, file, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
perror_with_name (("open"));
|
perror_with_name (("open"));
|
||||||
|
|
||||||
Elf64_Ehdr header;
|
Elf64_Ehdr header;
|
||||||
ssize_t ret = gdb::handle_eintr<ssize_t> (-1, ::read, fd, &header, sizeof (header));
|
ssize_t ret = gdb::handle_eintr (-1, ::read, fd, &header, sizeof (header));
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
perror_with_name (("read"));
|
perror_with_name (("read"));
|
||||||
gdb::handle_eintr<int> (-1, ::close, fd);
|
gdb::handle_eintr (-1, ::close, fd);
|
||||||
if (ret != sizeof (header))
|
if (ret != sizeof (header))
|
||||||
error ("Cannot read ELF file header: %s", file);
|
error ("Cannot read ELF file header: %s", file);
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2020-10-26 Pedro Alves <pedro@palves.net>
|
||||||
|
|
||||||
|
* eintr.h (handle_eintr): Replace Ret template parameter with
|
||||||
|
ErrorValType. Use it as type of the failure value. Deduce the
|
||||||
|
function's return type using decltype. Use lowercase for function
|
||||||
|
parameter names.
|
||||||
|
|
||||||
2020-10-25 Simon Marchi <simon.marchi@polymtl.ca>
|
2020-10-25 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* Makefile.in: Re-generate.
|
* Makefile.in: Re-generate.
|
||||||
|
@ -43,25 +43,29 @@ namespace gdb
|
|||||||
|
|
||||||
You could wrap it by writing the wrapped form:
|
You could wrap it by writing the wrapped form:
|
||||||
|
|
||||||
ssize_t ret = gdb::handle_eintr<ssize_t> (-1, ::write, pipe[1], "+", 1);
|
ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1);
|
||||||
|
|
||||||
The RET typename specifies the return type of the wrapped system call, which
|
ERRVAL specifies the failure value indicating that the call to the
|
||||||
is typically int or ssize_t. The R argument specifies the failure value
|
F function with ARGS... arguments was possibly interrupted with a
|
||||||
indicating the interrupted syscall when calling the F function with
|
signal. */
|
||||||
the A... arguments. */
|
|
||||||
|
|
||||||
template <typename Ret, typename Fun, typename... Args>
|
template<typename ErrorValType, typename Fun, typename... Args>
|
||||||
inline Ret handle_eintr (const Ret &R, const Fun &F, const Args &... A)
|
inline auto
|
||||||
|
handle_eintr (ErrorValType errval, const Fun &f, const Args &... args)
|
||||||
|
-> decltype (f (args...))
|
||||||
{
|
{
|
||||||
Ret ret;
|
decltype (f (args...)) ret;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ret = F (A...);
|
ret = f (args...);
|
||||||
}
|
}
|
||||||
while (ret == R && errno == EINTR);
|
while (ret == errval && errno == EINTR);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} /* namespace gdb */
|
||||||
|
|
||||||
#endif /* GDBSUPPORT_EINTR_H */
|
#endif /* GDBSUPPORT_EINTR_H */
|
||||||
|
Reference in New Issue
Block a user