Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix argument-passing error in linux-nat.c
@ 2008-09-25 13:21 Sérgio Durigan Júnior
  2008-09-25 13:53 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Sérgio Durigan Júnior @ 2008-09-25 13:21 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1593 bytes --]

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

[-- Attachment #2: linux-nat-status-pointer.patch --]
[-- Type: text/x-patch, Size: 559 bytes --]

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.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-25 17:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-25 13:21 [PATCH] Fix argument-passing error in linux-nat.c Sérgio Durigan Júnior
2008-09-25 13:53 ` Pedro Alves
2008-09-25 17:02   ` Thiago Jung Bauermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox