From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27657 invoked by alias); 23 Jul 2013 09:01:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 27638 invoked by uid 89); 23 Jul 2013 09:01:48 -0000 X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 23 Jul 2013 09:01:47 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id r6N91UDm003656; Tue, 23 Jul 2013 11:01:30 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id r6N91Tfu005129; Tue, 23 Jul 2013 11:01:29 +0200 (CEST) Date: Tue, 23 Jul 2013 09:01:00 -0000 Message-Id: <201307230901.r6N91Tfu005129@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: raunaq12@in.ibm.com CC: gdb-patches@sourceware.org, mark.kettenis@xs4all.nl, tromey@redhat.com In-reply-to: (message from Raunaq 12 on Tue, 23 Jul 2013 11:04:17 +0530) Subject: Re: [PATCH 3/5] powerpc64-aix inf-ptrace patch References: X-SW-Source: 2013-07/txt/msg00528.txt.bz2 > From: Raunaq 12 > Date: Tue, 23 Jul 2013 11:04:17 +0530 > > I have restricted the macro definitions to only gdb_ptrace.h. > Something like this as seen below - > > #ifdef PTRACE_TYPE_ARG5 > # ifdef BFD64 As Tom and I already told you, this #ifdef BFD64 is the wrong check. You should add an autoconf test for ptrace64() and use #ifdef HAVE_PTRACE64. > # define ptrace(request, pid, addr, data) \ > ptrace64 (request, (long long)pid, (long long)addr, data, 0) > # else > # define ptrace(request, pid, addr, data) \ > ptrace(request, (int)pid, (PTRACE_TYPE_ARG3)addr, data, 0) > # endif > #endif > > I have type cast pid here to avoid additional compiler warnings. Really? What is the fundamental type of pid_t on AIX? It's an int on any sane UNIX system, so expect it to be an int on AIX as well. So casting to an int is pointless, and passing an int where a wider signed integer type is expected should not produce a warning. Redundant casts are bad. They hide bugs. Please drop them. > > So unless I'm missing something, you should not need to make any > > changes to inf-ptrace.c itself. > > But, inf-ptrace.c makes ptrace calls as seen below - > > ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) > > If I make the macro definitions in gdb_ptrace.h as seen above, then > the casts for the 'Address'(3rd parameter in ptrace call) should > be removed from ptrace calls in inf-ptrace.c as seen below - > > ptrace (PT_DETACH, fpid, 1, 0) > > The macro is taking care of all the type casts. > ptrace64() accepts (long long) as the address parameter while > ptrace() accepts int* or any integer pointer as the type for address. > So, this type cast is necessary. Agree that pid cast is not needed. No this will break other systems. Instead, make sure PTRACE_TYPE_ARG3 gets defined to the proper type of the 3rd argument of ptrace64 when you choose to use it. I'd expect that if you add the autoconf check I mentioned you could simply change the #ifdef PTRACE_TYPE_ARG5 in gdb_ptrace.h to something like: #ifdef PTRACE_TYPE_ARG5 # ifdef HAVE_PTRACE64 # define ptrace(request, pid, addr, data) \ ptrace64 (request, pid, addr, data, 0) # undef PTRACE_TYPE_ARG3 # define PTRACE_TYPE_ARG3 long long # else # define ptrace(request, pid, addr, data) \ ptrace (request, pid, addr, data, 0) # endif #endif and then everything should just work.