LCOV - code coverage report
Current view: directory - src/trusted/debug_stub - abi.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 1 1 100.0 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2010 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : // This module provides an interface for performing ABI specific
       8                 : // functions needed by the Target and Host.  ABI objects are provided
       9                 : // to the rest of the system as "const" to prevent accidental modification.
      10                 : // None of the resources in the Abi object are actually owned by the Abi
      11                 : // object, they are assumed to be static and never destroyed.
      12                 : //
      13                 : // This module will only throw standard errors
      14                 : //    std::bad_alloc - when out of memory
      15                 : //    std::out_of_range - when using an out of range regsiter index
      16                 : //
      17                 : // It is required that Init be called prior to calling Find to ensure
      18                 : // the various built-in ABIs have been registered.
      19                 : 
      20                 : #ifndef NATIVE_CLIENT_GDB_RSP_ABI_H_
      21                 : #define NATIVE_CLIENT_GDB_RSP_ABI_H_ 1
      22                 : 
      23                 : #include <map>
      24                 : #include <string>
      25                 : 
      26                 : #include "native_client/src/include/portability.h"
      27                 : 
      28                 : namespace gdb_rsp {
      29                 : 
      30                 : class Abi {
      31                 :  public:
      32                 :   // Defines how a register is exposed to the debugger.
      33                 :   enum RegType {
      34                 :     GENERAL,
      35                 :     READ_ONLY,
      36                 :     X86_64_TRUSTED_PTR,
      37                 :     REG_TYPE_CNT
      38                 :   };
      39                 : 
      40                 :   // Defines an individual register
      41                 :   struct RegDef {
      42                 :     const char *name_;
      43                 :     uint32_t bytes_;
      44                 :     RegType type_;
      45                 :     uint32_t index_;
      46                 :     uint32_t offset_;
      47                 :   };
      48                 : 
      49                 :   // Defines how breakpoints work.
      50                 :   // code_ points to a series of bytes which will be placed in the code to
      51                 :   // create the breakpoint.  size_ is the size of that array.  We use a 32b
      52                 :   // size since the memory modification API only supports a 32b size.
      53                 :   struct BPDef {
      54                 :     uint32_t size_;
      55                 :     uint8_t *code_;
      56                 :   };
      57                 : 
      58                 :   // Returns the registered name of this ABI.
      59                 :   const char *GetName() const;
      60                 : 
      61                 :   // Returns a pointer to the breakpoint definition.
      62                 :   const BPDef *GetBreakpointDef() const;
      63                 : 
      64                 :   // Returns the size of the thread context.
      65                 :   uint32_t GetContextSize() const;
      66                 : 
      67                 :   // Returns the number of registers visbible.
      68                 :   uint32_t GetRegisterCount() const;
      69                 : 
      70                 :   // Returns a definition of the register at the provided index, or
      71                 :   // NULL if it does not exist.
      72                 :   const RegDef *GetRegisterDef(uint32_t index) const;
      73                 : 
      74                 :   // Returns a definition of the instruction pointer.
      75                 :   const RegDef *GetInstPtrDef() const;
      76                 : 
      77                 :   const char *GetTargetXml() const {
      78              17 :     return target_xml_;
      79                 :   }
      80                 : 
      81                 :   // Called to assign a set of register definitions to an ABI.
      82                 :   // This function is non-reentrant.
      83                 :   static void Register(const char *name, RegDef *defs,
      84                 :                        uint32_t cnt, uint32_t ip, const BPDef *bp,
      85                 :                        const char *target_xml);
      86                 : 
      87                 :   // Called to search the map for a matching Abi by name.
      88                 :   // This function is reentrant.
      89                 :   static const Abi *Find(const char *name);
      90                 : 
      91                 :   // Get the ABI of for the running application.
      92                 :   static const Abi *Get();
      93                 : 
      94                 :  protected:
      95                 :   const char *name_;
      96                 :   const RegDef *regDefs_;
      97                 :   uint32_t regCnt_;
      98                 :   uint32_t ctxSize_;
      99                 :   const BPDef *bpDef_;
     100                 :   uint32_t ipIndex_;
     101                 :   const char *target_xml_;
     102                 : 
     103                 :  private:
     104                 :   Abi();
     105                 :   ~Abi();
     106                 :   void operator =(const Abi&);
     107                 : };
     108                 : 
     109                 : typedef std::map<std::string, Abi*> AbiMap_t;
     110                 : 
     111                 : }  // namespace gdb_rsp
     112                 : 
     113                 : #endif  // NATIVE_CLIENT_GDB_RSP_ABI_H_
     114                 : 

Generated by: LCOV version 1.7