Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.
       [not found] <CAGWvnynVeLt6F-QREsP_CtQvwvtZgwqHxtcS6pn58LMf=AX=GA@mail.gmail.com>
@ 2013-08-12 12:02 ` Raunaq 12
  2013-08-12 15:53   ` David Edelsohn
  2013-08-12 12:11 ` Raunaq 12
  1 sibling, 1 reply; 10+ messages in thread
From: Raunaq 12 @ 2013-08-12 12:02 UTC (permalink / raw)
  To: David Edelsohn; +Cc: gdb-patches, Mark Kettenis, Ulrich Weigand



David Edelsohn <dje.gcc@gmail.com> wrote on 08/09/2013 09:23:42 PM:

> From: David Edelsohn <dje.gcc@gmail.com>
> To: Raunaq 12/India/IBM@IBMIN, Mark Kettenis <mark.kettenis@xs4all.nl>,
Ulrich Weigand
> <Ulrich.Weigand@de.ibm.com>
> Cc: gdb-patches@sourceware.org
> Date: 08/09/2013 09:22 PM
> Subject: Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.
>
> > When GDB is compiled in 64 BIT mode ptrace and ptracex calls are not
defined on AIX.
> > So, instead we check if ptrace64 is defined, if it is then we call that
instead of ptrace/x.
>
> Have you tested the patch in both 32 bit mode and 64 bit mode for both
host GDB and target
> debugee?

Yes, ran the tests in testsuite/gdb.base and any new failures did not arise
when

>I tried the earlier version of this patch from last year and experienced
problems
> debugging in 32 bit mode (I no longer could debug GCC).

The earlier version of this patch was using ptrace64 only if BFD64 was
defined,
i.e. when GDB was built in 64 BIT mode.
Did you build 32 bit gdb?
If so, according to the previous version of this patch,
no ptrace related calls were changed as ptrace64 was only
called if BFD64 was defined. Could you please resend the error you got
while debugging
32 bit GCC to my mail id? I can look into it to see where the problem is
coming from.

> ptrace, ptracex and ptrace64 are defined in syscalls.exp.
>
> ptrace64                syscall3264
> # 32
> ptrace                  syscall32
> ptracex                 syscall32

> As you wrote, ptrace and ptracex are 32 bit only API; ptrace64 is
available as 32 bit and 64 bit
> API. ptrace64 is suppose to support 32 bit debugee targets, but I
experienced problems.
>
> ptrace64 will be discovered as supported by configure when building 32
bit GDB.

> Is your intention to always use ptrace64 when it is available or only to
use it for GDB hosted on
> 64 bit mode?

My initial intention was to use ptrace64 only if ptrace64 was available and
GDB was built in 64 BIT. But after a few discussions over this, I decided
to use ptrace64 when ever the API is defined.

So, this present patch would use
ptrace64 even for a 32 bit build as you rightly noticed.
This did not change the test results for a 32 bit build of GDB.

Thanks,
Raunaq M. Bathija


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

* Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.
       [not found] <CAGWvnynVeLt6F-QREsP_CtQvwvtZgwqHxtcS6pn58LMf=AX=GA@mail.gmail.com>
  2013-08-12 12:02 ` [PATCH 4/5] powerpc64-aix ptrace64 when defined Raunaq 12
@ 2013-08-12 12:11 ` Raunaq 12
  2013-08-12 19:43   ` David Edelsohn
  1 sibling, 1 reply; 10+ messages in thread
From: Raunaq 12 @ 2013-08-12 12:11 UTC (permalink / raw)
  To: David Edelsohn; +Cc: gdb-patches, Mark Kettenis, Ulrich Weigand


[ sending again without the line wrapping that makes it so hard to read]

David Edelsohn <dje.gcc@gmail.com> wrote on 08/09/2013 09:23:42 PM:

