Home | History | Annotate | Download | only in ExecutionEngine
      1 /*
      2  * Copyright 2012, The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef BCC_EXECUTION_ENGINE_OBJECT_LOADER_H
     18 #define BCC_EXECUTION_ENGINE_OBJECT_LOADER_H
     19 
     20 #include <cstddef>
     21 
     22 #include "bcc/Support/Log.h"
     23 
     24 #include <utils/Vector.h>
     25 
     26 namespace bcc {
     27 
     28 class FileBase;
     29 class ObjectLoaderImpl;
     30 class SymbolResolverInterface;
     31 
     32 class ObjectLoader {
     33 public:
     34   enum SymbolType {
     35     // TODO: More types.
     36     kFunctionType,
     37     kUnknownType,
     38   };
     39 
     40 private:
     41   ObjectLoaderImpl *mImpl;
     42 
     43   void *mDebugImage;
     44 
     45   ObjectLoader() : mImpl(NULL), mDebugImage(0) { }
     46 
     47 public:
     48   // Load from a in-memory object. pName is a descriptive name of this memory.
     49   static ObjectLoader *Load(void *pMemStart, size_t pMemSize, const char *pName,
     50                             SymbolResolverInterface &pResolver,
     51                             bool pEnableGDBDebug);
     52 
     53   // Load from a file.
     54   static ObjectLoader *Load(FileBase &pFile,
     55                             SymbolResolverInterface &pResolver,
     56                             bool pEnableGDBDebug);
     57 
     58   void *getSymbolAddress(const char *pName) const;
     59 
     60   size_t getSymbolSize(const char *pName) const;
     61 
     62   // Get the symbol name where the symbol is of the type pType. If kUnknownType
     63   // is given, it returns all symbols' names in the object.
     64   bool getSymbolNameList(android::Vector<const char *>& pNameList,
     65                          SymbolType pType = kUnknownType) const;
     66 
     67   ~ObjectLoader();
     68 };
     69 
     70 } // namespace bcc
     71 
     72 #endif // BCC_EXECUTION_ENGINE_OBJECT_LOADER_H
     73