Logo Search packages:      
Sourcecode: eresi version File versions  Download package

void revm_object_print ( revmobj_t obj  ) 

Print an object

Parameters:
obj 

Definition at line 17 of file print.c.

References ASPECT_TYPE_BYTE, ASPECT_TYPE_CADDR, ASPECT_TYPE_DADDR, ASPECT_TYPE_INT, ASPECT_TYPE_LONG, ASPECT_TYPE_RAW, ASPECT_TYPE_SHORT, ASPECT_TYPE_STR, bzero(), s_revm_object::get_name, s_revm_object::get_obj, s_revm_object::immed, s_revm_object::immed_val, s_type::isptr, s_revm_object::otype, s_revm_object::parent, revm_object_print(), revm_output(), s_revm_object::root, and s_type::type.

Referenced by cmd_print(), and revm_object_print().

{
  u_char    byte;
  uint16_t  half;
  uint32_t  word;
  eresi_Addr      val;
  char            *str;
  char            logbuf[BUFSIZ];
  u_int           idx;
  aspectype_t     *type;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);
  bzero(logbuf, BUFSIZ);
  type = obj->otype;
  if (type && type->isptr)
    goto isptr;

  /* Print a non-pointer type */
  if (!obj->otype)
    snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_OBJECT_TYPE_0");
  else
    switch (obj->otype->type)
      {
      case ASPECT_TYPE_BYTE:
      byte = (obj->immed ? obj->immed_val.byte : obj->get_obj(obj->parent));
      word = (uint32_t) byte;
      snprintf(logbuf, BUFSIZ - 1, "'%s' (%s) ", 
             ((word > 31 && word < 127) ? revm_colornumber("%c", word) : 
              revm_colorfieldstr("?")), revm_colornumber("%hhd", word));
      break;
      case ASPECT_TYPE_SHORT:
      half = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent));
      word = (uint32_t) half;
      snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", 
             revm_colornumber("%hd", word), revm_colornumber("0x%hX", word));
      break;
      case ASPECT_TYPE_LONG:
      case ASPECT_TYPE_CADDR:
      case ASPECT_TYPE_DADDR:
      val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent));
      snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", 
             revm_colornumber("%d", val), revm_colornumber("0x%X", val));
      break;
      case ASPECT_TYPE_INT:
      word = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent));
      snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", 
             revm_colornumber("%d", word), revm_colornumber("0x%X", word));
      break;
      case ASPECT_TYPE_STR:
      str = (obj->immed ? obj->immed_val.str : 
             obj->get_name(obj->root, obj->parent));
      snprintf(logbuf, BUFSIZ, "%s ", revm_colorfieldstr(str));
      break;
      
      /* XXX: need a config variable to tell how many bytes we want */
      case ASPECT_TYPE_RAW:
      str = (char *) (obj->immed ? obj->immed_val.str : 
                  obj->get_name ? obj->get_name(obj->root, obj->parent) : "");
      for (idx = 0; idx < 10 && str[idx]; idx++)
        snprintf(logbuf, BUFSIZ, "%02X%s", 
               (u_char) str[idx], (idx < 9 && str[idx + 1] ? " " : ""));
      break;
      
      /* When the object type is unknown */
      default:
      snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_OBJECT_TYPE_%u ", obj->otype->type);
      break;
      }
  revm_output(logbuf);
  revm_endline();
  PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__);

  /* Now print a pointer */
 isptr:
  if (!obj->otype)
    snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_PTR_OBJECT_TYPE_0");
  else
    switch (obj->otype->type)
      {
      case ASPECT_TYPE_STR:
      case ASPECT_TYPE_BYTE:
      case ASPECT_TYPE_SHORT:
      case ASPECT_TYPE_LONG:
      case ASPECT_TYPE_CADDR:
      case ASPECT_TYPE_DADDR:
      case ASPECT_TYPE_INT:
      case ASPECT_TYPE_RAW:
      default:
      val = (obj->immed || !obj->parent ? obj->immed_val.ent : obj->get_obj(obj->parent));
      snprintf(logbuf, BUFSIZ - 1, "%s ", revm_colornumber("0x%X", val));
      break;
    }
  revm_output(logbuf);
  revm_endline();
  PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__);
}


Generated by  Doxygen 1.6.0   Back to index