Commit d7bc5a98 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add readline support to the repl, instead of wrapping with rlwrap which made things hard to debug

parent 009516c7
......@@ -89,6 +89,13 @@ and then repeat the correct process
apt-get install zsh
```
### readline
`readline` is used for the repl.
```
sudo apt-get install readline
```
# Optional dependencies
There are a number of optional dependencies that the build system knows about, but aren't strictly necessary for building and running Pyston. Most of them are related to developing and debugging:
......
......@@ -141,7 +141,7 @@ COMMON_CXXFLAGS += -DGITREV=$(shell git rev-parse HEAD | head -c 12) -DLLVMREV=$
COMMON_CXXFLAGS += -DDEFAULT_PYTHON_MAJOR_VERSION=$(PYTHON_MAJOR_VERSION) -DDEFAULT_PYTHON_MINOR_VERSION=$(PYTHON_MINOR_VERSION) -DDEFAULT_PYTHON_MICRO_VERSION=$(PYTHON_MICRO_VERSION)
# Use our "custom linker" that calls gold if available
COMMON_LDFLAGS := -B../tools/build_system -L/usr/local/lib -lpthread -ldl -lcurses -lm -lunwind -lz -llzma -L$(DEPS_DIR)/gcc-4.8.2-install/lib64
COMMON_LDFLAGS := -B../tools/build_system -L/usr/local/lib -lpthread -ldl -lcurses -lm -lunwind -lz -llzma -L$(DEPS_DIR)/gcc-4.8.2-install/lib64 -lreadline
# Make sure that we put all symbols in the dynamic symbol table so that MCJIT can load them;
# TODO should probably do the linking before MCJIT
COMMON_LDFLAGS += -Wl,-E
......@@ -718,17 +718,9 @@ check$1 test$1: pyston$1 ext
.PHONY: run$1 dbg$1
run$1: pyston$1 $$(RUN_DEPS)
if which rlwrap >/dev/null; then\
rlwrap ./pyston$1 $$(ARGS) ;\
else \
./pyston$1 $$(ARGS) ;\
fi
./pyston$1 $$(ARGS)
dbg$1: pyston$1 $$(RUN_DEPS)
if which rlwrap >/dev/null; then\
rlwrap zsh -c 'ulimit -v $$(MAX_DBG_MEM_KB); $$(GDB) $$(GDB_CMDS) --args ./pyston$1 $$(ARGS)' ; \
else \
zsh -c 'ulimit -v $$(MAX_DBG_MEM_KB); $$(GDB) $$(GDB_CMDS) --args ./pyston$1 $$(ARGS)' ; \
fi
zsh -c 'ulimit -v $$(MAX_DBG_MEM_KB); $$(GDB) $$(GDB_CMDS) --args ./pyston$1 $$(ARGS)'
run$1_%: %.py pyston$1 $$(RUN_DEPS)
$(VERB) zsh -c 'ulimit -v $$(MAX_MEM_KB); ulimit -d $$(MAX_MEM_KB); time ./pyston$1 $$(ARGS) $$<'
$$(call make_search,run$1_%)
......
......@@ -19,6 +19,8 @@
#include <stdint.h>
#include <sys/time.h>
#include <unistd.h>
#include <readline/history.h>
#include <readline/readline.h>
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
......@@ -194,15 +196,14 @@ int main(int argc, char** argv) {
BoxedModule* main = createModule("__main__", "<stdin>");
while (repl) {
printf(">> ");
fflush(stdout);
char* line = readline(">> ");
char* line = NULL;
size_t size;
int read;
if ((read = getline(&line, &size, stdin)) == -1) {
if (!line) {
repl = false;
} else {
add_history(line);
int size = strlen(line);
Timer _t("repl");
char buf[] = "pystontmp_XXXXXX";
......@@ -210,11 +211,11 @@ int main(int argc, char** argv) {
assert(tmpdir);
std::string tmp = std::string(tmpdir) + "/in.py";
if (VERBOSITY() >= 1) {
printf("writing %d bytes to %s\n", read, tmp.c_str());
printf("writing %d bytes to %s\n", size, tmp.c_str());
}
FILE* f = fopen(tmp.c_str(), "w");
fwrite(line, 1, read, f);
fwrite(line, 1, size, f);
fclose(f);
AST_Module* m = parse(tmp.c_str());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment