1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
24 #include <data_pckts.h>
26 typedef struct Hwcntr_packet
27 { /* HW counter profiling packet */
29 uint32_t tag
; /* hw counter index, register */
30 uint64_t interval
; /* overflow value */
33 typedef struct MHwcntr_packet
34 { /* extended (superset) Hwcntr_packet */
36 uint32_t tag
; /* hw counter index, register */
37 uint64_t interval
; /* overflow value */
38 Vaddr_type ea_vaddr
; /* virtual addr causing HWC event */
39 Vaddr_type pc_vaddr
; /* candidate eventPC */
40 uint64_t ea_paddr
; /* physical address for ea_vaddr */
41 uint64_t pc_paddr
; /* physical address for pc_vaddr */
42 uint64_t ea_pagesz
; /* pagesz (bytes) for ea_paddr */
43 uint64_t pc_pagesz
; /* pagesz (bytes) for pc_paddr */
44 uint32_t ea_lgrp
; /* latency group of ea_paddr */
45 uint32_t pc_lgrp
; /* latency group of pc_paddr */
46 uint32_t lgrp_lwp
; /* locality group of lwp */
47 uint32_t lgrp_ps
; /* locality group of process */
48 uint64_t latency
; /* latency in cycles (sampling only) */
49 uint64_t data_source
; /* data source (sampling only) */
53 #define CONTEXT_PC MC_PC
54 #define CONTEXT_SP MC_O6
55 #define CONTEXT_FP MC_O7
56 #define SETFUNCTIONCONTEXT(ucp,funcp) \
57 (ucp)->uc_mcontext.gregs[CONTEXT_PC] = (greg_t)(funcp); \
58 (ucp)->uc_mcontext.gregs[CONTEXT_SP] = 0; \
59 (ucp)->uc_mcontext.gregs[CONTEXT_FP] = 0;
65 #define CONTEXT_PC REG_RIP
66 #define CONTEXT_FP REG_RBP
67 #define CONTEXT_SP REG_RSP
70 #define CONTEXT_PC REG_EIP
71 #define CONTEXT_FP REG_EBP
72 #define CONTEXT_SP REG_ESP
74 #define SETFUNCTIONCONTEXT(ucp,funcp) \
75 (ucp)->uc_mcontext.gregs[CONTEXT_PC] = (greg_t)(funcp); \
76 (ucp)->uc_mcontext.gregs[CONTEXT_SP] = 0; \
77 (ucp)->uc_mcontext.gregs[CONTEXT_FP] = 0;
83 #define SETFUNCTIONCONTEXT(ucp,funcp) \
84 (ucp)->uc_mcontext.regs[CONTEXT_PC] = (greg_t)(funcp); \
85 (ucp)->uc_mcontext.regs[CONTEXT_SP] = 0; \
86 (ucp)->uc_mcontext.regs[CONTEXT_FP] = 0;