Linux 6.13-rc4
[linux.git] / arch / sh / kernel / ptrace.c
blobbfc59f2c2602f406ecc8ac0a0d97a148c06c2348
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/ptrace.h>
4 /**
5 * regs_query_register_offset() - query register offset from its name
6 * @name: the name of a register
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;
11 int regs_query_register_offset(const char *name)
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;
20 /**
21 * regs_query_register_name() - query register name from its offset
22 * @offset: the offset of a register in struct pt_regs.
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;
27 const char *regs_query_register_name(unsigned int offset)
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;