LCOV - code coverage report
Current view: directory - tools/profiler - shared-libraries.h (source / functions) Found Hit Coverage
Test: app.info Lines: 30 0 0.0 %
Date: 2012-06-02 Functions: 12 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is the Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *  Jeff Muizelaar <jmuizelaar@mozilla.com>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include <vector>
      40                 : #include <string.h>
      41                 : #include <stdlib.h>
      42                 : #include <mozilla/StandardInteger.h>
      43                 : 
      44                 : class SharedLibrary {
      45                 : public:
      46               0 :   SharedLibrary(unsigned long aStart, unsigned long aEnd, unsigned long aOffset, char *aName)
      47                 :     : mStart(aStart)
      48                 :     , mEnd(aEnd)
      49                 :     , mOffset(aOffset)
      50               0 :     , mName(strdup(aName))
      51               0 :   {}
      52                 : 
      53               0 :   SharedLibrary(const SharedLibrary& aEntry)
      54                 :     : mStart(aEntry.mStart)
      55                 :     , mEnd(aEntry.mEnd)
      56                 :     , mOffset(aEntry.mOffset)
      57               0 :     , mName(strdup(aEntry.mName))
      58               0 :   {}
      59                 : 
      60               0 :   SharedLibrary& operator=(const SharedLibrary& aEntry)
      61                 :   {
      62                 :     // Gracefully handle self assignment
      63               0 :     if (this == &aEntry) return *this;
      64                 : 
      65               0 :     mStart = aEntry.mStart;
      66               0 :     mEnd = aEntry.mEnd;
      67               0 :     mOffset = aEntry.mOffset;
      68               0 :     if (mName)
      69               0 :       free(mName);
      70               0 :     mName = strdup(aEntry.mName);
      71               0 :     return *this;
      72                 :   }
      73                 : 
      74               0 :   ~SharedLibrary()
      75                 :   {
      76               0 :     free(mName);
      77               0 :   }
      78                 : 
      79               0 :   uintptr_t GetStart() { return mStart; }
      80               0 :   uintptr_t GetEnd() { return mEnd; }
      81               0 :   char* GetName() { return mName; }
      82                 : 
      83                 : private:
      84                 :   explicit SharedLibrary() {}
      85                 : 
      86                 :   uintptr_t mStart;
      87                 :   uintptr_t mEnd;
      88                 :   uintptr_t mOffset;
      89                 :   char *mName;
      90                 : };
      91                 : 
      92               0 : class SharedLibraryInfo {
      93                 : public:
      94                 :   static SharedLibraryInfo GetInfoForSelf();
      95               0 :   SharedLibraryInfo() {}
      96                 : 
      97               0 :   void AddSharedLibrary(SharedLibrary entry)
      98                 :   {
      99               0 :     mEntries.push_back(entry);
     100               0 :   }
     101                 : 
     102               0 :   SharedLibrary& GetEntry(size_t i)
     103                 :   {
     104               0 :     return mEntries[i];
     105                 :   }
     106                 : 
     107               0 :   size_t GetSize()
     108                 :   {
     109               0 :     return mEntries.size();
     110                 :   }
     111                 : private:
     112                 :   std::vector<SharedLibrary> mEntries;
     113                 : };

Generated by: LCOV version 1.7