[haiku-commits] haiku: hrev45612 - in src/apps/debugger/user_interface/gui/teams_window: . src/apps/debugger

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 4 May 2013 02:38:43 +0200 (CEST)

hrev45612 adds 4 changesets to branch 'master'
old head: 5041cdf4d90ded8e958233b33b74add10def68ec
new head: aad822734d4078d8075cdc95e940eb23ce0e6a2a
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=aad8227+%5E5041cdf

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

72354d6: Also disable Attach button for kernel.

1953ec9: Add UI window for starting a new team.

9b57eae: Wire up Start new team button.

aad8227: Add message for starting a new team. Implements #9682.
  
  - The Debugger app now accepts a message asking it to start a new team.
    It attempts to do so given the path and arguments, and passes the
    result back to the sender if desired.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

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

7 files changed, 307 insertions(+), 28 deletions(-)
src/apps/debugger/Debugger.cpp                   |  93 +++++++++--
src/apps/debugger/Jamfile                        |   1 +
src/apps/debugger/MessageCodes.h                 |   1 +
.../gui/teams_window/StartTeamWindow.cpp         | 163 +++++++++++++++++++
.../gui/teams_window/StartTeamWindow.h           |  47 ++++++
.../gui/teams_window/TeamsWindow.cpp             |  28 ++--
.../gui/teams_window/TeamsWindow.h               |   2 +

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

Commit:      72354d67594e895d5435408a5b7918145e262009
URL:         http://cgit.haiku-os.org/haiku/commit/?id=72354d6
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Fri May  3 23:05:23 2013 UTC

Also disable Attach button for kernel.

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

diff --git a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp 
b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp
index 12b4b80..aecdb51 100644
--- a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp
+++ b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp
@@ -95,8 +95,11 @@ TeamsWindow::MessageReceived(BMessage* message)
                        TeamRow* row = dynamic_cast<TeamRow*>(
                                fTeamsListView->CurrentSelection());
                        bool enabled = false;
-                       if (row != NULL && row->TeamID() != fCurrentTeam)
-                               enabled = true;
+                       if (row != NULL) {
+                               team_id id = row->TeamID();
+                               if (id != fCurrentTeam && id != B_SYSTEM_TEAM)
+                                       enabled = true;
+                       }
 
                        fAttachTeamButton->SetEnabled(enabled);
                        break;

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

Commit:      1953ec9d1da2b88831fdb8de66e7c84c023ea9bb
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1953ec9
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Sat May  4 00:14:13 2013 UTC

Add UI window for starting a new team.

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

diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile
index caa8f1c..0f5eab1 100644
--- a/src/apps/debugger/Jamfile
+++ b/src/apps/debugger/Jamfile
@@ -227,6 +227,7 @@ Application Debugger :
        MemoryView.cpp
 
        # user_interface/gui/teams_window
+       StartTeamWindow.cpp
        TeamsWindow.cpp
        TeamsListView.cpp
 
