parseauxv.C

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 #include "common/h/parseauxv.h"
00032 #include <elf.h>
00033 #include <unistd.h>
00034 #include <assert.h>
00035 #include <stdio.h>
00036 #include <sys/types.h>
00037 #include <sys/stat.h>
00038 #include <fcntl.h>
00039 
00040 #include <vector>
00041 
00042 std::map<int, AuxvParser *> AuxvParser::pid_to_parser;
00043 
00044 AuxvParser *AuxvParser::createAuxvParser(int pid, unsigned asize)
00045 {
00046    AuxvParser *newparser = NULL;
00047    if (pid_to_parser.count(pid))
00048    {
00049       newparser = pid_to_parser[pid];
00050    }
00051    else
00052    {
00053       newparser = new AuxvParser(pid, asize);
00054       if (!newparser)
00055       {
00056          return NULL;
00057       }
00058       if (newparser->create_err)
00059       {
00060          delete newparser;
00061          return NULL;
00062       }
00063       pid_to_parser[pid] = newparser;
00064    }
00065 
00066    newparser->ref_count++;
00067    return newparser;
00068 }
00069 
00070 void AuxvParser::deleteAuxvParser()
00071 {
00072    assert(ref_count);
00073    ref_count--;
00074    if (!ref_count) {
00075       delete this;
00076       return;
00077    }
00078 }
00079 
00080 AuxvParser::~AuxvParser()
00081 {
00082    pid_to_parser.erase(pid);
00083 }
00084 
00085 AuxvParser::AuxvParser(int pid_, unsigned addr_size_) :
00086    pid(pid_),
00087    ref_count(0),
00088    interpreter_base(0x0),
00089    vsyscall_base(0x0),
00090    vsyscall_text(0x0),
00091    vsyscall_end(0x0),
00092    found_vsyscall(false),
00093    phdr(0x0),
00094    page_size(0x0),
00095    addr_size(addr_size_)
00096 {
00097    create_err = !readAuxvInfo();
00098 }
00099  
00100 Address AuxvParser::getInterpreterBase()
00101 {
00102    return interpreter_base;
00103 }
00104  
00105 bool AuxvParser::parsedVsyscall()
00106 {
00107    return found_vsyscall;
00108 }
00109 
00110 Address AuxvParser::getVsyscallBase()
00111 {
00112    return vsyscall_base;
00113 }
00114 
00115 Address AuxvParser::getVsyscallText()
00116 {
00117    return vsyscall_text;
00118 }
00119 
00120 Address AuxvParser::getVsyscallEnd()
00121 {
00122    return vsyscall_end;
00123 }   
00124 
00125 Address AuxvParser::getProgramBase()
00126 {
00127    return phdr;
00128 }
00129 
00130 Address AuxvParser::getPageSize()
00131 {
00132    return page_size;
00133 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1