bash-completion looks up tools in wrong directory

Bug #531730 reported by Alex Converse
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
valgrind (Debian)
Fix Released
Unknown
valgrind (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: valgrind

I filed this bug under valgrind because valgrind installs /etc/bash_completion.d/valgrind.

$ lsb_release -rd
Description: Ubuntu lucid (development branch)
Release: 10.04
$ uname -a
Linux barcelona 2.6.32-15-generic #22-Ubuntu SMP Tue Mar 2 02:23:29 UTC 2010 x86_64 GNU/Linux
$ apt-cache policy valgrind
valgrind:
  Installed: 1:3.6.0~svn20100212-0ubuntu2
  Candidate: 1:3.6.0~svn20100212-0ubuntu2
  Version table:
 *** 1:3.6.0~svn20100212-0ubuntu2 0
        500 http://us.archive.ubuntu.com lucid/main Packages
        100 /var/lib/dpkg/status
$ apt-cache policy bash-completion
bash-completion:
  Installed: 1:1.1-3
  Candidate: 1:1.1-3
  Version table:
 *** 1:1.1-3 0
        500 http://us.archive.ubuntu.com lucid/main Packages
        100 /var/lib/dpkg/status

When I try to use tab to complete valgrind tool names bash-completion spits out find errors

$ valgrind --tool=^Ifind: `/usr/lib/valgrind/x86-linux': No such file or directory
 find: `/usr/lib/valgrind/x86-linux': No such file or directory
 find: `/usr/lib/valgrind/x86-linux': No such file or directory
 find: `/usr/lib/valgrind/x86-linux': No such file or directory

$ ls --file-type /usr/lib/valgrind/
cachegrind-amd64-linux helgrind-x86-linux none-x86-linux
cachegrind-x86-linux lackey-amd64-linux python.supp
callgrind-amd64-linux lackey-x86-linux vgpreload_core-amd64-linux.so
callgrind-x86-linux libcoregrind-amd64-linux.a vgpreload_core-x86-linux.so
debian-libc6-dbg.supp libcoregrind-x86-linux.a vgpreload_drd-amd64-linux.so
debian.supp libreplacemalloc_toolpreload-amd64-linux.a vgpreload_drd-x86-linux.so
default.supp libreplacemalloc_toolpreload-x86-linux.a vgpreload_exp-ptrcheck-amd64-linux.so
drd-amd64-linux libvex-amd64-linux.a vgpreload_exp-ptrcheck-x86-linux.so
drd-x86-linux libvex-x86-linux.a vgpreload_helgrind-amd64-linux.so
exp-bbv-amd64-linux massif-amd64-linux vgpreload_helgrind-x86-linux.so
exp-bbv-x86-linux massif-x86-linux vgpreload_massif-amd64-linux.so
exp-ptrcheck-amd64-linux memcheck-amd64-linux vgpreload_massif-x86-linux.so
exp-ptrcheck-x86-linux memcheck-x86-linux vgpreload_memcheck-amd64-linux.so
helgrind-amd64-linux none-amd64-linux vgpreload_memcheck-x86-linux.so

As you can see there is no x86 directory inside /usr/lib/valgrind/

Tags: patch
Loïc Minier (lool)
summary: - Error completing valgrind tools
+ bash-completion looks up tools in wrong directory
Revision history for this message
LiraNuna (liranuna) wrote :

This is a relatively simple fix.

Replace line 67 with this line according to your architecture:

x86 (32bit):
            tools=`find /usr/lib/valgrind/*-x86-linux -executable -type f -exec basename {} -x86-linux \; | sed -e 's,\./,,g' | tr '\n' ' '`

x86_64 (64bit):
            tools=`find /usr/lib/valgrind/*-amd64-linux -executable -type f -exec basename {} -amd64-linux \; | sed -e 's,\./,,g' | tr '\n' ' '`

This will result:

$ valgrind --tool=
cachegrind drd exp-ptrcheck lackey memcheck
callgrind exp-bbv helgrind massif none

Changed in valgrind (Ubuntu):
status: New → Confirmed
Revision history for this message
Peter Wu (lekensteyn) wrote :

The previous command did not work correctly for 64-bit systems since the 32-bit tools are provided too.
The attached patch fixes the directory and optimizes the command a bit:

By adding `-printf '%f '`, the next parts were obsolete / conflicting:

 - `-exec basename {} \;` - this would get the basename, just like %f
- `sed -e 's,\./,,g'` - this is possibly a remainder before basename was available. It is supposed to remove all occurrences of ./
- `tr '\n' ' '` - this would join the lines with spaces, printf would not add a newline and the space after it works as well

If you've saved the patch as bash-completion-valgrind-tools.patch, you can run the below command to apply it:

    sudo patch -p0 < bash-completion-valgrind-tools.patch

Revision history for this message
Peter Wu (lekensteyn) wrote :

Oops missing backtick in the last patch, new patch here

Peter Wu (lekensteyn)
tags: added: patch
Revision history for this message
Alessandro Ghedini (ghedo) wrote :

This should have been fixed now.

Changed in valgrind (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Peter Wu (lekensteyn) wrote :

Well yes, the tools are now hardcoded.

Changed in valgrind (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.