8

I would like to set multiple breakpoints at once in different files in GDB.

Is it possible to have a script or any other way which I can run once I enter GDB debugger and have all the breakpoints set instead of setting them one by one using traditional set break command.

All the resources I searched pointed to how to set breakpoints effectively. But, nothing seems to address my concern.

1

1 Answer 1

10

You can use the source command in gdb.

You can also put the commands in the .gdbinit file which will be sourced when you start gdb. Put the commands there and they will be run without doing anything more.

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

1 Comment

If you are trying to set breakpoints on a library that will be loaded in the future, add set breakpoint pending on to the top of that source-file, or else gdb will reject the breakpoints since they are not found.

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.