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
cd /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.

January 6, 2013   Tags: c, linux/ubuntu

4 Responses

  1. неожиданный kdevelop crash | StasyakOFF Blog - August 28, 2013

    […] Источник […]

  2. Django & PyV8 | Adventures In Code - January 19, 2014

    […] it trying to get this file from? Why does it even need this file? I turn to google again, and I get this link. It proves to be the last step to solve the problem; for whatever reason, PyV8 needs the source to […]

  3. cool_john - November 4, 2014

    Hi. I googled here. I come across the same problem except on 14.04 ubuntu.
    Installed the eglibc-source but with no success.

    I am interested in your strace method.
    How can I can the scat traces in your article?
    (never used strace before).

    Thanks.

  4. Steve Jones - November 5, 2014

    @cool_john: strace basically hooks into a process and logs all the system calls it makes. You can run a program with strace by doing:

    strace

    or attach it to an existing process to see what it’s up to with:

    strace -p

    Bear in mind that strace produces *a lot* of output – a simple ‘ls’ command results in around 250 lines. So pulling out what you need to find is a bit tricky.

    For the problem above, I knew that nemiver was trying (and failing) to find a specific file, so I looked through the strace output for every line that mentioned it, and that told me where it was looking for the source files and therefore where I should put them. As I said, it’s an ugly way of doing things but I was desperate!

Leave a Reply