Debugging in Ubuntu 12.10 – missing file syscall-template.S
NOTE: There is an update at the bottom of this post. Please read it!
After upgrading my development machine to Ubuntu 12.04, I was disappointed to find that debugging suddenly stopped working properly. Every time I tried I got the error:
Cannot find file ‘../sysdeps/unix/syscall-template.S’
After that none of the debugging made much sense (and the repeated warnings were just getting in the way).
Life kind of got in the way and I didn’t do any C development for a good while – so much so that the 12.10 upgrade came around before I’d even thought about it any more. Sadly the problem hadn’t gone away, so after another period of inactivity I’m now fixing it.
I discovered that the file in question is in the sources for libc6. These can be obtained using the following command:
sudo apt-get source libc6
This downloads the sources to the current directory. Back to the debugger, and it still couldn’t find the files – not really a surprise, but I didn’t know where to put them. In desperation I ran strace on the debugger (nemiver, in this case) to see where it was looking for our friend. This is what I got:
stat(“/build/buildd/eglibc-2.15/misc/../sysdeps/unix/syscall-template.S”, 0x7fff0ba361f0) = -1 ENOENT (No such file or directory)
stat(“/home/test/../sysdeps/unix/syscall-template.S”, 0x7fff0ba361f0) = -1 ENOENT (No such file or directory)
stat(“/build/buildd/eglibc-2.15/misc/syscall-template.S”, 0x7fff0ba36200) = -1 ENOENT (No such file or directory)
stat(“/home/test/syscall-template.S”, 0x7fff0ba36200) = -1 ENOENT (No such file or directory)
Not knowing the inner workings of debuggers, and wanting to keep the files visible to all users, I decided to create the directory /build/buildd and put the libc6 sources in there:
sudo mkdir -p /build/buildd
sudo mv ~/eglic* .
Success! Nemiver found the files and was happy evermore. And since nemiver is a wrapper on gdb, I checked and confirmed that that’s happy too, so if you’re one of those crazy people who can understand gdb* then this will work for you.
By the way, I have no idea whether or not this is the ‘right’ way to do this kind of thing, and I strongly suspect it isn’t. But it works so I’m happy. If someone knows what I should have done I’ll be all ears.
*My only experience of debugging prior to learning C was Java debugging, which is the nicest debugging experience you can have. After that, gdb is a scary nightmare.
UPDATE 6th May 2014: It appears that the libc6 sources are available in newer Ubuntu releases as an installable package. You should be able to just do
sudo apt-get install eglibc-source
and everything will get installed in the right place and be visible to the debugger.
This information came to me from Adventures in Code.