Xdebug trace != profile

So it just took me all night to figure out that in Xdebug ‘tracing’ is different to ‘profiling’.

It didn’t help that the xdebug.trace_output_name included an example format of ‘cachegrind.out.%s’. Why would you name a trace file cachegrind.out if only profile files are in cachegrind format!?

In my efforts to get profiling to work I found myself loading trace files into KCachegrind and getting the rather unhelpful message: “Could not open the file “/run/shm/xdebug/trace…xt”. Check it exists and you have enough permissions to read it.”

So the error message is about file permissions. I checked and checked and checked again but the file permissions were OK. The problem was I was loading a trace file, not a profile file.

So I gave up on KCachegrind and tried to get webgrind to work. Turns out loading a trace file (not a profile file) into webgrind doesn’t work either. I got the same problem reported by Sven about ‘parsers is undefined’. I fucked around trying to update the jquery.tablesorter plugin in webgrind, but the problem was due to the fact I was loading a tracing file, not a profiling file.

In the end I got it all figured out. Here’s my /etc/php5/mods-enabled/xdebug.ini file:

zend_extension=/usr/lib/php5/20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
;xdebug.remote_host=127.0.0.1
xdebug.remote_host=10.1.1.203
;xdebug.remote_port=9000
xdebug.remote_port=9999

; http://www.xdebug.org/docs/all

xdebug.profiler_enable=1
xdebug.profiler_output_dir=/run/shm/xdebug
xdebug.profiler_output_name=cachegrind.out.%t.%R

xdebug.auto_trace=1
xdebug.collect_assignments=1
xdebug.collect_includes=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.collect_vars=0
xdebug.show_mem_delta=1
;2 for HTML:
xdebug.trace_format=0
xdebug.trace_options=1
xdebug.trace_output_dir=/run/shm/xdebug
xdebug.trace_output_name=trace.%t.%R
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

The above config supports generation of tracing files and profiling files. I can now load my profiling files into KCachegrind and webgrind.

Everything is easy when you know how!

Fixing meta-keys in Vim via Mac OS X Terminal.app

So I configured Terminal.app to use Option (Alt) as Meta key: Terminal => Preferences => Profiles => Keyboard => Use Option as Meta key

But wasn’t working for the key-bindings in my .vimrc:

nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z

So I found this article: Fix meta-keys that break out of Insert mode and ended up with the following snippet for my .vimrc which fixed my Meta-key problem:

let c='a'
while c <= 'z'
  exec "set <M-".tolower(c).">=\e".c
  exec "imap \e".c." <M-".tolower(c).">"
  let c = nr2char(1+char2nr(c))
endw

Everything is easy when you know how!

Entering SSH passphrase once in a KDE Pulse session

If you want KDE to remember your SSH key’s passphrase for your whole desktop session you can create a ~/.config/autostart/ssh-add.desktop file like this:

[Desktop Entry]
Type=Application
Name=ssh-add
Comment=Adds my private key to my session.
Exec=/usr/bin/konsole -e 'ssh-add /home/$USER/.ssh/id_rsa'

Fixing bug in /etc/cron.daily/etckeeper on Ubuntu Lucid

I was getting an error like this:

/etc/cron.daily/etckeeper:
bzr: ERROR: exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 34: ordinal not in range(128)

Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 853, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 1055, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 661, in run_argv_aliases
    return self.run_direct(**all_cmd_args)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 665, in run_direct
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 122, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/builtins.py", line 659, in run
    no_recurse, action=action, save=not dry_run)
  File "/usr/lib/python2.6/dist-packages/bzrlib/mutabletree.py", line 50, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/mutabletree.py", line 521, in smart_add
    for subf in sorted(os.listdir(abspath)):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 34: ordinal not in range(128)

bzr 2.1.4 on python 2.6.5 (Linux-2.6.35.4-rscloud-x86_64-with-Ubuntu-10.04-lucid)
arguments: ['/usr/bin/bzr', 'add', '-q', '.']
encoding: 'ANSI_X3.4-1968', fsenc: 'ANSI_X3.4-1968', lang: None
plugins:
  bzrtools             /usr/lib/python2.6/dist-packages/bzrlib/plugins/bzrtools [2.1.0]
  etckeeper            /usr/lib/python2.6/dist-packages/bzrlib/plugins/etckeeper [unknown]
  launchpad            /usr/lib/python2.6/dist-packages/bzrlib/plugins/launchpad [2.1.4]
  netrc_credential_store /usr/lib/python2.6/dist-packages/bzrlib/plugins/netrc_credential_store [2.1.4]
  news_merge           /usr/lib/python2.6/dist-packages/bzrlib/plugins/news_merge [2.1.4]

*** Bazaar has encountered an internal error.  This probably indicates a
    bug in Bazaar.  You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description of the problem.
etckeeper warning: bzr add failed
Committing to: /etc/
modified apache2/passwd.htdigest
modified apache2/sites-available/svn.jj5.net-ssl
Committed revision 87.

I’ve tried to fix it by adding:

export LANG=en_AU.UTF-8
export LANGUAGE=en_AU:en

As lines 2 and 3 in /etc/cron.daily/etckeeper.

Now I’ll wait a day or two and see if it worked…

KDE Plasma Desktop hacks

I managed to get my desktop settings so that files on the desktop were sorted automatically. But I didn’t want that. I edited the ~/.kde/share/config/plasma-desktop-appletsrc file and set the sortingStrategy=0 and that disabled automatic alphabetical desktop sorting.

I wanted to run an application on my desktop when I dropped some files on it. To do that I created a process.desktop file like this:

#!/usr/bin/env xdg-open
[Desktop Entry]
Icon=unknown
Name[en_US]=process
Name=process
Type=Application
Exec=/home/jj5/bin/tmp/process-test %F

Note the “%F” to receive the file list. More information here and here.