Add support for the Linux io_uring system calls
[valgrind.git] / coregrind / vgdb.h
blob4ca765ef50f8bfddada2b6d95d43b23d352266d8
2 /*--------------------------------------------------------------------*/
3 /*--- Declarations common for vgdb and implementations ---*/
4 /*--- of vgdb-invoker. vgdb.h ---*/
5 /*--------------------------------------------------------------------*/
7 /*
8 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
11 Copyright (C) 2011-2017 Philippe Waroquiers
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __VGDB_H
30 #define __VGDB_H
32 #include "pub_core_basics.h"
33 #include "pub_core_vki.h"
34 #include "pub_core_gdbserver.h"
36 #include <sys/types.h>
38 extern int debuglevel;
39 extern struct timeval dbgtv;
40 /* if level <= debuglevel, print timestamp, then print provided by debug info */
41 #define DEBUG(level, ...) (level <= debuglevel ? \
42 gettimeofday(&dbgtv, NULL), \
43 fprintf(stderr, "%ld.%6.6ld ", \
44 (long int)dbgtv.tv_sec, \
45 (long int)dbgtv.tv_usec), \
46 fprintf(stderr, __VA_ARGS__),fflush(stderr) \
47 : 0)
49 /* same as DEBUG but does not print time stamp info */
50 #define PDEBUG(level, ...) (level <= debuglevel ? \
51 fprintf(stderr, __VA_ARGS__),fflush(stderr) \
52 : 0)
54 /* if errno != 0,
55 report the errno and fprintf the ... varargs on stderr. */
56 #define ERROR(errno, ...) ((errno == 0 ? 0 : perror("syscall failed")), \
57 fprintf(stderr, __VA_ARGS__), \
58 fflush(stderr))
59 /* same as ERROR, but also exits with status 1 */
60 #define XERROR(errno, ...) ((errno == 0 ? 0 : perror("syscall failed")), \
61 fprintf(stderr, __VA_ARGS__), \
62 fflush(stderr), \
63 exit(1))
65 /* Calls malloc (size). Exits if memory can't be allocated. */
66 extern void *vmalloc(size_t size);
67 /* Calls realloc (size). Exits if memory can't be allocated. */
68 extern void *vrealloc(void *ptr,size_t size);
70 /* Will be set to True when any condition indicating we have to shutdown
71 is encountered. */
72 extern Bool shutting_down;
74 extern VgdbShared32 *shared32;
75 extern VgdbShared64 *shared64;
77 /*--------------------------------------------------------------------*/
78 /*--- Below is vgdb-invoker interface which must be implemented by ---*/
79 /*--- all vgdb-invoker implementations. ---*/
80 /*--------------------------------------------------------------------*/
82 /* Possibly produces additional usage information documenting the
83 invoker restrictions. */
84 void invoker_restrictions_msg(void);
86 /* Restore the registers to the saved value, then detaches from all threads.
87 Used as a cleanup handler for thread cancellation. */
88 void invoker_cleanup_restore_and_detach(void *v_pid);
90 /* Ensures that the gdbserver code is invoked by pid.
91 If an error occurs, resets the valgrind process
92 to the state it had before being invoked.
93 Returns True if invoke successful, False otherwise. */
94 Bool invoker_invoke_gdbserver(pid_t pid);
96 /* Called when connection with valgrind is lost. In case we
97 have lost the connection, it means that Valgrind has closed the
98 connection and is busy exiting. We can't and don't have to stop it in
99 this case. */
100 void invoker_valgrind_dying(void);
102 #endif // __VGDB_H
104 /*--------------------------------------------------------------------*/
105 /*--- end ---*/
106 /*--------------------------------------------------------------------*/