Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions doc/src/appendix.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,34 @@ Copyright (c) 2013-2022 Niels Lohmann
https://github.com/edwardtufte/tufte-css[Tufte CSS]::
Copyright (c) Dave Liepmann, Edward Tufte, et al. The documentation style is
based on this CSS.

== BSD-2 License

```
BSD-2 License

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

https://github.com/antirez/linenoise[Linenoise, a minimal readline replacement]::
Copyright (c) 2010-2014, Salvatore Sanfilippo
Copyright (c) 2010-2013, Pieter Noordhuis
4 changes: 4 additions & 0 deletions doc/src/history.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
* *New*: Add reading/parsing of property database from JSON data to base CPS
support from.
-- _René Ferdinand Rivera Morell_
* *New*: Added readline capabilities, command history, cmdline editing, etc,
to internal debugger (not on Windows), thanks to *linenoise* by
_Salvatore Sanfilippo_ (repo at https://github.com/antirez/linenoise.)
-- _Paolo Pastori_
* Fix Jam/{CPP} bind definitions of 4 or more values in a single
declared argument not actually adding all the definitions.
-- _Paolo Pastori_
Expand Down
1 change: 1 addition & 0 deletions src/engine/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ mod_string.cpp \
mod_summary.cpp \
mod_sysinfo.cpp \
mod_version.cpp \
ext_linenoise.cpp \
"

if test_true ${B2_DEBUG_OPT} ; then B2_CXXFLAGS="${B2_CXXFLAGS_DEBUG}"
Expand Down
64 changes: 53 additions & 11 deletions src/engine/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "jam.h"
#include "debugger.h"

#ifndef NT
#include "ext_linenoise.h"
#endif

#include "constants.h"
#include "cwd.h"
#include "function.h"
Expand Down Expand Up @@ -908,7 +912,7 @@ static void debug_parent_child_exited( int pid, int exit_code )
}
}

#if !NT
#ifndef NT

static void debug_parent_child_signalled( int pid, int id )
{
Expand Down Expand Up @@ -1740,21 +1744,21 @@ static void debug_mi_interpreter_exec( int argc, const char * * argv );

static struct command_elem parent_commands[] =
{
{ "run", &debug_parent_run },
{ "continue", &debug_parent_continue },
{ "kill", &debug_parent_kill },
{ "step", &debug_parent_step },
{ "next", &debug_parent_next },
{ "finish", &debug_parent_finish },
{ "backtrace", &debug_parent_backtrace },
{ "break", &debug_parent_break },
{ "clear", &debug_parent_clear },
{ "continue", &debug_parent_continue },
{ "delete", &debug_parent_delete },
{ "disable", &debug_parent_disable },
{ "enable", &debug_parent_enable },
{ "delete", &debug_parent_delete },
{ "clear", &debug_parent_clear },
{ "finish", &debug_parent_finish },
{ "help", &debug_parent_help },
{ "kill", &debug_parent_kill },
{ "next", &debug_parent_next },
{ "print", &debug_parent_print },
{ "backtrace", &debug_parent_backtrace },
{ "quit", &debug_parent_quit },
{ "help", &debug_parent_help },
{ "run", &debug_parent_run },
{ "step", &debug_parent_step },
{ "-break-insert", &debug_mi_break_insert },
{ "-break-delete", &debug_mi_break_delete },
{ "-break-disable", &debug_mi_break_disable },
Expand Down Expand Up @@ -2602,6 +2606,19 @@ static void debug_mi_interpreter_exec( int argc, const char * * argv )
process_command( (char *)argv[ 2 ] );
}

#ifndef NT
/* for Linenoise command completion using TAB */
void completion( const char *cmdbuf, linenoiseCompletions *lc ) {
size_t buflen = strlen( cmdbuf );
for ( struct command_elem & pci : parent_commands )
{
if ( pci.key[0] == '-' ) break; /* end of user commands reached */
if ( !buflen || !strncmp(cmdbuf, pci.key, buflen) )
linenoiseAddCompletion( lc, pci.key );
}
}
#endif

/* The debugger's main loop. */
int debugger( void )
{
Expand All @@ -2611,10 +2628,35 @@ int debugger( void )
printf( "=thread-group-added,id=\"i1\"\n(gdb) \n" );
while ( 1 )
{
#ifdef NT
if ( globs.debug_interface == DEBUG_INTERFACE_CONSOLE )
printf("(b2db) ");
fflush( stdout );
read_command();
#else
if ( globs.debug_interface == DEBUG_INTERFACE_CONSOLE )
{
/* Add support for command history, command line
* editing, command completion, and more, see
* https://github.com/antirez/linenoise
*/
linenoiseSetCompletionCallback( completion );

char *cmdline = linenoise( "(b2db) " );
if ( cmdline == NULL ) break; /* CTRL-C, CTRL-D, out of memory.. */

linenoiseHistoryAdd( cmdline );

process_command( cmdline );

linenoiseFree( cmdline );
}
else
{
fflush( stdout );
read_command();
}
#endif
}
return 0;
}
Expand Down
Loading
Loading