Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print `errno` name instead of value in GDB

Tags:

gdb

errno

I wonder if there is any way to print errno symbolic name instead of just a number in GDB. For example, instead of

errno = 13

I would like to see something like

EACCES
like image 354
vharavy Avatar asked Jul 04 '12 18:07

vharavy


1 Answers

Assuming you have a recent GDB with embedded Python, you can use the Python interpreter to do what you want.

The following (untested) code should be about right:

(gdb) python import errno
(gdb) python print errno.errorcode[13]

You should be able to define a python command, e.g. perrno, that will cut down on typing. Documentation here.

like image 149
Employed Russian Avatar answered Nov 15 '22 08:11

Employed Russian