Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "\b" mean in gdb string print output?

Tags:

c

gdb

When I issue the command p buf on a buffer buf which contains nonprintable characters, I usually get octal output when gdb is trying to print a nonprintable character.

However, this time I got a string like this.

foobar\341\204\004\b\357\373\377\277

What does the \b mean here?

like image 507
merlin2011 Avatar asked Apr 17 '13 05:04

merlin2011


2 Answers

\b is the backspace character (\010 if you're using ASCII).

Here are the rest of the escape sequences as defined by the C standard (5.2.2 Character display semantics):

2 Alphabetic escape sequences representing nongraphic characters in the execution character set are intended to produce actions on display devices as follows:

\a (alert) Produces an audible or visible alert without changing the active position.

\b (backspace) Moves the active position to the previous position on the current line. If the active position is at the initial position of a line, the behavior of the display device is unspecified.

\f (form feed) Moves the active position to the initial position at the start of the next logical page.

\n (new line) Moves the active position to the initial position of the next line.

\r (carriage return) Moves the active position to the initial position of the current line.

\t (horizontal tab) Moves the active position to the next horizontal tabulation position on the current line. If the active position is at or past the last defined horizontal tabulation position, the behavior of the display device is unspecified.

\v (vertical tab) Moves the active position to the initial position of the next vertical tabulation position. If the active position is at or past the last defined vertical tabulation position, the behavior of the display device is unspecified.

like image 99
NPE Avatar answered Nov 01 '22 20:11

NPE


The \b denotes the backspace ASCII character (whose code is 8 or \010 in octal)

like image 27
Basile Starynkevitch Avatar answered Nov 01 '22 21:11

Basile Starynkevitch