aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Weinhold <ingo_weinhold@gmx.de>2012-07-25 00:11:14 +0200
committerIngo Weinhold <ingo_weinhold@gmx.de>2012-07-25 00:11:14 +0200
commitaacf2782d8022d7178125948daac67533ef3e473 (patch)
tree82b4a4e45e30430ed963f6ad3ef13ee65337e32f
parentb866f1fa5493c354c9425b17e6563aac540406ab (diff)
Debugger: Switch from readline to libedithrev44401
-rw-r--r--src/apps/debugger/Jamfile8
-rw-r--r--src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp52
-rw-r--r--src/apps/debugger/user_interface/cli/CommandLineUserInterface.h6
3 files changed, 55 insertions, 11 deletions
diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile
index 62aa4c3386..335827b106 100644
--- a/src/apps/debugger/Jamfile
+++ b/src/apps/debugger/Jamfile
@@ -3,12 +3,10 @@ SubDir HAIKU_TOP src apps debugger ;
CCFLAGS += -Werror ;
C++FLAGS += -Werror ;
+UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
UsePrivateHeaders app debug interface kernel shared libroot ;
UsePrivateSystemHeaders ;
-# Use gdb's readline. It would be better to use an optional build feature.
-UseHeaders [ FDirName $(HAIKU_TOP) src bin gdb ] : true ;
-
SEARCH_SOURCE += [ FDirName $(SUBDIR) arch ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) arch x86 ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) debug_info ] ;
@@ -286,11 +284,11 @@ Application Debugger :
libshared.a
libexpression_parser.a
libmapm.a
- <gdb>libreadline.a
+ libedit.a
libtermcap.a
$(TARGET_LIBSTDC++)
- be tracker libdebug.so
+ be tracker libbsd.so libdebug.so
: Debugger.rdef
;
diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
index e45995f1d9..a381d676a9 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp
@@ -11,9 +11,6 @@
#include <algorithm>
-#include <readline/history.h>
-#include <readline/readline.h>
-
#include <ArgumentVector.h>
#include <AutoDeleter.h>
#include <Referenceable.h>
@@ -23,6 +20,13 @@
#include "CliThreadsCommand.h"
+static const char*
+get_prompt(EditLine* editLine)
+{
+ return "debugger> ";
+}
+
+
// #pragma mark - CommandEntry
@@ -79,6 +83,8 @@ private:
CommandLineUserInterface::CommandLineUserInterface()
:
fCommands(20, true),
+ fEditLine(NULL),
+ fHistory(NULL),
fShowSemaphore(-1),
fShown(false),
fTerminating(false)
@@ -90,6 +96,12 @@ CommandLineUserInterface::~CommandLineUserInterface()
{
if (fShowSemaphore >= 0)
delete_sem(fShowSemaphore);
+
+ if (fEditLine != NULL)
+ el_end(fEditLine);
+
+ if (fHistory != NULL)
+ history_end(fHistory);
}
@@ -113,6 +125,21 @@ CommandLineUserInterface::Init(Team* team, UserInterfaceListener* listener)
if (fShowSemaphore < 0)
return fShowSemaphore;
+ fEditLine = el_init("Debugger", stdin, stdout, stderr);
+ if (fEditLine == NULL)
+ return B_ERROR;
+
+ fHistory = history_init();
+ if (fHistory == NULL)
+ return B_ERROR;
+
+ HistEvent historyEvent;
+ history(fHistory, &historyEvent, H_SETSIZE, 100);
+
+ el_set(fEditLine, EL_HIST, &history, fHistory);
+ el_set(fEditLine, EL_EDITOR, "emacs");
+ el_set(fEditLine, EL_PROMPT, &get_prompt);
+
return B_OK;
}
@@ -141,6 +168,16 @@ CommandLineUserInterface::Terminate()
delete_sem(fShowSemaphore);
fShowSemaphore = -1;
}
+
+ if (fEditLine != NULL) {
+ el_end(fEditLine);
+ fEditLine = NULL;
+ }
+
+ if (fHistory != NULL) {
+ history_end(fHistory);
+ fHistory = NULL;
+ }
}
@@ -205,10 +242,10 @@ CommandLineUserInterface::_InputLoop()
{
while (!fTerminating) {
// read a command line
- char* line = readline("debugger> ");
+ int count;
+ const char* line = el_gets(fEditLine, &count);
if (line == NULL)
break;
- MemoryDeleter lineDeleter(line);
// parse the command line
ArgumentVector args;
@@ -231,8 +268,11 @@ CommandLineUserInterface::_InputLoop()
if (args.ArgumentCount() == 0)
continue;
- add_history(line);
+ // add line to history
+ HistEvent historyEvent;
+ history(fHistory, &historyEvent, H_ENTER, line);
+ // execute command
_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 f6a1c8b2c9..fb5da34da9 100644
--- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
+++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h
@@ -7,6 +7,10 @@
#define COMMAND_LINE_USER_INTERFACE_H
+#include <sys/cdefs.h>
+ // Needed in histedit.h.
+#include <histedit.h>
+
#include <ObjectList.h>
#include <String.h>
@@ -69,6 +73,8 @@ private:
private:
CliContext fContext;
CommandList fCommands;
+ EditLine* fEditLine;
+ History* fHistory;
sem_id fShowSemaphore;
bool fShown;
bool fTerminating;