Skip to content

Commit 1fc633d

Browse files
author
Magne Hov
committedSep 24, 2024
add script to install a suitable version of Python
1 parent 7fe9133 commit 1fc633d

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed
 

‎README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@ and start UDB while sourcing the `libpython.gdb` file from the same directory
2121
$ udb --ex "source ./libpython.gdb"
2222
```
2323

24-
The version of the `libpython.py` library must generally match the version of Python you want to
25-
debug. These extensions are built around the 3.10 version of the `libpython.py` library.
24+
The supported version of Python is currently cpython 3.10. The interpreter must have been compiled with full debug information (`-g3`) and without cpython's "computed gotos" feature.
25+
26+
You can use the `./setup-python` script to install a suitable version of Python with `pyenv`:
27+
28+
```
29+
$ source ./setup-python
30+
$ python --version
31+
Python 3.10.15
32+
```
2633

2734
### Usage
2835

2936
Use the following commands to inspect Python state:
3037

3138
- `py-print` (`pp`) to print Python objects
39+
- `py-eval` (`pe`) to evaluate Python expressions
3240
- `py-list` to list Python source code
3341
- `py-bt` to show Python backtrace
3442
- `py-locals` to show local Python variables
@@ -50,7 +58,7 @@ The `py-last-attr` command takes an optional argument to specify which attribute
5058

5159
---
5260

53-
Switch to the Python layout in TUI mode to get a better overview of your program. This layout automatically shows the output from `py-list`, `py-dis`, `py-locals` and `py-bt`:
61+
Switch to the Python layout in TUI mode to get a better overview of your program.
5462

5563
```
5664
> layout python

‎setup-python

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Ensure that pyenv is installed
4+
5+
PYENV_ROOT="$HOME/.local/share/undo/pyenv"
6+
if [ ! -d "$PYENV_ROOT" ]; then
7+
echo "Installing pyenv"
8+
git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT"
9+
fi
10+
11+
# Ensure an appropriate Python version is installed
12+
13+
PY_VERSION="3.10.15"
14+
# For optimal debug information we set `-g3 -Og`.
15+
CONFIGURE_OPTS="--with-computed-gotos=no" \
16+
PYTHON_CFLAGS="-g3 -Og" \
17+
$PYENV_ROOT/bin/pyenv install \
18+
--keep \
19+
--verbose \
20+
--skip-existing \
21+
$PY_VERSION
22+
23+
24+
# Make the python version available in the current shell
25+
export PATH="$PYENV_ROOT/versions/$PY_VERSION/bin:$PATH"

0 commit comments

Comments
 (0)
Please sign in to comment.