snare / voltron

A hacky debugger UI for hackers
MIT License
6.18k stars 414 forks source link

install.sh failed to find the Python version used by lldb #165

Closed NoAnyLove closed 8 years ago

NoAnyLove commented 8 years ago

The install.sh uses below code to check the python version used by lldb,

PYVER=$(lldb -Qxbo 'script import platform; print(".".join(platform.python_version_tuple()[:2]))'|tail -1)
PYTHON=$(lldb -Qxbo 'script import sys; print(sys.executable)'|tail -1)

It seems that the optioin -Qxbo doesn't work on some lldb versions. I had below error reported by lldb 3.8 and 3.7,

lldb: option '-Qxbo' is ambiguous; possibilities: '--one-line' '--one-line-on-crash' '--one-line-before-file'
...
error: unknown or ambiguous option
snare commented 8 years ago

Thanks, I'll investigate. I'm assuming this was on Linux?

NoAnyLove commented 8 years ago

Yes, I'm using Ubuntu

snare commented 8 years ago

Can you test if the following command works?

$ lldb -Qxb --one-line 'script import sys; print(sys.executable)'
NoAnyLove commented 8 years ago

Yes, it works on Ubuntu 15.10 and lldb 3.7. It outputs as follows.

$ lldb -Qxb --one-line 'script import sys; print(sys.executable)'
(lldb) script import sys; print(sys.executable)
/usr/bin/python
snare commented 8 years ago

Great, thank you!

snare commented 8 years ago

Could you please try the install script now from the last commit 4ffe85724606f70ff90c20d95358d9f28ac92703

NoAnyLove commented 8 years ago

Great, it works fine and outputs as follows,

