0

I've seen a similar thread here on stackoverflow

Why am I getting the message "Single-stepping until exit . . . which has no line number information" in GDB?

By the moment the accepted answer does not solve my problem.

What I do is to set a breakpoint at the main-function

(gdb) break main
Breakpoint 1 at 0x6fe
(gdb) run
Starting program: /home/bjorn/printprog 

Breakpoint 1, 0x00005555555546fe in main ()
(gdb) 

so far so god but when I start stepping I get the following:

(gdb) s
Single stepping until exit from function main,
which has no line number information.
hell world!!!!
Number of characters in the string are 14
__libc_start_main (main=0x5555555546fa <main>, argc=1, argv=0x7fffffffdef8, init=<optimized 
out>, fini=<optimized out>, 
rtld_fini=<optimized out>, stack_end=0x7fffffffdee8) at ../csu/libc-start.c:344
344 ../csu/libc-start.c: Filen eller katalogen finns inte.

"Filen eller katalogen finns inte." means "the file or catalog does not exist"

What could the problem be?

  • Something seems to be missing, is that the cause - start.c, do I need that file?

  • that versions differ between gcc and gdb?

GDB

 GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

GCC

gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
  • or could it be that my makefile is wrong or missing something?

makefile

  CC=gcc
  CFLAGS=-I.
  printprog: main.o print.o 
      $(CC) -g -o printprog main.o print.o -I.
java
  • 1,165
  • 1
  • 25
  • 50

1 Answers1

1

What appears to be happening is that your files are being compiled using an implicit rule, then the object files are linked using the rule you specify. Since your -g option is on the link command, not the compile command, it's too late. The compilation has already been done without debug information.

Rather, add the -g option to your CFLAGS symbol. This is used in the implicit rule, so the source files will be compiled with debug information. The option is not needed for linking (and -I. shouldn't be necessary either for compiling or linking).

  CC=gcc
  CFLAGS= -g
  printprog: main.o print.o 
      $(CC) -o printprog main.o print.o
Fred Larson
  • 60,987
  • 18
  • 112
  • 174