This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix argument-passing error in linux-nat.c
- From: Sérgio Durigan Júnior <sergiodj at linux dot vnet dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 25 Sep 2008 10:15:23 -0300
- Subject: [PATCH] Fix argument-passing error in linux-nat.c
Hi guys,
This is a very trivial patch that I have done (while I don't have yet
the 'catch syscall' patch! :D). Well, I found this little error in
linux-nat.c. Basically, the 'status' variable in the function
'get_pending_status' is a pointer to an integer, but the macros from
waitpid.h (WIFSTOPPED and WSTOPSIG) are being called with this pointer
as the argument, instead of the integer itself. It was just a matter of
putting a '*' in the front of the name ;-)
This fix did not cause any improvement on the testsuite (for 32-bit PPC
at least), but anyway it's better to do things right, huh? Also, as I'm
sending this e-mail, I'd like to propose one little modification in the
GDB code. As you all know GCC does not do type-checking in macros, which
makes it hard to identify problems like this one. To avoid future
issues, it would be a good thing to make a "wrapper" for these macros
(specially for those in waitpid.h). This wrapper could be something like
a "static inline", so we won't miss anything in the performance aspect.
For example, in the case of WSTOPSIG:
static inline int
internal_WSTOPSIG (int status)
{
return WSTOPSIG (status);
}
So, whenever we call internal_WSTOPSIG (ugly name, we certainly may want
to choose another one), we have *for free* a type-checking for its
argument :-).
I took a quick look at the code and there are not so many places to
replace the calls, so I think it would not be a hard job to do...
So, what do you think?
Thanks,
--
Sérgio Durigan Júnior
Linux on Power Toolchain - Software Engineer
Linux Technology Center - LTC
IBM Brazil
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 42e19b5..0851492 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1442,8 +1442,8 @@ get_pending_status (struct lwp_info *lp, int *status)
queue. */
if (queued_waitpid (GET_LWP (lp->ptid), status, __WALL) != -1)
{
- if (WIFSTOPPED (status))
- signo = target_signal_from_host (WSTOPSIG (status));
+ if (WIFSTOPPED (*status))
+ signo = target_signal_from_host (WSTOPSIG (*status));
/* If not stopped, then the lwp is gone, no use in
resending a signal. */