$ ./install.sh 
+ getopts :ud opt
+ '[' -n /usr/bin/gdb ']'
++ gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))'
+ PYVER=3.4
++ gdb -batch -q --nx -ex 'pi import sys; print(sys.executable)'
+ PYTHON=/usr/bin/python
+ PYTHON=/usr/bin/python3.4
+ install_apt
+ uname
+ grep -i Linux
+ sudo apt-get update
Hit http://us.archive.ubuntu.com wily InRelease
Hit http://security.ubuntu.com wily-security InRelease                                                                 
Hit http://us.archive.ubuntu.com wily-updates InRelease                                                                
Hit http://security.ubuntu.com wily-security/main Sources                                    
Hit http://us.archive.ubuntu.com wily-backports InRelease                         
Hit http://security.ubuntu.com wily-security/restricted Sources                                
Hit http://us.archive.ubuntu.com wily/main Sources                                      
Hit http://ppa.launchpad.net wily InRelease                                         
Hit http://security.ubuntu.com wily-security/universe Sources                                                     
Hit http://us.archive.ubuntu.com wily/restricted Sources                                 
Hit http://security.ubuntu.com wily-security/multiverse Sources                          
Hit http://us.archive.ubuntu.com wily/universe Sources                                   
Hit http://security.ubuntu.com wily-security/main amd64 Packages                         
Hit http://us.archive.ubuntu.com wily/multiverse Sources                                
Hit http://ppa.launchpad.net wily InRelease                                             
Hit http://us.archive.ubuntu.com wily/main amd64 Packages                                                        
Hit http://security.ubuntu.com wily-security/restricted amd64 Packages                  
Hit http://us.archive.ubuntu.com wily/restricted amd64 Packages                         
Hit http://security.ubuntu.com wily-security/universe amd64 Packages                    
Hit http://us.archive.ubuntu.com wily/universe amd64 Packages                           
Hit http://security.ubuntu.com wily-security/multiverse amd64 Packages                  
Hit http://ppa.launchpad.net wily/main amd64 Packages                                   
Hit http://us.archive.ubuntu.com wily/multiverse amd64 Packages                         
Hit http://security.ubuntu.com wily-security/main i386 Packages                         
Hit http://us.archive.ubuntu.com wily/main i386 Packages                                
Hit http://security.ubuntu.com wily-security/restricted i386 Packages                   
Hit http://us.archive.ubuntu.com wily/restricted i386 Packages                          
Hit http://security.ubuntu.com wily-security/universe i386 Packages
Hit http://ppa.launchpad.net wily/main i386 Packages                                    
Hit http://us.archive.ubuntu.com wily/universe i386 Packages                            
Hit http://security.ubuntu.com wily-security/multiverse i386 Packages                   
Hit http://us.archive.ubuntu.com wily/multiverse i386 Packages    
Hit http://security.ubuntu.com wily-security/main Translation-en  
Hit http://us.archive.ubuntu.com wily/main Translation-en                               
Hit http://ppa.launchpad.net wily/main Translation-en                                   
Hit http://security.ubuntu.com wily-security/multiverse Translation-en                                             
Hit http://us.archive.ubuntu.com wily/multiverse Translation-en                                                    
Hit http://security.ubuntu.com wily-security/restricted Translation-en                                             
Hit http://us.archive.ubuntu.com wily/restricted Translation-en                                                    
Hit http://security.ubuntu.com wily-security/universe Translation-en                                               
Hit http://us.archive.ubuntu.com wily/universe Translation-en                                                   
Hit http://us.archive.ubuntu.com wily-updates/main Sources     
Hit http://ppa.launchpad.net wily/main amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/restricted Sources
Hit http://us.archive.ubuntu.com wily-updates/universe Sources      
Hit http://us.archive.ubuntu.com wily-updates/multiverse Sources
Hit http://ppa.launchpad.net wily/main i386 Packages               
Hit http://us.archive.ubuntu.com wily-updates/main amd64 Packages  
Hit http://us.archive.ubuntu.com wily-updates/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/universe amd64 Packages
Hit http://ppa.launchpad.net wily/main Translation-en
Hit http://us.archive.ubuntu.com wily-updates/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/main i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/restricted i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/multiverse i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/main Translation-en
Hit http://us.archive.ubuntu.com wily-updates/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-updates/restricted Translation-en
Hit http://us.archive.ubuntu.com wily-updates/universe Translation-en
Hit http://us.archive.ubuntu.com wily-backports/main Sources
Hit http://us.archive.ubuntu.com wily-backports/restricted Sources
Hit http://us.archive.ubuntu.com wily-backports/universe Sources
Hit http://us.archive.ubuntu.com wily-backports/multiverse Sources
Hit http://us.archive.ubuntu.com wily-backports/main amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/universe amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/main i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/restricted i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/multiverse i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/main Translation-en
Hit http://us.archive.ubuntu.com wily-backports/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-backports/restricted Translation-en
Hit http://us.archive.ubuntu.com wily-backports/universe Translation-en
Reading package lists... Done                
+ echo 3.4
+ grep '3\.'
3.4
+ sudo apt-get -y install libreadline6-dev python3-dev python3-setuptools python3-yaml
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libreadline6-dev is already the newest version.
python3-dev is already the newest version.
python3-setuptools is already the newest version.
python3-yaml is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+ '[' -z ']'
++ gdb -batch -q --nx -ex 'pi import site; print(site.getsitepackages()[0])'
+ GDB_SITE_PACKAGES=/usr/local/lib/python3.4/dist-packages
+ sudo /usr/bin/python3.4 -m pip install -U .
The directory '/home/noanylove/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/noanylove/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing /home/noanylove/voltron
Collecting scruffington>=0.3.6 (from voltron==0.1.6)
  Downloading scruffington-0.3.6-py2.py3-none-any.whl
