From: "Sérgio Durigan Júnior" <sergiodj@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix argument-passing error in linux-nat.c
Date: Thu, 25 Sep 2008 13:21:00 -0000 [thread overview]
Message-ID: <1222348523.10481.5.camel@miki> (raw)
[-- 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. */
next reply other threads:[~2008-09-25 13:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-25 13:21 Sérgio Durigan Júnior [this message]
2008-09-25 13:53 ` Pedro Alves
2008-09-25 17:02 ` Thiago Jung Bauermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1222348523.10481.5.camel@miki \
--to=sergiodj@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox