Пример #1
0
status_t
BTeamDebugger::Install(team_id team)
{
	Uninstall();

	// create a debugger port
	char name[B_OS_NAME_LENGTH];
	snprintf(name, sizeof(name), "debugger for team %" B_PRId32, team);
	fDebuggerPort = create_port(100, name);
	if (fDebuggerPort < 0)
		return fDebuggerPort;

	port_id nubPort = install_team_debugger(team, fDebuggerPort);
	if (nubPort < 0) {
		delete_port(fDebuggerPort);
		fDebuggerPort = -1;
		return nubPort;
	}

	status_t error = BDebugContext::Init(team, nubPort);
	if (error != B_OK) {
		remove_team_debugger(team);
		delete_port(fDebuggerPort);
		fDebuggerPort = -1;
		return error;
	}

	return B_OK;
}
Пример #2
0
status_t
Team::Init(team_id teamID, port_id debuggerPort)
{
	// get team info
	team_info teamInfo;
	status_t error = get_team_info(teamID, &teamInfo);
	if (error != B_OK)
		return error;

	fID = teamID;
	fArgs = teamInfo.args;

	// install ourselves as the team debugger
	fNubPort = install_team_debugger(teamID, debuggerPort);
	if (fNubPort < 0) {
		fprintf(stderr, "%s: Failed to install as debugger for team %ld: "
			"%s\n", kCommandName, teamID, strerror(fNubPort));
		return fNubPort;
	}

	// init debug context
	error = init_debug_context(&fDebugContext, teamID, fNubPort);
	if (error != B_OK) {
		fprintf(stderr, "%s: Failed to init debug context for team %ld: "
			"%s\n", kCommandName, teamID, strerror(error));
		return error;
	}

	// set team debugging flags
	int32 teamDebugFlags = B_TEAM_DEBUG_THREADS
		| B_TEAM_DEBUG_TEAM_CREATION | B_TEAM_DEBUG_IMAGES;
	set_team_debugging_flags(fNubPort, teamDebugFlags);

	return B_OK;
}
Пример #3
0
status_t
LocalDebuggerInterface::Init()
{
	// create the architecture
#if defined(ARCH_x86)
	fArchitecture = new(std::nothrow) ArchitectureX86(this);
#elif defined(ARCH_x86_64)
	fArchitecture = new(std::nothrow) ArchitectureX8664(this);
#else
	return B_UNSUPPORTED;
#endif

	if (fArchitecture == NULL)
		return B_NO_MEMORY;

	status_t error = fArchitecture->Init();
	if (error != B_OK)
		return error;

	// create debugger port
	char buffer[128];
	snprintf(buffer, sizeof(buffer), "team %" B_PRId32 " debugger", fTeamID);
	fDebuggerPort = create_port(100, buffer);
	if (fDebuggerPort < 0)
		return fDebuggerPort;

	// install as team debugger
	fNubPort = install_team_debugger(fTeamID, fDebuggerPort);
	if (fNubPort < 0)
		return fNubPort;

	error = __start_watching_system(fTeamID, B_WATCH_SYSTEM_THREAD_PROPERTIES,
		fDebuggerPort, 0);
	if (error != B_OK)
		return error;

	// create debug context pool
	fDebugContextPool = new(std::nothrow) DebugContextPool(fTeamID, fNubPort);
	if (fDebugContextPool == NULL)
		return B_NO_MEMORY;

	error = fDebugContextPool->Init();
	if (error != B_OK)
		return error;

	return B_OK;
}
Пример #4
0
status_t
DebuggerInterface::Init()
{
	// create the architecture
#ifdef ARCH_x86
	fArchitecture = new(std::nothrow) ArchitectureX86(this);
#else
	return B_UNSUPPORTED;
#endif

	if (fArchitecture == NULL)
		return B_NO_MEMORY;

	status_t error = fArchitecture->Init();
	if (error != B_OK)
		return error;

	// create debugger port
	char buffer[128];
	snprintf(buffer, sizeof(buffer), "team %ld debugger", fTeamID);
	fDebuggerPort = create_port(100, buffer);
	if (fDebuggerPort < 0)
		return fDebuggerPort;

	// install as team debugger
	fNubPort = install_team_debugger(fTeamID, fDebuggerPort);
	if (fNubPort < 0)
		return fNubPort;

	// create debug context pool
	fDebugContextPool = new(std::nothrow) DebugContextPool(fTeamID, fNubPort);
	if (fDebugContextPool == NULL)
		return B_NO_MEMORY;

	error = fDebugContextPool->Init();
	if (error != B_OK)
		return error;

	return B_OK;
}
Пример #5
0
static void
haiku_init_child_debugging (thread_id threadID, bool debugThread)
{
	thread_info threadInfo;
	status_t result;
	port_id nubPort;

	// get a thread info
	result = get_thread_info(threadID, &threadInfo);
	if (result != B_OK)
		error("Thread with ID %ld not found: %s", threadID, strerror(result));

	// init our team debug structure
	sTeamDebugInfo.team = threadInfo.team;
	sTeamDebugInfo.debugger_port = -1;
	sTeamDebugInfo.context.nub_port = -1;
	sTeamDebugInfo.context.reply_port = -1;
	sTeamDebugInfo.threads = NULL;
	sTeamDebugInfo.events.head = NULL;
	sTeamDebugInfo.events.tail = NULL;

	// create the debugger port
	sTeamDebugInfo.debugger_port = create_port(10, "gdb debug");
	if (sTeamDebugInfo.debugger_port < 0) {
		error("Failed to create debugger port: %s",
			strerror(sTeamDebugInfo.debugger_port));
	}

	// install ourselves as the team debugger
	nubPort = install_team_debugger(sTeamDebugInfo.team,
		sTeamDebugInfo.debugger_port);
	if (nubPort < 0) {
		error("Failed to install ourselves as debugger for team %ld: %s",
			sTeamDebugInfo.team, strerror(nubPort));
	}

	// get the nub thread
	{
		team_info teamInfo;
		result = get_team_info(sTeamDebugInfo.team, &teamInfo);
		if (result != B_OK) {
			error("Failed to get info for team %ld: %s\n",
				sTeamDebugInfo.team, strerror(result));
		}

		sTeamDebugInfo.nub_thread = teamInfo.debugger_nub_thread;
	}

	// init the debug context
	result = init_debug_context(&sTeamDebugInfo.context, sTeamDebugInfo.team,
		nubPort);
	if (result != B_OK) {
		error("Failed to init debug context for team %ld: %s\n",
			sTeamDebugInfo.team, strerror(result));
	}

	// start debugging the thread
	if (debugThread) {
		result = debug_thread(threadID);
		if (result != B_OK) {
			error("Failed to start debugging thread %ld: %s", threadID,
				strerror(result));
		}
	}

	// set the team debug flags
	{
		debug_nub_set_team_flags message;
		message.flags = B_TEAM_DEBUG_SIGNALS /*| B_TEAM_DEBUG_PRE_SYSCALL
			| B_TEAM_DEBUG_POST_SYSCALL*/ | B_TEAM_DEBUG_TEAM_CREATION
			| B_TEAM_DEBUG_THREADS | B_TEAM_DEBUG_IMAGES;
			// TODO: We probably don't need all events

		haiku_send_debugger_message(&sTeamDebugInfo,
			B_DEBUG_MESSAGE_SET_TEAM_FLAGS, &message, sizeof(message), NULL, 0);
	}


	// the fun can start: push the target and init the rest
	push_target(sHaikuTarget);

	haiku_init_thread_list(&sTeamDebugInfo);
	haiku_init_image_list(&sTeamDebugInfo);

	disable_breakpoints_in_shlibs (1);

//	child_clear_solibs ();
		// TODO: Implement? Do we need this?

	clear_proceed_status ();
	init_wait_for_inferior ();

	target_terminal_init ();
	target_terminal_inferior ();
}