⛏️ index : haiku.git

author Augustin Cavalier <waddlesplash@gmail.com> 2025-11-18 18:45:06.0 -05:00:00
committer Augustin Cavalier <waddlesplash@gmail.com> 2025-11-18 18:45:06.0 -05:00:00
commit
2661f371fb31307a29b96701a47939dbf5ff6727 [patch]
tree
442fcf195c750622f23d75a4fc52dfffa21ed8cf
parent
f4415c86572c09315074ba831fee6da75f743e34
download
2661f371fb31307a29b96701a47939dbf5ff6727.tar.gz

Debugger: Don't wait for threads or user in the CLI input loop.

It seems to be unecessary and just hangs the CLI most of the time
if there's no thread about to stop.

Makes Debugger --team <team> actually work instead of just
hanging.

Diff

 src/apps/debugger/user_interface/cli/CliContext.cpp               | 20 +-------------------
 src/apps/debugger/user_interface/cli/CliContext.h                 |  1 -
 src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp |  5 -----
 3 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/src/apps/debugger/user_interface/cli/CliContext.cpp b/src/apps/debugger/user_interface/cli/CliContext.cpp
index ee14a12..b9da365 100644
--- a/src/apps/debugger/user_interface/cli/CliContext.cpp
+++ b/src/apps/debugger/user_interface/cli/CliContext.cpp
@@ -382,24 +382,6 @@


void
CliContext::WaitForThreadOrUser()
{
// TODO: Deal with SIGINT as well!

	AutoLocker<BLocker> locker(fLock);

	while (fStoppedThread == NULL) {
		_WaitForEvent(MSG_THREAD_STATE_CHANGED);
		if (fTerminating)
			break;
	}

	if (fCurrentThread == NULL)
		SetCurrentThread(fStoppedThread);
}


void
CliContext::WaitForEvent(uint32 event)
{
	AutoLocker<BLocker> locker(fLock);
@@ -442,7 +424,7 @@
			break;
		}
		case MSG_THREAD_STACK_TRACE_CHANGED:
			if (threadID == fCurrentThread->ID()) {
			if (fCurrentThread != NULL && threadID == fCurrentThread->ID()) {
				AutoLocker< ::Team> locker(fTeam);
				::Thread* thread = fTeam->ThreadByID(threadID);

diff --git a/src/apps/debugger/user_interface/cli/CliContext.h b/src/apps/debugger/user_interface/cli/CliContext.h
index 0b6c698..4b7f230 100644
--- a/src/apps/debugger/user_interface/cli/CliContext.h
+++ b/src/apps/debugger/user_interface/cli/CliContext.h
@@ -93,7 +93,6 @@

			void				QuitSession(bool killTeam);

			void				WaitForThreadOrUser();
			void				WaitForEvent(uint32 event);

private:
diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
index 7849f37..2692419 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
@@ -253,11 +253,6 @@
	thread_id currentThread = -1;

	while (!fTerminating) {
		// Wait for a thread or Ctrl-C.
		fContext->WaitForThreadOrUser();
		if (fContext->IsTerminating())
			break;

		// Print the active thread, if it changed.
		if (fContext->CurrentThreadID() != currentThread) {
			fContext->PrintCurrentThread();