Ejemplo n.º 1
0
Archivo: node.hpp Proyecto: g40/lexertl
    virtual id_type token() const
    {
        throw runtime_error("Internal error node::token().");
#ifdef __SUNPRO_CC
        // Stop bogus Solaris compiler warning
        return id_type();
#endif
    }
Ejemplo n.º 2
0
bool GDBDebugServer::cmd_write_all_registers(gdb_cmd & cmd)
{
	select_thread(general_ops_thread_id);
	auto th = selected_thread.lock();
	if (th->id_type() == 1) {
		auto ppu = std::static_pointer_cast<ppu_thread>(th);
		int ptr = 0;
		for (int i = 0; i < 71; ++i) {
			int sz = get_reg_size(ppu, i);
			set_reg(ppu, i, cmd.data.substr(ptr, sz * 2));
			ptr += sz * 2;
		}
		return send_cmd_ack("OK");
	}
	gdbDebugServer.warning("Unimplemented thread type %d", th->id_type());
	return send_cmd_ack("E01");
}
Ejemplo n.º 3
0
bool GDBDebugServer::cmd_read_all_registers(gdb_cmd & cmd)
{
	std::string result;
	select_thread(general_ops_thread_id);

	auto th = selected_thread.lock();
	if (th->id_type() == 1) {
		auto ppu = std::static_pointer_cast<ppu_thread>(th);
		//68 64-bit registers, and 3 32-bit
		result.reserve(68*16 + 3*8);
		for (int i = 0; i < 71; ++i) {
			result += get_reg(ppu, i);
		}
		return send_cmd_ack(result);
	}
	gdbDebugServer.warning("Unimplemented thread type %d", th->id_type());
	return send_cmd_ack("");
}
Ejemplo n.º 4
0
bool GDBDebugServer::cmd_read_register(gdb_cmd & cmd)
{
	if (!select_thread(general_ops_thread_id)) {
		return send_cmd_ack("E02");
	}
	auto th = selected_thread.lock();
	if (th->id_type() == 1) {
		auto ppu = std::static_pointer_cast<ppu_thread>(th);
		u32 rid = hex_to_u32(cmd.data);
		std::string result = get_reg(ppu, rid);
		if (!result.length()) {
			gdbDebugServer.warning("Wrong register id %d", rid);
			return send_cmd_ack("E01");
		}
		return send_cmd_ack(result);
	}
	gdbDebugServer.warning("Unimplemented thread type %d", th->id_type());
	return send_cmd_ack("");
}
Ejemplo n.º 5
0
void register_editor_dialog::updateRegister()
{
	const auto cpu = this->cpu.lock();

	std::string reg = sstr(m_register_combo->itemData(m_register_combo->currentIndex()));
	std::string str;

	if (g_system == system_type::ps3 && cpu->id_type() == 1)
	{
		auto& ppu = *static_cast<ppu_thread*>(cpu.get());

		std::size_t first_brk = reg.find('[');
		if (first_brk != -1)
		{
			long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str());
			if (reg.find("GPR") == 0) str = fmt::format("%016llx", ppu.gpr[reg_index]);
			if (reg.find("FPR") == 0) str = fmt::format("%016llx", ppu.fpr[reg_index]);
			if (reg.find("VR") == 0)  str = fmt::format("%016llx%016llx", ppu.vr[reg_index]._u64[1], ppu.vr[reg_index]._u64[0]);
		}
		if (reg == "CR")  str = fmt::format("%08x", ppu.cr_pack());
		if (reg == "LR")  str = fmt::format("%016llx", ppu.lr);
		if (reg == "CTR") str = fmt::format("%016llx", ppu.ctr);
	}
	else if (g_system == system_type::ps3 && cpu->id_type() != 1)
	{
		auto& spu = *static_cast<SPUThread*>(cpu.get());

		std::string::size_type first_brk = reg.find('[');
		if (first_brk != std::string::npos)
		{
			long reg_index;
			reg_index = atol(reg.substr(first_brk + 1, reg.length() - 2).c_str());
			if (reg.find("GPR") == 0) str = fmt::format("%016llx%016llx", spu.gpr[reg_index]._u64[1], spu.gpr[reg_index]._u64[0]);
		}
	}

	m_value_line->setText(qstr(str));
}
Ejemplo n.º 6
0
bool GDBDebugServer::cmd_write_register(gdb_cmd & cmd)
{
	if (!select_thread(general_ops_thread_id)) {
		return send_cmd_ack("E02");
	}
	auto th = selected_thread.lock();
	if (th->id_type() == 1) {
		auto ppu = std::static_pointer_cast<ppu_thread>(th);
		size_t eq_pos = cmd.data.find('=');
		if (eq_pos == std::string::npos) {
			gdbDebugServer.warning("Wrong write_register cmd data %s", cmd.data.c_str());
			return send_cmd_ack("E02");
		}
		u32 rid = hex_to_u32(cmd.data.substr(0, eq_pos));
		std::string value = cmd.data.substr(eq_pos + 1);
		if (!set_reg(ppu, rid, value)) {
			gdbDebugServer.warning("Wrong register id %d", rid);
			return send_cmd_ack("E01");
		}
		return send_cmd_ack("OK");
	}
	gdbDebugServer.warning("Unimplemented thread type %d", th->id_type());
	return send_cmd_ack("");
}
Ejemplo n.º 7
0
// Parse a primary type.
//
//    primary-type:
//      'void'
//      'byte'
//      'bool'
//      'char'
//      'int'
//      'float'
//      'auto'
//      id-type
//      decltype-type
//      function-type
//      '( unary-type )'
//      '{ type-list }'
//
// FIXME: Design a better integer and FP type suite.
Type&
Parser::primary_type()
{
  switch (lookahead()) {
    case void_tok:
      return on_void_type(accept());
    case bool_tok:
      return on_bool_type(accept());
    case int_tok:
      return on_int_type(accept());
    case byte_tok:
      return on_byte_type(accept());

    // TODO: Implement me.
    case char_tok:
      lingo_unimplemented("char type");
    
    case float_tok:
      lingo_unimplemented("float type");
    
    case auto_tok:
      lingo_unimplemented("auto type");
    
    case decltype_tok:
      return decltype_type();

    case class_tok:
      return on_class_type(accept());

    case coroutine_tok:
      return on_coroutine_type(accept());

    case lparen_tok: {
      // FIXME: We shouldn't need a tentative parse for this.
      if (Type* t = match_if(&Parser::function_type))
        return *t;
      return grouped_type();
    }
    
    case lbrace_tok:
      return tuple_type();

    default:
      return id_type();
  }
}
Ejemplo n.º 8
0
void register_editor_dialog::updateRegister(const QString& text)
{
	if (text.isEmpty())
	{
		m_value_line->setText("");
		return;
	}

	const auto cpu = this->cpu.lock();

	std::string reg = sstr(text);
	std::string str;

	if (cpu->id_type() == 1)
	{
		auto& ppu = *static_cast<ppu_thread*>(cpu.get());

		std::size_t first_brk = reg.find('[');
		if (first_brk != -1)
		{
			long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str());
			if (reg.compare(0, 3, "GPR") == 0) str = fmt::format("%016llx", ppu.gpr[reg_index]);
			if (reg.compare(0, 3, "FPR") == 0) str = fmt::format("%016llx", ppu.fpr[reg_index]);
			if (reg.compare(0, 2, "VR") == 0)  str = fmt::format("%016llx%016llx", ppu.vr[reg_index]._u64[1], ppu.vr[reg_index]._u64[0]);
		}
		if (reg == "CR")  str = fmt::format("%08x", ppu.cr_pack());
		if (reg == "LR")  str = fmt::format("%016llx", ppu.lr);
		if (reg == "CTR") str = fmt::format("%016llx", ppu.ctr);
	}
	else
	{
		auto& spu = *static_cast<spu_thread*>(cpu.get());

		std::string::size_type first_brk = reg.find('[');
		if (first_brk != std::string::npos)
		{
			long reg_index;
			reg_index = atol(reg.substr(first_brk + 1, reg.length() - 2).c_str());
			if (reg.compare(0, 3, "GPR") == 0) str = fmt::format("%016llx%016llx", spu.gpr[reg_index]._u64[1], spu.gpr[reg_index]._u64[0]);
		}
	}

	m_value_line->setText(qstr(str));
}
Ejemplo n.º 9
0
 inline id_type id_type::operator++(int)     // post-increment
 {
     return id_type((*gid_)++, unmanaged);
 }
