Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb cannot step into printf

Tags:

c++

c

gdb

here is my sample program:

#include<stdio.h>

int main()
{

printf("hello good morning \n");
return 0;
}


gcc -Wall -g temp.c


/opt/langtools/bin/gdb a.out
HP gdb 3.3 for PA-RISC 1.1 or 2.0 (narrow), HP-UX 11.00.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 3.3 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
(gdb) b 6
Breakpoint 1 at 0x2b14: file temp.c, line 6.
(gdb) run
Starting program: /oo_dgfqausr/test/dfqwrk4/temp/a.out

Breakpoint 1, main () at temp.c:6
6       printf("hello good morning \n");
(gdb) step
hello good morning
7       return 0;
(gdb)

as soon as i try to step into the printf function.its exiting and returning to main. does this mean that the shred library in which the printf function is defined is not provided with the debug symbols?Or am i doing something wrong?

like image 626
Vijay Avatar asked Apr 01 '11 11:04

Vijay


2 Answers

This means there's no available source/debug symbols for printf. You can use stepi to step into printf anyway, you'll only have disassembly available (use the disas command).

like image 69
Erik Avatar answered Sep 30 '22 20:09

Erik


That's correct, you likely do not have debugging symbols available. Make sure libc-devel or similar is installed. Also, make sure to compile with -O0 to prevent optimization; optimizations make debugging more difficult to follow.

like image 21
Jonathan Avatar answered Sep 30 '22 21:09

Jonathan