1 // SPDX-License-Identifier: GPL-2.0 2 #include <linux/ptrace.h> 3 4 /** 5 * regs_query_register_offset() - query register offset from its name 6 * @name: the name of a register 7 * 8 * regs_query_register_offset() returns the offset of a register in struct 9 * pt_regs from its name. If the name is invalid, this returns -EINVAL; 10 */ regs_query_register_offset(const char * name)11int regs_query_register_offset(const char *name) 12 { 13 const struct pt_regs_offset *roff; 14 for (roff = regoffset_table; roff->name != NULL; roff++) 15 if (!strcmp(roff->name, name)) 16 return roff->offset; 17 return -EINVAL; 18 } 19 20 /** 21 * regs_query_register_name() - query register name from its offset 22 * @offset: the offset of a register in struct pt_regs. 23 * 24 * regs_query_register_name() returns the name of a register from its 25 * offset in struct pt_regs. If the @offset is invalid, this returns NULL; 26 */ regs_query_register_name(unsigned int offset)27const char *regs_query_register_name(unsigned int offset) 28 { 29 const struct pt_regs_offset *roff; 30 for (roff = regoffset_table; roff->name != NULL; roff++) 31 if (roff->offset == offset) 32 return roff->name; 33 return NULL; 34 } 35