Requirement already up-to-date: flask in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: flask_restful in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: blessed in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: pygments in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: requests in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: requests_unixsocket in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: six in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: pysigset in /usr/local/lib/python3.4/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: pyyaml in /usr/local/lib/python3.4/dist-packages (from scruffington>=0.3.6->voltron==0.1.6)
Requirement already up-to-date: Werkzeug>=0.7 in /usr/local/lib/python3.4/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: itsdangerous>=0.21 in /usr/local/lib/python3.4/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: Jinja2>=2.4 in /usr/local/lib/python3.4/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: click>=2.0 in /usr/local/lib/python3.4/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: aniso8601>=0.82 in /usr/local/lib/python3.4/dist-packages (from flask_restful->voltron==0.1.6)
Requirement already up-to-date: pytz in /usr/local/lib/python3.4/dist-packages (from flask_restful->voltron==0.1.6)
Requirement already up-to-date: wcwidth>=0.1.4 in /usr/local/lib/python3.4/dist-packages (from blessed->voltron==0.1.6)
Requirement already up-to-date: urllib3>=1.8 in /usr/local/lib/python3.4/dist-packages (from requests_unixsocket->voltron==0.1.6)
Requirement already up-to-date: MarkupSafe in /usr/lib/python3/dist-packages (from Jinja2>=2.4->flask->voltron==0.1.6)
Requirement already up-to-date: python-dateutil in /usr/local/lib/python3.4/dist-packages (from aniso8601>=0.82->flask_restful->voltron==0.1.6)
Installing collected packages: scruffington, voltron
  Found existing installation: scruffington 0.3.4
    Uninstalling scruffington-0.3.4:
      Successfully uninstalled scruffington-0.3.4
  Found existing installation: voltron 0.1.6
    Uninstalling voltron-0.1.6:
      Successfully uninstalled voltron-0.1.6
  Running setup.py install for voltron ... done
