[haiku-commits] haiku: hrev45029 - in src/apps/debugger: user_interface/cli controllers

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 19 Dec 2012 00:12:12 +0100 (CET)

hrev45029 adds 2 changesets to branch 'master'
old head: eceaf78610c282b83758a34a51ce6752faed74ee
new head: 03289a339ceabd34eb4f909f13585a780ac4bef2
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=03289a3+%5Eeceaf78

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

486c4d3: Revert unintended change in previous commit.

03289a3: More adjustments to CliContext.
  
  - CliContext now listens for value node container events so that
    commands can request such a wait as well
  - Implement an event wait mechanism for commands to make use of.
    Adjust CliStackTrace and CliPrintVariable accordingly.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

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

5 files changed, 75 insertions(+), 17 deletions(-)
.../controllers/DebugReportGenerator.cpp         |  4 +-
.../debugger/user_interface/cli/CliContext.cpp   | 49 ++++++++++++++++++++
.../debugger/user_interface/cli/CliContext.h     | 15 +++++-
.../cli/CliPrintVariableCommand.cpp              | 14 +++---
.../user_interface/cli/CliStackTraceCommand.cpp  | 10 ++--

############################################################################

Commit:      486c4d38b276d221d011f33ebce8c0d7d0b22f9c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=486c4d3
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Tue Dec 18 23:11:28 2012 UTC

Revert unintended change in previous commit.

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

diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp 
b/src/apps/debugger/controllers/DebugReportGenerator.cpp
index 983d2d3..e37ff70 100644
--- a/src/apps/debugger/controllers/DebugReportGenerator.cpp
+++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp
@@ -336,9 +336,9 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BString& 
_output,
                for (int32 i = 0; i < container->CountChildren(); i++) {
                        ValueNodeChild* child = container->ChildAt(i);
                        containerLocker.Unlock();
-                       _ResolveValueIfNeeded(child->Node(), frame, 2);
+                       _ResolveValueIfNeeded(child->Node(), frame, 1);
                        containerLocker.Lock();
-                       UiUtils::PrintValueNodeGraph(_output, child, 3, 2);
+                       UiUtils::PrintValueNodeGraph(_output, child, 3, 1);
                }
                _output << "\n";
        }

############################################################################

Revision:    hrev45029
Commit:      03289a339ceabd34eb4f909f13585a780ac4bef2
URL:         http://cgit.haiku-os.org/haiku/commit/?id=03289a3
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Tue Dec 18 23:10:22 2012 UTC

More adjustments to CliContext.

- CliContext now listens for value node container events so that
  commands can request such a wait as well
- Implement an event wait mechanism for commands to make use of.
  Adjust CliStackTrace and CliPrintVariable accordingly.

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

diff --git a/src/apps/debugger/user_interface/cli/CliContext.cpp 
b/src/apps/debugger/user_interface/cli/CliContext.cpp
index 7b430dc..7654b3e 100644
--- a/src/apps/debugger/user_interface/cli/CliContext.cpp
+++ b/src/apps/debugger/user_interface/cli/CliContext.cpp
@@ -118,6 +118,7 @@ CliContext::Init(Team* team, UserInterfaceListener* 
listener)
        fNodeManager = new(std::nothrow) ValueNodeManager();
        if (fNodeManager == NULL)
                return B_NO_MEMORY;
+       fNodeManager->AddListener(this);
 
        return B_OK;
 }
@@ -317,6 +318,25 @@ CliContext::WaitForThreadOrUser()
 
 
 void