Ejemplo n.º 10
0
namespace Scene {
    Node::id_type Node::s_current_id = id_type(0);

    Node::Node(string_type const & __n, ptr_node_type const & __p):
        _id(s_current_id),
        _name(__n),
        _local_transform(1.0),
        _parent(__p),
        _child()
    {
        s_current_id++;

        if(_parent != nullptr)
            _parent->_child.insert(this);
    }

    Node::~Node() {
        for(auto it = _child.begin() ; it != _child.end() ; it++)
            delete *it;
    }

    Node::id_type const & Node::id() const {
        return _id;
    }

    Node::string_type const & Node::name() const {
        return _name;
    }

    void Node::apply(transform_type const & __t) {
        _local_transform *= __t;
    }

    void Node::apply(rotation_type const & __a) {
        _local_transform = glm::rotate(_local_transform,
                __a, glm::vec3(0.0, 0.0, 1.0));
    }

    void Node::apply(translation_type const & __v) {
        _local_transform = glm::translate(_local_transform, __v);
    }

    void Node::apply(scale_type const & __s) {
        _local_transform = glm::scale(_local_transform,
                glm::vec3(__s.x, __s.y, 1.0));
    }

    Node::node_set_type const & Node::child() const {
        return _child;
    }

    Node::ptr_node_type const & Node::parent() const {
        return _parent;
    }