diff --git a/src/apps/debugger/MessageCodes.h b/src/apps/debugger/MessageCodes.h
index 7eba27d..f35929f 100644
--- a/src/apps/debugger/MessageCodes.h
+++ b/src/apps/debugger/MessageCodes.h
@@ -49,6 +49,7 @@ enum {
        MSG_TEAM_DEBUGGER_QUIT                                          = 
'dbqt',
        MSG_SHOW_TEAMS_WINDOW                                           = 
'stsw',
        MSG_TEAMS_WINDOW_CLOSED                                         = 
'tswc',
+       MSG_START_NEW_TEAM                                                      
= 'sttt',
        MSG_DEBUG_THIS_TEAM                                                     
= 'dbtt',
        MSG_SHOW_INSPECTOR_WINDOW                                       = 
'sirw',
        MSG_INSPECTOR_WINDOW_CLOSED                                     = 
'irwc',
diff --git 
a/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.cpp 
b/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.cpp
new file mode 100644
index 0000000..26a798a
--- /dev/null
+++ b/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.cpp
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+#include "StartTeamWindow.h"
+
+#include <Alert.h>
+#include <Application.h>
+#include <Button.h>
+#include <FilePanel.h>
+#include <LayoutBuilder.h>
+#include <Path.h>
+#include <String.h>
+#include <StringView.h>
+#include <TextControl.h>
+
+#include "MessageCodes.h"
+#include "UserInterface.h"
+
+
+enum {
+       MSG_BROWSE_TEAM         = 'brte',
+       MSG_SET_TEAM_PATH       = 'setp'
+};
+
+
+StartTeamWindow::StartTeamWindow()
+       :
+       BWindow(BRect(), "Start new team", B_TITLED_WINDOW,
+               B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
+       fGuideText(NULL),
+       fTeamTextControl(NULL),
+       fArgumentsTextControl(NULL),
+       fBrowseTeamButton(NULL),
+       fBrowseTeamPanel(NULL),
+       fStartButton(NULL),
+       fCancelButton(NULL)
+{
+}
+
+
+StartTeamWindow::~StartTeamWindow()
+{
+       delete fBrowseTeamPanel;
+}
+
+
+StartTeamWindow*
+StartTeamWindow::Create()
+{
+       StartTeamWindow* self = new StartTeamWindow;
+
+       try {
+               self->_Init();
+       } catch (...) {
+               delete self;
+               throw;
+       }
+
+       return self;
+
+}
+
+void
+StartTeamWindow::_Init()
+{
+       fGuideText = new BStringView("guide", "Set new team parameters below.");
+       fTeamTextControl = new BTextControl("Path: ", NULL, NULL);
+       fArgumentsTextControl = new BTextControl("Arguments: ", NULL, NULL);
+       fBrowseTeamButton = new BButton("Browse" B_UTF8_ELLIPSIS, new BMessage(
+                       MSG_BROWSE_TEAM));
+       fStartButton = new BButton("Start team", new 
BMessage(MSG_START_NEW_TEAM));
+       fCancelButton = new BButton("Cancel", new BMessage(B_QUIT_REQUESTED));
+
+       BLayoutBuilder::Group<>(this, B_VERTICAL)
+               .SetInsets(4.0f, 4.0f, 4.0f, 4.0f)
+               .Add(fGuideText)
+               .AddGroup(B_HORIZONTAL, 4.0f)
+                       .Add(fTeamTextControl)
+                       .Add(fBrowseTeamButton)
+               .End()
+               .AddGroup(B_HORIZONTAL, 4.0f)
+                       .Add(fArgumentsTextControl)
+               .End()
+               .AddGroup(B_HORIZONTAL, 4.0f)
+                       .AddGlue()
+                       .Add(fCancelButton)
+                       .Add(fStartButton)
+               .End();
+
+       fTeamTextControl->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET));
+
+       fStartButton->SetTarget(this);
+       fCancelButton->SetTarget(this);
+}
+
+void
+StartTeamWindow::Show()
+{
+       CenterOnScreen();
+       BWindow::Show();
+}
+
+void
+StartTeamWindow::MessageReceived(BMessage* message)
+{
+       switch (message->what) {
+               case MSG_BROWSE_TEAM:
+               {
+                       if (fBrowseTeamPanel == NULL) {
+                               fBrowseTeamPanel = new(std::nothrow) 
BFilePanel(B_OPEN_PANEL,
+                                       new BMessenger(this));
+                               if (fBrowseTeamPanel == NULL)
+                                       break;
+                               BMessage* message = new(std::nothrow) BMessage(
+                                       MSG_SET_TEAM_PATH);
+                               if (message == NULL) {
+                                       delete fBrowseTeamPanel;
+                                       fBrowseTeamPanel = NULL;
+                                       break;
+                               }
+                               fBrowseTeamPanel->SetMessage(message);
+                       }
+
+                       fBrowseTeamPanel->Show();
+                       break;
+               }
+               case MSG_SET_TEAM_PATH:
+               {
+                       entry_ref ref;
+                       if (message->FindRef("refs", &ref) == B_OK) {
+                               BPath path(&ref);
+                               
fTeamTextControl->TextView()->SetText(path.Path());
+                       }
+                       break;
+               }
+               case MSG_START_NEW_TEAM:
+               {
+                       BMessage appMessage(MSG_START_NEW_TEAM);
+                       appMessage.AddString("path", 
fTeamTextControl->TextView()->Text());
+                       appMessage.AddString("arguments", 
fArgumentsTextControl->TextView()
+                                       ->Text());
+                       BMessage reply;
+                       be_app_messenger.SendMessage(&appMessage, &reply);
+                       status_t error = reply.FindInt32("status");
+                       if (error != B_OK) {
+                               BString messageString;
+                               messageString.SetToFormat("Failed to start 
team: %s.",
+                                       strerror(error));
+                               BAlert* alert = new(std::nothrow) BAlert("Start 
team failed",
+                                       messageString.String(), "Close");
+                               if (alert != NULL)
+                                       alert->Go();
+                       } else
+                               PostMessage(B_QUIT_REQUESTED);
+                       break;
+               }
+               default:
+                       BWindow::MessageReceived(message);
+                       break;
+       }
+
+}
diff --git 
a/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.h 
b/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.h
new file mode 100644
index 0000000..c81059e
--- /dev/null
+++ b/src/apps/debugger/user_interface/gui/teams_window/StartTeamWindow.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef START_TEAM_WINDOW_H
+#define START_TEAM_WINDOW_H
+
+
+#include <Window.h>
+
+
+class BButton;
+class BFilePanel;
+class BStringView;
+class BTextControl;
+
+
+class StartTeamWindow : public BWindow
+{
+public:
+                                                               
StartTeamWindow();
+
+                                                               
~StartTeamWindow();
+
+       static  StartTeamWindow*        Create();
+                                                                       // 
throws
+
+
+       virtual void                            MessageReceived(BMessage* 
message);
+
+       virtual void                            Show();
+
+private:
+                       void                            _Init();
+
+
+private:
+                       BStringView*            fGuideText;
+                       BTextControl*           fTeamTextControl;
+                       BTextControl*           fArgumentsTextControl;
+                       BButton*                        fBrowseTeamButton;
+                       BFilePanel*                     fBrowseTeamPanel;
+                       BButton*                        fStartButton;
+                       BButton*                        fCancelButton;
+};
+
+#endif // START_TEAM_WINDOW_H

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

