Re: [DynInst_API:] PATCH: have SymtabAPI properly use ELF contents to set architecture


Date: Tue, 28 Jul 2015 14:57:19 -0500
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] PATCH: have SymtabAPI properly use ELF contents to set architecture
On 07/28/2015 01:47 PM, Jim Galarowicz wrote:

Hi Bill, all,

I cancelled my original post - too large.   Resending a shortened version..

I sent mail to a NASA representative about the elf.h EM_ architecture
enumerated value.
The elf.h files that I've been able to locate only go up to the
enumerated value of 95.
The Intel MIC application seems to be indicating a value of 181.

As per one of your suggestions, I put a switch case block in for the
enum value of 181 in dwarfHandle.C and mapped it to

    #define EM_X86_64    62        /* AMD x86-64 architecture */


 From dwarfHandle.C:

    Dyninst::Architecture arch;
    fprintf(stderr,"file->e_machine()=%d\n", file->e_machine());
    switch (file->e_machine()) {
       case EM_386:
          arch = Arch_x86;
          break;
       case EM_X86_64:
          arch = Arch_x86_64;
          break;
       case EM_PPC:
          arch = Arch_ppc32;
          break;
       case EM_PPC64:
          arch = Arch_ppc64;
          break;
       //steve: added, defination found: /usr/include/linux/elf-em.h
       case EM_ARM:
          arch = Arch_aarch32;
          break;
#if defined(arch_aarch64)
       case EM_AARCH64:
               arch = Arch_aarch64;
              break;
#endif
*      case 181:**
**         arch = Arch_x86_64;**
**         break;*
       default:
          assert(0 && "Unsupported architecture in ELF file.");
      return false;
    }
    sw = Dwarf::DwarfFrameParser::create(*frame_data, arch);

    init_dwarf_status = dwarf_status_ok;
    return true;
}

The execution of dyninst on the Intel MIC binary completes with this
change in.

*However, we don't get any statement or loop information.  It looks like
we are not finding any functions when we use the code below.**
**functions.size() is always 0.**
**Could this be because Dyninst doesn't have the correct architecture
settings to work with?  Or were there more subtle changes to the API?*

I'm not sure. Can you send me a sample binary and an address you're failing to get functions/loops at, and I can take a look?

(Do you guys try to get statement information through symtab directly, or only through BPatch? If the latter, does going directly through symtab work?)