> From: David Edelsohn <dje.gcc@gmail.com>
> To: Raunaq 12/India/IBM@IBMIN, Mark Kettenis <mark.kettenis@xs4all.nl>, Ulrich Weigand
> <Ulrich.Weigand@de.ibm.com>
> Cc: gdb-patches@sourceware.org
> Date: 08/09/2013 09:22 PM
> Subject: Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.
>
> > When GDB is compiled in 64 BIT mode ptrace and ptracex calls are not defined on AIX.
> > So, instead we check if ptrace64 is defined, if it is then we call that instead of ptrace/x.
>
> Have you tested the patch in both 32 bit mode and 64 bit mode for both host GDB and target
> debugee?

Yes, ran the tests in testsuite/gdb.base and any new failures did not arise when

>I tried the earlier version of this patch from last year and experienced problems
> debugging in 32 bit mode (I no longer could debug GCC).

The earlier version of this patch was using ptrace64 only if BFD64 was defined,
i.e. when GDB was built in 64 BIT mode.
Did you build 32 bit gdb?
If so, according to the previous version of this patch,
no ptrace related calls were changed as ptrace64 was only
called if BFD64 was defined. Could you please resend the error you got while debugging
32 bit GCC to my mail id? I can look into it to see where the problem is coming from.

> ptrace, ptracex and ptrace64 are defined in syscalls.exp.
>
> ptrace64                syscall3264
> # 32
> ptrace                  syscall32
> ptracex                 syscall32

> As you wrote, ptrace and ptracex are 32 bit only API; ptrace64 is available as 32 bit and 64 bit
> API. ptrace64 is suppose to support 32 bit debugee targets, but I experienced problems.
>
> ptrace64 will be discovered as supported by configure when building 32 bit GDB.

> Is your intention to always use ptrace64 when it is available or only to use it for GDB hosted on
> 64 bit mode?

My initial intention was to use ptrace64 only if ptrace64 was available and
GDB was built in 64 BIT. But after a few discussions over this, I decided
to use ptrace64 when ever the API is defined.

So, this present patch would use
ptrace64 even for a 32 bit build as you rightly noticed.
This did not change the test results for a 32 bit build of GDB.

Thanks,
Raunaq M. Bathija


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

* Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.
  2013-08-12 12:02 ` [PATCH 4/5] powerpc64-aix ptrace64 when defined Raunaq 12
@ 2013-08-12 15:53   ` David Edelsohn
  0 siblings, 0 replies; 10+ messages in thread
From: David Edelsohn @ 2013-08-12 15:53 UTC (permalink / raw)
  To: Raunaq 12; +Cc: GDB Patches, Mark Kettenis, Ulrich Weigand

On Mon, Aug 12, 2013 at 8:00 AM, Raunaq 12 <raunaq12@in.ibm.com> wrote:

> The earlier version of this patch was using ptrace64 only if BFD64 was
> defined,
> i.e. when GDB was built in 64 BIT mode.
> Did you build 32 bit gdb?
> If so, according to the previous version of this patch,
> no ptrace related calls were changed as ptrace64 was only
> called if BFD64 was defined. Could you please resend the error you got
> while debugging
> 32 bit GCC to my mail id? I can look into it to see where the problem is
> coming from.

I have not tried to build GDB with the latest test of patches.  When I
used the earlier patches to build GDB in 32 bit mode but with
--enable-64-bit-bfd (because I want to debug 64 bit applications), and
tried to use the debugger with GCC, I encountered the problem that no
function call argument values were available.

Thanks, David


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

* Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.
  2013-08-12 12:11 ` Raunaq 12
@ 2013-08-12 19:43   ` David Edelsohn
  2013-08-22 23:32     ` Joel Brobecker
  0 siblings, 1 reply; 10+ messages in thread
From: David Edelsohn @ 2013-08-12 19:43 UTC (permalink / raw)
  To: Raunaq 12; +Cc: GDB Patches, Mark Kettenis, Ulrich Weigand

On Mon, Aug 12, 2013 at 8:10 AM, Raunaq 12 <raunaq12@in.ibm.com> wrote:

> My initial intention was to use ptrace64 only if ptrace64 was available and
> GDB was built in 64 BIT. But after a few discussions over this, I decided
> to use ptrace64 when ever the API is defined.
>
> So, this present patch would use
> ptrace64 even for a 32 bit build as you rightly noticed.
> This did not change the test results for a 32 bit build of GDB.

I built gdb-7.6 with the ptrace64 patch (without --enable-64-bit-bfd)
and it seems to work correctly on cc1plus. So at least the current
patch does not harm debugging.

Thanks, David


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

* Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.
  2013-08-12 19:43   ` David Edelsohn
@ 2013-08-22 23:32     ` Joel Brobecker
  2013-08-23  0:48       ` [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.") Joel Brobecker
  0 siblings, 1 reply; 10+ messages in thread
From: Joel Brobecker @ 2013-08-22 23:32 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Raunaq 12, GDB Patches, Mark Kettenis, Ulrich Weigand

> I built gdb-7.6 with the ptrace64 patch (without --enable-64-bit-bfd)
> and it seems to work correctly on cc1plus. So at least the current
> patch does not harm debugging.

Actually, I just found that it breaks thread support on 32bit AIX,
at least.  A simpler way to show the problem is:

    (gdb) x /x &__n_pthreads
    0xf06a8258 <__n_pthreads>:      Cannot access memory at address 0xf06a8258

Prior to the patch, we have:

    (gdb) x /x &__n_pthreads
    0xf06a8258 <__n_pthreads>:      0x00000003

The error returned by ptrace64 is EIO (5), which means it thinks
the address is wrong (or else the request ID is invalid, but I doubt
that). I'm a bit rushed, as usual, but I still have a little extra
time today to dig a little further.

-- 
Joel


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

* [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.")
  2013-08-22 23:32     ` Joel Brobecker
@ 2013-08-23  0:48       ` Joel Brobecker
  2013-08-23  7:23         ` David Edelsohn
  2013-08-29 21:03         ` Checked in: [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.") Joel Brobecker
  0 siblings, 2 replies; 10+ messages in thread
From: Joel Brobecker @ 2013-08-23  0:48 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Raunaq 12, GDB Patches, Mark Kettenis, Ulrich Weigand

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

Hello again,

> Actually, I just found that it breaks thread support on 32bit AIX,
> at least.  A simpler way to show the problem is:
> 
>     (gdb) x /x &__n_pthreads
>     0xf06a8258 <__n_pthreads>:      Cannot access memory at address 0xf06a8258
> 
> Prior to the patch, we have:
> 
>     (gdb) x /x &__n_pthreads
>     0xf06a8258 <__n_pthreads>:      0x00000003

Attached is the patch I checked in locally at AdaCore:

gdb/ChangeLog:

        * rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t"
        instead of "long long" in call to ptrace64.

Tested on ppc-aix in full 32bit mode (both GDB and inferior are
32bit). I think the other scenario would be 64bit GDB debugging
a 32bit inferior, but I don't have a 64bit compiler to try it.

I'd like to commit this patch, unless there are comments/suggestions.

Thank you,
-- 
Joel

[-- Attachment #2: 0001-thread-support-broken-on-ppc-aix.patch --]
[-- Type: text/x-diff, Size: 2060 bytes --]

From 91f7d8c9ae626954479217739aaa476e79e5daeb Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Thu, 22 Aug 2013 20:33:27 -0400
Subject: [PATCH] thread support broken on ppc-aix.

Thread support got broken when adding 64bit support on ppc-aix.
Upon digging further, I found that the following patch...

   | * gdb_ptrace.h: Use ptrace64 instead of ptrace if HAVE_PTRACE64
   | is defined.
   | * rs6000-nat.c: Check for __ld_info64_ if compiling 64 BIT gdb.
   | (rs6000_ptrace32): Call ptrace64 instead of ptrace if present.
   | (rs6000_ptrace64): Call ptace64 instead of ptracex if present.
   | * configure.ac: Check for ptrace64.
   | * configure, config.in: Regenerate.

... is responsible for this regression:

    (gdb) x /x &__n_pthreads
    0xf06a8258 <__n_pthreads>: Cannot access memory at address 0xf06a8258

Prior to the patch, we have:

    (gdb) x /x &__n_pthreads
    0xf06a8258 <__n_pthreads>: 0x00000003

The problem occurs inside rs6000_ptrace32, while calling ptrace64.
The address is given to rs6000_ptrace32 as an "int *", while
ptrace64 takes a "long long". The cast causes the address to be
sign-extended, which results in GDB trying to read the wrong address.

This patch fixes the issue by casting the address to a "uintptr_t"
instead, and letting the compiler do the implicit conversion to
"long long" in the function call.

gdb/ChangeLog:

        * rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t"
        instead of "long long" in call to ptrace64.

---
 gdb/rs6000-nat.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 0953356..b214cd9 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -132,7 +132,7 @@ static int
 rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf)
 {
   #ifdef HAVE_PTRACE64
-  int ret = ptrace64 (req, id, (long long) addr, data, buf);
+  int ret = ptrace64 (req, id, (uintptr_t) addr, data, buf);
   #else
   int ret = ptrace (req, id, (int *)addr, data, buf);
   #endif
-- 
1.7.0.4


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

* Re: [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.")
  2013-08-23  0:48       ` [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.") Joel Brobecker
@ 2013-08-23  7:23         ` David Edelsohn
  2013-08-23 13:34           ` Joel Brobecker
  2013-08-29 21:03         ` Checked in: [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.") Joel Brobecker
  1 sibling, 1 reply; 10+ messages in thread
From: David Edelsohn @ 2013-08-23  7:23 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Raunaq 12, GDB Patches, Mark Kettenis, Ulrich Weigand

On Thu, Aug 22, 2013 at 8:48 PM, Joel Brobecker <brobecker@adacore.com> wrote:
> Hello again,
>
>> Actually, I just found that it breaks thread support on 32bit AIX,
>> at least.  A simpler way to show the problem is:
>>
>>     (gdb) x /x &__n_pthreads
>>     0xf06a8258 <__n_pthreads>:      Cannot access memory at address 0xf06a8258
>>
>> Prior to the patch, we have:
>>
>>     (gdb) x /x &__n_pthreads
>>     0xf06a8258 <__n_pthreads>:      0x00000003
>
> Attached is the patch I checked in locally at AdaCore:
>
> gdb/ChangeLog:
>
>         * rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t"
>         instead of "long long" in call to ptrace64.
>
> Tested on ppc-aix in full 32bit mode (both GDB and inferior are
> 32bit). I think the other scenario would be 64bit GDB debugging
> a 32bit inferior, but I don't have a 64bit compiler to try it.
>
> I'd like to commit this patch, unless there are comments/suggestions.

LGTM.

Is there a testcase that can be added to the GDB testsuite to catch
this type of regression?

Thanks, David


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

* Re: [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.")
  2013-08-23  7:23         ` David Edelsohn
@ 2013-08-23 13:34           ` Joel Brobecker
       [not found]             ` <CAGWvnyna5R2AR0imAC4W+aCJXPFjwPm+45yP9VOgkO68T7sF7w@mail.gmail.com>
  0 siblings, 1 reply; 10+ messages in thread
From: Joel Brobecker @ 2013-08-23 13:34 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Raunaq 12, GDB Patches, Mark Kettenis, Ulrich Weigand

> > gdb/ChangeLog:
> >
> >         * rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t"
> >         instead of "long long" in call to ptrace64.
> >
> > Tested on ppc-aix in full 32bit mode (both GDB and inferior are
> > 32bit). I think the other scenario would be 64bit GDB debugging
> > a 32bit inferior, but I don't have a 64bit compiler to try it.
> >
> > I'd like to commit this patch, unless there are comments/suggestions.
> 
> LGTM.

Thanks :)

> Is there a testcase that can be added to the GDB testsuite to catch
> this type of regression?

All testcases involving thread support should reveal this type of
failure. I cannot remember exactly how this patch was tested, but
ISTR that it couldn't be tested through the official testsuite,
for some reasons that were deemed reasonable...

-- 
Joel


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

* Checked in: [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.")
  2013-08-23  0:48       ` [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.") Joel Brobecker
  2013-08-23  7:23         ` David Edelsohn
@ 2013-08-29 21:03         ` Joel Brobecker
  1 sibling, 0 replies; 10+ messages in thread
From: Joel Brobecker @ 2013-08-29 21:03 UTC (permalink / raw)
  To: gdb-patches

> gdb/ChangeLog:
> 
>         * rs6000-nat.c (rs6000_ptrace32): Cast "addr" to "uintptr_t"
>         instead of "long long" in call to ptrace64.
> 
> Tested on ppc-aix in full 32bit mode (both GDB and inferior are
> 32bit). I think the other scenario would be 64bit GDB debugging
> a 32bit inferior, but I don't have a 64bit compiler to try it.
> 
> I'd like to commit this patch, unless there are comments/suggestions.

Now checked in.

-- 
Joel


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

* Re: [RFA/ppc-aix] fix thread support breakage
       [not found]               ` <OFC7611E7B.F19F366D-ON65257BE2.003745A0-65257BE2.00386093@in.ibm.com>
@ 2013-09-17 18:38                 ` Tom Tromey
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2013-09-17 18:38 UTC (permalink / raw)
  To: Raunaq 12
  Cc: David Edelsohn, Joel Brobecker, GDB Patches, Mark Kettenis,
	Ulrich Weigand

>>>>> ">" == Raunaq 12 <raunaq12@in.ibm.com> writes:

>> David, my intention was to run test cases for all the combinations
>> that you have mentioned above. Since we use XLC (AIX native compiler)
>> to compile the test cases, the entire test bucket does not run very
>> smoothly.

I guess this supplies a future to-do list :-)

>> In fact it is a very cumbersome process. So the test failures would
>> have been over looked by me.

The standard thing to do is run the test suite twice, once before your
patch and once after, and compare the results.

Tom


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

end of thread, other threads:[~2013-09-17 18:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAGWvnynVeLt6F-QREsP_CtQvwvtZgwqHxtcS6pn58LMf=AX=GA@mail.gmail.com>
2013-08-12 12:02 ` [PATCH 4/5] powerpc64-aix ptrace64 when defined Raunaq 12
2013-08-12 15:53   ` David Edelsohn
2013-08-12 12:11 ` Raunaq 12
2013-08-12 19:43   ` David Edelsohn
2013-08-22 23:32     ` Joel Brobecker
2013-08-23  0:48       ` [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.") Joel Brobecker
2013-08-23  7:23         ` David Edelsohn
2013-08-23 13:34           ` Joel Brobecker
     [not found]             ` <CAGWvnyna5R2AR0imAC4W+aCJXPFjwPm+45yP9VOgkO68T7sF7w@mail.gmail.com>
     [not found]               ` <OFC7611E7B.F19F366D-ON65257BE2.003745A0-65257BE2.00386093@in.ibm.com>
2013-09-17 18:38                 ` [RFA/ppc-aix] fix thread support breakage Tom Tromey
2013-08-29 21:03         ` Checked in: [RFA/ppc-aix] fix thread support breakage (was: "Re: [PATCH 4/5] powerpc64-aix ptrace64 when defined.") Joel Brobecker

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