To see the start up process of a C++ program (with one console application and a shared library), first I installed CodeBlocks IDE on Ubuntu 18.04, but it only show main as the first entry in the call stack.
Then I use gdb to run the program and set a break point at "_start" (supposed to be the default Unix application entry point) then "main", but when break at "main", the backtrace command only show one frame.
How to see the call stack before main and further how to setup dgb for the symbols/sources for system libraries to view the source?
The GDB setting you need is set backtrace past-main on:
Backtraces will continue past the user entry point.
(gdb) set backtrace past-main on
(gdb) start
(gdb) bt
#0 main (argc=argc@entry=1, argv=argv@entry=0x7ffffffee1a8) at hoist.c:7
#1 0x00007fffff0802e1 in __libc_start_main (main=0x8000580 <main>, argc=1, argv=0x7ffffffee1a8, init=<optimized out>,
fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffffffee198) at ../csu/libc-start.c:291
#2 0x000000000800069a in _start ()
(gdb) fr 1
#1 0x00007fffff0802e1 in __libc_start_main (main=0x8000580 <main>, argc=1, argv=0x7ffffffee1a8, init=<optimized out>,
fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffffffee198) at ../csu/libc-start.c:291
291 ../csu/libc-start.c: No such file or directory.
After installing the glibc source as described in GDB complaining about missing raise.c :
(gdb) fr 1
#1 0x00007fffff0802e1 in __libc_start_main (main=0x8000580 <main>, argc=1, argv=0x7ffffffee1a8, init=<optimized out>,
fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffffffee198) at ../csu/libc-start.c:291
291 result = main (argc, argv, __environ MAIN_AUXVEC_PARAM);