Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of all (integer) constants for various types

Does there exist some kind of service, where I can input a system "enum type" (or similar) and get a list of all the possible values?

When debugging with gdb and you encounter an error, it would be nice to quickly get the name of the error, without having to look through related headers files of the header file where the type is defined.

For example the type kern_return_t in OS X is defined in /usr/include/mach/i386/kern_return.h which basically only contains one line of content (no includes):

typedef int     kern_return_t;

The valid values are defined in /usr/include/mach/kern_return.h, which makes sense, but I can never remember this path and I would like to speed up this process.

Example:

Input: kern_return_t

Output:

0 | KERN_SUCCESS
1 | KERN_INVALID_ADDRESS
2 | KERN_PROTECTION_FAILURE
3 | KERN_NO_SPACE
4 | KERN_INVALID_ARGUMENT
5 | KERN_FAILURE
6 | KERN_RESOURCE_SHORTAGE
7 | KERN_NOT_RECEIVER
8 | KERN_NO_ACCESS
9 | KERN_MEMORY_FAILURE
...
like image 934
Tyilo Avatar asked Sep 20 '13 20:09

Tyilo


1 Answers

This is what open -h was made for. I recommend combining it with -s however, like so:

$ open -s iOS -h kern_return
kern_return?
[0] cancel
[1] all

[2] /usr/include/mach/i386/kern_return.h
[3] /usr/include/mach/kern_return.h
[4] /usr/include/mach/machine/kern_return.h
[5] /System/Library/Frameworks/Kernel.framework/Headers/mach/i386/kern_return.h
[6] /System/Library/Frameworks/Kernel.framework/Headers/mach/kern_return.h
[7] /System/Library/Frameworks/Kernel.framework/Headers/mach/machine/kern_return.h

Which header(s) for "kern_return"?
like image 190
Colin Barrett Avatar answered Oct 13 '22 14:10

Colin Barrett