[haiku-commits] haiku: hrev44878 - in src/apps/debugger/user_interface: cli util gui/team_window

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 23 Nov 2012 05:42:45 +0100 (CET)

hrev44878 adds 2 changesets to branch 'master'
old head: 53a59cd99a876a158c480989e9787757ef7a28ed
new head: bb7d146c64d025442c6798caf2d13114dfd18deb
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=bb7d146+%5E53a59cd

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

53342f9: Factor out report name generation as a utility function.

bb7d146: Add CLI command for saving debug reports.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

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

7 files changed, 95 insertions(+), 15 deletions(-)
src/apps/debugger/Jamfile                        |  1 +
.../user_interface/cli/CliDebugReportCommand.cpp | 39 ++++++++++++++++++++
.../user_interface/cli/CliDebugReportCommand.h   | 20 ++++++++++
.../cli/CommandLineUserInterface.cpp             |  7 +++-
.../gui/team_window/TeamWindow.cpp               | 17 ++-------
.../debugger/user_interface/util/UiUtils.cpp     | 22 +++++++++++
src/apps/debugger/user_interface/util/UiUtils.h  |  4 ++

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

Commit:      53342f94c969443d6877b2b0bbfe35f4d7fb2d23
URL:         http://cgit.haiku-os.org/haiku/commit/?id=53342f9
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Fri Nov 23 04:41:11 2012 UTC

Factor out report name generation as a utility function.

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

diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp 
b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
index 1c50a88..869d9ff 100644
--- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
@@ -10,7 +10,6 @@
 #include <stdio.h>
 
 #include <Button.h>
-#include <DateTime.h>
 #include <FilePanel.h>
 #include <FindDirectory.h>
 #include <LayoutBuilder.h>
@@ -44,6 +43,7 @@
 #include "StackTraceView.h"
 #include "Tracing.h"
 #include "TypeComponentPath.h"
+#include "UiUtils.h"
 #include "UserInterface.h"
 #include "Variable.h"
 #include "WatchPromptWindow.h"
@@ -221,21 +221,12 @@ TeamWindow::MessageReceived(BMessage* message)
                case MSG_CHOOSE_DEBUG_REPORT_LOCATION:
                {
                        try {
-                               BPath teamPath(fTeam->Name());
-                               BDateTime currentTime;
-                               currentTime.SetTime_t(time(NULL));
-                               BString filename;
-                               filename.SetToFormat("%s-%" B_PRId32 
"-debug-%02"
-                                       B_PRId32 "-%02" B_PRId32 "-%02" 
B_PRId32 "-%02"
-                                       B_PRId32 "-%02" B_PRId32 "-%02" 
B_PRId32 ".report",
-                                       teamPath.Leaf(), fTeam->ID(), 
currentTime.Date().Day(),
-                                       currentTime.Date().Month(), 
currentTime.Date().Year(),
-                                       currentTime.Time().Hour(), 
currentTime.Time().Minute(),
-                                       currentTime.Time().Second());
+                               char filename[B_FILE_NAME_LENGTH];
+                               UiUtils::ReportNameForTeam(fTeam, filename, 
sizeof(filename));
                                BMessenger msgr(this);
                                fFilePanel = new BFilePanel(B_SAVE_PANEL, &msgr,
                                        NULL, 0, false, new 
BMessage(MSG_GENERATE_DEBUG_REPORT));
-                               fFilePanel->SetSaveText(filename.String());
+                               fFilePanel->SetSaveText(filename);
                                fFilePanel->Show();
                        } catch (...) {
                                delete fFilePanel;
diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp 
b/src/apps/debugger/user_interface/util/UiUtils.cpp
index 539e069..72aa281 100644
--- a/src/apps/debugger/user_interface/util/UiUtils.cpp
+++ b/src/apps/debugger/user_interface/util/UiUtils.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright 2012, Ingo Weinhold, ingo_weinhold@xxxxxxx
+ * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxxx
  * Distributed under the terms of the MIT License.
  */
 
@@ -8,11 +9,14 @@
 
 #include <stdio.h>
 
+#include <DateTime.h>
+#include <Path.h>
 #include <Variant.h>
 
 #include "FunctionInstance.h"
 #include "Image.h"
 #include "StackFrame.h"
+#include "Team.h"
 #include "Thread.h"
 
 
@@ -134,3 +138,21 @@ UiUtils::ImageTypeToString(image_type type, char* buffer, 
size_t bufferSize)
 
        return buffer;
 }
+
+
+/*static*/ const char*
+UiUtils::ReportNameForTeam(::Team* team, char* buffer, size_t bufferSize)
+{
+       BPath teamPath(team->Name());
+       BDateTime currentTime;
+       currentTime.SetTime_t(time(NULL));
+       snprintf(buffer, bufferSize, "%s-%" B_PRId32 "-debug-%02" B_PRId32 
"-%02"
+               B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 "-%02" B_PRId32 "-%02"
+               B_PRId32 ".report", teamPath.Leaf(), team->ID(),
+               currentTime.Date().Day(), currentTime.Date().Month(),
+               currentTime.Date().Year(), currentTime.Time().Hour(),
+               currentTime.Time().Minute(), currentTime.Time().Second());
+
+       return buffer;
+
+}
diff --git a/src/apps/debugger/user_interface/util/UiUtils.h 
b/src/apps/debugger/user_interface/util/UiUtils.h
index 4415754..81ed46d 100644
--- a/src/apps/debugger/user_interface/util/UiUtils.h
+++ b/src/apps/debugger/user_interface/util/UiUtils.h
@@ -12,6 +12,7 @@
 
 class BVariant;
 class StackFrame;
+class Team;
 
 
 class UiUtils {
@@ -25,6 +26,9 @@ public:
                                                                        char* 
buffer, size_t bufferSize);
        static  const char*                     ImageTypeToString(image_type 
type,
                                                                        char* 
buffer, size_t bufferSize);
+
+       static  const char*                     ReportNameForTeam(::Team* team,
+                                                                       char* 
buffer, size_t bufferSize);
 };
 
 

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

