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?

4
  • 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: stackoverflow.com/questions/1504965/… Commented Dec 27, 2011 at 10:18
  • i want automatically set breakpoints on all functions defined in the header.. Commented Dec 27, 2011 at 10:29
  • 1
    Duplicate of stackoverflow.com/questions/1476002/… ? Commented Dec 27, 2011 at 10:41
  • This might be of help as well: link Commented Dec 27, 2011 at 10:43

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

2

Use break as shown here

For Example:

break master.c:5

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.