Path: blob/master/tools/perf/arch/x86/util/dwarf-regs.c
10825 views
/*1* dwarf-regs.c : Mapping of DWARF debug register numbers into register names.2* Extracted from probe-finder.c3*4* Written by Masami Hiramatsu <[email protected]>5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.19*20*/2122#include <libio.h>23#include <dwarf-regs.h>2425/*26* Generic dwarf analysis helpers27*/2829#define X86_32_MAX_REGS 830const char *x86_32_regs_table[X86_32_MAX_REGS] = {31"%ax",32"%cx",33"%dx",34"%bx",35"$stack", /* Stack address instead of %sp */36"%bp",37"%si",38"%di",39};4041#define X86_64_MAX_REGS 1642const char *x86_64_regs_table[X86_64_MAX_REGS] = {43"%ax",44"%dx",45"%cx",46"%bx",47"%si",48"%di",49"%bp",50"%sp",51"%r8",52"%r9",53"%r10",54"%r11",55"%r12",56"%r13",57"%r14",58"%r15",59};6061/* TODO: switching by dwarf address size */62#ifdef __x86_64__63#define ARCH_MAX_REGS X86_64_MAX_REGS64#define arch_regs_table x86_64_regs_table65#else66#define ARCH_MAX_REGS X86_32_MAX_REGS67#define arch_regs_table x86_32_regs_table68#endif6970/* Return architecture dependent register string (for kprobe-tracer) */71const char *get_arch_regstr(unsigned int n)72{73return (n <= ARCH_MAX_REGS) ? arch_regs_table[n] : NULL;74}757677