Commit:      9b57eae7e69447edb44571418928da54014f7359
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9b57eae
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Sat May  4 00:15:11 2013 UTC

Wire up Start new team button.

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

diff --git a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp 
b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp
index aecdb51..dc04342 100644
--- a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp
+++ b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.cpp
@@ -22,12 +22,12 @@
 
 #include "MessageCodes.h"
 #include "SettingsManager.h"
+#include "StartTeamWindow.h"
 #include "TeamsWindow.h"
 #include "TeamsListView.h"
 
 
 enum {
-       MSG_CREATE_NEW_TEAM = 'crnt',
        MSG_TEAM_SELECTION_CHANGED = 'tesc'
 };
 
@@ -72,9 +72,13 @@ void
 TeamsWindow::MessageReceived(BMessage* message)
 {
        switch (message->what) {
-               case MSG_CREATE_NEW_TEAM:
+               case MSG_START_NEW_TEAM:
                {
-                       // TODO: implement
+                       fStartTeamWindow = StartTeamWindow::Create();
+                       if (fStartTeamWindow == NULL)
+                               break;
+
+                       fStartTeamWindow->Show();
                        break;
                }
 
@@ -141,9 +145,10 @@ TeamsWindow::_Init()
                .Add(fTeamsListView = new TeamsListView("TeamsList", 
fCurrentTeam))
                .SetInsets(1.0f, 1.0f, 1.0f, 1.0f)
                .AddGroup(B_HORIZONTAL, 4.0f)
-                       .Add(fAttachTeamButton = new BButton("Attach"))
-                       .Add(fCreateTeamButton = new BButton("Create new team"
-                                       B_UTF8_ELLIPSIS))
+                       .Add(fAttachTeamButton = new BButton("Attach", new 
BMessage(
+                                               MSG_DEBUG_THIS_TEAM)))
+                       .Add(fCreateTeamButton = new BButton("Start new team"
+                                       B_UTF8_ELLIPSIS, new 
BMessage(MSG_START_NEW_TEAM)))
                        .End()
                .End();
 
@@ -151,10 +156,6 @@ TeamsWindow::_Init()
        fTeamsListView->SetSelectionMessage(new BMessage(
                        MSG_TEAM_SELECTION_CHANGED));
 
-       fAttachTeamButton->SetMessage(new BMessage(MSG_DEBUG_THIS_TEAM));
-       fAttachTeamButton->SetEnabled(false);
-       fCreateTeamButton->SetMessage(new BMessage(MSG_CREATE_NEW_TEAM));
-       // TODO: re-enable once action is implemented
        fAttachTeamButton->SetEnabled(false);
 }
 
diff --git a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h 
b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h
index d6c469c..d4f4ebb 100644
--- a/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h
+++ b/src/apps/debugger/user_interface/gui/teams_window/TeamsWindow.h
@@ -14,6 +14,7 @@ class BListView;
 class BFile;
 class BMessage;
 class SettingsManager;
+class StartTeamWindow;
 class TeamsListView;
 
 class TeamsWindow : public BWindow {
@@ -36,6 +37,7 @@ private:
 private:
                        team_id                         fCurrentTeam;
                        TeamsListView*          fTeamsListView;
+                       StartTeamWindow*        fStartTeamWindow;
                        BButton*                        fAttachTeamButton;
                        BButton*                        fCreateTeamButton;
                        SettingsManager*        fSettingsManager;

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

Revision:    hrev45612
Commit:      aad822734d4078d8075cdc95e940eb23ce0e6a2a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=aad8227
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Sat May  4 00:16:08 2013 UTC

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

Add message for starting a new team. Implements #9682.

- The Debugger app now accepts a message asking it to start a new team.
  It attempts to do so given the path and arguments, and passes the
  result back to the sender if desired.

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

diff --git a/src/apps/debugger/Debugger.cpp b/src/apps/debugger/Debugger.cpp
index 295b054..9b2db43 100644
--- a/src/apps/debugger/Debugger.cpp
+++ b/src/apps/debugger/Debugger.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2011, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2011-2013, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
  */
 
@@ -15,6 +15,8 @@
 #include <Application.h>
 #include <Message.h>
 
+#include <ArgumentVector.h>
+#include <AutoDeleter.h>
 #include <AutoLocker.h>
 #include <ObjectList.h>
 
@@ -279,7 +281,8 @@ get_debugged_program(const Options& options, 
DebuggedProgramInfo& _info)
 static TeamDebugger*
 start_team_debugger(team_id teamID, SettingsManager* settingsManager,
        TeamDebugger::Listener* listener, thread_id threadID = -1,
-       bool stopInMain = false, UserInterface* userInterface = NULL)
+       bool stopInMain = false, UserInterface* userInterface = NULL,
+       status_t* _result = NULL)
 {
        if (teamID < 0)
                return NULL;
@@ -307,11 +310,13 @@ start_team_debugger(team_id teamID, SettingsManager* 
settingsManager,
                printf("Error: debugger for team %" B_PRId32 " failed to init: 
%s!\n",
                        teamID, strerror(error));
                delete debugger;
-               return NULL;
+               debugger = NULL;
        } else
                printf("debugger for team %" B_PRId32 " created and initialized 
"
                        "successfully!\n", teamID);
 
+       if (_result != NULL)
+               *_result = error;
        return debugger;
 }
 
@@ -342,6 +347,9 @@ private:
 
                        TeamDebugger*           _FindTeamDebugger(team_id 
teamID) const;
 
+                       status_t                        _StartNewTeam(const 
char* path, const char* args);
+                       status_t                        
_StartOrFindTeam(Options& options);
+
 private:
                        SettingsManager         fSettingsManager;
                        TeamDebuggerList        fTeamDebuggers;
@@ -433,6 +441,20 @@ Debugger::MessageReceived(BMessage* message)
                        start_team_debugger(teamID, &fSettingsManager, this);
                        break;
                }
