libxcache: Fix SQL bindings in db_remove_id.
libxcache: Export db_remove_id.
xcache: Extra debugging note when adding cache entry.
libxcache: Add function for testing dictionary membership.
libxcache: Fix: purge existing entry before adding a new cache entry.

Previously the old (uppermost) cache entry was being reused. This caused
incoherent data where there would be a single trace entry linked to multiple,
conflicting entries for individual inputs and outputs.
libxcache: Fix: Check for existing input before re-adding.

Previously we were re-adding any inputs that were read multiple times during a
run. This was causing them to be re-stated and their new measurement to
overwrite the old one. This left us with an inaccurate final measurement.
xcache: Fix tracking of open().

The way we were tracking opening of RW files got confused in the face of flags
like O_CREAT. It turns out some programs use O_RDWR|O_CREAT open calls as an
optimisation in some tricky circumstances.