Exemplo n.º 1
0
SdbPacket *SdbPacketQueue::
get_packet()
{
	mLock holds(this);
	SdbPacket *p = first;
	remove_pointer(p);
	return p;
}
char * callgraph_t::get_node_label(int n, char *buf, int bufsize) const
{
	int_ea_map_t::const_iterator it = node2ea.find(n);
	
	if ( it != node2ea.end() )
	{
		const citem_t *item = it->second;

		char *ptr = buf;
		char *endp = buf + bufsize;
		
		// Each node will have the element type at the first line
		APPEND(ptr, endp, get_ctype_name(item->op));
		const cexpr_t *e = (const cexpr_t *)item;
		const cinsn_t *i = (const cinsn_t *)item;

		// For some item types, display additional information
		switch (item->op)
		{
		case cot_call:
			char buf[MAXSTR];
			if (get_func_name(e->x->obj_ea, buf, sizeof(buf)) == NULL)
				ptr += qsnprintf(ptr, endp - ptr, " sub_%a", e->x->obj_ea);
			ptr += qsnprintf(ptr, endp - ptr, " %s", buf);
			break;
		case cot_ptr: // *x
		case cot_memptr: // x->m
			// Display access size for pointers
			ptr += qsnprintf(ptr, endp - ptr, ".%d", e->ptrsize);
			if (item->op == cot_ptr)
				break;
		case cot_memref: // x.m
			// Display member offset for structure fields
			ptr += qsnprintf(ptr, endp - ptr, " (m=%d)", e->m);
			break;
		case cot_obj: // v

		case cot_var: // l
			// Display object size for local variables and global data
			ptr += qsnprintf(ptr, endp - ptr, ".%d", e->refwidth);
		case cot_num: // n
		case cot_helper: // arbitrary name
		case cot_str: // string constant
			// Display helper names and number values
			APPCHAR(ptr, endp, ' ');
			e->print1(ptr, endp - ptr, NULL);
			tag_remove(ptr, ptr, sizeof(ptr));
			ptr = tail(ptr);
			break;
		case cit_goto:
			// Display target label number for gotos
			ptr += qsnprintf(ptr, endp - ptr, " LABEL_%d", i->cgoto->label_num);
			break;
		case cit_asm:
			// Display instruction block address and size for asm-statements
			ptr += qsnprintf(ptr, endp - ptr, " %a.%" FMT_Z, *i->casm->begin(), i->casm->size());
			break;
		default:
			break;
		}
    
		ptr += qsnprintf(ptr, endp-ptr, "\nea: %a", item->ea);

		if ( item->is_expr() && !e->type.empty() )
		{
		  // For typed expressions, the third line will have
		  // the expression type in human readable form
		  APPCHAR(ptr, endp, '\n');
		  qstring out;
		  if (e->type.print(&out))
		  {
			  APPEND(ptr, endp, out.c_str());
		  }
		  else 
		  { // could not print the type?
			APPCHAR(ptr, endp, '?');
			APPZERO(ptr, endp);
		  }

		  if(e->type.is_ptr())
			{
				tinfo_t ptr_rem = remove_pointer(e->type);
				if(ptr_rem.is_struct())
				{
					qstring typenm;
					ptr_rem.print(&typenm, "prefix ", 0, 0, PRTYPE_MULTI | PRTYPE_TYPE | PRTYPE_SEMI);
				}
			}
		}
	}
	
	return buf;
}
  // Display a graph node. Feel free to modify this function to fine tune the node display.
  char * idaapi cfunc_graph_t::get_node_label(int n, char *buf, int bufsize)
  {
    char *ptr = buf;
    char *endp = buf + bufsize;
    // Get the corresponding ctree item
    const citem_t *item = items[n];
    // Each node will have the element type at the first line
    APPEND(ptr, endp, get_ctype_name(item->op));
    const cexpr_t *e = (const cexpr_t *)item;
    const cinsn_t *i = (const cinsn_t *)item;
    // For some item types, display additional information
    switch ( item->op )
    {
      case cot_ptr     : // *x
      case cot_memptr  : // x->m
        // Display access size for pointers
        ptr += qsnprintf(ptr, endp-ptr, ".%d", e->ptrsize);
        if ( item->op == cot_ptr )
          break;
      case cot_memref  : // x.m
        // Display member offset for structure fields
        ptr += qsnprintf(ptr, endp-ptr, " (m=%d)", e->m);
        break;
      case cot_obj     : // v
      case cot_var     : // l
        // Display object size for local variables and global data
        ptr += qsnprintf(ptr, endp-ptr, ".%d", e->refwidth);
      case cot_num     : // n
      case cot_helper  : // arbitrary name
      case cot_str     : // string constant
        // Display helper names and number values
        APPCHAR(ptr, endp, ' ');
        e->print1(ptr, endp-ptr, NULL);
        tag_remove(ptr, ptr, 0);
        ptr = tail(ptr);
        break;
     case cit_goto:
        // Display target label number for gotos
        ptr += qsnprintf(ptr, endp-ptr, " LABEL_%d", i->cgoto->label_num);
        break;
     case cit_asm:
        // Display instruction block address and size for asm-statements
        ptr += qsnprintf(ptr, endp-ptr, " %a.%"FMT_Z, *i->casm->begin(), i->casm->size());
        break;
      default:
        break;
    }
    // The second line of the node contains the item address
    ptr += qsnprintf(ptr, endp-ptr, "\nea: %a", item->ea);
    if ( item->is_expr() && !e->type.empty() )
    {
      // For typed expressions, the third line will have
      // the expression type in human readable form
      APPCHAR(ptr, endp, '\n');
      if ( print_type_to_one_line(ptr, endp-ptr, idati, e->type.u_str()) != T_NORMAL )
      { // could not print the type?
        APPCHAR(ptr, endp, '?');
        APPZERO(ptr, endp);
      }

	  if(e->type.is_ptr())
		{
			typestring ptr_rem = remove_pointer(e->type);
			if(ptr_rem.is_struct())
			{
				qstring typenm;

				print_type_to_qstring(&typenm, "prefix ", 0,0, PRTYPE_MULTI | PRTYPE_TYPE | PRTYPE_SEMI, idati, ptr_rem.u_str());

//				print_type_to_one_line(ptr, endp-ptr, idati, ptr_rem.u_str());
			}
		}
    }
    return buf;
  }