LCOV - code coverage report
Current view: top level - tools/profiler/lul - platform-linux-lul.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 19 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include <stdio.h>
       7             : #include <signal.h>
       8             : #include <string.h>
       9             : #include <stdlib.h>
      10             : #include <time.h>
      11             : 
      12             : #include "platform.h"
      13             : #include "PlatformMacros.h"
      14             : #include "LulMain.h"
      15             : #include "shared-libraries.h"
      16             : #include "AutoObjectMapper.h"
      17             : 
      18             : // Contains miscellaneous helpers that are used to connect the Gecko Profiler
      19             : // and LUL.
      20             : 
      21             : // Find out, in a platform-dependent way, where the code modules got
      22             : // mapped in the process' virtual address space, and get |aLUL| to
      23             : // load unwind info for them.
      24             : void
      25           0 : read_procmaps(lul::LUL* aLUL)
      26             : {
      27           0 :   MOZ_ASSERT(aLUL->CountMappings() == 0);
      28             : 
      29             : # if defined(GP_OS_linux) || defined(GP_OS_android)
      30           0 :   SharedLibraryInfo info = SharedLibraryInfo::GetInfoForSelf();
      31             : 
      32           0 :   for (size_t i = 0; i < info.GetSize(); i++) {
      33           0 :     const SharedLibrary& lib = info.GetEntry(i);
      34             : 
      35           0 :     std::string nativePath = lib.GetNativeDebugPath();
      36             : 
      37             : #   if defined(GP_OS_android)
      38             :     // We're using faulty.lib.  Use a special-case object mapper.
      39             :     AutoObjectMapperFaultyLib mapper(aLUL->mLog);
      40             : #   else
      41             :     // We can use the standard POSIX-based mapper.
      42           0 :     AutoObjectMapperPOSIX mapper(aLUL->mLog);
      43             : #   endif
      44             : 
      45             :     // Ask |mapper| to map the object.  Then hand its mapped address
      46             :     // to NotifyAfterMap().
      47           0 :     void*  image = nullptr;
      48           0 :     size_t size  = 0;
      49           0 :     bool ok = mapper.Map(&image, &size, nativePath);
      50           0 :     if (ok && image && size > 0) {
      51           0 :       aLUL->NotifyAfterMap(lib.GetStart(), lib.GetEnd()-lib.GetStart(),
      52           0 :                            nativePath.c_str(), image);
      53           0 :     } else if (!ok && lib.GetDebugName().IsEmpty()) {
      54             :       // The object has no name and (as a consequence) the mapper failed to map
      55             :       // it.  This happens on Linux, where GetInfoForSelf() produces such a
      56             :       // mapping for the VDSO.  This is a problem on x86-{linux,android} because
      57             :       // lack of knowledge about the mapped area inhibits LUL's special
      58             :       // __kernel_syscall handling.  Hence notify |aLUL| at least of the
      59             :       // mapping, even though it can't read any unwind information for the area.
      60           0 :       aLUL->NotifyExecutableArea(lib.GetStart(), lib.GetEnd()-lib.GetStart());
      61             :     }
      62             : 
      63             :     // |mapper| goes out of scope at this point and so its destructor
      64             :     // unmaps the object.
      65             :   }
      66             : 
      67             : # else
      68             : #  error "Unknown platform"
      69             : # endif
      70           0 : }
      71             : 
      72             : // LUL needs a callback for its logging sink.
      73             : void
      74           0 : logging_sink_for_LUL(const char* str)
      75             : {
      76             :   // These are only printed when Verbose logging is enabled (e.g. with
      77             :   // MOZ_LOG="prof:5"). This is because LUL's logging is much more verbose than
      78             :   // the rest of the profiler's logging, which occurs at the Info (3) and Debug
      79             :   // (4) levels.
      80           0 :   MOZ_LOG(gProfilerLog, mozilla::LogLevel::Verbose, ("[%d] %s", getpid(), str));
      81           0 : }

Generated by: LCOV version 1.13