[haiku-commits] haiku: hrev48222 - src/apps/debugger/user_interface/cli

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 5 Nov 2014 01:22:19 +0100 (CET)

hrev48222 adds 1 changeset to branch 'master'
old head: 9a6331459f21e0d4ac4e9fa4e951390159011039
new head: 8b9099b1b24358076e28f6e3a894e6f39de4cece
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=8b9099b+%5E9a63314

----------------------------------------------------------------------------

8b9099b: Debugger: Fix #11411.
  
  CliContext/CommandLineUserInterface:
  - Process the debug report event asynchronously. The missing lock that
    was fixed in commit 5ac34e5a78305abac4c758a34db9f1e34aee54ed highlighted
    a problem in how the CLI was handling the case where it was intended to
    exit immediately after saving a report, since it issued the quit request
    directly from the report event handler. This resulted in locking issues,
    as the team debugger would then attempt to tear itself down, during which
    it needs to acquire the team lock. However, that was already being held
    by the thread in which the CLI was initiating the quit, resulting in a
    deadlock.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48222
Commit:      8b9099b1b24358076e28f6e3a894e6f39de4cece
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8b9099b
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Tue Nov  4 22:38:43 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/11411

----------------------------------------------------------------------------

4 files changed, 42 insertions(+), 23 deletions(-)
.../debugger/user_interface/cli/CliContext.cpp   | 26 +++++++++++++++++++
.../debugger/user_interface/cli/CliContext.h     | 10 +++++++-
.../cli/CommandLineUserInterface.cpp             | 27 +++++---------------
.../cli/CommandLineUserInterface.h               |  2 --

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/cli/CliContext.cpp 
b/src/apps/debugger/user_interface/cli/CliContext.cpp
index f36f87d..6acb238 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;
+
                }
        }
 }
@@ -504,6 +519,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)
 {
        _QueueEvent(
diff --git a/src/apps/debugger/user_interface/cli/CliContext.h 
b/src/apps/debugger/user_interface/cli/CliContext.h
index f83cc34..b2a349f 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 5494b24..dfbe7c5 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 85dffcd..8eec3a3 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;


Other related posts:

  • » [haiku-commits] haiku: hrev48222 - src/apps/debugger/user_interface/cli - anevilyak