Save GDB Breakpoints

It wasn’t that long ago (well, okay, it was back in 2010, but anyway), that using the GDB debugger left you with the issue of how to maintain your breakpoints from one debug session to the next.

After carefully adding breakpoints, and spending time getting them in just the right place, it was a real headache to have to repeat that exercise the next time you ran a debug session – especially when you were dealing with one of those nefarious bugs that can take days to track down.

I used to list my breakpoints, copy and paste them to a file, then add them to the .gdbinit file for the next time I wanted to use them. Annoying.

Well, in case you’ve been doing the same, or if it never even occurred to you that you could preserve your perfectly positioned breakpoints between sessions, I thought I’d mention that since gdb 7.2 you’ve been able to save your breakpoints in one single step with the following command:

save breakpoints myfile.txt


And when you want to use them again, just import them with:

source myfile.txt

Here’s a quickie screenshot where I’ve added 4 breakpoints, saved them to a bp.txt file, deleted them, listed breakpoints to show none present, then re-added them and listed them to show them after import.

Great stuff :-)




C++ Eclipse Masterclass Now Open!


It’s HERE!

This morning at 9am GMT the C++ Eclipse Masterclass opened for enrolment. Hurrah!

I have poured my heart and soul into creating this course, and I am so proud to finally be launching it today.

It opens with an early bird discount which runs until midnight GMT on 1st June, so if you want to grab a bargain, act now!

If you have any questions, or feedback, please do get in touch.

And thank you, to all of my readers, for your ongoing support and enthusiasm. I wouldn’t be doing any of this without you.

atoi and itoa

atoi and iota seem like perfect partners.

atoi is the ‘ascii to integer’ function and itoa is the reverse, the ‘integer to ascii’ function.

You would use atoi to convert a string, say, “23557” to the actual integer 23557.

Similarly, you would use itoa to convert an integer, say 44711, to the equivalent string “44711”.

Very handy.

Now, if you’ve written a lot of code using Microsoft Visual C++ (which is where I first started when I was learning C and C++), you may not be aware of the fact that atoi is part of the ANSI standard, whereas itoa is not. The MSVC compiler supports itoa, so if you are coding on this platform – particularly if you are learning on this platform – then it appears that atoi and itoa are a complementary pair that would be available everywhere. Not so!

Read More »

Fibonacci | Recursively or Not?

You’re probably all aware of the Fibonacci number sequence. Starting with 0 and 1, the next number is determined by the sum of the previous two numbers, so the sequence begins:

0, 1, 1, 2, 3, 5, 8, 13, 21, …

This is a mathematical concept, and it is defined by a “recurrence relation” (that’s a fancy way of saying that each number (or ‘term’) is generated from a previously calculated value), of:

Fn = Fn-1 + Fn-2

with “seed” or starting values of:

F0 = 0 and F1 = 1.

So, as you can imagine, this seems to lend itself nicely to programmatic recursion. Here’s a little program that will give you the 40th number in the Fibonacci sequence, using recursion:

Read More »