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.


  1. 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).


  2. @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:


    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!

  3. Hi,
    I am using ubuntu 16.04 LTS and latest eclipse (2017). I am trying to do a UDP connection using the real time application( used PREEMPT_RT). So, when i call the mlockall() function, it is always showing “cannot allocate memory” no matter whatever fix i did. when I debugged it using the eclipse, it is showing the error “can’t find a source file at /build/glibc-bfm8X4/…/sysdeps/unix/syscall-template.S”.

    I have installed the libraries using the command “sudo apt-get source libc6” and still its not working. And i am not able to put the libraries in the new directory, since the destination is different.Where should i place theses files?How can i resolve this?

  4. The quick and dirty solution would be to create symbolic links where the debugger is looking for the files. Not pretty, but it should work with any luck.

Leave a Reply

Your email address will not be published. Required fields are marked *