[haiku-commits] haiku: hrev45034 - in src/apps/debugger/user_interface: cli util

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 20 Dec 2012 04:29:12 +0100 (CET)

hrev45034 adds 3 changesets to branch 'master'
old head: c8d82cf6db9148209256e0ed89bdef72aa355d97
new head: 7024fac2201165285f896cb3e2abaebabe4c8f1d
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=7024fac+%5Ec8d82cf

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

64f5c19: Add copyright attributions from originating code.

cef640f: Fix missing line break.

7024fac: Clean up _RegisterCommands().
  
  - _RegisterCommand() now accepts a space separated list of names
    to register a command by and creates a registration for each.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

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

4 files changed, 42 insertions(+), 31 deletions(-)
.../user_interface/cli/CliDumpMemoryCommand.cpp  |  5 ++
.../cli/CommandLineUserInterface.cpp             | 62 ++++++++++----------
.../cli/CommandLineUserInterface.h               |  3 +
.../debugger/user_interface/util/UiUtils.cpp     |  3 +-

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

Commit:      64f5c19ebfcaae2aeae05272ddf97f3a16ad6bc4
URL:         http://cgit.haiku-os.org/haiku/commit/?id=64f5c19
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Thu Dec 20 03:01:33 2012 UTC

Add copyright attributions from originating code.

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

diff --git a/src/apps/debugger/user_interface/cli/CliDumpMemoryCommand.cpp 
b/src/apps/debugger/user_interface/cli/CliDumpMemoryCommand.cpp
index 4d8c7d8..50899f1 100644
--- a/src/apps/debugger/user_interface/cli/CliDumpMemoryCommand.cpp
+++ b/src/apps/debugger/user_interface/cli/CliDumpMemoryCommand.cpp
@@ -1,6 +1,11 @@
 /*
+ * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@xxxxxx.
+ * Copyright 2002-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
  * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
+ *
+ * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
+ * Distributed under the terms of the NewOS License.
  */
 
 

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

Commit:      cef640f784086ddac272fc50d57437fd4ca4edde
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cef640f
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Thu Dec 20 03:01:51 2012 UTC

Fix missing line break.

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

diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp 
b/src/apps/debugger/user_interface/util/UiUtils.cpp
index 2b3e2d1..a27956f 100644
--- a/src/apps/debugger/user_interface/util/UiUtils.cpp
+++ b/src/apps/debugger/user_interface/util/UiUtils.cpp
@@ -230,7 +230,8 @@ UiUtils::PrintValueNodeGraph(BString& _output, 
ValueNodeChild* child,
 }
 
 
