Hen*_*her 7 python gdb cython nixos nix
我正在尝试在NixOS上进行cython调试.我可以在nix-shell中轻松安装cython(为简单起见而选择),如下所示:
$ nix-shell -p 'python27.withPackages( p: [ p.cython ])'
$ cat /nix/store/s0w3phb2saixi0a9bzk8pjbczjaz8d7r-python-2.7.14-env/bin/python
#! /nix/store/jgw8hxx7wzkyhb2dr9hwsd9h2caaasdc-bash-4.4-p12/bin/bash -e
export PYTHONHOME="/nix/store/s0w3phb2saixi0a9bzk8pjbczjaz8d7r-python-2.7.14-env"
export PYTHONNOUSERSITE="true"
exec "/nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python" "${extraFlagsArray[@]}" "$@"
Run Code Online (Sandbox Code Playgroud)
然后我们做一个普通的nix-shell只是python,看看我们得到了什么版本的python.
[henry@bollum:~/Projects/eyeserver/nixshell]$ nix-shell -p 'python27'
$ which python
/nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python
# ^^^^^^^
# non-debug
Run Code Online (Sandbox Code Playgroud)
一切都很好 - 我们在两种情况下都获得了非调试python.如果我们gdb它,我们得到(没有找到调试符号).见最后一行.
$ gdb
/nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python...(no debugging symbols found)...done.
Run Code Online (Sandbox Code Playgroud)
当我们在python上使用enableDebugging时,我们会得到不同的结果.$ nix-shell -p'enableDebugging python27'
$ which python
/nix/store/a4wd8mcpqr54hmw0x95fw8fhvk8avh5a-python-2.7.14/bin/python
# ^^^^^^
# debug
$ gdb
/nix/store/a4wd8mcpqr54hmw0x95fw8fhvk8avh5a-python-2.7.14/bin/python
GNU gdb (GDB) 8.0.1
...
Reading symbols from /nix/store/a4wd8mcpqr54hmw0x95fw8fhvk8avh5a-python-2.7.14/bin/python...done.
Run Code Online (Sandbox Code Playgroud)
当我们尝试使用包含的cython(或任何其他包)时,会出现问题.
$ nix-shell -p'(enableDebugging python27).withPackages(p:[p.cython])'
$ cat `which python`
#! /nix/store/jgw8hxx7wzkyhb2dr9hwsd9h2caaasdc-bash-4.4-p12/bin/bash -e
export PYTHONHOME="/nix/store/s0w3phb2saixi0a9bzk8pjbczjaz8d7r-python-2.7.14-env"
export PYTHONNOUSERSITE="true"
exec "/nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python" "${extraFlagsArray[@]}" "$@"
# ^^^^^^^
# non-debug
$ gdb /nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python
GNU gdb (GDB) 8.0.1
...
Reading symbols from /nix/store/i3bx1iw2d0i3vh9sa1nf92ynlrw324w8-python-2.7.14/bin/python...(no debugging symbols found)...done.
(gdb)
quit
Run Code Online (Sandbox Code Playgroud)
环境中的python版本现在是非调试的,尝试调试它会得到可怕的(找不到调试符号).这使得gdb对于调试cython程序的作用微乎其微.
小智 6
with import <nixpkgs> {};
let
self = enableDebugging python;
in [ gdb ((python.override{inherit self;}).withPackages(ps: with ps; [ cython ])) ]
Run Code Online (Sandbox Code Playgroud)
包装器中引用的可执行文件现在具有调试符号。
如果我们查看,pkgs/all-packages.nix我们会看到该enableDebugging函数的实现:
enableDebugging = pkg: pkg.override { stdenv = stdenvAdapters.keepDebugInfo pkg.stdenv; };
Run Code Online (Sandbox Code Playgroud)
它会覆盖单个派生以使用不同的stdenv. 在您的情况下,您希望覆盖 Python 解释器,它是使用 获得的派生的依赖项python.withPackages。
您的尝试enableDebugging python方向是正确的,但是,python.withPackages使用的引用也python需要更新。
| 归档时间: |
|
| 查看次数: |
377 次 |
| 最近记录: |