Friday, 11 October 2013

GDB and the shell game

Sometimes, a good thing can be too good, and so it is with GDB's pretty printing of strings.

I spent quite some time trying to figure out why GDB showed me "\"AA" and not (as expected) "AA" or, even just "\"AA"\". 

To cut a long story short, svn_cstring_split() doesn't do strings with spaces inside strings many favours, and so, "AA BB CC" ends up as 3 elements, '"AA', 'BB' and 'CC"' respectively, which then ends up as "\"AA", "BB" and "CC"\" in the GDB display.

I didn't think that GDB would pretty print anything let alone decorate strings with escaping slashes... and so wondered for quite a while where the extra "\ went! :-D

I should have employed this kitty to help me here: