Reputation: 18264
I tend to use a lot of virtual environments, especially with Python. Some of the code I have run in a specific virtual environment and contains some C++ code. This code core dumps and I want to use lldb
to debug it.
However, I get this
; lldb a.out -c core.17915
Core file '/path/core.17915' (x86_64) was loaded.
Process 0 stopped
* thread #1: tid = 0, 0x0000000000559689
[...] ← lots of irrelevant data for this question.
(lldb) frame variable
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named lldb.embedded_interpreter
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
zsh: segmentation fault (core dumped) lldb a.out -c core.17915
I can import the lldb just fine running outside the virtual environment but cannot do that in the virtual environment. I do not wish to add all the system modules to the virtual environment as that kind of defeats the point of having a virtual environment in the first place.
How can I have the lldb
module loaded in my virtual environment?
Upvotes: 0
Views: 623
Reputation: 18264
The problem stems form the fact that virtual environments do not copy system wide installed modules by default. Which is the whole point of virtual environments. However, in a development setting, some of those modules are needed. Thus, in tox.ini
, I call a script (via commands
) that does post set up work. In that script, I have
lib_python_path="/usr/lib64/python2.7"
dst="$VIRTUAL_ENV/lib/python2.7/site-packages"
…
# Copy lldb, iff it exists.
if [ -d "${lib_python_path}/site-packages/lldb" ]
then
ln -f -s ${lib_python_path}/site-packages/lldb ${dst}
fi
This seems to do the trick.
Upvotes: 1
Reputation: 15425
I suspect something in the "lots of irrelevant data for this question" may be relevant. ;)
Can you compile a simple program like
$ echo "int main () { }" > /tmp/a.c
$ clang -g -o /tmp/a.out /tmp/a.c
$ lldb -x /tmp/a.out
(lldb) br s -n main
(lldb) r
(lldb) fr v
(or gcc
, whatever). Does that work? If that doesn't work, there's something pretty weird about how you've installed lldb. If it does work, then figure out what you're doing differently between these two examples.
Upvotes: 0