    void Node::parent(ptr_node_type const & __p) {
        if(_parent != nullptr)
            _parent->_child.erase(this);
        if(__p != nullptr)
            __p->_child.insert(this);

        _parent = __p;
    }

    void Node::remove_parent() {
        if(_parent != nullptr)
            _parent->_child.erase(this);
        _parent = nullptr;
    }

    bool Node::is_drawn(transform_type const &,
            rectangle_type const &) const
    {
        // TODO
        return true;
    }

    void Node::draw_all(transform_type __t, rectangle_type const & __r) const {
        transform_type t = __t * _local_transform;
        draw(t);
        for(auto const & c : _child) {
            if(c->is_drawn(t, __r))
                c->draw_all(t, __r);
        }
    }

    void Node::draw(transform_type const &) const {
    }
}
Ejemplo n.º 11
0
void register_editor_dialog::OnOkay(const std::shared_ptr<cpu_thread>& _cpu)
{
	const auto cpu = _cpu.get();

	std::string reg = sstr(m_register_combo->currentText());
	std::string value = sstr(m_value_line->text());

	if (cpu->id_type() == 1)
	{
		auto& ppu = *static_cast<ppu_thread*>(cpu);

		while (value.length() < 32) value = "0" + value;
		const auto first_brk = reg.find('[');
		try
		{
			if (first_brk != -1)
			{
				const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str());
				if (reg.compare(0, 3, "GPR") == 0 || reg.compare(0, 3, "FPR") == 0)
				{
					const ullong reg_value = std::stoull(value.substr(16, 31), 0, 16);
					if (reg.compare(0, 3, "GPR") == 0) ppu.gpr[reg_index] = (u64)reg_value;
					if (reg.compare(0, 3, "FPR") == 0) (u64&)ppu.fpr[reg_index] = (u64)reg_value;
					return;
				}
				if (reg.compare(0, 2, "VR") == 0)
				{
					const ullong reg_value0 = std::stoull(value.substr(16, 31), 0, 16);
					const ullong reg_value1 = std::stoull(value.substr(0, 15), 0, 16);
					ppu.vr[reg_index]._u64[0] = (u64)reg_value0;
					ppu.vr[reg_index]._u64[1] = (u64)reg_value1;
					return;
				}
			}
			if (reg == "LR" || reg == "CTR")
			{
				const ullong reg_value = std::stoull(value.substr(16, 31), 0, 16);
				if (reg == "LR") ppu.lr = (u64)reg_value;
				if (reg == "CTR") ppu.ctr = (u64)reg_value;
				return;
			}
			if (reg == "CR")
			{
				const ullong reg_value = std::stoull(value.substr(24, 31), 0, 16);
				if (reg == "CR") ppu.cr_unpack((u32)reg_value);
				return;
			}
		}
		catch (std::invalid_argument&) //if any of the stoull conversion fail
		{
		}
	}
	else
	{
		auto& spu = *static_cast<spu_thread*>(cpu);

		while (value.length() < 32) value = "0" + value;
		const auto first_brk = reg.find('[');
		try
		{
			if (first_brk != -1)
			{
				const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - 2).c_str());
				if (reg.compare(0, 3, "GPR") == 0)
				{
					const ullong reg_value0 = std::stoull(value.substr(16, 31), 0, 16);
					const ullong reg_value1 = std::stoull(value.substr(0, 15), 0, 16);
					spu.gpr[reg_index]._u64[0] = (u64)reg_value0;
					spu.gpr[reg_index]._u64[1] = (u64)reg_value1;
					return;
				}
			}
		}
		catch (std::invalid_argument&)
		{
		}
	}
	QMessageBox::critical(this, tr("Error"), tr("This value could not be converted.\nNo changes were made."));
}
Ejemplo n.º 12
0
instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, const std::shared_ptr<cpu_thread>& _cpu, CPUDisAsm* _disasm)
	: QDialog(parent)
	, pc(_pc)
	, cpu(_cpu)
	, disasm(_disasm)
{
	setWindowTitle(tr("Edit instruction"));
	setAttribute(Qt::WA_DeleteOnClose);
	setMinimumSize(300, sizeHint().height());

	const auto cpu = _cpu.get();
	cpu_offset = g_system == system_type::ps3 && cpu->id_type() != 1 ? static_cast<SPUThread&>(*cpu).offset : 0;
	QString instruction = qstr(fmt::format("%08x", vm::ps3::read32(cpu_offset + pc).value()));

	QVBoxLayout* vbox_panel(new QVBoxLayout());
	QHBoxLayout* hbox_panel(new QHBoxLayout());
	QVBoxLayout* vbox_left_panel(new QVBoxLayout());
	QVBoxLayout* vbox_right_panel(new QVBoxLayout());
	QHBoxLayout* hbox_b_panel(new QHBoxLayout());

	QPushButton* button_ok(new QPushButton(tr("Ok")));
	QPushButton* button_cancel(new QPushButton(tr("Cancel")));
	button_ok->setFixedWidth(80);
	button_cancel->setFixedWidth(80);

	QLabel* t1_text = new QLabel(tr("Address:     "), this);
	QLabel* t2_text = new QLabel(tr("Instruction: "), this);
	QLabel* t3_text = new QLabel(tr("Preview:     "), this);
	QLabel* t1_addr = new QLabel(qstr(fmt::format("%08x", pc)), this);
	t2_instr = new QLineEdit(this);
	t2_instr->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
	t2_instr->setPlaceholderText(instruction);
	t2_instr->setText(instruction);
	t2_instr->setMaxLength(8);
	t2_instr->setMaximumWidth(65);
	t3_preview = new QLabel("", this);

	// Layouts
	vbox_left_panel->addWidget(t1_text);
	vbox_left_panel->addWidget(t2_text);
	vbox_left_panel->addWidget(t3_text);

	vbox_right_panel->addWidget(t1_addr);
	vbox_right_panel->addWidget(t2_instr);
	vbox_right_panel->addWidget(t3_preview);
	vbox_right_panel->setAlignment(Qt::AlignLeft);

	hbox_b_panel->addWidget(button_ok);
	hbox_b_panel->addWidget(button_cancel);
	hbox_b_panel->setAlignment(Qt::AlignCenter);

	// Main Layout
	hbox_panel->addLayout(vbox_left_panel);
	hbox_panel->addSpacing(10);
	hbox_panel->addLayout(vbox_right_panel);
	vbox_panel->addLayout(hbox_panel);
	vbox_panel->addSpacing(10);
	vbox_panel->addLayout(hbox_b_panel);
	setLayout(vbox_panel);
	setModal(true);

	// Events
	connect(button_ok, &QAbstractButton::pressed, [=]() {
		bool ok;
		ulong opcode = t2_instr->text().toULong(&ok, 16);
		if (!ok)
			QMessageBox::critical(this, tr("Error"), tr("This instruction could not be parsed.\nNo changes were made."));
		else
			vm::ps3::write32(cpu_offset + pc, (u32)opcode);
		accept();
	});
	connect(button_cancel, &QAbstractButton::pressed, this, &instruction_editor_dialog::reject);
	connect(t2_instr, &QLineEdit::textChanged, this, &instruction_editor_dialog::updatePreview);

	updatePreview();
}
Ejemplo n.º 13
0
int list_check()
{
  int type;
  element_id id;
  int numerr = 0;


  /* free_discards(DISCARDS_ALL); */
  for ( type = 0 ; type < NUMELEMENTS ; type++ )
  { 
    element_id backid = NULLID;

    if ( (web.representation == SIMPLEX)  && (type == EDGE) ) continue;
    #ifndef HASH_ID
    /* check free list */
    {  int freecount,maxfree;
     maxfree = web.skel[type].maxcount - web.skel[type].count
                 - web.skel[type].discard_count;
    id = web.skel[type].free;
    freecount = 0;
    while ( id != NULLID )
    { freecount++;
      if ( freecount > maxfree )
      { sprintf(msg,"Type %d freelist has too many elements: %d.\n",
            type,freecount);
        erroutstring(msg);
        if ( ++numerr > MAXERR )
        {erroutstring("Too many errors.\n"); return numerr;}
        break;
      }
      if ( id_type(id) != type )
      { sprintf(msg,"Type %d freelist has bad id %lX\n",type,(unsigned long)id);
        erroutstring(msg);
        if ( ++numerr > MAXERR )
        {erroutstring("Too many errors.\n"); return numerr;}
        break;
      }
      if ( elptr(id)->backchain != backid )
      { sprintf(msg,
         "Type %d freelist has bad backchain %X instead of %X for id %lX\n",
            type, (unsigned long)elptr(id)->backchain,(unsigned long)backid,
           (unsigned long)id);
        erroutstring(msg);
        if ( ++numerr > MAXERR )
        {erroutstring("Too many errors.\n"); return numerr;}
      }
      backid = id;
       
      id = elptr(id)->forechain;
    } /* end while */
    if ( backid != web.skel[type].freelast )
    { sprintf(msg,"Type %d freelist has bad freelast %lX instead of %lX.\n",
          type, (unsigned long)web.skel[type].freelast,(unsigned long)backid);
      erroutstring(msg);
    }

    if ( freecount != maxfree )
    { sprintf(msg,"Type %d freelist has %d elements instead of %d.\n",
          type,freecount,maxfree);
      erroutstring(msg);
    }
    if ( !equal_id(id,NULLID) )
    { sprintf(msg,"Type %d freelist last id is non-null: %lX\n",type,
          (unsigned long)id);
      erroutstring(msg);
    }
    }
    #endif
    
#ifndef MPI_EVOLVER
  { int usedcount,maxused,discards;
    element_id prev_id;

    /* check used list */
    maxused = web.skel[type].count;
    id = web.skel[type].used;
    prev_id = NULLID;
    usedcount = 0;
    discards = 0;
    while ( valid_id(id) )
    { 
      if ( valid_element(id) )
        usedcount++;
      else discards++;

      if ( usedcount > maxused )
      { sprintf(msg,"Type %d usedlist has too many elements: %d.\n",
            type,usedcount);
        erroutstring(msg);
        if ( ++numerr > MAXERR )
        {erroutstring("Too many errors.\n"); return numerr;}
        break;
      }
      if ( id_type(id) != type )
      { sprintf(msg,"Type %d usedlist has bad id %lX of type %d\n",
            type,(unsigned long)id,id_type(id));
        erroutstring(msg);
        if ( ++numerr > MAXERR )
        { erroutstring("Too many errors.\n"); return numerr;}
        break;
      }
      if ( !equal_id(prev_id,elptr(id)->backchain) )
      { sprintf(msg,"Type %d used list id %lX has backchain %lX instead of %lX\n",
              type,(unsigned long)id,(unsigned long)elptr(id)->backchain,
             (unsigned long)prev_id);
        erroutstring(msg);
        if ( ++numerr > MAXERR )
        {erroutstring("Too many errors.\n"); return numerr;}
      }
      prev_id = id;
      id = elptr(id)->forechain;
    } /* end while */
    if ( usedcount != maxused )
    { sprintf(msg,"Type %d usedlist has %d elements.\n",type,usedcount);
      erroutstring(msg);
    }
    if ( discards != web.skel[type].discard_count )
    { sprintf(msg,"Type %d usedlist has %d elements.\n",type,usedcount);
      erroutstring(msg);
    }
    if ( !equal_id(id,NULLID) )
    { sprintf(msg,"Type %d usedlist last id is non-null: %lX\n",type,
          (unsigned long)id);
      erroutstring(msg);
    }
  }
#endif
  } /* end for loop */

  #ifdef MPI_EVOLVER
  for ( type = VERTEX ; type < NUMELEMENTS ; type++ )
  { int k;
    for ( k = 0 ; k < web.skel[type].maxcount ; k++ )
      if ( (web.skel[type].ibase[k]->local_id & OFFSETMASK) != k )
      { sprintf(msg,"Task %d: local_id is %08X on %s ibase[0x%X], self id %08X\n",
          this_task,(int)(web.skel[type].ibase[k]->local_id),
           typenames[type],k, (int)(web.skel[type].ibase[k]->self_id));
        erroutstring(msg);
      }
  }
  #endif
  
  return numerr;
} /* end list_check() */
Ejemplo n.º 14
0
 cache_state_type() : curr(), next(), word(id_type(-2)) {}
Ejemplo n.º 15
0
 cache_prob_type() : prob(0.0), pos(size_type(-2)), word(id_type(-2)) {}
Ejemplo n.º 16
0
 cache_pos_type() : pos(size_type(-2)), pos_next(size_type(-1)), id(id_type(-2)) {}