1b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov/* Definitions of interface to the "low" (arch specific) functions 2b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov needed for interfacing the Valgrind gdbserver with the Valgrind 3b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov guest. 4b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 5436e89c602e787e7a27dd6624b09beed41a0da8aDmitriy Ivanov Copyright (C) 2011, 2012 6b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov Free Software Foundation, Inc. 7b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 8b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov This file has been inspired from a file that is part of GDB. 9b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov It has been modified to integrate it in valgrind 10b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 11b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov This program is free software; you can redistribute it and/or modify 12b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov it under the terms of the GNU General Public License as published by 13b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov the Free Software Foundation; either version 2 of the License, or 14b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov (at your option) any later version. 15b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 16b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov This program is distributed in the hope that it will be useful, 17b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov but WITHOUT ANY WARRANTY; without even the implied warranty of 18b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov GNU General Public License for more details. 20b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 21b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov You should have received a copy of the GNU General Public License 22b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov along with this program; if not, write to the Free Software 23b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov Foundation, Inc., 51 Franklin Street, Fifth Floor, 24b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov Boston, MA 02110-1301, USA. */ 25b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 26b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#ifndef VALGRIND_LOW_H 27b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#define VALGRIND_LOW_H 28b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 29436e89c602e787e7a27dd6624b09beed41a0da8aDmitriy Ivanov#include "pub_core_basics.h" // ThreadId 30436e89c602e787e7a27dd6624b09beed41a0da8aDmitriy Ivanov#include "server.h" // CORE_ADDR 31436e89c602e787e7a27dd6624b09beed41a0da8aDmitriy Ivanov 32b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov/* defines the characteristics of the "low" valgrind target architecture. 33b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov In other words, struct valgrind_target_ops defines the functions and 34b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov data which are specific to the architecture (x86 or amd64 or 35b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov ppc32 or ...). */ 36b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovstruct valgrind_target_ops 37b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov{ 38b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov int num_regs; 39b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov struct reg *reg_defs; 40b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 41b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov int stack_pointer_regno; 42b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov /* register number of the stack pointer register */ 43b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 44b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov /* transfer the register regno from/to valgrind (guest state) 45b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov to/from buf 46b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov according to transfer_direction. 47b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov *mod set to True if destination content is modified by the transfer 48b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov otherwise it is set to False. */ 49b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov void (*transfer_register) (ThreadId tid, int regno, void * buf, 50b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov transfer_direction dir, int size, Bool *mod); 51b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 52b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 53b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov CORE_ADDR (*get_pc) (void); 54b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov void (*set_pc) (CORE_ADDR newpc); 55b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 56b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov /* What string to report to GDB when it asks for the architecture, 57b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov or NULL not to answer. */ 58b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov const char *arch_string; 59b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 60663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng /* Returns the target xml description of the set of registers. 61b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov For some architectures (e.g. arm), it is mandatory 62b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov to give a description of the registers, otherwise 63b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov gdb does not understand the reply to the 'g' packet 64663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng (which is used to get the registers). 65663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng If shadow_mode, returns a target xml description 66663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng including the two shadow registers sets. 67663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng This is mandatory to use the option --vgdb-shadow-registers=yes. 68663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Returns NULL if there is no target xml file*/ 69436e89c602e787e7a27dd6624b09beed41a0da8aDmitriy Ivanov const char* (*target_xml) (Bool shadow_mode); 70b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 71b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov}; 72b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 73b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovextern void x86_init_architecture (struct valgrind_target_ops *target); 74b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovextern void amd64_init_architecture (struct valgrind_target_ops *target); 75b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovextern void arm_init_architecture (struct valgrind_target_ops *target); 76436e89c602e787e7a27dd6624b09beed41a0da8aDmitriy Ivanovextern void arm64_init_architecture (struct valgrind_target_ops *target); 77b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovextern void ppc32_init_architecture (struct valgrind_target_ops *target); 78b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovextern void ppc64_init_architecture (struct valgrind_target_ops *target); 79b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovextern void s390x_init_architecture (struct valgrind_target_ops *target); 80663860b1408516d02ebfcb3a9999a134e6cfb223Ben Chengextern void mips32_init_architecture (struct valgrind_target_ops *target); 81436e89c602e787e7a27dd6624b09beed41a0da8aDmitriy Ivanovextern void mips64_init_architecture (struct valgrind_target_ops *target); 82b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 83b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#endif 84