views:

143

answers:

2

I am debugging a networking code and want to print ip addresses which are declared as int32. when i print it using gdb print command, i get some values which is not much meaningful.

How can i possibly print them in meaningful format?

+1  A: 

Make a function that calls inet_ntoa, and then call it with the 'p' command in gdb on your int.

bmargulies
+6  A: 

Just use inet_ntoa(3) as so:

(gdb) p (char*)inet_ntoa(0x01234567)  # Replace with your IP address
$1 = 0xa000b660 "103.69.35.1"
Adam Rosenfield