-/*static*/ void UiUtils::DumpMemory(BString& _output, int32 indentLevel,
+/*static*/ void
+UiUtils::DumpMemory(BString& _output, int32 indentLevel,
        TeamMemoryBlock* block, target_addr_t address, int32 itemSize,
        int32 displayWidth, int32 count)
 {

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

Revision:    hrev45034
Commit:      7024fac2201165285f896cb3e2abaebabe4c8f1d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7024fac
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Thu Dec 20 03:27:45 2012 UTC

Clean up _RegisterCommands().

- _RegisterCommand() now accepts a space separated list of names
  to register a command by and creates a registration for each.

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

diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp 
b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
index 85a204b..f29b87e 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
@@ -306,43 +306,22 @@ CommandLineUserInterface::_InputLoop()
 status_t
 CommandLineUserInterface::_RegisterCommands()
 {
-       BReference<CliCommand> stackTraceCommandReference(
-               new(std::nothrow) CliStackTraceCommand, true);
-       BReference<CliCommand> stackTraceCommandReference2(
-               stackTraceCommandReference.Get());
-
-       BReference<CliCommand> dumpCommandReference(
-               new(std::nothrow) CliDumpMemoryCommand, true);
-       BReference<CliCommand> dumpCommandReference2(
-               dumpCommandReference.Get());
-       if (!_RegisterCommand("db", dumpCommandReference.Detach()))
-               return B_NO_MEMORY;
-       dumpCommandReference = dumpCommandReference2.Get();
-       if (!_RegisterCommand("ds", dumpCommandReference.Detach()))
-               return B_NO_MEMORY;
-       dumpCommandReference = dumpCommandReference2.Get();
-       if (!_RegisterCommand("dw", dumpCommandReference.Detach()))
-               return B_NO_MEMORY;
-       dumpCommandReference = dumpCommandReference2.Get();
-       if (!_RegisterCommand("dl", dumpCommandReference.Detach()))
-               return B_NO_MEMORY;
-       if (!_RegisterCommand("string", dumpCommandReference2.Detach()))
-               return B_NO_MEMORY;
-
-       if (_RegisterCommand("bt", stackTraceCommandReference.Detach())
+       if (_RegisterCommand("bt sc", new(std::nothrow) CliStackTraceCommand)
                && _RegisterCommand("continue", new(std::nothrow) 
CliContinueCommand)
+               && _RegisterCommand("db ds dw dl string", new(std::nothrow)
+                       CliDumpMemoryCommand)
                && _RegisterCommand("frame", new(std::nothrow) 
CliStackFrameCommand)
                && _RegisterCommand("help", new(std::nothrow) HelpCommand(this))
                && _RegisterCommand("print", new(std::nothrow) 
CliPrintVariableCommand)
                && _RegisterCommand("quit", new(std::nothrow) CliQuitCommand)
                && _RegisterCommand("save-report",
                        new(std::nothrow) CliDebugReportCommand)
-               && _RegisterCommand("sc", stackTraceCommandReference2.Detach())
                && _RegisterCommand("stop", new(std::nothrow) CliStopCommand)
                && _RegisterCommand("thread", new(std::nothrow) 
CliThreadCommand)
                && _RegisterCommand("threads", new(std::nothrow) 
CliThreadsCommand)
                && _RegisterCommand("variables",
                        new(std::nothrow) CliVariablesCommand)) {
+               fCommands.SortItems(&_CompareCommandEntries);
                return B_OK;
        }
 
@@ -358,11 +337,23 @@ CommandLineUserInterface::_RegisterCommand(const BString& 
name,
        if (name.IsEmpty() || command == NULL)
                return false;
 
-       CommandEntry* entry = new(std::nothrow) CommandEntry(name, command);
-       if (entry == NULL || !fCommands.AddItem(entry)) {
-               delete entry;
-               return false;
-       }
+       BString nextName;
+       int32 startIndex = 0;
+       int32 spaceIndex;
+       do {
+               spaceIndex = name.FindFirst(' ', startIndex);
+               if (spaceIndex == B_ERROR)
+                       spaceIndex = name.Length();
+               name.CopyInto(nextName, startIndex, spaceIndex - startIndex);
+
+               CommandEntry* entry = new(std::nothrow) CommandEntry(nextName,
+                       command);
+               if (entry == NULL || !fCommands.AddItem(entry)) {
+                       delete entry;
+                       return false;
+               }
+               startIndex = spaceIndex + 1;
+       } while (startIndex < name.Length());
 
        return true;
 }
@@ -441,3 +432,14 @@ CommandLineUserInterface::_PrintHelp(const char* 
commandName)
                        entry->Command()->Summary());
        }
 }
+
+
+/*static */
+int
+CommandLineUserInterface::_CompareCommandEntries(const CommandEntry* command1,
+       const CommandEntry* command2)
+{
+       return ::Compare(command1->Name(), command2->Name());
+}
+
+
diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h 
b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
index 15630bd..2ca3488 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
@@ -72,6 +72,9 @@ private:
                                                                        const 
char* const* argv);
                        CommandEntry*           _FindCommand(const char* 
commandName);
                        void                            _PrintHelp(const char* 
commandName);
+       static  int                                     _CompareCommandEntries(
+                                                                       const 
CommandEntry* command1,
+                                                                       const 
CommandEntry* command2);
 
 private:
                        CliContext                      fContext;


Other related posts: