diff --git a/src/apps/debugger/user_interface/cli/CliContext.cpp b/src/apps/debugger/user_interface/cli/CliContext.cpp index f36f87d3e3..6acb238f6f 100644 --- a/src/apps/debugger/user_interface/cli/CliContext.cpp +++ b/src/apps/debugger/user_interface/cli/CliContext.cpp @@ -97,6 +97,7 @@ CliContext::CliContext() fInputLoopWaitingForEvents(0), fEventsOccurred(0), fInputLoopWaiting(false), + fInteractive(true), fTerminating(false), fCurrentThread(NULL), fCurrentStackTrace(NULL), @@ -207,6 +208,13 @@ CliContext::Terminating() } +void +CliContext::SetInteractive(bool interactive) +{ + fInteractive = interactive; +} + + thread_id CliContext::CurrentThreadID() const { @@ -444,6 +452,13 @@ CliContext::ProcessPendingEvents() fExpressionValue->AcquireReference(); } break; + case EVENT_DEBUG_REPORT_CHANGED: + if (!IsInteractive()) { + Terminating(); + QuitSession(true); + } + break; + } } } @@ -503,6 +518,17 @@ CliContext::ExpressionEvaluated(const Team::ExpressionEvaluationEvent& event) } +void +CliContext::DebugReportChanged(const Team::DebugReportEvent& event) +{ + printf("Successfully saved debug report to %s\n", + event.GetReportPath()); + + _QueueEvent(new(std::nothrow) Event(EVENT_DEBUG_REPORT_CHANGED)); + _SignalInputLoop(EVENT_DEBUG_REPORT_CHANGED); +} + + void CliContext::MemoryBlockRetrieved(TeamMemoryBlock* block) { diff --git a/src/apps/debugger/user_interface/cli/CliContext.h b/src/apps/debugger/user_interface/cli/CliContext.h index f83cc34f2a..b2a349fca4 100644 --- a/src/apps/debugger/user_interface/cli/CliContext.h +++ b/src/apps/debugger/user_interface/cli/CliContext.h @@ -39,7 +39,8 @@ public: EVENT_THREAD_STACK_TRACE_CHANGED = 0x20, EVENT_VALUE_NODE_CHANGED = 0x40, EVENT_TEAM_MEMORY_BLOCK_RETRIEVED = 0x80, - EVENT_EXPRESSION_EVALUATED = 0x100 + EVENT_EXPRESSION_EVALUATED = 0x100, + EVENT_DEBUG_REPORT_CHANGED = 0x200 }; public: @@ -54,6 +55,9 @@ public: bool IsTerminating() const { return fTerminating; } + bool IsInteractive() const { return fInteractive; } + void SetInteractive(bool interactive); + // service methods for the input loop thread follow Team* GetTeam() const { return fTeam; } @@ -110,6 +114,9 @@ private: const Team::ExpressionEvaluationEvent& event); + virtual void DebugReportChanged( + const Team::DebugReportEvent& event); + // TeamMemoryBlock::Listener virtual void MemoryBlockRetrieved(TeamMemoryBlock* block); @@ -141,6 +148,7 @@ private: uint32 fInputLoopWaitingForEvents; uint32 fEventsOccurred; bool fInputLoopWaiting; + bool fInteractive; volatile bool fTerminating; Thread* fCurrentThread; diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index 5494b24b12..dfbe7c598d 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -128,6 +128,8 @@ CommandLineUserInterface::Init(Team* team, UserInterfaceListener* listener) if (error != B_OK) return error; + fContext.SetInteractive(!fSaveReport); + error = _RegisterCommands(); if (error != B_OK) return error; @@ -229,11 +231,7 @@ CommandLineUserInterface::Run() if (error != B_OK) return; - if (!fSaveReport) { - _InputLoop(); - // Release the Show() semaphore to signal Terminate(). - release_sem(fShowSemaphore); - } else { + if (fSaveReport) { ArgumentVector args; char buffer[256]; const char* parseErrorLocation; @@ -245,6 +243,10 @@ CommandLineUserInterface::Run() } else _SubmitSaveReport(); } + + _InputLoop(); + // Release the Show() semaphore to signal Terminate(). + release_sem(fShowSemaphore); } @@ -266,21 +268,6 @@ CommandLineUserInterface::ThreadStateChanged(const Team::ThreadEvent& event) } -void -CommandLineUserInterface::DebugReportChanged( - const Team::DebugReportEvent& event) -{ - printf("Successfully saved debug report to %s\n", - event.GetReportPath()); - - if (fSaveReport) { - fContext.QuitSession(true); - // Release the Show() semaphore to signal Terminate(). - release_sem(fShowSemaphore); - } -} - - /*static*/ status_t CommandLineUserInterface::_InputLoopEntry(void* data) { diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h index 85dffcd3a7..8eec3a3c87 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h @@ -55,8 +55,6 @@ public: // Team::Listener virtual void ThreadStateChanged( const Team::ThreadEvent& event); - virtual void DebugReportChanged( - const Team::DebugReportEvent& event); private: struct CommandEntry;