简体   繁体   中英

How can I debug a function in particular file of a running application using gdb?

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?

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

Use break as shown here

For Example:

break master.c:5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM