Esempio n. 1
0
EXPORT unsigned short CALL DebugMemRead16(unsigned int address)
{
#ifdef DBG
    return read_memory_16(address);
#else
    DebugMessage(M64MSG_ERROR, "Bug: DebugMemRead16() called, but Debugger not supported in Core library");
    return 0;
#endif
}
Esempio n. 2
0
//Draws the text for the 'value' column.
void value_data_func(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
    GValue val_str, val_addr, val_type, val_offset;
    char str[512]; //just to be safe; 'double' values can be up to 307-digit numbers! possibly more!
    uint32 addr, type, offset = 0;
    uint64 magic;
    
    memset(&val_str, 0, sizeof(val_str)); //why do I have to do this? ._.
    memset(&val_addr, 0, sizeof(val_addr));
    memset(&val_type, 0, sizeof(val_type));
    memset(&val_offset, 0, sizeof(val_offset));
    g_value_init(&val_str, G_TYPE_STRING);
    
    //Get the address, offset and type
    gtk_tree_model_get_value(tree_model, iter, Col_Address, &val_addr);
    addr = g_value_get_int(&val_addr);
    
    gtk_tree_model_get_value(tree_model, iter, Col_Offset, &val_offset);
    offset = g_value_get_int(&val_offset);
    
    gtk_tree_model_get_value(tree_model, iter, Col_Type, &val_type);
    type = g_value_get_int(&val_type);
    
    //If it's a pointer, follow it.
    if(type & Type_pointer)
    {
        type &= ~Type_pointer;
        addr = read_memory_32_unaligned(addr) + offset;
        //not that it makes a lot of sense to read a pointer from an unaligned
        //address, but let them do it if they want...
    }
    
    if(get_memory_flags(addr) & MEM_FLAG_READABLE)
    {   
        //Read the variable and format it for display.
        switch(type)
        {
            case Type_int8:     sprintf(str, "%d", (char)read_memory_8(addr)); break;
            case Type_int16:    sprintf(str, "%d", (short)read_memory_16(addr)); break;
            case Type_int32:    sprintf(str, "%d", (int)read_memory_32_unaligned(addr)); break;
            case Type_int64:    sprintf(str, "%" PRId64, (long long int)read_memory_64_unaligned(addr)); break;
            
            case Type_uint8:    sprintf(str, "%u", (unsigned char)read_memory_8(addr)); break;
            case Type_uint16:   sprintf(str, "%u", (unsigned short)read_memory_16(addr)); break;
            case Type_uint32:   sprintf(str, "%u", (unsigned int)read_memory_32_unaligned(addr)); break;
            case Type_uint64:   sprintf(str, "%" PRIu64, (unsigned long long int)read_memory_64_unaligned(addr)); break;
            
            case Type_hex8:     sprintf(str, "%02X", read_memory_8(addr)); break;
            case Type_hex16:    sprintf(str, "%04X", read_memory_16(addr)); break;
            case Type_hex32:    sprintf(str, "%08X", read_memory_32_unaligned(addr)); break;
            case Type_hex64:    sprintf(str, "%08X %08X", read_memory_32_unaligned(addr), read_memory_32_unaligned(addr + 4)); break;
            
            case Type_float:
                addr = read_memory_32_unaligned(addr);
                sprintf(str, "%g", *((float*)&addr)); //magic conversion to IEEE754. I have no idea how this works.
            break;
            
            case Type_double:
                magic = read_memory_64_unaligned(addr);
                sprintf(str, "%lg", *((double*)&magic));
            break;
            
            default:            sprintf(str, "??? (%X)", type); break;
        }
    }
    else strcpy(str, "-"); //unreadable
    
    //Set the cell text.
    g_value_set_string(&val_str, str);
    g_object_set_property(G_OBJECT(cell), "text", &val_str);
}