Successfully installed scruffington-0.3.6 voltron-0.1.6
+ grep voltron /home/noanylove/.gdbinit
+ '[' -n /usr/bin/lldb ']'
++ lldb -Qxb --one-line 'script import platform; print(".".join(platform.python_version_tuple()[:2]))'
++ tail -1
bind: Invalid command `enable-meta-key'.
+ PYVER=2.7
++ lldb -Qxb --one-line 'script import sys; print(sys.executable)'
++ tail -1
bind: Invalid command `enable-meta-key'.
+ PYTHON=/usr/bin/python
+ PYTHON=/usr/bin/python2.7
+ '[' -z ']'
++ lldb -Qxb --one-line 'script import site; print(site.getsitepackages()[0])'
++ tail -1
bind: Invalid command `enable-meta-key'.
+ LLDB_SITE_PACKAGES=/usr/local/lib/python2.7/dist-packages
+ install_apt
+ uname
+ grep -i Linux
+ sudo apt-get update
Hit http://us.archive.ubuntu.com wily InRelease
Hit http://us.archive.ubuntu.com wily-updates InRelease                                                                                              
Hit http://us.archive.ubuntu.com wily-backports InRelease                                      
Hit http://security.ubuntu.com wily-security InRelease                                       
Hit http://us.archive.ubuntu.com wily/main Sources                     
Hit http://ppa.launchpad.net wily InRelease                                          
Hit http://us.archive.ubuntu.com wily/restricted Sources                                                        
Hit http://us.archive.ubuntu.com wily/universe Sources                                 
Hit http://security.ubuntu.com wily-security/main Sources                              
Hit http://us.archive.ubuntu.com wily/multiverse Sources                            
Hit http://ppa.launchpad.net wily InRelease                                         
Hit http://us.archive.ubuntu.com wily/main amd64 Packages                                                    
Hit http://us.archive.ubuntu.com wily/restricted amd64 Packages                         
Hit http://security.ubuntu.com wily-security/restricted Sources                         
Hit http://us.archive.ubuntu.com wily/universe amd64 Packages                           
Hit http://ppa.launchpad.net wily/main amd64 Packages                                   
Hit http://us.archive.ubuntu.com wily/multiverse amd64 Packages   
Hit http://security.ubuntu.com wily-security/universe Sources     
Hit http://us.archive.ubuntu.com wily/main i386 Packages                                
Hit http://us.archive.ubuntu.com wily/restricted i386 Packages                          
Hit http://ppa.launchpad.net wily/main i386 Packages              
Hit http://us.archive.ubuntu.com wily/universe i386 Packages                            
Hit http://security.ubuntu.com wily-security/multiverse Sources                         
Hit http://us.archive.ubuntu.com wily/multiverse i386 Packages                          
Hit http://ppa.launchpad.net wily/main Translation-en                                   
Hit http://us.archive.ubuntu.com wily/main Translation-en                               
Hit http://security.ubuntu.com wily-security/main amd64 Packages                        
Hit http://us.archive.ubuntu.com wily/multiverse Translation-en                         
Hit http://us.archive.ubuntu.com wily/restricted Translation-en                         
Hit http://ppa.launchpad.net wily/main amd64 Packages             
Hit http://security.ubuntu.com wily-security/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily/universe Translation-en                           
Hit http://ppa.launchpad.net wily/main i386 Packages                                    
Hit http://security.ubuntu.com wily-security/universe amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/main Sources                              
Hit http://us.archive.ubuntu.com wily-updates/restricted Sources                        
Hit http://security.ubuntu.com wily-security/multiverse amd64 Packages                  
Hit http://ppa.launchpad.net wily/main Translation-en                                   
Hit http://us.archive.ubuntu.com wily-updates/universe Sources                          
Hit http://us.archive.ubuntu.com wily-updates/multiverse Sources
Hit http://security.ubuntu.com wily-security/main i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/main amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/universe amd64 Packages
Hit http://security.ubuntu.com wily-security/restricted i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com wily-updates/main i386 Packages    
Hit http://us.archive.ubuntu.com wily-updates/restricted i386 Packages
Hit http://security.ubuntu.com wily-security/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/multiverse i386 Packages
Hit http://security.ubuntu.com wily-security/multiverse i386 Packages
Hit http://us.archive.ubuntu.com wily-updates/main Translation-en  
Hit http://us.archive.ubuntu.com wily-updates/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-updates/restricted Translation-en
Hit http://security.ubuntu.com wily-security/main Translation-en
Hit http://us.archive.ubuntu.com wily-updates/universe Translation-en
Hit http://us.archive.ubuntu.com wily-backports/main Sources       
Hit http://security.ubuntu.com wily-security/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-backports/restricted Sources 
Hit http://security.ubuntu.com wily-security/restricted Translation-en
Hit http://us.archive.ubuntu.com wily-backports/universe Sources   
Hit http://us.archive.ubuntu.com wily-backports/multiverse Sources 
Hit http://us.archive.ubuntu.com wily-backports/main amd64 Packages
Hit http://security.ubuntu.com wily-security/universe Translation-en
Hit http://us.archive.ubuntu.com wily-backports/restricted amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/universe amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com wily-backports/main i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/restricted i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/universe i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/multiverse i386 Packages
Hit http://us.archive.ubuntu.com wily-backports/main Translation-en
Hit http://us.archive.ubuntu.com wily-backports/multiverse Translation-en
Hit http://us.archive.ubuntu.com wily-backports/restricted Translation-en
Hit http://us.archive.ubuntu.com wily-backports/universe Translation-en
Reading package lists... Done            
+ echo 2.7
+ grep '3\.'
+ sudo apt-get -y install libreadline6-dev python-dev python-setuptools python-yaml
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libreadline6-dev is already the newest version.
python-dev is already the newest version.
Suggested packages:
  python-setuptools-doc
The following NEW packages will be installed:
  python-setuptools python-yaml
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 280 kB of archives.
After this operation, 1,025 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ wily/main python-setuptools all 18.4-1 [171 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ wily/main python-yaml amd64 3.11-2build1 [109 kB]
Fetched 280 kB in 0s (631 kB/s)      
Selecting previously unselected package python-setuptools.
(Reading database ... 185759 files and directories currently installed.)
Preparing to unpack .../python-setuptools_18.4-1_all.deb ...
Unpacking python-setuptools (18.4-1) ...
Selecting previously unselected package python-yaml.
Preparing to unpack .../python-yaml_3.11-2build1_amd64.deb ...
Unpacking python-yaml (3.11-2build1) ...
Setting up python-setuptools (18.4-1) ...
Setting up python-yaml (3.11-2build1) ...
+ '[' /usr/local/lib/python2.7/dist-packages == /usr/local/lib/python3.4/dist-packages ']'
+ sudo /usr/bin/python2.7 -m pip install -U .
The directory '/home/noanylove/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/noanylove/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing /home/noanylove/voltron
Requirement already up-to-date: scruffington>=0.3.6 in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: flask in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: flask_restful in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: blessed in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: pygments in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Collecting requests (from voltron==0.1.6)
  Downloading requests-2.11.1-py2.py3-none-any.whl (514kB)
    100% |████████████████████████████████| 522kB 1.0MB/s 
Requirement already up-to-date: requests_unixsocket in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: six in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Requirement already up-to-date: pysigset in /usr/local/lib/python2.7/dist-packages (from voltron==0.1.6)
Collecting pyyaml (from scruffington>=0.3.6->voltron==0.1.6)
  Downloading PyYAML-3.12.tar.gz (253kB)
    100% |████████████████████████████████| 256kB 1.3MB/s 
Requirement already up-to-date: itsdangerous>=0.21 in /usr/local/lib/python2.7/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: click>=2.0 in /usr/local/lib/python2.7/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: Jinja2>=2.4 in /usr/local/lib/python2.7/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: Werkzeug>=0.7 in /usr/local/lib/python2.7/dist-packages (from flask->voltron==0.1.6)
Requirement already up-to-date: pytz in /usr/local/lib/python2.7/dist-packages (from flask_restful->voltron==0.1.6)
Requirement already up-to-date: aniso8601>=0.82 in /usr/local/lib/python2.7/dist-packages (from flask_restful->voltron==0.1.6)
Requirement already up-to-date: wcwidth>=0.1.4 in /usr/local/lib/python2.7/dist-packages (from blessed->voltron==0.1.6)
Collecting urllib3>=1.8 (from requests_unixsocket->voltron==0.1.6)
  Downloading urllib3-1.16-py2.py3-none-any.whl (98kB)
    100% |████████████████████████████████| 102kB 2.5MB/s 
Requirement already up-to-date: MarkupSafe in /usr/local/lib/python2.7/dist-packages (from Jinja2>=2.4->flask->voltron==0.1.6)
Requirement already up-to-date: python-dateutil in /usr/local/lib/python2.7/dist-packages (from aniso8601>=0.82->flask_restful->voltron==0.1.6)
Installing collected packages: requests, voltron, pyyaml, urllib3
  Found existing installation: requests 2.9.1
    Uninstalling requests-2.9.1:
      Successfully uninstalled requests-2.9.1
  Found existing installation: voltron 0.1.6
    Uninstalling voltron-0.1.6:
      Successfully uninstalled voltron-0.1.6
  Running setup.py install for voltron ... done
  Found existing installation: PyYAML 3.11
    Uninstalling PyYAML-3.11:
      Successfully uninstalled PyYAML-3.11
  Running setup.py install for pyyaml ... done
  Found existing installation: urllib3 1.14
    Uninstalling urllib3-1.14:
      Successfully uninstalled urllib3-1.14
Successfully installed pyyaml-3.12 requests-2.11.1 urllib3-1.16 voltron-0.1.6
+ grep voltron /home/noanylove/.lldbinit
+ '[' -z /usr/bin/gdb ']'
+ set +x
==============================================================
Installed for GDB (/usr/bin/gdb):
  Python:             /usr/bin/python2.7
  Packages directory: /usr/local/lib/python3.4/dist-packages
  Already loaded in:  ~/.gdbinit
Installed for LLDB (/usr/bin/lldb):
  Python:             /usr/bin/python2.7
  Packages directory: /usr/local/lib/python2.7/dist-packages
  Already loaded in:  ~/.lldbinit
snare commented 8 years ago

Excellent, thanks.