rem: thread = load_program(programArgs, programArgCount);
add: thread = load_program(programArgs, programArgCount, traceLoading); if (thread < 0) { fprintf(stderr, "Failed to start `%s': %s\n", programArgs[0], strerror(thread)); exit(1); }
context: main(int argc, const char *const *argv){	sArgc = argc;	sArgv = argv;	// parameters	const char *const *programArgs = NULL;	int32 programArgCount = 0;	bool printArguments = true;	bool colorize = true;	bool fastMode = false;	bool printReturnValues = true;	bool traceChildThreads = false;	bool traceTeam = false;	// parse arguments	for (int argi = 1; argi < argc; argi++) {		const char *arg = argv[argi];		if (arg[0] == '-') {			if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) {				print_usage_and_exit(false);			} else if (strcmp(arg, "-a") == 0) {				printArguments = false;			} else if (strcmp(arg, "-c") == 0) {				colorize = false;			} else if (strcmp(arg, "-f") == 0) {				fastMode = true;			} else if (strcmp(arg, "-r") == 0) {				printReturnValues = false;			} else if (strcmp(arg, "-s") == 0) {				traceChildThreads = true;			} else if (strcmp(arg, "-T") == 0) {				traceTeam = true;			} else {				print_usage_and_exit(true);			}		} else {			programArgs = argv + argi;			programArgCount = argc - argi;			break;		}	}	// check parameters	if (!programArgs)		print_usage_and_exit(true);	// initialize our syscalls vector and map	init_syscalls();	// don't colorize the output, if we don't have a terminal	colorize = colorize && isatty(STDOUT_FILENO);	// get thread/team to be debugged	thread_id thread = -1;	team_id team = -1;	if (programArgCount > 1		|| !get_id(*programArgs, (traceTeam ? team : thread))) {		// we've been given an executable and need to load it		thread = load_program(programArgs, programArgCount);	}			// get the team ID, if we have none yet	if (team < 0) {		thread_info threadInfo;		status_t error = get_thread_info(thread, &threadInfo);		if (error != B_OK) {			fprintf(stderr, "Failed to get info for thread %ld: %s\n", thread,				strerror(error));			exit(1);		}		team = threadInfo.team;	}	// create a debugger port	port_id debuggerPort = create_port(10, "debugger port");	if (debuggerPort < 0) {		fprintf(stderr, "Failed to create debugger port: %s\n",			strerror(debuggerPort));		exit(1);	}	// install ourselves as the team debugger	port_id nubPort = install_team_debugger(team, debuggerPort);	if (nubPort < 0) {		fprintf(stderr, "Failed to install team debugger: %s\n",			strerror(nubPort));		exit(1);	}	// set team debugging flags	int32 teamDebugFlags = (traceTeam ? B_TEAM_DEBUG_POST_SYSCALL : 0);	set_team_debugging_flags(nubPort, teamDebugFlags);	// set thread debugging flags	if (thread >= 0) {		int32 threadDebugFlags = 0;		if (!traceTeam) {			threadDebugFlags = B_THREAD_DEBUG_POST_SYSCALL				| (traceChildThreads					? B_THREAD_DEBUG_SYSCALL_TRACE_CHILD_THREADS : 0);		}		set_thread_debugging_flags(nubPort, thread, threadDebugFlags);		// resume the target thread to be sure, it's running		resume_thread(thread);	}	MemoryReader memoryReader(nubPort);	// debug loop	while (true) {		int32 code;		debug_debugger_message_data message;		ssize_t messageSize = read_port(debuggerPort, &code, &message,			sizeof(message));		if (messageSize < 0) {			if (messageSize == B_INTERRUPTED)				continue;			fprintf(stderr, "Reading from debugger port failed: %s\n",				strerror(messageSize));			exit(1);		}		thread_id concernedThread = -1;		switch (code) {			case B_DEBUGGER_MESSAGE_POST_SYSCALL:			{				concernedThread = message.origin.thread;				print_syscall(message.post_syscall, memoryReader,					printArguments, !fastMode, printReturnValues, colorize);				break;			}			case B_DEBUGGER_MESSAGE_THREAD_STOPPED:			case B_DEBUGGER_MESSAGE_PRE_SYSCALL:			case B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED:			case B_DEBUGGER_MESSAGE_TEAM_CREATED:			case B_DEBUGGER_MESSAGE_THREAD_CREATED:			case B_DEBUGGER_MESSAGE_IMAGE_CREATED:			case B_DEBUGGER_MESSAGE_IMAGE_DELETED:				concernedThread = message.origin.thread;				break;			case B_DEBUGGER_MESSAGE_THREAD_DELETED:				// nothing to do: a thread was deleted				break;			case B_DEBUGGER_MESSAGE_TEAM_DELETED:				// the debugged team is gone				exit(0);		}		// tell the thread to continue		if (concernedThread >= 0) {			run_thread(nubPort, concernedThread);		}	}		return 0;}