Revision:    hrev44878
Commit:      bb7d146c64d025442c6798caf2d13114dfd18deb
URL:         http://cgit.haiku-os.org/haiku/commit/?id=bb7d146
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Fri Nov 23 04:41:34 2012 UTC

Add CLI command for saving debug reports.

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

diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile
index a1a1ddb..4eb1281 100644
--- a/src/apps/debugger/Jamfile
+++ b/src/apps/debugger/Jamfile
@@ -192,6 +192,7 @@ Application Debugger :
        CliCommand.cpp
        CliContext.cpp
        CliContinueCommand.cpp
+       CliDebugReportCommand.cpp
        CliStackTraceCommand.cpp
        CliStopCommand.cpp
        CliThreadCommand.cpp
diff --git a/src/apps/debugger/user_interface/cli/CliDebugReportCommand.cpp 
b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.cpp
new file mode 100644
index 0000000..213b5f7
--- /dev/null
+++ b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+
+
+#include "CliDebugReportCommand.h"
+
+#include <Entry.h>
+#include <FindDirectory.h>
+#include <Path.h>
+#include <String.h>
+
+#include "CliContext.h"
+#include "UiUtils.h"
+#include "UserInterface.h"
+
+
+CliDebugReportCommand::CliDebugReportCommand()
+       :
+       CliCommand("save debug report",
+               "%s\n"
+               "Saves a debug information report for the current team.")
+{
+}
+
+
+void
+CliDebugReportCommand::Execute(int argc, const char* const* argv, CliContext& 
context)
+{
+       char buffer[B_FILE_NAME_LENGTH];
+       UiUtils::ReportNameForTeam(context.GetTeam(), buffer, sizeof(buffer));
+       BPath path;
+       find_directory(B_DESKTOP_DIRECTORY, &path);
+       path.Append(buffer);
+       entry_ref ref;
+       if (get_ref_for_path(path.Path(), &ref) == B_OK)
+               context.GetUserInterfaceListener()->DebugReportRequested(&ref);
+}
diff --git a/src/apps/debugger/user_interface/cli/CliDebugReportCommand.h 
b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.h
new file mode 100644
index 0000000..ffe423c
--- /dev/null
+++ b/src/apps/debugger/user_interface/cli/CliDebugReportCommand.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef CLI_DEBUG_REPORT_COMMAND_H
+#define CLI_DEBUG_REPORT_COMMAND_H
+
+
+#include "CliCommand.h"
+
+
+class CliDebugReportCommand : public CliCommand {
+public:
+                                                               
CliDebugReportCommand();
+       virtual void                            Execute(int argc, const char* 
const* argv,
+                                                                       
CliContext& context);
+};
+
+
+#endif // CLI_DEBUG_REPORT_COMMAND_H
diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp 
b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
index 1871c45..bbd0f86 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011, Rene Gollent, rene@xxxxxxxxxxxx
+ * Copyright 2011-2012, Rene Gollent, rene@xxxxxxxxxxxx
  * Copyright 2012, Ingo Weinhold, ingo_weinhold@xxxxxxx
  * Distributed under the terms of the MIT License.
  */
@@ -17,6 +17,7 @@
 
 #include "CliContext.h"
 #include "CliContinueCommand.h"
+#include "CliDebugReportCommand.h"
 #include "CliQuitCommand.h"
 #include "CliStackTraceCommand.h"
 #include "CliStopCommand.h"
@@ -284,7 +285,9 @@ CommandLineUserInterface::_RegisterCommands()
                _RegisterCommand("sc", stackTraceCommandReference2.Detach()) &&
                _RegisterCommand("stop", new(std::nothrow) CliStopCommand) &&
                _RegisterCommand("thread", new(std::nothrow) CliThreadCommand) 
&&
-               _RegisterCommand("threads", new(std::nothrow) 
CliThreadsCommand)) {
+               _RegisterCommand("threads", new(std::nothrow) 
CliThreadsCommand) &&
+               _RegisterCommand("save-report",
+                       new(std::nothrow) CliDebugReportCommand)) {
                return B_OK;
        }
 


Other related posts: