LCOV - code coverage report
Current view: directory - src/trusted/validator/x86/decoder - ncopcode_desc_verbose.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 29 27 93.1 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 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                 : /* Descriptors to model instructions, opcodes, and instruction operands. */
       8                 : 
       9                 : #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc.h"
      10                 : 
      11                 : #include <assert.h>
      12                 : #include <string.h>
      13                 : 
      14                 : #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h"
      15                 : 
      16                 : #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc_inl.c"
      17                 : 
      18             610 : void NaClInstPrint(struct Gio* f,
      19             610 :                    const NaClDecodeTables* tables,
      20             610 :                    const NaClInst* inst) {
      21                 :   { /* Print out instruction type less the NACLi_ prefix. */
      22             610 :     const char* name = NaClInstTypeString(inst->insttype);
      23             610 :     gprintf(f, "%s ", name + strlen("NACLi_"));
      24                 :   }
      25            1191 :   if (inst->flags) NaClIFlagsPrint(f, inst->flags);
      26             610 :   gprintf(f, "\n");
      27                 : 
      28                 :   /* If instruction type is invalid, and doesn't have
      29                 :    * special translation purposes, then don't print additional
      30                 :    * (ignored) information stored in the modeled instruction.
      31                 :    */
      32             622 :   if ((NACLi_INVALID != inst->insttype) ||
      33                 :       ((inst->flags & NACL_IFLAG(Opcode0F0F)))) {
      34             600 :     Bool is_first = TRUE;
      35             600 :     int i;
      36             600 :     gprintf(f, "    %s", NaClMnemonicName(inst->name));
      37            3162 :     for (i = 0; i < inst->num_operands; ++i) {
      38             981 :       const NaClOp* op = NaClGetInstOperandInline(tables, inst, i);
      39             981 :       if (NULL == op->format_string) continue;
      40             981 :       if (is_first) {
      41             496 :         is_first = FALSE;
      42             496 :       } else {
      43             485 :         gprintf(f, ",");
      44                 :       }
      45             981 :       gprintf(f, " %s", op->format_string);
      46             981 :     }
      47             600 :     gprintf(f, "\n");
      48                 :     /* Now print actual encoding of each operand. */
      49            3162 :     for (i = 0; i < inst->num_operands; ++i) {
      50             981 :       gprintf(f, "      ");
      51             981 :       NaClOpPrint(f, NaClGetInstOperand(tables, inst, i));
      52             981 :     }
      53             600 :   }
      54             610 : }
      55                 : 
      56                 : /* Dummy routine to allow unreferenced NaClGetInstNumberOperandsInline
      57                 :  * inline.
      58                 :  */
      59                 : uint8_t NaClNcopcodeDescVerboseDummyNaClGetInstNumberOperands(
      60               0 :     const NaClInst* inst) {
      61               0 :   return NaClGetInstNumberOperandsInline(inst);
      62                 : }

Generated by: LCOV version 1.7