Exemplo n.º 1
0
int cN2Prov0501::ProcessBx(unsigned char *data, int len, int pos)
{
  if(data[pos-1]!=0xBC) {
    PRINTF(L_SYS_EMU,"%04X: bad nano %02X for ROM 120",id,data[pos-1]);
    return -1;
    }
  if(pos!=(0x93-0x80)) { // maybe exploitable
    PRINTF(L_SYS_EMU,"%04X: refuse to execute from %04x",id,0x80+pos);
    return -1;
    }
  if(Init(id,120)) {
    SetMem(0x80,data,len);
    SetPc(0x80+pos);
    SetSp(0x0FFF,0x0FE0);
    Set(0x0001,0xFF);
    Set(0x000E,0xFF);
    Set(0x0000,0x04);
    ClearBreakpoints();
    AddBreakpoint(0x821f);
    AddBreakpoint(0x0000);
    AddRomCallbacks();
    while(!Run(hasMaprom ? 20000:5000)) {
      if(GetPc()==0x821f) {
        GetMem(0x80,data,len);
        return a;
        }
      else if(GetPc()==0x0000) break;
      else if(!RomCallbacks()) break;
      }
    }
  return -1;
}
Exemplo n.º 2
0
cb::shared_ptr<DebuggerBreakpoint> DebuggerState::AddBreakpoint(const wxString& file, int line,
                                                                bool temp, const wxString& lineText)
{
    wxString bpfile = ConvertToValidFilename(file);

    // do we have a bp there?
    int idx = HasBreakpoint(bpfile, line, temp);
    // if yes, remove old breakpoint first
    if (idx != -1)
        RemoveBreakpoint(idx);

    // create new bp
//    Manager::Get()->GetLogManager()->DebugLog(F(_T("DebuggerState::AddBreakpoint() : bp: file=%s, bpfile=%s"), file.c_str(), bpfile.c_str()));
    cb::shared_ptr<DebuggerBreakpoint> bp(new DebuggerBreakpoint);
    bp->type = DebuggerBreakpoint::bptCode;
    bp->filename = bpfile;
    bp->filenameAsPassed = file;
    bp->line = line;
    bp->temporary = temp;
    bp->lineText = lineText;
    bp->userData = Manager::Get()->GetProjectManager()->FindProjectForFile(file, nullptr, false, false);
    AddBreakpoint(bp);

    return bp;
}
Exemplo n.º 3
0
// Add a breakpoint using the 'Properties' dialog
void BreakptMgr::AddBreakpoint()
{
    BreakptPropertiesDlg dlg(NULL);
    dlg.SetTitle(_("Create a breakpoint or watchpoint"));

    LEditor* const editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    BreakpointInfo bp;
    bp.Create(editor ? editor->GetFileName().GetFullPath() : wxString(), editor ? editor->GetCurrentLine() : -1, GetNextID());
    dlg.EnterBPData(bp);

    if (dlg.ShowModal() != wxID_OK) {
        return;
    }

    if (AddBreakpoint(dlg.b)) {
        IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
        if ((!dlg.b.is_enabled) && dbgr && dbgr->IsRunning()) {
            SetBPEnabledState(dlg.b.debugger_id, dlg.b.is_enabled);
        }
        wxString msg;
        if (dlg.b.bp_type == BP_type_watchpt) {
            msg = _("Watchpoint successfully added");
        } else {
            msg = _("Breakpoint successfully added");
        }
        clMainFrame::Get()->SetStatusMessage(msg, 0);
    }
}
Exemplo n.º 4
0
void BreakptMgr::DropBreakpoint(const BreakpointInfo& bp, int newline)
{
    if ( DelBreakpoint(bp.GetId()) ) {
        BreakpointInfo new_bp = bp;
        new_bp.lineno = newline;
        AddBreakpoint( new_bp );
    }
}
Exemplo n.º 5
0
bool BreakptMgr::AddBreakpointByAddress(const wxString& address)
{
    BreakpointInfo bp;
    bp.memory_address = address;
    bp.origin = BO_Other;
    bp.internal_id = GetNextID();
    return AddBreakpoint(bp);
}
Exemplo n.º 6
0
int cN2Prov0501::RunEmu(unsigned char *data, int len, unsigned short load, unsigned short run, unsigned short stop, unsigned short fetch, int fetch_len)
{
  if(Init(id,120)) {
    SetSp(0x0FFF,0x0EF8);
    SetMem(load,data,len);
    SetPc(run);
    ClearBreakpoints();
    AddBreakpoint(stop);
    if(stop!=0x0000) AddBreakpoint(0x0000);
    AddRomCallbacks();
    while(!Run(100000)) {
      if(GetPc()==0x0000 || GetPc()==stop) {
        GetMem(fetch,data,fetch_len);
        return 1;
        }
      else if(!RomCallbacks()) break;
      }
    }
  return -1;
}
Exemplo n.º 7
0
void BreakptMgr::LoadSession(const SessionEntry& session)
{
    const std::vector<BreakpointInfo>& breakpoints = session.GetBreakpoints();
    for (std::vector<BreakpointInfo>::const_iterator itr = breakpoints.begin(); itr != breakpoints.end(); ++itr) {
        BreakpointInfo bp = *itr;
        bp.internal_id = GetNextID();
        bp.origin      = BO_Editor;
        AddBreakpoint(bp);
    }
    RefreshBreakpointMarkers();
}
Exemplo n.º 8
0
cb::shared_ptr<DebuggerBreakpoint> DebuggerState::AddBreakpoint(const wxString& dataAddr, bool onRead, bool onWrite)
{
    cb::shared_ptr<DebuggerBreakpoint> bp(new DebuggerBreakpoint);
    bp->type = DebuggerBreakpoint::bptData;
    bp->breakAddress = dataAddr;
    bp->breakOnRead = onRead;
    bp->breakOnWrite = onWrite;
    AddBreakpoint(bp);

    return bp;
}
Exemplo n.º 9
0
bool BreakpointManager::ToggleBreakpoint(QString _file,int _line)
{
    Breakpoint temp(_file,_line);
    if (IsBreakpointSet(temp) == true)
        {
        RemoveBreakpoint(temp);
        return false;
        }
    else
        {
        AddBreakpoint(temp);
        return true;
        }
}
Exemplo n.º 10
0
bool BreakptMgr::AddBreakpointByLineno(const wxString& file, const int lineno, const wxString& conditions/*=wxT("")*/, const bool is_temp, bool is_disabled)
{
    BreakpointInfo bp;
    bp.Create(file, lineno, GetNextID());
    bp.origin = BO_Editor;
    if (is_temp) {
        bp.bp_type = BP_type_tempbreak;
        bp.is_temp = true;
        
    } 
    bp.is_enabled = !is_disabled;
    bp.conditions = conditions;
    return AddBreakpoint(bp);
}
Exemplo n.º 11
0
void LLDBConnector::AddBreakpoints(const LLDBBreakpoint::Vec_t& breakpoints)
{
    for(size_t i = 0; i < breakpoints.size(); ++i) {
        AddBreakpoint(breakpoints.at(i), false);
    }
}
Exemplo n.º 12
0
/* virtual */ OP_STATUS
ES_RemoteDebugFrontend::Received(ES_DebugMessage *message)
{
	OpAutoPtr<ES_DebugMessage> anchor(message);

	ES_DebugMessagePart *part = message->GetFirstPart();

	if (part->GetType() == ES_DebugMessagePart::BODY_CONTINUE)
	{
		ES_ContinueMessagePart *body = (ES_ContinueMessagePart *) part;
		return Continue(body->runtime_id, (ES_DebugFrontend::Mode) body->mode);
	}
	else if (part->GetType() == ES_DebugMessagePart::BODY_EVAL)
	{
		ES_EvalMessagePart *body = (ES_EvalMessagePart *) part;

		OpString script;
		RETURN_IF_ERROR(script.SetFromUTF8(body->script, body->script_length));

		unsigned variables_count = 0;

		ES_DebugMessagePart *iter = (ES_DebugMessagePart *) part->Suc();
		while (iter)
		{
			if (iter->GetType() == ES_DebugMessagePart::AUXILIARY_EVAL_VARIABLE)
				++variables_count;
			iter = (ES_DebugMessagePart *) iter->Suc();
		}

		ES_DebugVariable *variables;
		if (variables_count != 0)
		{
			variables = new ES_DebugVariable[variables_count];
			if (variables)
			{
				unsigned index = 0;

				iter = (ES_DebugMessagePart *) part->Suc();
				while (iter)
				{
					if (iter->GetType() == ES_DebugMessagePart::AUXILIARY_EVAL_VARIABLE)
					{
						ES_EvalVariableMessagePart *evalvariable = (ES_EvalVariableMessagePart *) iter;
						variables[index].name = evalvariable->name;
						variables[index].name_length = evalvariable->name_length;
						variables[index].value = evalvariable->value;
						++index;
					}
					iter = (ES_DebugMessagePart *) iter->Suc();
				}
			}
			else
				variables_count = 0;
		}
		else
			variables = NULL;

		OP_STATUS status = Eval(body->tag, body->runtime_id, body->thread_id, body->frame_index, script.CStr(), script.Length(), variables, variables_count);
		delete[] variables;
		if (status == OpStatus::ERR)
		{
			ES_DebugValue value;
			return EvalReply(body->tag, EVAL_STATUS_ABORTED, value);
		}
		else
			return status;
	}
	else if (part->GetType() == ES_DebugMessagePart::BODY_EXAMINE)
	{
		ES_ExamineMessagePart *body = (ES_ExamineMessagePart *) part;
		return Examine(body->tag, body->runtime_id, body->in_scope, body->thread_id, body->frame_index, body->objects_count, body->object_ids);
	}
	else if (part->GetType() == ES_DebugMessagePart::BODY_BACKTRACE)
	{
		ES_BacktraceMessagePart *body = (ES_BacktraceMessagePart *) part;
		return Backtrace(body->tag, body->runtime_id, body->thread_id, body->max_frames);
	}
	else if (part->GetType() == ES_DebugMessagePart::BODY_ADD_BREAKPOINT || part->GetType() == ES_DebugMessagePart::BODY_REMOVE_BREAKPOINT)
	{
		ES_ChangeBreakpointMessagePart *body = (ES_ChangeBreakpointMessagePart *) part;

		if (body->add)
			return AddBreakpoint(body->id, body->bpdata);
		else
			return RemoveBreakpoint(body->id);
	}
	else if (part->GetType() == ES_DebugMessagePart::BODY_SET_CONFIGURATION)
	{
		ES_SetConfigurationMessagePart *body = (ES_SetConfigurationMessagePart *) part;
		return SetStopAt(body->stop_at_script, body->stop_at_exception, body->stop_at_error, body->stop_at_abort, body->stop_at_gc);
	}
	else if (part->GetType() == ES_DebugMessagePart::BODY_BREAK)
	{
		ES_BreakMessagePart *body = (ES_BreakMessagePart *) part;
		return Break(body->runtime_id, body->thread_id);
	}

	OP_ASSERT(FALSE);

	return OpStatus::OK;
}
Exemplo n.º 13
0
void cN2Prov0501::AddRomCallbacks(void)
{
  if(!hasMaprom)
    AddBreakpoint(0x3840); // map handler
}
Exemplo n.º 14
0
//ab Add Breakpoint
//rb Remove Breakpoint
//sp Suspend
void SQDbgServer::ParseMsg(const char *msg)
{
	
	switch(*((unsigned short *)msg)){
		case MSG_ID('a','b'): {
			BreakPoint bp;
			if(ParseBreakpoint(msg+3,bp)){
				AddBreakpoint(bp);
				scprintf(_SC("added bp %d %s\n"),bp._line,bp._src.c_str());
			}
			else
				scprintf(_SC("error parsing add breakpoint"));
							 }
			break;
		case MSG_ID('r','b'): {
			BreakPoint bp;
			if(ParseBreakpoint(msg+3,bp)){
				RemoveBreakpoint(bp);
				scprintf(_SC("removed bp %d %s\n"),bp._line,bp._src.c_str());
			}else
				scprintf(_SC("error parsing remove breakpoint"));
							}
			break;
		case MSG_ID('g','o'):
			if(_state!=eDBG_Running){
				_state=eDBG_Running;
				BeginDocument();
					BeginElement(_SC("resumed"));
					EndElement(_SC("resumed"));
				EndDocument();
//				Send(_SC("<resumed/>\r\n"));
				scprintf(_SC("go (execution resumed)\n"));
			}
			break;
		case MSG_ID('s','p'):
			if(_state!=eDBG_Suspended){
				_state=eDBG_Suspended;
				scprintf(_SC("suspend\n"));
			}
			break;
		case MSG_ID('s','o'):
			if(_state==eDBG_Suspended){
				_state=eDBG_StepOver;
			}
			break;
		case MSG_ID('s','i'):
			if(_state==eDBG_Suspended){
				_state=eDBG_StepInto;
				scprintf(_SC("step into\n"));
			}
			break;
		case MSG_ID('s','r'):
			if(_state==eDBG_Suspended){
				_state=eDBG_StepReturn;
				scprintf(_SC("step return\n"));
			}
			break;
		case MSG_ID('d','i'):
			if(_state!=eDBG_Disabled){
				_state=eDBG_Disabled;
				scprintf(_SC("disabled\n"));
			}
			break;
		case MSG_ID('a','w'): {
			Watch w;
			if(ParseWatch(msg+3,w))
			{
				AddWatch(w);
				scprintf(_SC("added watch %d %s\n"),w._id,w._exp.c_str());
			}
			else
				scprintf(_SC("error parsing add watch"));
								}
			break;
		case MSG_ID('r','w'): {
			int id;
			if(ParseRemoveWatch(msg+3,id))
			{
				RemoveWatch(id);
				scprintf(_SC("added watch %d\n"),id);
			}
			else
				scprintf(_SC("error parsing remove watch"));
								}
			break;
		case MSG_ID('t','r'):
			scprintf(_SC("terminate from user\n"));
			break;
		case MSG_ID('r','d'):
			scprintf(_SC("ready\n"));
			_ready=true;
			break;
		default:
			scprintf(_SC("unknown packet"));

	}
}