FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / coregrind / m_gdbserver / valgrind_low.h
blobd8ae3c908616b6f25b7828998e99d172e4c3eed3
1 /* Definitions of interface to the "low" (arch specific) functions
2 needed for interfacing the Valgrind gdbserver with the Valgrind
3 guest.
5 Copyright (C) 2011, 2012
6 Free Software Foundation, Inc.
8 This file has been inspired from a file that is part of GDB.
9 It has been modified to integrate it in valgrind
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.
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.
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. */
26 #ifndef VALGRIND_LOW_H
27 #define VALGRIND_LOW_H
29 #include "pub_core_basics.h" // ThreadId
30 #include "server.h" // CORE_ADDR
32 /* defines the characteristics of the "low" valgrind target architecture.
33 In other words, struct valgrind_target_ops defines the functions and
34 data which are specific to the architecture (x86 or amd64 or
35 ppc32 or ...). */
36 struct valgrind_target_ops
38 int num_regs;
40 int stack_pointer_regno;
41 /* register number of the stack pointer register */
43 struct reg *reg_defs;
45 /* transfer the register regno from/to valgrind (guest state)
46 to/from buf
47 according to transfer_direction.
48 *mod set to True if destination content is modified by the transfer
49 otherwise it is set to False. */
50 void (*transfer_register) (ThreadId tid, int regno, void * buf,
51 transfer_direction dir, int size, Bool *mod);
54 CORE_ADDR (*get_pc) (void);
55 void (*set_pc) (CORE_ADDR newpc);
57 /* What string to report to GDB when it asks for the architecture,
58 or NULL not to answer. */
59 const char *arch_string;
61 /* Returns the target xml description of the set of registers.
62 For some architectures (e.g. arm), it is mandatory
63 to give a description of the registers, otherwise
64 gdb does not understand the reply to the 'g' packet
65 (which is used to get the registers).
66 If shadow_mode, returns a target xml description
67 including the two shadow registers sets.
68 This is mandatory to use the option --vgdb-shadow-registers=yes.
69 Returns NULL if there is no target xml file*/
70 const char* (*target_xml) (Bool shadow_mode);
72 /* Returns the address in the thread control block where dtv is found.
73 Return NULL if an error occurs or no support for tls/dtv is available.
74 Note that the addressability of the returned result has not been
75 verified. In other words, target_get_dtv just adds some magic
76 offset to the arch specific thread register or thread pointer or ...
78 The implementation of this is of course depending on the arch
79 but also depends on the way pthread lib arranges its data.
80 For background info about tls handling, read
81 'ELF Handling For Thread-Local Storage'
82 http://www.akkadia.org/drepper/tls.pdf
83 (slightly obsolete e.g. the size of a dtv entry is 2 words now).
84 The reference is the glibc source, in particular the arch specific
85 file tls.h.
87 For platforms where the dtv is located in the tcb, the magic offset
88 to add to the thread pointer/register/... can be found by doing:
89 cd none/tests
90 gdb ./tls
91 set debug-file-directory /usr/lib/debug # or equivalent
92 start
93 p &((struct pthread*)0x0)->header.dtv
94 Currently the dtv offset is hardcoded, based on the assumption
95 that this is relatively stable. If that would be false, then
96 getoff-<platform> should be modified to output this offset e.g.
97 depending on the glibc version. */
98 CORE_ADDR** (*target_get_dtv)(ThreadState *tst);
102 extern void x86_init_architecture (struct valgrind_target_ops *target);
103 extern void amd64_init_architecture (struct valgrind_target_ops *target);
104 extern void arm_init_architecture (struct valgrind_target_ops *target);
105 extern void arm64_init_architecture (struct valgrind_target_ops *target);
106 extern void ppc32_init_architecture (struct valgrind_target_ops *target);
107 extern void ppc64_init_architecture (struct valgrind_target_ops *target);
108 extern void s390x_init_architecture (struct valgrind_target_ops *target);
109 extern void mips32_init_architecture (struct valgrind_target_ops *target);
110 extern void mips64_init_architecture (struct valgrind_target_ops *target);
111 extern void nanomips_init_architecture (struct valgrind_target_ops *target);
113 #endif