Path: blob/master/tools/perf/arch/x86/util/unwind-libunwind.c
26292 views
// SPDX-License-Identifier: GPL-2.012#include <errno.h>3#include "../../util/debug.h"4#ifndef REMOTE_UNWIND_LIBUNWIND5#include <libunwind.h>6#include "perf_regs.h"7#include "../../util/unwind.h"8#endif910#ifdef HAVE_ARCH_X86_64_SUPPORT11int LIBUNWIND__ARCH_REG_ID(int regnum)12{13int id;1415switch (regnum) {16case UNW_X86_64_RAX:17id = PERF_REG_X86_AX;18break;19case UNW_X86_64_RDX:20id = PERF_REG_X86_DX;21break;22case UNW_X86_64_RCX:23id = PERF_REG_X86_CX;24break;25case UNW_X86_64_RBX:26id = PERF_REG_X86_BX;27break;28case UNW_X86_64_RSI:29id = PERF_REG_X86_SI;30break;31case UNW_X86_64_RDI:32id = PERF_REG_X86_DI;33break;34case UNW_X86_64_RBP:35id = PERF_REG_X86_BP;36break;37case UNW_X86_64_RSP:38id = PERF_REG_X86_SP;39break;40case UNW_X86_64_R8:41id = PERF_REG_X86_R8;42break;43case UNW_X86_64_R9:44id = PERF_REG_X86_R9;45break;46case UNW_X86_64_R10:47id = PERF_REG_X86_R10;48break;49case UNW_X86_64_R11:50id = PERF_REG_X86_R11;51break;52case UNW_X86_64_R12:53id = PERF_REG_X86_R12;54break;55case UNW_X86_64_R13:56id = PERF_REG_X86_R13;57break;58case UNW_X86_64_R14:59id = PERF_REG_X86_R14;60break;61case UNW_X86_64_R15:62id = PERF_REG_X86_R15;63break;64case UNW_X86_64_RIP:65id = PERF_REG_X86_IP;66break;67default:68pr_err("unwind: invalid reg id %d\n", regnum);69return -EINVAL;70}7172return id;73}74#else75int LIBUNWIND__ARCH_REG_ID(int regnum)76{77int id;7879switch (regnum) {80case UNW_X86_EAX:81id = PERF_REG_X86_AX;82break;83case UNW_X86_EDX:84id = PERF_REG_X86_DX;85break;86case UNW_X86_ECX:87id = PERF_REG_X86_CX;88break;89case UNW_X86_EBX:90id = PERF_REG_X86_BX;91break;92case UNW_X86_ESI:93id = PERF_REG_X86_SI;94break;95case UNW_X86_EDI:96id = PERF_REG_X86_DI;97break;98case UNW_X86_EBP:99id = PERF_REG_X86_BP;100break;101case UNW_X86_ESP:102id = PERF_REG_X86_SP;103break;104case UNW_X86_EIP:105id = PERF_REG_X86_IP;106break;107default:108pr_err("unwind: invalid reg id %d\n", regnum);109return -EINVAL;110}111112return id;113}114#endif /* HAVE_ARCH_X86_64_SUPPORT */115116117