Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » No source available for "__libc_start_main() " (Eclipse newbie, trying to debug C projects)
No source available for "__libc_start_main() " [message #762247] Wed, 07 December 2011 18:57 Go to next message
Lk  is currently offline Lk Friend
Messages: 4
Registered: December 2011
Junior Member
Well, title and description say the most... i'm an ubuntu 11.10 user, i installed eclipse 3.7.0 through the Ubuntu Software Center (but i tried "manually" directly downloading from the official site before). Everything just goes fine (i guess), and i can even almost debug the code: at the end of the debugging, right after the closing "}", i receive the error 'No source available for "__libc_start_main() "', here are some rows showed if i click on "show disassembly":
0x0014a113 <__libc_start_main+243>: mov  %eax,(%esp)
0x0014a116 <__libc_start_main+246>: call 0x1639e0 <exit>
0x0014a11b <__libc_start_main+251>: xor  %ecx,%ecx
0x0014a11d <__libc_start_main+253>: jmp  0x14a054 <__libc_start_main+52>
0x0014a122 <__libc_start_main+258>: mov  0x3894(%ebx),%eax
0x0014a128 <__libc_start_main+264>: ror  $0x9,%eax
0x0014a12b <__libc_start_main+267>: xor  %gs:0x18,%eax

I'm not expert in assembly but it seems to me that he indeed can access to the libc_start_main (whatever that is), so what is the problem??
At least a few times this didn't happened, but i couldn't find any pattern.
After the debugging is terminated the console shows the following message:
Stopped due to shared library event
Stopped due to shared library event
Single stepping until exit from function __libc_start_main,
which has no line number information.


Now, the program is indeed debugged as the error is only at the end of the debugging, but this is nonetheless very annoying...

I hope i included enough informations, and if not just tell me what do you need to know!
Thanks in advance (and sorry for any grammar mistakes Smile )
Re: No source available for "__libc_start_main() " [message #762300 is a reply to message #762247] Wed, 07 December 2011 20:56 Go to previous messageGo to next message
Ken Mising name is currently offline Ken Mising nameFriend
Messages: 5
Registered: December 2011
Junior Member
I'm having a similiar issue. When I start debugging I get a tab next to my "main.c" source tab with "No source available for "main() at 0x400fd0" and a "View Disassembly" button in it, and it's not showing the break in the "main.c" source file, although it is breaking.

Ken....

Re: No source available for "__libc_start_main() " [message #762334 is a reply to message #762300] Wed, 07 December 2011 22:34 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
I believe that libc_start_main is the runtime function that calls your main method. This gets linked in and is not compiled with your program. You won't have source for this function. Do you do a step over/out on the closing }? If so, then the next instruction to execute would be in this function. Since there is no source you get the message.

Ken, have you compiled your program with debugging information included? If not, then the debugger doesn't have the information it needs to map the executable to source code.
Re: No source available for "__libc_start_main() " [message #762403 is a reply to message #762334] Thu, 08 December 2011 01:59 Go to previous messageGo to next message
Ken Mising name is currently offline Ken Mising nameFriend
Messages: 5
Registered: December 2011
Junior Member
I have added the -g option to the makefile but am now having another issue, which I will start a new topic on.

Ken....
Re: No source available for "__libc_start_main() " [message #762545 is a reply to message #762403] Thu, 08 December 2011 09:21 Go to previous messageGo to next message
Lk  is currently offline Lk Friend
Messages: 4
Registered: December 2011
Junior Member
@dpwegener, the error pops out only when i try to step over/into the closing }, so what you are telling is that simply one is not supposed to do that? i know that it is of no use, and i can simply "resume" instead and i get no error, but i don't see the point of displaying such un error message if the fact that it is pointing out is "obvious", i.e. is not really an error!
Re: No source available for &quot;__libc_start_main() &quot; [message #762560 is a reply to message #762247] Thu, 08 December 2011 09:54 Go to previous messageGo to next message
HagenFriend
Messages: 90
Registered: April 2010
Member
When you start executing a C program, some application startup code - to
setup the application stack and to initialize your static variables - is
executed before the "main" routine.

This application startup code is part of the "C runtime".

Often the name of the precompiled module doing the initial setup is
"crt0.o" (C RunTime 0 [Zero] objectfile) or something.

When you have standard libraries enables, the linker will add it
automatically before the start of the actual application code.

You likely have the source code for the pre-"main" initialization module.

But (a) very likely it is written in assembly language anyway (stack and
variable setup are not easily done in C), and (b) because the
application startup code is part of the C runtime library source that
came with your C compiler toolchain, it is not part of your Eclipse
project, and so Eclipse does not know about it.


If you really want to look at this code whilst debugging, you need to
change the build options to omit the standard libraries (and setup
code), and compile your own crt0.o module.
This then needs to be the very first linked module, otherwise your
application will not properly start.


In daily practice, I'd just set a breakpoint at "main" and would not
worry about the setup code.
Re: No source available for &quot;__libc_start_main() &quot; [message #762565 is a reply to message #762560] Thu, 08 December 2011 10:02 Go to previous messageGo to next message
HagenFriend
Messages: 90
Registered: April 2010
Member
In your case the _libc_start_main module does this:
- it does the (call-stack and static and BSS variable) setup
- it calls your main() routine

Now, for the compiler and for your computer, your main() routine is just
like any other function.
You call a function and at the end it returns, possibly with a return value.
[Remember, the main() signature is "int main(argc, ...).]

- when main() returns with its return code it returns _to_ the code in
_libc_start_main function that called your main().
- this code needs to do some cleanup, and to hand the return code to the
operating system

[Hope this fills "the missing link" I left dangling with my last mail.]
Re: No source available for &quot;__libc_start_main() &quot; [message #762790 is a reply to message #762565] Thu, 08 December 2011 16:18 Go to previous message
Lk  is currently offline Lk Friend
Messages: 4
Registered: December 2011
Junior Member
Thank you very much! You've been very clear and i've learned something new.. i could not ask for more! Very Happy
Previous Topic:[AST] Getting AST Node from Binding
Next Topic:How to get CDT to use MSYS shell?
Goto Forum:
  


Current Time: Fri Apr 19 03:44:18 GMT 2024

Powered by FUDForum. Page generated in 0.02130 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top