+CliContext::WaitForEvents(int32 eventMask)
+{
+       for (;;) {
+               _PrepareToWaitForEvents(eventMask | EVENT_USER_INTERRUPT);
+               uint32 events = fEventsOccurred;
+               if ((events & eventMask) == 0) {
+                       events = _WaitForEvents();
+               }
+
+               if ((events & EVENT_QUIT) != 0 || (events & eventMask) != 0) {
+                       _SignalInputLoop(eventMask);
+                       ProcessPendingEvents();
+                       return;
+               }
+       }
+}
+
+
+void
 CliContext::ProcessPendingEvents()
 {
        AutoLocker<Team> teamLocker(fTeam);
@@ -405,6 +425,35 @@ CliContext::ThreadStackTraceChanged(const 
Team::ThreadEvent& threadEvent)
 
 
 void
+CliContext::ValueNodeChanged(ValueNodeChild* nodeChild, ValueNode* oldNode,
+       ValueNode* newNode)
+{
+       _SignalInputLoop(EVENT_VALUE_NODE_CHANGED);
+}
+
+
+void
+CliContext::ValueNodeChildrenCreated(ValueNode* node)
+{
+       _SignalInputLoop(EVENT_VALUE_NODE_CHANGED);
+}
+
+
+void
+CliContext::ValueNodeChildrenDeleted(ValueNode* node)
+{
+       _SignalInputLoop(EVENT_VALUE_NODE_CHANGED);
+}
+
+
+void
+CliContext::ValueNodeValueChanged(ValueNode* oldNode)
+{
+       _SignalInputLoop(EVENT_VALUE_NODE_CHANGED);
+}
+
+
+void
 CliContext::_QueueEvent(Event* event)
 {
        if (event == NULL) {
diff --git a/src/apps/debugger/user_interface/cli/CliContext.h 
b/src/apps/debugger/user_interface/cli/CliContext.h
index faf6bfa..09d79d8 100644
--- a/src/apps/debugger/user_interface/cli/CliContext.h
+++ b/src/apps/debugger/user_interface/cli/CliContext.h
@@ -13,6 +13,7 @@
 #include <Locker.h>
 
 #include "Team.h"
+#include "ValueNodeContainer.h"
 
 
 class StackFrame;
@@ -22,7 +23,8 @@ class UserInterfaceListener;
 class ValueNodeManager;
 
 
-class CliContext : private Team::Listener {
+class CliContext : private Team::Listener,
+       private ValueNodeContainer::Listener {
 public:
                        enum {
                                EVENT_QUIT                                      
                = 0x01,
@@ -30,7 +32,8 @@ public:
                                EVENT_THREAD_ADDED                              
        = 0x04,
                                EVENT_THREAD_REMOVED                            
= 0x08,
                                EVENT_THREAD_STOPPED                            
= 0x10,
-                               EVENT_THREAD_STACK_TRACE_CHANGED        = 0x20
+                               EVENT_THREAD_STACK_TRACE_CHANGED        = 0x20,
+                               EVENT_VALUE_NODE_CHANGED                        
= 0x40
                        };
 
 public:
@@ -70,6 +73,7 @@ public:
                        void                            QuitSession(bool 
killTeam);
 
                        void                            WaitForThreadOrUser();
+                       void                            WaitForEvents(int32 
eventMask);
                        void                            ProcessPendingEvents();
 
 private:
@@ -87,6 +91,13 @@ private:
        virtual void                            ThreadStackTraceChanged(
                                                                        const 
Team::ThreadEvent& event);
 
+       // ValueNodeContainer::Listener
+       virtual void                            
ValueNodeChanged(ValueNodeChild* nodeChild,
+                                                                       
ValueNode* oldNode, ValueNode* newNode);
+       virtual void                            
ValueNodeChildrenCreated(ValueNode* node);
+       virtual void                            
ValueNodeChildrenDeleted(ValueNode* node);
+       virtual void                            
ValueNodeValueChanged(ValueNode* node);
+
 private:
                        void                            _QueueEvent(Event* 
event);
 
diff --git a/src/apps/debugger/user_interface/cli/CliPrintVariableCommand.cpp 
b/src/apps/debugger/user_interface/cli/CliPrintVariableCommand.cpp
index 2bb2eb1..2c984fe 100644
--- a/src/apps/debugger/user_interface/cli/CliPrintVariableCommand.cpp
+++ b/src/apps/debugger/user_interface/cli/CliPrintVariableCommand.cpp
@@ -116,16 +116,14 @@ CliPrintVariableCommand::_ResolveValueIfNeeded(ValueNode* 
node,
                context.GetUserInterfaceListener()->ValueNodeValueRequested(
                        context.CurrentThread()->GetCpuState(), container, 
node);
 
-               // TODO: implement proper waiting
-               while (!context.IsTerminating()) {
-                       context.ProcessPendingEvents();
-                       if (node->LocationAndValueResolutionState()
-                               != VALUE_NODE_UNRESOLVED) {
-                               break;
-                       }
+
+               while (node->LocationAndValueResolutionState()
+                       == VALUE_NODE_UNRESOLVED) {
                        containerLocker.Unlock();
-                       snooze(20000);
+                       
context.WaitForEvents(CliContext::EVENT_VALUE_NODE_CHANGED);
                        containerLocker.Lock();
+                       if (context.IsTerminating())
+                               return B_ERROR;
                }
        }
 
diff --git a/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp 
b/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp
index 9e7f033..37885e2 100644
--- a/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp
+++ b/src/apps/debugger/user_interface/cli/CliStackTraceCommand.cpp
@@ -45,11 +45,11 @@ CliStackTraceCommand::Execute(int argc, const char* const* 
argv,
 
        // get its stack trace
        StackTrace* stackTrace = thread->GetStackTrace();
-       if (stackTrace == NULL) {
-               // TODO: Wait for stack trace!
-               printf("Current thread doesn't have a stack trace. Waiting not "
-                       "implemented yet\n");
-               return;
+       while (stackTrace == NULL) {
+               
context.WaitForEvents(CliContext::EVENT_THREAD_STACK_TRACE_CHANGED);
+               if (context.IsTerminating())
+                       return;
+               stackTrace = thread->GetStackTrace();
        }
        BReference<StackTrace> stackTraceReference(stackTrace);
                // hold a reference until we're done


Other related posts:

  • » [haiku-commits] haiku: hrev45029 - in src/apps/debugger: user_interface/cli controllers - anevilyak