• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Definitions of interface to the "low" (arch specific) functions
2    needed for interfacing the Valgrind gdbserver with the Valgrind
3    guest.
4 
5    Copyright (C) 2011
6    Free Software Foundation, Inc.
7 
8    This file has been inspired from a file that is part of GDB.
9    It has been modified to integrate it in valgrind
10 
11    This program is free software; you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 2 of the License, or
14    (at your option) any later version.
15 
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20 
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 51 Franklin Street, Fifth Floor,
24    Boston, MA 02110-1301, USA.  */
25 
26 #ifndef VALGRIND_LOW_H
27 #define VALGRIND_LOW_H
28 
29 /* defines the characteristics of the "low" valgrind target architecture.
30    In other words, struct valgrind_target_ops defines the functions and
31    data which are specific to the architecture (x86 or amd64 or
32    ppc32 or ...). */
33 struct valgrind_target_ops
34 {
35    int num_regs;
36    struct reg *reg_defs;
37 
38    int stack_pointer_regno;
39    /* register number of the stack pointer register */
40 
41    /* transfer the register regno from/to valgrind (guest state)
42       to/from buf
43       according to transfer_direction.
44       *mod set to True if destination content is modified by the transfer
45       otherwise it is set to False. */
46    void (*transfer_register) (ThreadId tid, int regno, void * buf,
47                               transfer_direction dir, int size, Bool *mod);
48 
49 
50    CORE_ADDR (*get_pc) (void);
51    void (*set_pc) (CORE_ADDR newpc);
52 
53    /* What string to report to GDB when it asks for the architecture,
54       or NULL not to answer.  */
55    const char *arch_string;
56 
57    /* Description of the set of registers.
58       For some architectures (e.g. arm), it is mandatory
59       to give a description of the registers, otherwise
60       gdb does not understand the reply to the 'g' packet
61       (which is used to get the registers). */
62    const char *target_xml;
63 
64    /* Same as target_xml, but describes also the two shadow
65       registers set.
66       This is mandatory to use the option --vgdb-shadow-registers=yes. */
67    const char *shadow_target_xml;
68 };
69 
70 
71 /* convert from CORE_ADDR to void* */
72 extern void* C2v(CORE_ADDR addr);
73 
74 /* builds an image of bin according to byte order of the architecture
75    Useful for register and int image */
76 extern char* heximage (char *buf, char *bin, int count);
77 
78 /* returns a pointer to the architecture state corresponding to
79    the provided register set: 0 => normal guest registers,
80                               1 => shadow1
81                               2 => shadow2 */
82 VexGuestArchState* get_arch (int set, ThreadState* tst);
83 
84 extern void x86_init_architecture (struct valgrind_target_ops *target);
85 extern void amd64_init_architecture (struct valgrind_target_ops *target);
86 extern void arm_init_architecture (struct valgrind_target_ops *target);
87 extern void ppc32_init_architecture (struct valgrind_target_ops *target);
88 extern void ppc64_init_architecture (struct valgrind_target_ops *target);
89 extern void s390x_init_architecture (struct valgrind_target_ops *target);
90 
91 #endif
92