diff options
author | Pedro Alves <palves@redhat.com> | 2015-07-24 14:57:20 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-07-24 15:12:15 +0100 |
commit | 54019719152ab269fb4cec2c6a8a245ba6af6e49 (patch) | |
tree | d1252dcf1e0543ff063fde98919eaa8d55a05c0d /gdb/gdbserver/config.in | |
parent | e379037592ff71dc633c6d3de0828babe805ae96 (diff) | |
download | gdb-54019719152ab269fb4cec2c6a8a245ba6af6e49.zip gdb-54019719152ab269fb4cec2c6a8a245ba6af6e49.tar.gz gdb-54019719152ab269fb4cec2c6a8a245ba6af6e49.tar.bz2 |
C++: handle glibc's ptrace(enum __ptrace_request, ...)
Building in C++ mode issues ~40 warnings like this:
../../src/gdb/linux-nat.c: In function ‘int linux_handle_extended_wait(lwp_info*, int, int)’:
../../src/gdb/linux-nat.c:2016:51: warning: invalid conversion from ‘int’ to ‘__ptrace_request’ [-fpermissive]
ptrace (PTRACE_GETEVENTMSG, pid, 0, &new_pid);
The issue is that in glibc, ptrace's first parameter is an enum.
That's not a problem if we pick the PTRACE_XXX requests from
sys/ptrace.h, as those will be values of the corresponding enum.
However, we have fallback definitions for PTRACE_XXX symbols when the
system headers miss them (such as PTRACE_GETEVENTMSG above), and those
are plain integer constants. E.g., nat/linux-ptrace.h:
#define PTRACE_GETEVENTMSG 0x4201
One idea would be to fix this by defining those fallbacks like:
-#define PTRACE_GETEVENTMSG 0x4201
+#define PTRACE_GETEVENTMSG ((enum __ptrace_request) 0x4201)
However, while glibc's ptrace uses enum __ptrace_request for first
parameter:
extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
other libc's, like e.g., Android's bionic do not -- in that case, the
first parameter is int:
long ptrace(int request, pid_t pid, void * addr, void * data);
So the fix I came up is to make configure/ptrace.m4 also detect the
type of the ptrace's first parameter and defin PTRACE_TYPE_ARG1, as
already does the for parameters 3-4, and then simply wrap ptrace with
a macro that casts the first argument to the detected type. (I'm
leaving adding a nicer wrapper for when we drop building in C).
While this adds the wrapper, GNU/Linux files won't use it until the
next patch, which makes all native GNU/Linux files include
gdb_ptrace.h.
gdb/ChangeLog:
2015-07-24 Pedro Alves <palves@redhat.com>
* ptrace.m4 (ptrace tests): Test in C++ mode. Try with 'enum
__ptrace_request as first parameter type instead of int.
(PTRACE_TYPE_ARG1): Define.
* nat/gdb_ptrace.h [!PTRACE_TYPE_ARG5] (ptrace): Define as wrapper
that casts first argument to PTRACE_TYPE_ARG1.
* config.in: Regenerate.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2015-07-24 Pedro Alves <palves@redhat.com>
* config.in: Regenerate.
* configure: Regenerate.
Diffstat (limited to 'gdb/gdbserver/config.in')
-rw-r--r-- | gdb/gdbserver/config.in | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 6f2d0a1..e2566a9 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -310,6 +310,9 @@ /* Additional package description */ #undef PKGVERSION +/* Define to the type of arg 1 for ptrace. */ +#undef PTRACE_TYPE_ARG1 + /* Define to the type of arg 3 for ptrace. */ #undef PTRACE_TYPE_ARG3 |