brintos

brintos / linux-shallow public Read only

0
0
Text · 1.2 KiB · 0f6ebc3 Raw
45 lines · c
1// SPDX-License-Identifier: GPL-2.02/*3 * dwarf-regs.c : Mapping of DWARF debug register numbers into register names.4 *5 * Copyright (C) 2020-2023 Loongson Technology Corporation Limited6 */7 8#include <stdio.h>9#include <errno.h> /* for EINVAL */10#include <string.h> /* for strcmp */11#include <dwarf-regs.h>12 13struct pt_regs_dwarfnum {14	const char *name;15	unsigned int dwarfnum;16};17 18static struct pt_regs_dwarfnum loongarch_gpr_table[] = {19	{"%r0", 0}, {"%r1", 1}, {"%r2", 2}, {"%r3", 3},20	{"%r4", 4}, {"%r5", 5}, {"%r6", 6}, {"%r7", 7},21	{"%r8", 8}, {"%r9", 9}, {"%r10", 10}, {"%r11", 11},22	{"%r12", 12}, {"%r13", 13}, {"%r14", 14}, {"%r15", 15},23	{"%r16", 16}, {"%r17", 17}, {"%r18", 18}, {"%r19", 19},24	{"%r20", 20}, {"%r21", 21}, {"%r22", 22}, {"%r23", 23},25	{"%r24", 24}, {"%r25", 25}, {"%r26", 26}, {"%r27", 27},26	{"%r28", 28}, {"%r29", 29}, {"%r30", 30}, {"%r31", 31},27	{NULL, 0}28};29 30const char *get_arch_regstr(unsigned int n)31{32	n %= 32;33	return loongarch_gpr_table[n].name;34}35 36int regs_query_register_offset(const char *name)37{38	const struct pt_regs_dwarfnum *roff;39 40	for (roff = loongarch_gpr_table; roff->name != NULL; roff++)41		if (!strcmp(roff->name, name))42			return roff->dwarfnum;43	return -EINVAL;44}45