0

Environment:

  • Eclipse IDE for C/C++ Developers Version: Mars Release (4.5.0)
  • Ubuntu 14.04

I have a problem with 'Debug mode' under Eclipse. I tried to debug a simple program as an experiment:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
    char *s = malloc(1);
    free(s);
    s = NULL;
    return 0;
}

The program is building correctly and is working without any Errors/Warnings but during debugging I am receiving following error: enter image description here

I have searched my entire hard drive and file malloc.c is not present.

The questions:

  1. If the file malloc.c can not be found, why the program can be build and is running correctly?

  2. Why the debugger has a problems with functions visible to the compiler?

  3. Has anyone saw this issue in the past and knows the solution?

  4. What kind of programming environment with debug mode are you using other than Eclipse?

I have found a couple similar topics, but without the general issue solution:

  1. How can i Escape from "no source available" errors when stepping OVER a stdio function in eclipse (C language, using CDT)
  2. GDB on eclipse debug mode can't find stdlib/rand.c

Running commands:

# apt-get install libc6-dbg
# apt-get source libc6

Does not solve the problem.

1
  • you probably need to ask one question at a time / Commented Sep 9, 2015 at 19:30

1 Answer 1

1

To get the source file malloc.c you need the source code for glibc.

If you have to debug into glibc, odds are you do are a glibc developer. In nearly every other case, you are better served by stepping over glibc. When you set your breakpoint, I highly suggest that you step over the glibc calls.

Glibc is generally implemented not by a lot of C code, but by a lot of machine specific code lightly wrapped in C APIs, and the machine specific code is different for every machine.

Also, the debugger isn't having a problem, it is reporting that it doesn't have the source code for a library (glibc in this case) and is happy to keep debugging (but it can't show you a line number until it steps out of the glibc malloc call).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.