コード例 #1
0
////////////////////////////////////////////////////////////////////////////////
// ResultDepositValue()
//
//    This event handler is called when the proxy completes a 'deposit' operation
//    (in response to an earlier call to pldbg_deposit_value()).
//
//    We schedule a refresh of our variable window(s) for the next idle period.
//
void dbgController::ResultDepositValue(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, _("Could not deposit the new value.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			pgSet *set = qry->ResultSet();

			if (set->GetBool(0))
			{
				m_frm->SetStatusText(_("Value changed"));

				m_dbgThread->AddQuery(
				    wxString::Format(ms_cmdGetVars, m_model->GetSession().c_str()),
				    NULL, RESULT_ID_GET_VARS);
			}
			else
			{
				wxLogError(_("Could not deposit the new value."));
			}
		}

		// Release the result-set
		qry->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #2
0
void dbgController::ResultNewBreakpointWait(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, _("Could not create the breakpoint.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			pgSet *set = _ev.GetQuery()->ResultSet();
			m_frm->EnableToolsAndMenus(false);

			m_dbgThread->AddQuery(
			    wxString::Format(
			        ms_cmdWaitForTarget, m_model->GetSession().c_str()),
			    NULL, RESULT_ID_TARGET_READY);

			m_frm->LaunchWaitingDialog();
		}

		// Release the result-set
		qry->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #3
0
void dbgController::ResultDeletedBreakpoint(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, _("Could not drop the breakpoint.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			pgSet *set = qry->ResultSet();

			if (set->GetBool(0))
			{
				m_frm->SetStatusText(_("Breakpoint dropped"));
			}
		}

		// Release the result-set
		qry->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #4
0
void dbgController::ResultBreakpoints(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, _("Error fetching breakpoints.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			pgSet *set = qry->ResultSet();

			int pkgCol = -1, funcCol = set->ColNumber(wxT("func")),
			    lineCol = set->ColNumber(wxT("linenumber"));

			if (set->HasColumn(wxT("pkg")))
			{
				pkgCol = set->ColNumber(wxT("pkg"));
			}

			m_dbgThread->AddQuery(
			    wxString::Format(ms_cmdGetVars, m_model->GetSession().c_str()),
			    NULL, RESULT_ID_GET_VARS);

			m_frm->ClearBreakpointMarkers();
			dbgBreakPointList &breakpoints = m_model->GetBreakPoints();
			WX_CLEAR_ARRAY(breakpoints);

			while (!set->Eof())
			{
				// The result set contains one tuple per breakpoint:
				//   pkg, func, linenumber, target
				//   or,
				//   func, linenumber, target
				wxString pkg = (pkgCol == -1) ? wxT("0") : set->GetVal(pkgCol);
				wxString func = set->GetVal(funcCol);
				int lineNumber = (int)set->GetLong(lineCol);

				// Save this break-points in break-point list
				breakpoints.Append(new dbgBreakPoint(func, pkg, lineNumber));

				// Mark the break-point in the viewer
				if (pkg == m_model->GetDisplayedPackage() &&
				        func == m_model->GetDisplayedFunction())
				{
					m_frm->MarkBreakpoint(lineNumber - 1);
				}
				set->MoveNext();
			}
		}

		// Release the result-set
		qry->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #5
0
void dbgController::ResultTargetReady(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (m_frm)
	{
		m_frm->CloseProgressBar();
		m_frm->EnableToolsAndMenus(false);
	}

	if (!HandleQuery(qry,
	                 _("Error fetching target information.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		bool goAhead = false;
		goAhead = (qry->ReturnCode() == PGRES_TUPLES_OK);
		pgSet *set = qry->ResultSet();

		// Save the current running target pid
		m_currTargetPid = set->GetVal(0);

		// Next line release the actual result-set
		set = NULL;

		// Release the result-set
		qry->Release();
		UNLOCKMUTEX(m_dbgThreadLock);

		pgParamsArray *params = new pgParamsArray;

		params->Add(new pgParam(PGOID_TYPE_INT4, &(m_model->GetSession())));
		if (m_ver <= DEBUGGER_V2_API)
		{
			m_dbgThread->AddQuery(ms_cmdWaitForBreakpointV1, params, RESULT_ID_BREAKPOINT);
		}
		else
		{
			m_dbgThread->AddQuery(ms_cmdWaitForBreakpointV2, params, RESULT_ID_BREAKPOINT);
		}
	}
	else
	{
		UNLOCKMUTEX(m_dbgThreadLock);
	}
}
コード例 #6
0
void dbgController::ResultNewBreakpoint(pgQueryResultEvent &_ev)
{
	// We will wait for the last new break-point, which will be handled in
	// dbgController::ResultNewBreakpointWait function
	if (!HandleQuery(_ev.GetQuery(), _("Could not create the breakpoint.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		// Release the result-set
		_ev.GetQuery()->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #7
0
void dbgController::ResultListenerCreated(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry,
	                 _("Could not create the proxy listener for in-process debugging.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			pgSet *set = qry->ResultSet();

			// We now have a global listener and a session handle. Grab the session
			// handle (we'll need it for just about everything else).
			m_model->GetSession() = set->GetVal(0);

			// Release the result-set
			qry->Release();

			// Now create any global breakpoints that the user requested. We start
			// by asking the server to resolve the breakpoint name into an OID (or,
			// a pair of OID's if the target is defined in a package). As each
			// (targetInof) result arrives, we add a break-point at the resulting
			// OID.
			unsigned int idx = 1;
			long resultId;

			dbgBreakPointList breakpoints = m_model->GetBreakPoints();
			for (dbgBreakPointList::Node *node = breakpoints.GetFirst(); node;
			        node = node->GetNext(), ++idx)
			{
				dbgBreakPoint *breakpoint = node->GetData();

				if(idx < breakpoints.GetCount())
				{
					resultId = RESULT_ID_NEW_BREAKPOINT;
				}
				else
				{
					resultId = RESULT_ID_NEW_BREAKPOINT_WAIT;
				}

				/*
				 * In EnterpriseDB versions <= 9.1 the
				 * pldbg_set_global_breakpoint function took five arguments,
				 * the 2nd argument being the package's OID, if any. Starting
				 * with 9.2, the package OID argument is gone, and the function
				 * takes four arguments like the community version has always
				 * done.
				 */
				if (m_dbgConn->GetIsEdb() && !m_dbgConn->BackendMinimumVersion(9, 2))
				{
					m_dbgThread->AddQuery(
					    wxString::Format(
					        ms_cmdAddBreakpointEDB, m_model->GetSession().c_str(),
					        breakpoint->GetPackageOid().c_str(),
					        breakpoint->GetFunctionOid().c_str(),
					        m_model->GetTargetPid().c_str()),
					    NULL, resultId);
				}
				else
				{
					m_dbgThread->AddQuery(
					    wxString::Format(
					        ms_cmdAddBreakpointPG, m_model->GetSession().c_str(),
					        breakpoint->GetFunctionOid().c_str(),
					        m_model->GetTargetPid().c_str()),
					    NULL, resultId);
				}
			}
			UNLOCKMUTEX(m_dbgThreadLock);
		}
		else
		{
			// Release the result-set
			qry->Release();
			UNLOCKMUTEX(m_dbgThreadLock);
		}
	}
	else
	{
		UNLOCKMUTEX(m_dbgThreadLock);
	}
}
コード例 #8
0
void dbgController::ResultStack(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, _("Error fetching the call stack.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			pgSet *set = qry->ResultSet();

			dbgStackFrameList stacks;
			ctlStackWindow    *stackWin = m_frm->GetStackWindow();

			// Fetched the stack, now fetch the break-points
			m_dbgThread->AddQuery(
			    wxString::Format(ms_cmdGetBreakpoints, m_model->GetSession().c_str()),
			    NULL, RESULT_ID_GET_BREAKPOINTS);

			stackWin->ClearStack();

			int selected = 0,
			    levelCol = set->ColNumber(wxT("level")),
			    pkgCol = set->HasColumn(wxT("pkg")) ? set->ColNumber(wxT("level")) : -1,
			    funCol = set->ColNumber(wxT("func")),
			    targetCol = set->ColNumber(wxT("targetname")),
			    argsCol = set->ColNumber(wxT("args")),
			    lineCol = set->ColNumber(wxT("linenumber"));

			while (!set->Eof())
			{
				// The result set contains one tuple per frame:
				//        package, function, linenumber, args
				dbgStackFrame *frame = new dbgStackFrame(
				    set->GetVal(levelCol),
				    pkgCol != -1 ? set->GetVal(wxT("pkg")) : wxT("0"),
				    set->GetVal(funCol),
				    wxString::Format(
				        wxT("%s(%s)@%s"),
				        set->GetVal(targetCol).c_str(),
				        set->GetVal(argsCol).c_str(),
				        set->GetVal(lineCol).c_str()));

				// Select this one in the stack window
				if (frame->GetFunction() == m_model->GetDisplayedFunction() &&
				        frame->GetPackage() == m_model->GetDisplayedPackage())
				{
					selected = set->CurrentPos() - 1;
				}

				stacks.Append(frame);
				set->MoveNext();
			}
			stackWin->SetStack(stacks, selected);
		}

		// Release the result-set
		qry->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #9
0
void dbgController::ResultVarList(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, _("Error fetching variables.")))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			ctlVarWindow *paramWin = NULL, *pkgVarWin = NULL, *varWin = NULL;
			pgSet *set = qry->ResultSet();

			while (!set->Eof())
			{
				switch((char)(set->GetVal(wxT("varclass"))[0]))
				{
					case 'A':
					{
						if (paramWin == NULL)
							paramWin = m_frm->GetParamWindow(true);

						paramWin->AddVar(
						    set->GetVal(wxT("name")),
						    set->GetVal(wxT("value")),
						    set->GetVal(wxT("dtype")),
						    set->GetBool(wxT("isconst")));

						break;
					}
					case 'P':
					{
						if (pkgVarWin == NULL)
							pkgVarWin = m_frm->GetPkgVarWindow(true);

						pkgVarWin->AddVar(
						    set->GetVal(wxT("name")),
						    set->GetVal(wxT("value")),
						    set->GetVal(wxT("dtype")),
						    set->GetBool(wxT("isconst")));

						break;
					}
					default:
					{
						if (varWin == NULL)
							varWin = m_frm->GetVarWindow(true);

						varWin->AddVar(
						    set->GetVal(wxT("name")),
						    set->GetVal(wxT("value")),
						    set->GetVal(wxT("dtype")),
						    set->GetBool(wxT("isconst")));

						break;
					}
				}
				set->MoveNext();
			}
		}

		// Release the result-set
		qry->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #10
0
void dbgController::ResultBreakpoint(pgQueryResultEvent &_ev)
{
	if (m_frm)
		m_frm->CloseProgressBar();

	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, wxEmptyString))
		return;

	LOCKMUTEX(m_dbgThreadLock);
	// Do not bother to process the result, if the debugger thread is not
	// running or not exists
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (qry->ReturnCode() == PGRES_TUPLES_OK)
		{
			wxString func,
			         pkg = wxT("0");

			pgSet *set = qry->ResultSet();

			if (set->HasColumn(wxT("pkg")))
			{
				pkg = set->GetVal(wxT("pkg"));
			}
			func = set->GetVal(wxT("func"));

			m_model->GetFocusedPackage() = pkg;
			m_model->GetFocusedFunction() = func;

			int lineNo = (int)(set->GetLong(wxT("linenumber")) - 1);

			if (lineNo < 0)
				lineNo = -1;
			else
				lineNo -= m_lineOffset;
			m_model->GetCurrLineNo() = lineNo;

			wxString strSource = set->GetVal(wxT("src"));

			if (strSource.IsEmpty())
				strSource = _("<source not available>");

			dbgCachedStack src(pkg, func, set->GetVal(wxT("targetname")),
			                   set->GetVal(wxT("args")), strSource);

			m_model->AddSource(func, src);
			m_frm->DisplaySource(src);

			m_dbgThread->AddQuery(
			    wxString::Format(ms_cmdGetStack, m_model->GetSession().c_str()),
			    NULL, RESULT_ID_GET_STACK);

			m_frm->EnableToolsAndMenus(true);
		}

		// Release the result-set
		qry->Release();
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #11
0
void dbgController::ResultPortAttach(pgQueryResultEvent &_ev)
{
	pgBatchQuery *qry = _ev.GetQuery();

	if (!HandleQuery(qry, _("Error attaching the proxy session.")))
	{
		return;
	}

	if (qry->ReturnCode() != PGRES_TUPLES_OK)
	{
		Stop();

		return;
	}

	m_frm->EnableToolsAndMenus(false);

	wxString strSession = qry->ResultSet()->GetVal(0);
	m_model->GetSession() = strSession;

	pgParamsArray *params = new pgParamsArray;

	params->Add(new pgParam(PGOID_TYPE_INT4, &strSession));

	LOCKMUTEX(m_dbgThreadLock);
	if (m_dbgThread && m_dbgThread->IsRunning())
	{
		if (m_ver <= DEBUGGER_V2_API)
		{
			m_dbgThread->AddQuery(ms_cmdWaitForBreakpointV1, params, RESULT_ID_BREAKPOINT);
		}
		else
		{
			m_dbgThread->AddQuery(ms_cmdWaitForBreakpointV2, params, RESULT_ID_BREAKPOINT);
		}
		qry->Release();

		// Now create any breakpoints that the user created in last execution. We
		// start by asking the server to resolve the breakpoint name into an OID (or,
		// a pair of OID's if the target is defined in a package). As each
		// (targetInof) result arrives, we add a break-point at the resulting OID.
		dbgBreakPointList breakpoints = m_model->GetBreakPoints();

		for (dbgBreakPointList::Node *node = breakpoints.GetFirst(); node;
		        node = node->GetNext())
		{
			dbgBreakPoint *breakpoint = node->GetData();
			/*
			 * In EnterpriseDB versions <= 9.1 the
			 * pldbg_set_global_breakpoint function took five arguments,
			 * the 2nd argument being the package's OID, if any. Starting
			 * with 9.2, the package OID argument is gone, and the function
			 * takes four arguments like the community version has always
			 * done.
			 */
			if (m_dbgConn->GetIsEdb() && !m_dbgConn->BackendMinimumVersion(9, 2))
			{
				m_dbgThread->AddQuery(
				    wxString::Format(
				        ms_cmdSetBreakpointV1, m_model->GetSession().c_str(),
				        breakpoint->GetPackageOid().c_str(),
				        breakpoint->GetFunctionOid().c_str(),
				        breakpoint->GetLineNo()),
				    NULL, RESULT_ID_NEW_BREAKPOINT);
			}
			else
			{
				m_dbgThread->AddQuery(
				    wxString::Format(
				        ms_cmdSetBreakpointV2, m_model->GetSession().c_str(),
				        breakpoint->GetFunctionOid().c_str(),
				        breakpoint->GetLineNo()),
				    NULL, RESULT_ID_NEW_BREAKPOINT);
			}
		}
	}
	UNLOCKMUTEX(m_dbgThreadLock);
}
コード例 #12
0
ファイル: MasterServer.cpp プロジェクト: jochao/HoloToolkit
bool MasterServer::OnReceive(RakPeerInterface *peer, Packet *packet)
{

	RakNetStatisticsStruct *rss;
	RakNetTime connectionTime;
	RakNetTime time;
	unsigned serverIndex;
	time = RakNet::GetTime();

	// Quick and dirty flood attack security:
	// If a client has been connected for more than 5 seconds,
	// and has sent more than 1000 bytes per second on average then ban them
	rss=rakPeer->GetStatistics(packet->playerId);
	if (rss)
	{
		connectionTime=time-rss->connectionStartTime;
		if (connectionTime > FLOOD_ATTACK_CHECK_DELAY &&
			(float)(rss->bitsReceived/8) / (float) connectionTime > FLOOD_ATTACK_BYTES_PER_MS)
		{
			rakPeer->CloseConnection(packet->playerId, true,0);
#ifdef _SHOW_MASTER_SERVER_PRINTF
			printf("%s banned for session due to for flood attack\n", (char*)rakPeer->PlayerIDToDottedIP(packet->playerId));
#endif
			rakPeer->AddToBanList(rakPeer->PlayerIDToDottedIP(packet->playerId));

			// Find all servers with this IP and kill them.
			serverIndex=0;
			while (serverIndex < gameServerList.serverList.Size())
			{
				if (gameServerList.serverList[serverIndex]->connectionIdentifier.binaryAddress==packet->playerId.binaryAddress)
				{
					delete gameServerList.serverList[serverIndex];
					gameServerList.serverList.RemoveAtIndex(serverIndex);
				}
				else
					serverIndex++;
			}
		}
	}

	switch(packet->data[0])
	{
	case ID_QUERY_MASTER_SERVER:
		HandleQuery(packet);
		return true;
	case ID_MASTER_SERVER_DELIST_SERVER:
		HandleDelistServer(packet);
		return true;
	case ID_MASTER_SERVER_SET_SERVER:
		HandleUpdateServer(packet);
		return true;
	case ID_PONG:
		HandlePong(packet);
		return false;
	case ID_RELAYED_CONNECTION_NOTIFICATION:
		HandleRelayedConnectionNotification(packet);
		return true;
	}

	return false; // Absorb packet
}