diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 80c98fe660..8e489e862b 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -6,6 +6,9 @@ C++FLAGS += -Werror ; 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 ] ; @@ -273,9 +276,14 @@ Application Debugger : debug_utils.a libcolumnlistview.a libshared.a + libshared.a + libexpression_parser.a + libmapm.a + libreadline.a + libtermcap.a $(TARGET_LIBSTDC++) - be tracker libdebug.so libshared.a libexpression_parser.a libmapm.a + be tracker 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 09db85f913..614a227544 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -11,7 +11,11 @@ #include +#include +#include + #include +#include #include #include "CliCommand.h" @@ -226,16 +230,15 @@ CommandLineUserInterface::_InputLoop() { while (!fTerminating) { // read a command line - printf("debugger> "); - fflush(stdout); - char buffer[256]; - if (fgets(buffer, sizeof(buffer), stdin) == NULL) + char* line = readline("debugger> "); + if (line == NULL) break; + MemoryDeleter lineDeleter(line); // parse the command line ArgumentVector args; const char* parseErrorLocation; - switch (args.Parse(buffer, &parseErrorLocation)) { + switch (args.Parse(line, &parseErrorLocation)) { case ArgumentVector::NO_ERROR: break; case ArgumentVector::NO_MEMORY: @@ -243,7 +246,7 @@ CommandLineUserInterface::_InputLoop() continue; case ArgumentVector::UNTERMINATED_QUOTED_STRING: printf("Parse error: Unterminated quoted string starting at " - "character %zu.\n", parseErrorLocation - buffer + 1); + "character %zu.\n", parseErrorLocation - line + 1); continue; case ArgumentVector::TRAILING_BACKSPACE: printf("Parse error: trailing backspace.\n"); @@ -253,6 +256,8 @@ CommandLineUserInterface::_InputLoop() if (args.ArgumentCount() == 0) continue; + add_history(line); + _ExecuteCommand(args.ArgumentCount(), args.Arguments()); }