+               case MSG_START_NEW_TEAM:
+               {
+                       const char* teamPath = NULL;
+                       const char* args = NULL;
+
+                       message->FindString("path", &teamPath);
+                       message->FindString("arguments", &args);
+
+                       status_t result = _StartNewTeam(teamPath, args);
+                       BMessage reply;
+                       reply.AddInt32("status", result);
+                       message->SendReply(&reply);
+                       break;
+               }
                case MSG_TEAM_DEBUGGER_QUIT:
                {
                        int32 threadID;
@@ -467,20 +489,8 @@ Debugger::ArgvReceived(int32 argc, char** argv)
                return;
        }
 
-       DebuggedProgramInfo programInfo;
-       if (!get_debugged_program(options, programInfo))
-               return;
-
-       TeamDebugger* debugger = _FindTeamDebugger(programInfo.team);
-       if (debugger != NULL) {
-               printf("There's already a debugger for team: %" B_PRId32 "\n",
-                       programInfo.team);
-               debugger->Activate();
-               return;
-       }
+       _StartOrFindTeam(options);
 
-       start_team_debugger(programInfo.team, &fSettingsManager, this,
-               programInfo.thread, programInfo.stopInMain);
 }
 
 
@@ -557,6 +567,57 @@ Debugger::_FindTeamDebugger(team_id teamID) const
 }
 
 
+status_t
+Debugger::_StartNewTeam(const char* path, const char* args)
+{
+       if (path == NULL)
+               return B_BAD_VALUE;
+
+       BString data;
+       data.SetToFormat("%s %s", path, args);
+       if (data.Length() == 0)
+               return B_NO_MEMORY;
+
+       ArgumentVector argVector;
+       argVector.Parse(data.String());
+
+       Options options;
+       options.commandLineArgc = argVector.ArgumentCount();
+       if (options.commandLineArgc <= 0)
+               return B_BAD_VALUE;
+
+       char** argv = argVector.DetachArguments();
+
+       options.commandLineArgv = argv;
+       MemoryDeleter deleter(argv);
+
+       return _StartOrFindTeam(options);
+}
+
+
+status_t
+Debugger::_StartOrFindTeam(Options& options)
+{
+       DebuggedProgramInfo programInfo;
+       if (!get_debugged_program(options, programInfo))
+               return B_BAD_VALUE;
+
+       TeamDebugger* debugger = _FindTeamDebugger(programInfo.team);
+       if (debugger != NULL) {
+               printf("There's already a debugger for team: %" B_PRId32 "\n",
+                       programInfo.team);
+               debugger->Activate();
+               return B_OK;
+       }
+
+       status_t result;
+       start_team_debugger(programInfo.team, &fSettingsManager, this,
+               programInfo.thread, programInfo.stopInMain, NULL, &result);
+
+       return result;
+}
+
+
 // #pragma mark - CliDebugger
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev45612 - in src/apps/debugger/user_interface/gui/teams_window: . src/apps/debugger - anevilyak