--bw

    std::vector<LoopInfo> getLoopsAt(const Address& address,
    BPatch_image& image)
    {
         std::vector<LoopInfo> retval;

         // Iterate over each module within the specified image

         BPatch_Vector<BPatch_module*>* modules = image.getModules();
         std::cerr << "DyninstSymbols.cxx: modules=" << modules <<
    std::endl;

         if (modules == NULL)
         {
             return retval;
         }

         std::cerr << "DyninstSymbols.cxx: modules->size()=" <<
    modules->size() << std::endl;

         for (unsigned int m = 0; m < modules->size(); ++m)
         {
             BPatch_module* module = (*modules)[m];

             if (module == NULL)
             {
                 continue;
             }

             Address module_base = (uint64_t)module->getBaseAddr();

             // Find the function(s) containing the specified address

             BPatch_Vector<BPatch_function*> functions;

    *module->findFunctionByAddress( (void*)((module_base +
    address).getValue()), functions, false, false);*

             std::cerr << "DyninstSymbols.cxx: functions.size()=" <<
    functions.size() << std::endl;



Here is the output from the OpenSpeedShop run:

    PBS maia96 3> osspcsamp "mpiexec.hydra -host mic0 -np 30 ./nbody.mic"

    [openss]: pcsamp experiment using the pcsamp experiment default
    sampling rate: "100".
    [openss]: pcsamp experiment calling openss.
    [openss]: Setting up offline raw data directory in
    /nobackup/jgalarow/offline-oss
    [openss]: Running offline pcsamp experiment using the command:
    "mpiexec.hydra -host mic0 -np 30
    /nobackupp8/jgalarow/maia/ossoffline/compute/bin/ossrun -c pcsamp
    ./nbody.mic"

    /nasa/mic_knc/mic/basic/basic.2.0/bin/modulecmd: Command not found.
    Iteration 1 of 50...
    Iteration 2 of 50...
    ..
    ..
    Iteration 48 of 50...
    Iteration 49 of 50...
    Iteration 50 of 50...

    [openss]: Converting raw data from /nobackup/jgalarow/offline-oss
    into temp file X.0.openss

    Processing raw data for nbody.mic ...
    Processing processes and threads ...
    Processing performance data ...
    Processing symbols ...
    Resolving symbols for /nobackupp8/jgalarow/demos/nbody/nbody.mic
    file->e_machine()=181
    file->e_machine()=62
    Resolving symbols for /lib64/libc-2.14.90.so
    --SERIOUS-- #68: Can't read executable file /lib64/libc-2.14.90.so:
    No such file or directory
    WARNING: Dyninst failed to open the linked object
    "/lib64/libc-2.14.90.so"!
    Resolving symbols for
    /nasa/intel/impi/5.0.3.048/mic/lib/release_mt/libmpi.so.12.0
    file->e_machine()=181
    Resolving symbols for
    /nobackupp8/jgalarow/maia/ossoffline/compute/lib64/openspeedshop/pcsamp-rt-offline.so
    file->e_machine()=181
    Resolving symbols for
    /nasa/intel/impi/5.0.3.048/mic/lib/libmpifort.so.12.0
    file->e_machine()=181
    Updating database with symbols ...
    Finished ...

    [openss]: Restoring and displaying default view for:
         /nobackupp8/jgalarow/demos/nbody/nbody.mic-pcsamp-4.openss
    [openss]: The restored experiment identifier is:  -x 1

      Exclusive   % of CPU  Function (defining location)
       CPU time       Time
             in
       seconds.
    154.130000  53.387600  main (nbody.mic)
      98.710000  34.191202  __svml_div8_mask (nbody.mic)
      33.140000  11.479044  MPIDI_CH3I_Progress (libmpi.so.12.0)
       2.350000   0.813994  sqrt (nbody.mic)
       0.060000   0.020783  MPIDI_CH3_iSendv (libmpi.so.12.0)
       0.050000   0.017319  MPID_Isend (libmpi.so.12.0)
       0.050000   0.017319  MPI_Irecv (libmpi.so.12.0)
       0.040000   0.013855  MPI_Isend (libmpi.so.12.0)
       0.020000   0.006928  __I_MPI___intel_lrb_memcpy (libmpifort.so.12.0)
       0.020000   0.006928  MPIR_Waitall_impl (libmpi.so.12.0)
       0.020000   0.006928  MPIDI_CH3_Request_destroy (libmpi.so.12.0)
       0.020000   0.006928  MPIDI_CH3U_Recvq_FDU_or_AEP (libmpi.so.12.0)
       0.010000   0.003464  MPIU_Handle_obj_alloc (libmpi.so.12.0)
       0.010000   0.003464  MPIC_Wait (libmpi.so.12.0)
       0.010000   0.003464  MPID_Irecv (libmpi.so.12.0)
       0.010000   0.003464  MPIDI_CH3_PktHandler_EagerSend (libmpi.so.12.0)
       0.010000   0.003464  MPIDI_nem_active_vc (libmpi.so.12.0)
       0.010000   0.003464  MPID_Send (libmpi.so.12.0)
       0.010000   0.003464  PMPI_Waitall (libmpi.so.12.0)
       0.010000   0.003464  MPIDI_CH3I_Posted_recv_enqueued (libmpi.so.12.0)
       0.010000   0.003464  MPIR_Allreduce_intra (libmpi.so.12.0)


    PBS maia96 4> openss -cli -f
    /nobackupp8/jgalarow/demos/nbody/nbody.mic-pcsamp-4.openss
    openss>>[openss]: The restored experiment identifier is:  -x 1
    openss>>expview

      Exclusive   % of CPU  Function (defining location)
       CPU time       Time
             in
       seconds.
    154.130000  53.387600  main (nbody.mic)
      98.710000  34.191202  __svml_div8_mask (nbody.mic)
      33.140000  11.479044  MPIDI_CH3I_Progress (libmpi.so.12.0)
       2.350000   0.813994  sqrt (nbody.mic)
       0.060000   0.020783  MPIDI_CH3_iSendv (libmpi.so.12.0)
       0.050000   0.017319  MPID_Isend (libmpi.so.12.0)
       0.050000   0.017319  MPI_Irecv (libmpi.so.12.0)
       0.040000   0.013855  MPI_Isend (libmpi.so.12.0)
       0.020000   0.006928  __I_MPI___intel_lrb_memcpy (libmpifort.so.12.0)
       0.020000   0.006928  MPIR_Waitall_impl (libmpi.so.12.0)
       0.020000   0.006928  MPIDI_CH3_Request_destroy (libmpi.so.12.0)
       0.020000   0.006928  MPIDI_CH3U_Recvq_FDU_or_AEP (libmpi.so.12.0)
       0.010000   0.003464  MPIU_Handle_obj_alloc (libmpi.so.12.0)
       0.010000   0.003464  MPIC_Wait (libmpi.so.12.0)
       0.010000   0.003464  MPID_Irecv (libmpi.so.12.0)
       0.010000   0.003464  MPIDI_CH3_PktHandler_EagerSend (libmpi.so.12.0)
       0.010000   0.003464  MPIDI_nem_active_vc (libmpi.so.12.0)
       0.010000   0.003464  MPID_Send (libmpi.so.12.0)
       0.010000   0.003464  PMPI_Waitall (libmpi.so.12.0)
       0.010000   0.003464  MPIDI_CH3I_Posted_recv_enqueued (libmpi.so.12.0)
       0.010000   0.003464  MPIR_Allreduce_intra (libmpi.so.12.0)

    openss>>expview -vstatements
    (There are no objects specified for the basic Detail report.)

    openss>>expview -vloops
    (There are no objects specified for the basic Detail report.)

    openss>>expview -v linkedobjects

      Exclusive   % of CPU  LinkedObject
       CPU time       Time
             in
       seconds.
    255.200000  88.270900  nbody.mic
      33.730000  11.666840  libmpi.so.12.0
       0.140000   0.048424  libc-2.14.90.so
       0.030000   0.010377  libmpifort.so.12.0
       0.010000   0.003459  pcsamp-rt-offline.so
    openss>>
    openss>>quit


On 07/28/2015 11:40 AM, Bill Williams wrote:
On 07/28/2015 11:31 AM, Jim Galarowicz wrote:
Hi Bill,

I've built dyninst from the latest git bits for dyninst and then changed
our source to get around the loop head API issue.
When I run using the new version of dyninst, I'm still getting the
architecture assert shown below.

Is there anything I can try to get around this issue?

Have you tracked down the target elf.h on maia? If I can get my hands
on the enums from that, I can (or you can, for that matter) patch
appropriately in that switch--it's entirely a matter of mapping ELF
machine IDs to the closest available dyninst architecture (if one
exists).




--
--bw

Bill Williams
Paradyn Project
bill@xxxxxxxxxxx
[← Prev in Thread] Current Thread [Next in Thread→]