Commit c66c9375 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add Makefile support for debugging CPython

And some install instructions on how to get a pre-built debug build,
and to put the sources where the Pyston make system expects them.
parent 513b7986
...@@ -869,6 +869,10 @@ runpy_%: %.py ext_python ...@@ -869,6 +869,10 @@ runpy_%: %.py ext_python
PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7 python $< PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7 python $<
$(call make_search,runpy_%) $(call make_search,runpy_%)
dbgpy_%: %.py ext_pythondbg
export PYTHON_VERSION=$$(python2.7-dbg -V 2>&1 | awk '{print $$2}'); PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7-pydebug $(GDB) --ex "dir $(DEPS_DIR)/python-src/python2.7-$$PYTHON_VERSION/debian" $(GDB_CMDS) --args python2.7-dbg $<
$(call make_search,dbgpy_%)
# "kill valgrind": # "kill valgrind":
kv: kv:
ps aux | awk '/[v]algrind/ {print $$2}' | xargs kill -9; true ps aux | awk '/[v]algrind/ {print $$2}' | xargs kill -9; true
...@@ -991,9 +995,11 @@ ext_pyston_selfhost_release: pyston_release $(TEST_EXT_MODULE_NAMES:%=$(TEST_DIR ...@@ -991,9 +995,11 @@ ext_pyston_selfhost_release: pyston_release $(TEST_EXT_MODULE_NAMES:%=$(TEST_DIR
cd $(TEST_DIR)/test_extension; DISTUTILS_DEBUG=1 time ../../pyston_release setup.py build cd $(TEST_DIR)/test_extension; DISTUTILS_DEBUG=1 time ../../pyston_release setup.py build
cd $(TEST_DIR)/test_extension; ln -sf $(TEST_EXT_MODULE_NAMES:%=build/lib.unknown-2.7/%.pyston.so) . cd $(TEST_DIR)/test_extension; ln -sf $(TEST_EXT_MODULE_NAMES:%=build/lib.unknown-2.7/%.pyston.so) .
.PHONY: ext_python .PHONY: ext_python ext_pythondbg
ext_python: $(TEST_EXT_MODULE_NAMES:%=$(TEST_DIR)/test_extension/*.c) ext_python: $(TEST_EXT_MODULE_NAMES:%=$(TEST_DIR)/test_extension/*.c)
cd $(TEST_DIR)/test_extension; python setup.py build cd $(TEST_DIR)/test_extension; python setup.py build
ext_pythondbg: $(TEST_EXT_MODULE_NAMES:%=$(TEST_DIR)/test_extension/*.c)
cd $(TEST_DIR)/test_extension; python2.7-dbg setup.py build
$(FROM_CPYTHON_SRCS:.c=.o): %.o: %.c $(BUILD_SYSTEM_DEPS) $(FROM_CPYTHON_SRCS:.c=.o): %.o: %.c $(BUILD_SYSTEM_DEPS)
$(ECHO) Compiling C file to $@ $(ECHO) Compiling C file to $@
......
...@@ -248,36 +248,19 @@ download from http://code.google.com/p/gperftools/downloads/list ...@@ -248,36 +248,19 @@ download from http://code.google.com/p/gperftools/downloads/list
standard ./configure, make, make install standard ./configure, make, make install
``` ```
### ninja-based LLVM build ### Debug build of CPython
Ninja is supposed to be faster than make; I've only tried it very briefly, and it does seem to be faster when modifying LLVM files. May or may not be worth using; thought I'd jot down my notes though: Having a debug-enabled CPython can be useful for debugging issues with our extension modules. To get it set up:
You may or may not need a more-recent version of ninja than your package manager provides:
``` ```
sudo apt-get install python2.7-dbg
cd ~/pyston_deps cd ~/pyston_deps
git clone https://github.com/martine/ninja.git mkdir python-src
cd ninja cd python-src
git checkout v1.4.0 apt-get source python2.7-dbg
./bootstrap.py
```
```
cd ~/pyston_deps
wget http://www.cmake.org/files/v3.0/cmake-3.0.0.tar.gz
tar zxvf cmake-3.0.0.tar.gz
cd cmake-3.0.0
./configure
make -j4
```
```
cd ~/pyston_deps
mkdir llvm-trunk-cmake
cd llvm-trunk-cmake
CXX=g++ CC=gcc PATH=~/pyston_deps/gcc-4.8.2-install/bin:$PATH:~/pyston_deps/ninja CMAKE_MAKE_PROGRAM=~/pyston_deps/ninja/ninja ~/pyston_deps/cmake-3.0.0/bin/cmake ../llvm-trunk -G Ninja -DLLVM_TARGETS_TO_BUILD=host -DCMAKE_BUILD_TYPE=RELEASE -DLLVM_ENABLE_ASSERTIONS=ON
~/pyston_deps/ninja/ninja # runs in parallel
``` ```
Then, run `make dbgpy_TESTNAME` and it will launch the test under gdb. There's also a [wiki page](https://wiki.python.org/moin/DebuggingWithGdb) with some extra Python-specific GDB commands.
# (Experimental) CMake build system # (Experimental) CMake build system
......
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