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

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 10 Dec 2013 00:44:09 +0100 (CET)

hrev46516 adds 1 changeset to branch 'master'
old head: 67ba05e6db7bb24b42cacfd19f57800fda739e42
new head: dad4ae32f19e9cf1a55f016a4a7a2635ae392bf9
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=dad4ae3+%5E67ba05e

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

dad4ae3: Debugger: Fix race condition.
  
  - For the functionality added to address #10283, we need to wait until we
  receive the Team listener's thread state change notification before submitting
  the report generation request, else the thread might not actually be stopped
  yet when the generator walks the thread list. Should fix some lingering issues
  with stack traces sometimes not being returned when using this mode of
  operation.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

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

Revision:    hrev46516
Commit:      dad4ae32f19e9cf1a55f016a4a7a2635ae392bf9
URL:         http://cgit.haiku-os.org/haiku/commit/?id=dad4ae3
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Mon Dec  9 23:39:50 2013 UTC

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

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

2 files changed, 35 insertions(+), 4 deletions(-)
.../cli/CommandLineUserInterface.cpp             | 36 +++++++++++++++++---
.../cli/CommandLineUserInterface.h               |  3 ++

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

diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp 
b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
index 48e937a..ab2c837 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
@@ -226,11 +226,26 @@ CommandLineUserInterface::Run()
                                fReportTargetThread);
                        args.Parse(buffer, &parseErrorLocation);
                        _ExecuteCommand(args.ArgumentCount(), args.Arguments());
+               } else
+                       _SubmitSaveReport();
+       }
+}
+
+
+void
+CommandLineUserInterface::ThreadStateChanged(const Team::ThreadEvent& event)
+{
+       if (fSaveReport) {
+               Thread* thread = event.GetThread();
+               // If we were asked to attach/report on a specific thread
+               // rather than a team, and said thread was still
+               // running, when we attached, we need to wait for its 
corresponding
+               // stop state before generating a report, else we might not get 
its
+               // stack trace.
+               if (thread->ID() == fReportTargetThread
+                       && thread->State() == THREAD_STATE_STOPPED) {
+                       _SubmitSaveReport();
                }
-               snprintf(buffer, sizeof(buffer), "save-report %s",
-                       fReportPath != NULL ? fReportPath : "");
-               args.Parse(buffer, &parseErrorLocation);
-               _ExecuteCommand(args.ArgumentCount(), args.Arguments());
        }
 }
 
@@ -465,3 +480,16 @@ CommandLineUserInterface::_ReportTargetThreadStopNeeded() 
const
 
        return thread->State() != THREAD_STATE_STOPPED;
 }
+
+
+void
+CommandLineUserInterface::_SubmitSaveReport()
+{
+       ArgumentVector args;
+       char buffer[256];
+       const char* parseErrorLocation;
+       snprintf(buffer, sizeof(buffer), "save-report %s",
+               fReportPath != NULL ? fReportPath : "");
+       args.Parse(buffer, &parseErrorLocation);
+       _ExecuteCommand(args.ArgumentCount(), args.Arguments());
+}
diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h 
b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
index 7f1e534..12d479c 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
@@ -50,6 +50,8 @@ public:
                                                                        // 
input loop.
 
        // Team::Listener
+       virtual void                            ThreadStateChanged(
+                                                                       const 
Team::ThreadEvent& event);
        virtual void                            DebugReportChanged(
                                                                        const 
Team::DebugReportEvent& event);
 
@@ -78,6 +80,7 @@ private:
                                                                        const 
CommandEntry* command2);
 
                        bool                            
_ReportTargetThreadStopNeeded() const;
+                       void                            _SubmitSaveReport();
 
 private:
                        CliContext                      fContext;


Other related posts:

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