1

I have made an application in which there is a file main.c which uses a function from the master.c file. I would like to debug my application for all functions defined in the master.c file by using gdb tool. Is this possible and if so how?

DrYap
  • 6,525
  • 2
  • 31
  • 54
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
  • What do you mean by the term debug my application? If you refine that term, either an answer below is already answering the question, or we might be able to find a more specific solution. Do you want to automatically set breakpoints on all functions defined in the header? Do you want to inspect memory of all functions? Or do you want to test the functions by comparing them to specific output for given inputs? This might be of help as well: http://stackoverflow.com/questions/1504965/how-to-run-a-linux-program-line-by-line – Alexander Oh Dec 27 '11 at 10:18
  • i want automatically set breakpoints on all functions defined in the header.. – Jeegar Patel Dec 27 '11 at 10:29
  • 1
    Duplicate of http://stackoverflow.com/questions/1476002/gdb-set-breakpoint-on-all-functions-in-a-file ? – another.anon.coward Dec 27 '11 at 10:41
  • This might be of help as well: [link](http://stackoverflow.com/questions/1715053/how-to-use-gdb-to-debug-a-big-project) – cyber_raj Dec 27 '11 at 10:43

2 Answers2

5

You must compile your program using -g flag.

Then you start gdb your_program and set break points: break master.c:37 that will set a break point on master.c, line #37 or you could set breaks at functions: break foo().

Then start your program by run and continue with the debugging process, inspect, continue, watch, display...

http://www.gnu.org/software/gdb/

http://www.gnu.org/software/gdb/documentation/

http://www.cs.cmu.edu/~gilpin/tutorial/

Google for more documentation on using gdb.

Of course there is:

Debug a running program with gdb

Paul
  • 20,883
  • 7
  • 57
  • 74
2

Use break as shown here

For Example:

break master.c:5
Sangeeth Saravanaraj
  • 16,027
  • 21
  • 69
  • 98
oferlivny
  • 300
  • 4
  • 15