This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: AIX 64bit support
Hi Abid,
Thanks for the review and comments and sorry for the delay in reply.
Let me know if we can do #ifdef check in a macro and call the marco as
mentioned below would be feasible to reduce the many #ifdef checks ?
macro for ptrace64aix
#define ptrace_check_64aix(req, tid, addr, data, buff) \
#ifdef BFD64 \
if (!ptrace64aix (req, (long long) tid, \
(long long) addr, data, buff)) \
#else \
if (!ptrace64aix (req, tid, \
(unsigned long) addr, data, buff)) \
#endif \
macro call
ptrace_check_64aix(PTT_READ_GPRS, tid, gprs64, 0 , NULL);
etc...
macro for ptrace32 call
#define ptrace_check_32aix(req, tid, addr, data, buff) \
#ifdef BFD64 \
if (!ptrace32 (req, (long long) tid, (long long) addr, data, buff)) \
#else \
if (!ptrace32 (req, tid, addr, 0, NULL)) \
#endif \
macro call
ptrace_check_32aix(PTT_READ_FPRS, tid, (int *) fprs, 0, NULL)
etc ....
I will add comment for the other changes
On Thu, Aug 9, 2012 at 2:31 PM, Abid, Hafiz <Hafiz_Abid@mentor.com> wrote:
> Hi Sangamesh,
> I dont know this code much but a few things that caught my eye. Comments inline.
>
>
>> -----Original Message-----
>> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
>> owner@sourceware.org] On Behalf Of swamy sangamesh
>> Sent: Thursday, August 09, 2012 9:23 AM
>> To: gdb-patches@sourceware.org
>> Subject: AIX 64bit support
>>
>> Hi All,
>>
>> Below patches adds the support for 64-bit gdb for ppc64 running on
>> AIX, plus some bug fixes which are caused
>> by the way gcc and xlc generated binary are read. Please consider the
>> patches if its fine.
>>
>> gdb:
>>
>>
>> * configure.tgt (powerpc64-*-aix*): Match powerpc64 running
>> aix.
>>
>> * configure.host (powerpc64-*-aix*): Likewise.
>>
>> * aix-thread.c (ptrace64aix): Added BFD64 for 64 bit support.
>> (ptrace32): Likewise.
>> (pdc_read_regs): Likewise.
>> (pdc_write_regs): Likewise.
>> (aix_thread_resume): Likewise.
>> (fetch_regs_kernel_thread): Likewise.
>> (store_regs_kernel_thread): Likewise.
>>
>> * inf-ptrace.c (inf_ptrace_follow_fork): Added BFD64 for 64 bit
>> support.
>> (inf_ptrace_me): Likewise.
>> (inf_ptrace_post_startup_inferior): Likewise.
>> (inf_ptrace_attach): Likewise.
>> (inf_ptrace_post_attach): Likewise.
>> (inf_ptrace_detach): Likewise.
>> (inf_ptrace_kill): Likewise.
>> (inf_ptrace_resume): Likewise.
>> (inf_ptrace_wait): Likewise.
>> (inf_ptrace_xfer_partial): Likewise.
>> (inf_ptrace_fetch_register): Likewise.
>> (inf_ptrace_store_register): Likewise.
>>
>> * rs6000-nat.c (global): Check for __ld_info64 if compiling 64-
>> bit gdb.
>> (rs6000_ptrace32): Added BFD64 for 64 bit support.
>> (rs6000_ptrace64): Likewise.
>>
>> * xcoffread.c (read_xcoff_symtab): Make fcn_start_addr large
>> enough to hold 64-bit address.
>> Skip reading symbols starting with @FIX.
>> Read correct auxilliary entry if the entries are more than one
>> in cases like xlc generated binary.
>> Read the filename from CSECT entry,if we break at CSECT entry
>> other than first entry we need to get
>> the filename instead of _start_.
>>
>> * config/rs6000/nm-rs6000.h: When analysing core check if ptid
>> is not 1.
>>
>> * symtab.c (find_pc_sect_line): Read correct line table
>> entries, xlc compiler generates extra entry.
>>
>> --- ./gdb/configure.tgt_orig 2012-07-25 15:59:30.934837815 +0530
>> +++ ./gdb/configure.tgt 2012-07-31 14:16:36.761045509 +0530
>> @@ -406,7 +406,7 @@
>> gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppcobsd-tdep.o \
>> corelow.o solib.o solib-svr4.o"
>> ;;
>> -powerpc-*-aix* | rs6000-*-*)
>> +powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
>> # Target: PowerPC running AIX
>> gdb_target_obs="rs6000-tdep.o rs6000-aix-tdep.o xcoffread.o \
>> ppc-sysv-tdep.o solib.o solib-svr4.o"
>> --- ./gdb/configure.host_orig 2012-07-31 13:27:34.729045416 +0530
>> +++ ./gdb/configure.host 2012-07-31 13:28:55.717046154 +0530
>> @@ -123,7 +123,7 @@
>> gdb_host=nbsd ;;
>> mips64*-*-openbsd*) gdb_host=obsd64 ;;
>>
>> -powerpc-*-aix* | rs6000-*-*)
>> +powerpc-*-aix* | powerpc64-*-aix* | rs6000-*-*)
>> gdb_host=aix ;;
>> powerpc-*-linux*) gdb_host=linux ;;
>> powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
>> --- ./gdb/aix-thread.c_orig 2012-08-07 17:11:21.270057686 +0530
>> +++ ./gdb/aix-thread.c 2012-08-07 17:11:17.998084929 +0530
>> @@ -239,23 +239,42 @@
>> }
>>
>> /* Call ptracex (REQ, ID, ADDR, DATA, BUF). Return success. */
>> +/* For 64-bit gdb Call ptrace64 to trace 32-bit and 64-bit debugee */
>>
>> static int
>> +#ifdef BFD64
>> +ptrace64aix (int req, long long id, long long addr, int data, int
>> *buf)
>> +{
>> + errno = 0;
>> + return ptrace_check (req, id, ptrace64 (req, id, addr, data, buf));
>> +}
>> +#else
>> ptrace64aix (int req, int id, long long addr, int data, int *buf)
>> {
>> errno = 0;
>> return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
>> }
>> +#endif
>>
>> /* Call ptrace (REQ, ID, ADDR, DATA, BUF). Return success. */
>> +/* For 64-bit gdb Call ptrace64 to trace 32-bit and 64-bit debugee */
>>
>> static int
>> +#ifdef BFD64
>> +ptrace32 (int req, long long id, long long addr, int data, int *buf)
>> +{
>> + errno = 0;
>> + return ptrace_check (req, id,
>> + ptrace64 (req, id, addr, data, buf));
>> +}
>> +#else
>> ptrace32 (int req, int id, int *addr, int data, int *buf)
>> {
>> errno = 0;
>> return ptrace_check (req, id,
>> ptrace (req, id, (int *) addr, data, buf));
>> }
>> +#endif
>>
>> /* If *PIDP is a composite process/thread id, convert it to a
>> process id. */
>> @@ -346,14 +365,23 @@
>> {
>> if (arch64)
>> {
>> + #ifdef BFD64
>> + if (!ptrace64aix (PTT_READ_GPRS, tid,
>> + (long long) gprs64, 0, NULL))
>> + #else
>> if (!ptrace64aix (PTT_READ_GPRS, tid,
>> (unsigned long) gprs64, 0, NULL))
>> + #endif
>> memset (gprs64, 0, sizeof (gprs64));
>> memcpy (context->gpr, gprs64, sizeof(gprs64));
>> }
>> else
>> {
>> + #ifdef BFD64
>> + if (!ptrace32 (PTT_READ_GPRS, tid, (long long) gprs32, 0,
>> NULL))
>> + #else
>> if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
>> + #endif
> If you introduce new functions which has the #ifdef checks and then call those functions from here then code will be a lot cleaner in my opinion. Then all these #ifdef checks will only be in one place.
>
>> memset (gprs32, 0, sizeof (gprs32));
>> memcpy (context->gpr, gprs32, sizeof(gprs32));
>> }
>> @@ -362,7 +390,11 @@
>> /* Floating-point registers. */
>> if (flags & PTHDB_FLAG_FPRS)
>> {
>> + #ifdef BFD64
>> + if (!ptrace32 (PTT_READ_FPRS, tid, (long long) fprs, 0 , NULL))
>> + #else
>> if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
>> + #endif
>> memset (fprs, 0, sizeof (fprs));
>> memcpy (context->fpr, fprs, sizeof(fprs));
>> }
>> @@ -372,14 +404,23 @@
>> {
>> if (arch64)
>> {
>> + #ifdef BFD64
>> + if (!ptrace64aix (PTT_READ_SPRS, tid,
>> + (long long) &sprs64, 0, NULL))
>> + #else
>> if (!ptrace64aix (PTT_READ_SPRS, tid,
>> (unsigned long) &sprs64, 0, NULL))
>> + #endif
>> memset (&sprs64, 0, sizeof (sprs64));
>> memcpy (&context->msr, &sprs64, sizeof(sprs64));
>> }
>> else
>> {
>> + #ifdef BFD64
>> + if (!ptrace32 (PTT_READ_SPRS, tid, (long long) &sprs32, 0,
>> NULL))
>> + #else
>> if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
>> + #endif
>> memset (&sprs32, 0, sizeof (sprs32));
>> memcpy (&context->msr, &sprs32, sizeof(sprs32));
>> }
>> @@ -411,16 +452,29 @@
>> if (flags & PTHDB_FLAG_GPRS)
>> {
>> if (arch64)
>> + #ifdef BFD64
>> + ptrace64aix (PTT_WRITE_GPRS, tid,
>> + (long long) context->gpr, 0, NULL);
>> + #else
>> ptrace64aix (PTT_WRITE_GPRS, tid,
>> (unsigned long) context->gpr, 0, NULL);
>> + #endif
>> else
>> + #ifdef BFD64
>> + ptrace32 (PTT_WRITE_GPRS, tid, (long long) context->gpr, 0,
>> NULL);
>> + #else
>> ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
>> + #endif
>> }
>>
>> /* Floating-point registers. */
>> if (flags & PTHDB_FLAG_FPRS)
>> {
>> + #ifdef BFD64
>> + ptrace32 (PTT_WRITE_FPRS, tid, (long long) context->fpr, 0,
>> NULL);
>> + #else
>> ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
>> + #endif
>> }
>>
>> /* Special-purpose registers. */
>> @@ -428,12 +482,21 @@
>> {
>> if (arch64)
>> {
>> + #ifdef BFD64
>> + ptrace64aix (PTT_WRITE_SPRS, tid,
>> + (long long) &context->msr, 0, NULL);
>> + #else
>> ptrace64aix (PTT_WRITE_SPRS, tid,
>> (unsigned long) &context->msr, 0, NULL);
>> + #endif
>> }
>> else
>> {
>> + #ifdef BFD64
>> + ptrace32 (PTT_WRITE_SPRS, tid, (long long) &context->msr, 0,
>> NULL);
>> + #else
>> ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0,
>> NULL);
>> + #endif
>> }
>> }
>> return 0;
>> @@ -998,11 +1061,21 @@
>> tid[1] = 0;
>>
>> if (arch64)
>> + #ifdef BFD64
>> + ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
>> + target_signal_to_host (sig), (void *) tid);
>> + #else
>> ptrace64aix (PTT_CONTINUE, tid[0], 1,
>> target_signal_to_host (sig), (void *) tid);
>> + #endif
>> else
>> + #ifdef BFD64
>> + ptrace32 (PTT_CONTINUE, tid[0], (long long) 1,
>> + target_signal_to_host (sig), (void *) tid);
>> + #else
>> ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
>> target_signal_to_host (sig), (void *) tid);
>> + #endif
>> }
>> }
>>
>> @@ -1231,14 +1304,24 @@
>> {
>> if (arch64)
>> {
>> + #ifdef BFD64
>> + if (!ptrace64aix (PTT_READ_GPRS, tid,
>> + (long long) gprs64, 0, NULL))
>> + #else
>> if (!ptrace64aix (PTT_READ_GPRS, tid,
>> (unsigned long) gprs64, 0, NULL))
>> + #endif
>> memset (gprs64, 0, sizeof (gprs64));
>> supply_gprs64 (regcache, gprs64);
>> }
>> else
>> {
>> + #ifdef BFD64
>> + if (!ptrace32 (PTT_READ_GPRS, tid,
>> + (long long) gprs32, 0, NULL))
>> + #else
>> if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
>> + #endif
>> memset (gprs32, 0, sizeof (gprs32));
>> for (i = 0; i < ppc_num_gprs; i++)
>> supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
>> @@ -1252,7 +1335,12 @@
>> || (regno >= tdep->ppc_fp0_regnum
>> && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
>> {
>> + #ifdef BFD64
>> + if (!ptrace32 (PTT_READ_FPRS, tid,
>> + (long long) fprs, 0, NULL))
>> + #else
>> if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
>> + #endif
>> memset (fprs, 0, sizeof (fprs));
>> supply_fprs (regcache, fprs);
>> }
>> @@ -1263,8 +1351,13 @@
>> {
>> if (arch64)
>> {
>> + #ifdef BFD64
>> + if (!ptrace64aix (PTT_READ_SPRS, tid,
>> + (long long ) &sprs64, 0, NULL))
>> + #else
>> if (!ptrace64aix (PTT_READ_SPRS, tid,
>> (unsigned long) &sprs64, 0, NULL))
>> + #endif
>> memset (&sprs64, 0, sizeof (sprs64));
>> supply_sprs64 (regcache, sprs64.pt_iar, sprs64.pt_msr,
>> sprs64.pt_cr, sprs64.pt_lr, sprs64.pt_ctr,
>> @@ -1274,7 +1367,12 @@
>> {
>> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>>
>> + #ifdef BFD64
>> + if (!ptrace32 (PTT_READ_SPRS, tid, (long long ) &sprs32,
>> + 0, NULL))
>> + #else
>> if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
>> + #endif
>> memset (&sprs32, 0, sizeof (sprs32));
>> supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
>> sprs32.pt_cr,
>> sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
>> @@ -1561,16 +1659,32 @@
>> if (arch64)
>> {
>> /* Pre-fetch: some regs may not be in the cache. */
>> + #ifdef BFD64
>> + ptrace64aix (PTT_READ_GPRS, tid, (long long) gprs64, 0,
>> NULL);
>> + #else
>> ptrace64aix (PTT_READ_GPRS, tid, (unsigned long) gprs64, 0,
>> NULL);
>> + #endif
>> fill_gprs64 (regcache, gprs64);
>> + #ifdef BFD64
>> + ptrace64aix (PTT_WRITE_GPRS, tid, (long long) gprs64, 0,
>> NULL);
>> + #else
>> ptrace64aix (PTT_WRITE_GPRS, tid, (unsigned long) gprs64, 0,
>> NULL);
>> + #endif
>> }
>> else
>> {
>> /* Pre-fetch: some regs may not be in the cache. */
>> + #ifdef BFD64
>> + ptrace32 (PTT_READ_GPRS, tid, (long long) gprs32, 0, NULL);
>> + #else
>> ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
>> + #endif
>> fill_gprs32 (regcache, gprs32);
>> + #ifdef BFD64
>> + ptrace32 (PTT_WRITE_GPRS, tid, (long long) gprs32, 0, NULL);
>> + #else
>> ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
>> + #endif
>> }
>> }
>>
>> @@ -1582,9 +1696,17 @@
>> && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
>> {
>> /* Pre-fetch: some regs may not be in the cache. */
>> + #ifdef BFD64
>> + ptrace32 (PTT_READ_FPRS, tid, (long long) fprs, 0, NULL);
>> + #else
>> ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
>> + #endif
>> fill_fprs (regcache, fprs);
>> + #ifdef BFD64
>> + ptrace32 (PTT_WRITE_FPRS, tid, (long long) fprs, 0, NULL);
>> + #else
>> ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
>> + #endif
>> }
>>
>> /* Special-purpose registers. */
>> @@ -1594,13 +1716,23 @@
>> if (arch64)
>> {
>> /* Pre-fetch: some registers won't be in the cache. */
>> + #ifdef BFD64
>> + ptrace64aix (PTT_READ_SPRS, tid,
>> + (long long) &sprs64, 0, NULL);
>> + #else
>> ptrace64aix (PTT_READ_SPRS, tid,
>> (unsigned long) &sprs64, 0, NULL);
>> + #endif
>> fill_sprs64 (regcache, &sprs64.pt_iar, &sprs64.pt_msr,
>> &sprs64.pt_cr, &sprs64.pt_lr, &sprs64.pt_ctr,
>> &sprs64.pt_xer, &sprs64.pt_fpscr);
>> + #ifdef BFD64
>> + ptrace64aix (PTT_WRITE_SPRS, tid,
>> + (long long ) &sprs64, 0, NULL);
>> + #else
>> ptrace64aix (PTT_WRITE_SPRS, tid,
>> (unsigned long) &sprs64, 0, NULL);
>> + #endif
>> }
>> else
>> {
>> @@ -1616,7 +1748,12 @@
>> gdb_assert (sizeof (sprs32.pt_iar) == 4);
>>
>> /* Pre-fetch: some registers won't be in the cache. */
>> + #ifdef BFD64
>> + ptrace32 (PTT_READ_SPRS, tid,
>> + (long long) &sprs32, 0, NULL);
>> + #else
>> ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
>> + #endif
>>
>> fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
>> &tmp_ctr, &tmp_xer, &tmp_fpscr);
>> @@ -1635,7 +1772,11 @@
>> regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
>> &sprs32.pt_mq);
>>
>> + #ifdef BFD64
>> + ptrace32 (PTT_WRITE_SPRS, tid, (long long) &sprs32, 0, NULL);
>> + #else
>> ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
>> + #endif
>> }
>> }
>> }
>> --- ./gdb/inf-ptrace.c_orig 2012-07-25 21:07:04.273078850 +0530
>> +++ ./gdb/inf-ptrace.c 2012-08-02 00:35:56.425443341 +0530
>> @@ -49,8 +49,13 @@
>>
>> pid = ptid_get_pid (inferior_ptid);
>>
>> + #ifdef BFD64
>> + if (ptrace64 (PT_GET_PROCESS_STATE, (long long) pid,
>> + (long long) &pe, sizeof pe) == -1)
>> + #else
>> if (ptrace (PT_GET_PROCESS_STATE, pid,
>> (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
>> + #endif
>> perror_with_name (("ptrace"));
>>
>> gdb_assert (pe.pe_report_event == PTRACE_FORK);
>> @@ -74,7 +79,13 @@
>> it. */
>> remove_breakpoints ();
>>
>> + #ifdef BFD64
>> + if (ptrace64 (PT_DETACH, (long long) pid,
>> + (long long) 1, 0) == -1)
>> + #else
>> if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
>> + #endif
>> +
>> perror_with_name (("ptrace"));
>>
>> /* Switch inferior_ptid out of the parent's way. */
>> @@ -90,7 +101,12 @@
>> /* Breakpoints have already been detached from the child by
>> infrun.c. */
>>
>> + #ifdef BFD64
>> + if (ptrace64 (PT_DETACH, (long long) fpid,
>> + (long long) 1, 0) == -1)
>> + #else
>> if (ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) == -1)
>> + #endif
>> perror_with_name (("ptrace"));
>> }
>>
>> @@ -106,7 +122,11 @@
>> inf_ptrace_me (void)
>> {
>> /* "Trace me, Dr. Memory!" */
>> + #ifdef BFD64
>> + ptrace64 (PT_TRACE_ME, (long long) 0, (long long) 0, 0, 0);
>> + #else
>> ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0);
>> + #endif
>> }
>>
>> /* Start a new inferior Unix child process. EXEC_FILE is the file to
>> @@ -159,8 +179,13 @@
>> /* Set the initial event mask. */
>> memset (&pe, 0, sizeof pe);
>> pe.pe_set_event |= PTRACE_FORK;
>> + #ifdef BFD64
>> + if (ptrace64 (PT_SET_EVENT_MASK, (long long) ptid_get_pid (pid),
>> + (long long) &pe, sizeof pe, 0) == -1)
>> + #else
>> if (ptrace (PT_SET_EVENT_MASK, ptid_get_pid (pid),
>> (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
>> + #endif
>> perror_with_name (("ptrace"));
>> }
>>
>> @@ -229,7 +254,11 @@
>>
>> #ifdef PT_ATTACH
>> errno = 0;
>> + #ifdef BFD64
>> + ptrace64 (PT_ATTACH, (long long) pid, (long long) 0, 0, 0);
>> + #else
>> ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0);
>> + #endif
>> if (errno != 0)
>> perror_with_name (("ptrace"));
>> #else
>> @@ -259,8 +288,13 @@
>> /* Set the initial event mask. */
>> memset (&pe, 0, sizeof pe);
>> pe.pe_set_event |= PTRACE_FORK;
>> + #ifdef BFD64
>> + if (ptrace64 (PT_SET_EVENT_MASK, (long long) pid,
>> + (long long) &pe, sizeof pe, 0) == -1)
>> + #else
>> if (ptrace (PT_SET_EVENT_MASK, pid,
>> (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
>> + #endif
>> perror_with_name (("ptrace"));
>> }
>>
>> @@ -293,7 +327,11 @@
>> previously attached to the inferior. It *might* work if we
>> started the process ourselves. */
>> errno = 0;
>> + #ifdef BFD64
>> + ptrace64 (PT_DETACH, (long long) pid, (long long) 1, sig, 0);
>> + #else
>> ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, sig);
>> + #endif
>> if (errno != 0)
>> perror_with_name (("ptrace"));
>> #else
>> @@ -318,7 +356,11 @@
>> if (pid == 0)
>> return;
>>
>> + #ifdef BFD64
>> + ptrace64 (PT_KILL, (long long) pid, (long long) 0, 0, 0);
>> + #else
>> ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0);
>> + #endif
>> waitpid (pid, &status, 0);
>>
>> target_mourn_inferior ();
>> @@ -372,7 +414,12 @@
>> where it was. If GDB wanted it to start some other way, we have
>> already written a new program counter value to the child. */
>> errno = 0;
>> + #ifdef BFD64
>> + ptrace64 (request, (long long) pid, (long long) 1,
>> + target_signal_to_host (signal), 0);
>> + #else
>> ptrace (request, pid, (PTRACE_TYPE_ARG3)1, target_signal_to_host
>> (signal));
>> + #endif
>> if (errno != 0)
>> perror_with_name (("ptrace"));
>> }
>> @@ -425,8 +472,13 @@
>> ptrace_state_t pe;
>> pid_t fpid;
>>
>> + #ifdef BFD64
>> + if (ptrace64 (PT_GET_PROCESS_STATE, (long long) pid,
>> + (long long) &pe, sizeof pe, 0) == -1)
>> + #else
>> if (ptrace (PT_GET_PROCESS_STATE, pid,
>> (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
>> + #endif
>> perror_with_name (("ptrace"));
>>
>> switch (pe.pe_report_event)
>> @@ -440,8 +492,13 @@
>> if (fpid == -1)
>> perror_with_name (("waitpid"));
>>
>> + #ifdef BFD64
>> + if (ptrace64 (PT_GET_PROCESS_STATE, (long long) fpid,
>> + (long long) &pe, sizeof pe, 0) == -1)
>> + #else
>> if (ptrace (PT_GET_PROCESS_STATE, fpid,
>> (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
>> + #endif
>> perror_with_name (("ptrace"));
>>
>> gdb_assert (pe.pe_report_event == PTRACE_FORK);
>> @@ -495,7 +552,11 @@
>> piod.piod_len = len;
>>
>> errno = 0;
>> + #ifdef BFD64
>> + if (ptrace64 (PT_IO, (long long) pid, (long long) &piod, 0, 0)
>> == 0)
>> + #else
>> if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0)
>> + #endif
>> /* Return the actual number of bytes read or written. */
>> return piod.piod_len;
>> /* If the PT_IO request is somehow not supported, fallback on
>> @@ -536,9 +597,14 @@
>> || (offset + partial_len
>> < rounded_offset + sizeof (PTRACE_TYPE_RET)))
>> /* Need part of initial word -- fetch it. */
>> + #ifdef BFD64
>> + buffer.word = ptrace64 (PT_READ_I, (long long) pid,
>> + (long long) rounded_offset, 0,
>> 0);
>> + #else
>> buffer.word = ptrace (PT_READ_I, pid,
>> (PTRACE_TYPE_ARG3)(uintptr_t)
>> rounded_offset, 0);
>> + #endif
>>
>> /* Copy data to be written over corresponding part of
>> buffer. */
>> @@ -546,17 +612,28 @@
>> writebuf, partial_len);
>>
>> errno = 0;
>> + #ifdef BFD64
>> + ptrace64 (PT_WRITE_D, (long long) pid,
>> + (long long) rounded_offset, buffer.word, 0);
>> + #else
>> ptrace (PT_WRITE_D, pid,
>> (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
>> buffer.word);
>> + #endif
>> if (errno)
>> {
>> /* Using the appropriate one (I or D) is necessary for
>> Gould NP1, at least. */
>> errno = 0;
>> + #ifdef BFD64
>> + ptrace64 (PT_WRITE_I, (long long) pid,
>> + (long long) rounded_offset,
>> + buffer.word, 0);
>> + #else
>> ptrace (PT_WRITE_I, pid,
>> (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
>> buffer.word);
>> + #endif
>> if (errno)
>> return 0;
>> }
>> @@ -565,9 +642,15 @@
>> if (readbuf)
>> {
>> errno = 0;
>> + #ifdef BFD64
>> + buffer.word = ptrace64 (PT_READ_I, (long long) pid,
>> + (long long) rounded_offset,
>> + 0, 0);
>> + #else
>> buffer.word = ptrace (PT_READ_I, pid,
>> (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
>> 0);
>> + #endif
>> if (errno)
>> return 0;
>> /* Copy appropriate bytes out of the buffer. */
>> @@ -687,7 +770,11 @@
>> for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
>> {
>> errno = 0;
>> + #ifdef BFD64
>> + buf[i] = ptrace64 (PT_READ_U, (long long) pid, (long long) addr,
>> 0, 0);
>> + #else
>> buf[i] = ptrace (PT_READ_U, pid,
>> (PTRACE_TYPE_ARG3)(uintptr_t)addr, 0);
>> + #endif
>> if (errno != 0)
>> error (_("Couldn't read register %s (#%d): %s."),
>> gdbarch_register_name (gdbarch, regnum),
>> @@ -746,7 +833,11 @@
>> for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
>> {
>> errno = 0;
>> + #ifdef BFD64
>> + ptrace64 (PT_WRITE_U, (long long) pid, (long long) addr, buf[i],
>> 0);
>> + #else
>> ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)(uintptr_t)addr,
>> buf[i]);
>> + #endif
>> if (errno != 0)
>> error (_("Couldn't write register %s (#%d): %s."),
>> gdbarch_register_name (gdbarch, regnum),
>> --- ./gdb/rs6000-nat.c_orig 2012-07-25 21:07:40.838080241 +0530
>> +++ ./gdb/rs6000-nat.c 2012-07-27 11:27:27.560170366 +0530
>> @@ -66,7 +66,7 @@
>> /* In 32-bit compilation mode (which is the only mode from which
>> ptrace()
>> works on 4.3), __ld_info32 is #defined as equivalent to ld_info.
>> */
>>
>> -#ifdef __ld_info32
>> +#if defined (__ld_info32) || defined (__ld_info64)
>> # define ARCH3264
>> #endif
>>
>> @@ -181,7 +181,11 @@
>> static int
>> rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf)
>> {
>> + #ifdef BFD64
>> + int ret = ptrace64 (req, (long long) id, (long long) addr, data,
>> buf);
>> + #else
>> int ret = ptrace (req, id, (int *)addr, data, buf);
>> + #endif
>> #if 0
>> printf ("rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
>> req, id, (unsigned int)addr, data, (unsigned int)buf, ret);
>> @@ -195,7 +199,11 @@
>> rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
>> {
>> #ifdef ARCH3264
>> + #ifdef BFD64
>> + int ret = ptrace64 (req, (long long) id, addr, data, (int *)buf);
>> + #else
>> int ret = ptracex (req, id, addr, data, buf);
>> + #endif
>> #else
>> int ret = 0;
>> #endif
>> --- ./gdb/xcoffread.c_orig 2012-08-07 17:36:42.378057756 +0530
>> +++ ./gdb/xcoffread.c 2012-08-07 17:36:48.702060320 +0530
>> @@ -956,7 +956,7 @@
>> unsigned int max_symnum;
>> int just_started = 1;
>> int depth = 0;
>> - int fcn_start_addr = 0;
>> + file_ptr fcn_start_addr = 0;
>>
>> struct coff_symbol fcn_stab_saved = { 0 };
>>
>> @@ -1061,7 +1061,7 @@
>> }
>>
>> /* if symbol name starts with ".$" or "$", ignore it. */
>> - if (cs->c_name[0] == '$'
>> + if (cs->c_name[0] == '$' || (!strncmp(cs->c_name, "@FIX", 4))
>> || (cs->c_name[1] == '$' && cs->c_name[0] == '.'))
> Now that you have changed the if condition, please also update the comments before it.
>
>> continue;
>>
>> @@ -1081,8 +1081,7 @@
>> /* Done with all files, everything from here on is globals. */
>> }
>>
>> - if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT)
>> - && cs->c_naux == 1)
>> + if (cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT)
>> {
>> /* Dealing with a symbol with a csect entry. */
>>
>> @@ -1093,8 +1092,16 @@
>> #define CSECT_SCLAS(PP) (CSECT(PP).x_smclas)
>>
>> /* Convert the auxent to something we can access. */
>> - bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs-
>> >c_sclass,
>> - 0, cs->c_naux, &main_aux);
>> + /* xcoff can have more than 1 auxent */
>> + if (cs->c_naux > 1)
>> + bfd_coff_swap_aux_in (abfd,
>> + raw_auxptr + ((coff_data
>> (abfd)->local_symesz) * (cs->c_naux - 1)),
>> + cs->c_type, cs->c_sclass,
>> cs->c_naux - 1, cs->c_naux, &main_aux);
>> + else if (cs->c_naux == 1)
>> + bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs-
>> >c_sclass,
>> + 0, cs->c_naux, &main_aux);
>> + else
>> + ;
>>
>> switch (CSECT_SMTYP (&main_aux))
>> {
>> @@ -1123,43 +1130,44 @@
>> approach does not work! GCC (and I think xlc)
>> seem
>> to put all the code in the unnamed program csect.
>> */
>>
>> - if (last_csect_name)
>> - {
>> - complete_symtab (filestring, file_start_addr);
>> - cur_src_end_addr = file_end_addr;
>> - end_symtab (file_end_addr, objfile,
>> - SECT_OFF_TEXT (objfile));
>> - end_stabs ();
>> - start_stabs ();
>> - /* Give all csects for this source file the same
>> - name. */
>> - start_symtab (filestring, NULL, (CORE_ADDR) 0);
>> - record_debugformat (debugfmt);
>> - }
>> -
>> - /* If this is the very first csect seen,
>> - basically `__start'. */
>> - if (just_started)
>> - {
>> - first_object_file_end
>> - = cs->c_value + CSECT_LEN (&main_aux);
>> - just_started = 0;
>> - }
>> -
>> - file_start_addr =
>> - cs->c_value + ANOFFSET (objfile->section_offsets,
>> - SECT_OFF_TEXT (objfile));
>> - file_end_addr = file_start_addr + CSECT_LEN
>> (&main_aux);
>> -
>> - if (cs->c_name && (cs->c_name[0] == '.'
>> - || cs->c_name[0] == '@'))
>> - {
>> - last_csect_name = cs->c_name;
>> - last_csect_val = cs->c_value;
>> - last_csect_sec = secnum_to_section (cs->c_secnum,
>> - objfile);
>> - }
>> - }
>> + if (just_started)
>> + {
>> + first_object_file_end
>> + = cs->c_value + CSECT_LEN (&main_aux);
>> + just_started = 0;
>> + }
>> +
>> + file_start_addr =
>> + cs->c_value + ANOFFSET (objfile-
>> >section_offsets,
>> + SECT_OFF_TEXT
>> (objfile));
>> + file_end_addr = file_start_addr + CSECT_LEN
>> (&main_aux);
>> +
>> + if (cs->c_name && (cs->c_name[0] == '.'
>> + || cs->c_name[0] == '@'))
>> + {
>> + last_csect_name = cs->c_name;
>> + last_csect_val = cs->c_value;
>> + last_csect_sec = secnum_to_section (cs-
>> >c_secnum,
>> +
>> objfile);
>> + }
>> + if (last_csect_name)
>> + {
>> + filestring = pst->filename;
>> + complete_symtab (filestring,
>> file_start_addr);
>> + cur_src_end_addr = file_end_addr;
>> + end_symtab (file_end_addr, objfile,
>> + SECT_OFF_TEXT (objfile));
>> + end_stabs ();
>> + start_stabs ();
>> + /* Give all csects for this source file the
>> same
>> + name. */
>> + start_symtab (filestring, (char *)NULL,
>> (CORE_ADDR) 0);
>> + record_debugformat (debugfmt);
>> + }
>> + /* If this is the very first csect seen,
>> + basically `__start'. */
>> + }
>> +
>> continue;
>>
>> /* All other symbols are put into the minimal symbol
>> --- ./gdb/config/rs6000/nm-rs6000.h_orig 2012-08-07 17:48:46.181058139
>> +0530
>> +++ ./gdb/config/rs6000/nm-rs6000.h 2012-08-07 17:47:18.749096013 +0530
>> @@ -30,7 +30,7 @@
>> and figure out where the shared libraries have got to. */
>>
>> #define SOLIB_ADD(a, b, c, d) \
>> - if (PIDGET (inferior_ptid)) \
>> + if (PIDGET (inferior_ptid) != 1) \
>> /* Attach to process. */ \
>> xcoff_relocate_symtab (PIDGET (inferior_ptid)); \
>> else \
>> --- ./gdb/symtab.c_orig 2012-08-07 17:52:15.181060405 +0530
>> +++ ./gdb/symtab.c 2012-08-07 17:53:04.653058722 +0530
>> @@ -2072,6 +2072,9 @@
>> {
>> /* Leave prev pointing to the linetable entry for the last line
>> that started at or before PC. */
>> + if ((item->pc > pc) && !i) /* for xlc one less entry for
>> line table */
>> + prev = item; /* point item as prev */
>> +
>> if (item->pc > pc)
>> break;
>>
>>
>> bfd:
>>
>> * configure (powerpc64-*-aix[5-9].*): Match powerpc64 running
>> aix for core file support
>>
>> * rs6000-core.c: Check for __ld_info64 if compiling 64-bit gdb.
>> Added BFD64 check if we are using old core file format for 32-
>> bit gdb.
>> Set sizeof CORE_COMMONSZ appropriately in case of either new
>> or old core file format.
>> (read_hdr): Added BFD64 check for 64-bit support.
>> (rs6000coff_core_p): Likewise.
>> (rs6000coff_core_file_matches_executable_p): Likewise.
>> (rs6000coff_core_file_failing_command): Likewise.
>> (rs6000coff_core_file_failing_command): Likewise.
>>
>>
>> --- ./bfd/configure_orig 2011-11-11 12:01:31.188995290 +0530
>> +++ ./bfd/configure 2012-07-25 16:07:39.010735665 +0530
>> @@ -13973,7 +13973,7 @@
>> rs6000-*-lynx*)
>> COREFILE=lynx-core.lo
>> ;;
>> - rs6000-*-aix[5-9].* | powerpc-*-aix[5-9].*)
>> + rs6000-*-aix[5-9].* | powerpc-*-aix[5-9].* | powerpc64-*-aix[5-9].*)
>> COREFILE=rs6000-core.lo
>> COREFLAG="$COREFLAG -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE"
>> ;;
>> @@ -14011,6 +14011,7 @@
>> rs6000-*-*) COREFILE=rs6000-core.lo ;;
>> powerpc-*-aix4*) COREFILE=rs6000-core.lo ;;
>> powerpc-*-aix*) COREFILE=rs6000-core.lo ;;
>> + powerpc64-*-aix) COREFILE=rs6000-core.lo ;;
>> powerpc-*-beos*) ;;
>> powerpc-*-freebsd* | powerpc-*-kfreebsd*-gnu)
>> COREFILE='' ;;
>> --- ./bfd/rs6000-core.c_orig 2011-11-10 19:02:59.093607185 +0530
>> +++ ./bfd/rs6000-core.c 2012-07-27 12:32:11.960181190 +0530
>> @@ -94,7 +94,7 @@
>> /* Union of 32-bit and 64-bit versions of ld_info. */
>>
>> typedef union {
>> -#ifdef __ld_info32
>> +#if defined (__ld_info32) || defined (__ld_info64)
>> struct __ld_info32 l32;
>> struct __ld_info64 l64;
>> #else
>> @@ -111,8 +111,10 @@
>> #else
>> struct core_dump new_dump; /* for simpler coding */
>> #endif
>> +#ifndef BFD64 /* use old only if gdb is 32-bit */
>> struct core_dump old; /* old AIX 4.2- core dump, still
>> used on
>> 4.3+ with appropriate SMIT config */
>> +#endif
>> } CoreHdr;
>>
>> /* Union of old and new vm_info structures. */
>> @@ -124,14 +126,20 @@
>> #else
>> struct vm_info new_dump;
>> #endif
>> +#ifndef BFD64
>> struct vm_info old;
>> +#endif
>> } VmInfo;
>> #endif
>>
>> /* Return whether CoreHdr C is in new or old format. */
>>
>> #ifdef AIX_CORE_DUMPX_CORE
>> -# define CORE_NEW(c) (!(c).old.c_entries)
>> + #ifndef BFD64
>> + # define CORE_NEW(c) (!(c).old.c_entries)
>> + #else
>> + # define CORE_NEW(c) (!(c).new_dump.c_entries)
>> + #endif
>> #else
>> # define CORE_NEW(c) 0
>> #endif
>> @@ -260,8 +268,13 @@
>>
>> /* Size of the leading portion that old and new core dump structures
>> have in
>> common. */
>> -#define CORE_COMMONSZ ((int) &((struct core_dump *) 0)->c_entries \
>> - + sizeof (((struct core_dump *) 0)->c_entries))
>> +#ifdef AIX_CORE_DUMPX_CORE
>> +#define CORE_COMMONSZ ((long) &((struct core_dumpx *) 0)->c_entries \
>> + + sizeof (((struct core_dumpx *) 0)-
>> >c_entries))
>> +#else
>> +#define CORE_COMMONSZ ((int) &((struct core_dump *) 0)->c_entries \
>> + + sizeof (((struct core_dump *) 0)->c_entries)
>> +#endif
>>
>> /* Define prototypes for certain functions, to avoid a compiler
>> warning
>> saying that they are missing. */
>> @@ -292,8 +305,10 @@
>> /* Read the trailing portion of the structure. */
>> if (CORE_NEW (*core))
>> size = sizeof (core->new_dump);
>> + #ifndef BFD64
>> else
>> size = sizeof (core->old);
>> + #endif
>> size -= CORE_COMMONSZ;
>> return bfd_bread ((char *) core + CORE_COMMONSZ, size, abfd) ==
>> size;
>> }
>> @@ -358,6 +373,7 @@
>> c_stackend = CNEW_STACKORG (core.new_dump) + c_size;
>> c_lsize = CNEW_LSIZE (core.new_dump);
>> c_loader = CNEW_LOADER (core.new_dump);
>> + #ifndef BFD64
>> proc64 = CNEW_PROC64 (core.new_dump);
>> }
>> else
>> @@ -368,6 +384,7 @@
>> c_stackend = COLD_STACKEND;
>> c_lsize = 0x7ffffff;
>> c_loader = (file_ptr) (ptr_to_uint) COLD_LOADER (core.old);
>> + #endif
>> proc64 = 0;
>> }
>>
>> @@ -381,11 +398,13 @@
>> c_regsize = sizeof (CNEW_MSTSAVE (core.new_dump));
>> c_regptr = &CNEW_MSTSAVE (core.new_dump);
>> }
>> + #ifndef BFD64
>> else
>> {
>> c_regsize = sizeof (COLD_MSTSAVE (core.old));
>> c_regptr = &COLD_MSTSAVE (core.old);
>> }
>> + #endif
>> c_regoff = (char *) c_regptr - (char *) &core;
>>
>> if (bfd_stat (abfd, &statbuf) < 0)
>> @@ -435,7 +454,11 @@
>> }
>>
>> /* Sanity check on the c_tab field. */
>> + #ifndef BFD64
>> if (!CORE_NEW (core) && (c_loader < (file_ptr) sizeof core.old ||
>> + #else
>> + if (!CORE_NEW (core) && (c_loader < (file_ptr) sizeof core.new_dump
>> ||
>> + #endif
>> c_loader >= statbuf.st_size ||
>> c_loader >= c_stack))
>> {
>> @@ -449,7 +472,11 @@
>> bfd_get_filename (abfd));
>>
>> /* Allocate core file header. */
>> + #ifndef BFD64
>> size = CORE_NEW (core) ? sizeof (core.new_dump) : sizeof (core.old);
>> + #else
>> + size = sizeof (core.new_dump);
>> + #endif
>> tmpptr = (char *) bfd_zalloc (abfd, (bfd_size_type) size);
>> if (!tmpptr)
>> return NULL;
>> @@ -542,6 +569,7 @@
>> c_vmregions = core.new_dump.c_vmregions;
>> c_vmm = (file_ptr) core.new_dump.c_vmm;
>> }
>> + #ifndef BFD64
>> else
>> {
>> c_datasize = core.old.c_datasize;
>> @@ -549,6 +577,7 @@
>> c_vmregions = core.old.c_vmregions;
>> c_vmm = (file_ptr) (ptr_to_uint) core.old.c_vmm;
>> }
>> + #endif
>>
>> /* .data section from executable. */
>> if (c_datasize)
>> @@ -615,7 +644,11 @@
>> file_ptr vminfo_offset;
>> bfd_vma vminfo_addr;
>>
>> + #ifndef BFD64
>> size = CORE_NEW (core) ? sizeof (vminfo.new_dump) : sizeof
>> (vminfo.old);
>> + #else
>> + size = sizeof (vminfo.new_dump);
>> + #endif
>> if (bfd_bread (&vminfo, size, abfd) != size)
>> goto fail;
>>
>> @@ -625,12 +658,14 @@
>> vminfo_size = vminfo.new_dump.vminfo_size;
>> vminfo_offset = vminfo.new_dump.vminfo_offset;
>> }
>> + #ifndef BFD64
>> else
>> {
>> vminfo_addr = (bfd_vma) (long) vminfo.old.vminfo_addr;
>> vminfo_size = vminfo.old.vminfo_size;
>> vminfo_offset = vminfo.old.vminfo_offset;
>> }
>> + #endif
>>
>> if (vminfo_offset)
>> if (!make_bfd_asection (abfd, ".vmdata",
>> @@ -670,8 +705,10 @@
>>
>> if (CORE_NEW (core))
>> c_loader = CNEW_LOADER (core.new_dump);
>> + #ifndef BFD64
>> else
>> c_loader = (file_ptr) (ptr_to_uint) COLD_LOADER (core.old);
>> + #endif
>>
>> if (CORE_NEW (core) && CNEW_PROC64 (core.new_dump))
>> size = (int) ((LdInfo *) 0)->l64.ldinfo_filename;
>> @@ -734,8 +771,12 @@
>> rs6000coff_core_file_failing_command (bfd *abfd)
>> {
>> CoreHdr *core = core_hdr (abfd);
>> + #ifndef BFD64
>> char *com = CORE_NEW (*core) ?
>> CNEW_COMM (core->new_dump) : COLD_COMM (core->old);
>> + #else
>> + char *com = CNEW_COMM (core->new_dump);
>> + #endif
>>
>> if (*com)
>> return com;
>> @@ -747,7 +788,11 @@
>> rs6000coff_core_file_failing_signal (bfd *abfd)
>> {
>> CoreHdr *core = core_hdr (abfd);
>> + #ifndef BFD64
>> return CORE_NEW (*core) ? core->new_dump.c_signo : core-
>> >old.c_signo;
>> + #else
>> + return core->new_dump.c_signo;
>> + #endif
>> }
>>
>> #endif /* AIX_CORE */
>>
>> --
>> Thanks & Regards,
>> Sangamesh
>
> Regards,
> Abid
--
Thanks & Regards,
Sangamesh