Exemplo n.º 1
0
void NaClExpVectorPrint(struct Gio* file, NaClInstState* state) {
  uint32_t i;
  NaClExpVector* vector = NaClInstStateExpVector(state);
  gprintf(file, "NaClExpVector[%d] = {\n", vector->number_expr_nodes);
  for (i = 0; i < vector->number_expr_nodes; i++) {
    NaClExp* node = &vector->node[i];
    gprintf(file, "  { %s[%d] , ",
            NaClExpKindName(node->kind),
            NaClExpKindRank(node->kind));
    switch (node->kind) {
      case ExprRegister:
        NaClPrintDisassembledReg(file, node);
        break;
      case ExprConstant:
        NaClPrintDisassembledConst(file, state, node);
        break;
      default:
        gprintf(file, "%"NACL_PRIu64, NaClGetExprUnsignedValue(node));
        break;
    }
    gprintf(file, ", ");
    NaClPrintExpFlags(file, node->flags);
    gprintf(file, " },\n");
  }
  gprintf(file, "};\n");
}
Exemplo n.º 2
0
/* Append the given constant onto the given vector of expression
 * nodes. Returns the appended expression node.
 */
static INLINE NaClExp* NaClAppendConst(uint64_t value, NaClExpFlags flags,
                                       NaClExpVector* vector) {
  uint32_t val1;
  uint32_t val2;
  DEBUG(
      NaClLog(LOG_INFO, "Append constant %"NACL_PRIx64" : ", value);
      NaClPrintExpFlags(NaClLogGetGio(), flags);
      gprintf(NaClLogGetGio(), "\n"));
  NaClSplitExpConstant(value, &val1, &val2);
  if (val2 == 0) {
    return NaClAppendExp(ExprConstant, val1, flags, vector);
  } else {
    NaClExp* root = NaClAppendExp(ExprConstant64, 0, flags, vector);
    NaClAppendExp(ExprConstant, val1, NACL_EFLAG(ExprUnsignedHex), vector);
    NaClAppendExp(ExprConstant, val2, NACL_EFLAG(ExprUnsignedHex), vector);
    return root;
  }
}