|
||||
File indexing completed on 2024-11-15 09:59:09
0001 0002 /*--------------------------------------------------------------------*/ 0003 /*--- Handle remote gdb protocol. pub_tool_gdbserver.h ---*/ 0004 /*--------------------------------------------------------------------*/ 0005 0006 /* 0007 This file is part of Valgrind, a dynamic binary instrumentation 0008 framework. 0009 0010 Copyright (C) 2011-2017 Philippe Waroquiers 0011 0012 This program is free software; you can redistribute it and/or 0013 modify it under the terms of the GNU General Public License as 0014 published by the Free Software Foundation; either version 2 of the 0015 License, or (at your option) any later version. 0016 0017 This program is distributed in the hope that it will be useful, but 0018 WITHOUT ANY WARRANTY; without even the implied warranty of 0019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0020 General Public License for more details. 0021 0022 You should have received a copy of the GNU General Public License 0023 along with this program; if not, see <http://www.gnu.org/licenses/>. 0024 0025 The GNU General Public License is contained in the file COPYING. 0026 */ 0027 0028 #ifndef __PUB_TOOL_GDBSERVER_H 0029 #define __PUB_TOOL_GDBSERVER_H 0030 0031 #include "pub_tool_basics.h" // VG_ macro 0032 0033 //-------------------------------------------------------------------- 0034 // PURPOSE: This module provides the support to have a gdb 0035 // connecting to a valgrind process using remote gdb protocol. It provides 0036 // * A function to allow a tool (or the valgrind core) to 0037 // wait for a gdb to connect and then handle gdb commands. 0038 // Typically, this can be used to let the user debug the process 0039 // when valgrind reports an error. 0040 // * A function allowing to instrument the code to support gdb breakpoints. 0041 // * A function allowing the tool to support watchpoints. 0042 // * A utility function to help implementing the processing of the 0043 // gdb_monitor_command strings. 0044 0045 0046 // Function to be used by tool or coregrind to allow a gdb to connect 0047 // to this process. 0048 // Calling VG_(gdbserver) with tid > 0 means to let a debugger attach 0049 // to the valgrind process. gdbserver will report to gdb that the 0050 // process stopped in thread tid. 0051 // Calling VG_(gdbserver) with tid == 0 indicates to close 0052 // the connection with GDB (if still open) and stop gdbserver. 0053 //-------------------------------------------------------------------- 0054 extern void VG_(gdbserver) ( ThreadId tid ); 0055 0056 /* defines the various kinds of breakpoints that gdbserver 0057 might ask to insert/remove. Note that the below matches 0058 the gdbserver protocol definition. The level of support 0059 of the various breakpoint kinds depends on the tool. 0060 0061 For the moment, it is unclear how a tool would implement 0062 hardware_breakpoint in valgrind :). 0063 0064 software_breakpoint implies some (small) specific 0065 instrumentation to be done for gdbserver. This instrumentation 0066 is implemented for all tools in m_translate.c. 0067 0068 write/read/access watchpoints can only be done by tools 0069 which are maintaining some notion of address accessibility 0070 as part of their instrumentation. watchpoints can then 0071 be done by marking the watched address(es) as not accessible. 0072 But instead of giving back an error (or whatever the tool 0073 wants to do with unaccessible mechanism), the tool must then 0074 just call gdbserver. See memcheck for an example of reusing 0075 accessibility for watchpoint support. 0076 */ 0077 typedef 0078 enum { 0079 software_breakpoint, 0080 hardware_breakpoint, 0081 write_watchpoint, 0082 read_watchpoint, 0083 access_watchpoint } PointKind; 0084 extern const HChar* VG_(ppPointKind) (PointKind kind); 0085 0086 0087 /* watchpoint support --------------------------------------*/ 0088 /* True if one or more bytes in [addr, addr+len[ are being watched by 0089 gdbserver for write or read or access. 0090 In addition, VG_(is_watched) will invoke gdbserver if 0091 the access provided by the tool matches the watchpoint kind. 0092 For this, the tool must pass the kind of access it has detected: 0093 write_watchpoint indicates the tool has detected a write 0094 read_watchpoint indicates the tool has detected a read 0095 access_watchpoint indicates the tool has detected an access but does 0096 not know if this is a read or a write 0097 */ 0098 extern Bool VG_(is_watched)(PointKind kind, Addr addr, Int szB); 0099 0100 extern void VG_(needs_watchpoint) ( 0101 // indicates the given Addr/len is being watched (insert) 0102 // or not watched anymore (! insert). 0103 // gdbserver will maintain the list of watched addresses. 0104 // The tool can use VG_(is_watched) to verify if an 0105 // access to an Addr is in one of the watched intervals. 0106 // Must return True if the watchpoint has been properly inserted or 0107 // removed. False if not supported. 0108 // Note that an address can only be watched for a single kind. 0109 // The tool must be ready to be called successively with 0110 // multiple kinds for the same addr and len and with 0111 // different kinds. The last kind must replace the previous values. 0112 // Behaviour with multiple watches having overlapping addr+len 0113 // is undefined. 0114 Bool (*watchpoint) (PointKind kind, Bool insert, Addr addr, SizeT len) 0115 ); 0116 0117 0118 // can be used during the processing of the VG_USERREQ__GDB_MONITOR_COMMAND 0119 // tool client request to output information to gdb or vgdb. 0120 // The output of VG_(gdb_printf) is not subject to 'output control' 0121 // by the user: e.g. the monitor command 'v.set log_output' has no effect. 0122 // The output of VG_(gdb_printf) is given to gdb/vgdb. The only case 0123 // in which this output is not given to gdb/vgdb is when the connection 0124 // with gdb/vgdb has been lost : in such a case, output is written 0125 // to the valgrind log output. 0126 // To produce some output which is subject to user output control via 0127 // monitor command v.set gdb_output or mixed output, use VG_(printf) 0128 // or VG_(umsg) or similar. 0129 // Typically, VG_(gdb_printf) has to be used when there is no point 0130 // having this output in the output log of Valgrind. Examples 0131 // is the monitor help output, or if vgdb is used to implement 0132 // 'tool control scripts' such as callgrind_control. 0133 extern UInt VG_(gdb_printf) ( const HChar *format, ... ) PRINTF_CHECK(1, 2); 0134 0135 /* Utility functions to (e.g.) parse gdb monitor commands. 0136 0137 keywords is a set of keywords separated by a space 0138 keyword_id will search for the keyword starting with the string input_word 0139 and return its position. 0140 It returns -1 if no keyword matches. 0141 It returns -2 if two or more keywords are starting with input_word 0142 and none of these matches exactly input_word 0143 Example with keywords = "hello world here is hell" : 0144 input_word result 0145 ---------- ------ 0146 paradise => -1 0147 i => 3 0148 hell => 4 0149 hel => -2 0150 ishtar => -1 0151 0152 report indicates when to output an error msg with VG_(gdb_printf). 0153 kwd_report_none : no error is reported. 0154 kwd_report_all : the error msg will show all possible keywords 0155 kwd_report_duplicated_matches : the error msg will show only the 0156 ambiguous matches. 0157 */ 0158 typedef 0159 enum { 0160 kwd_report_none, 0161 kwd_report_all, 0162 kwd_report_duplicated_matches } kwd_report_error; 0163 extern Int VG_(keyword_id) (const HChar* keywords, const HChar* input_word, 0164 kwd_report_error report); 0165 0166 /* Extract an address and (optionally) a size from the string 0167 currently being parsed by strtok_r (see pub_tool_libcbase.h). 0168 If no size in the string, keeps the current value of szB. 0169 If parsing is ok, 0170 returns True. 0171 If parsing is not ok; 0172 set *address and *szB to 0, 0173 reports problem to the user using VG_(gdb_printf) 0174 returns False. */ 0175 extern Bool VG_(strtok_get_address_and_size) (Addr* address, 0176 SizeT* szB, 0177 HChar **ssaveptr); 0178 0179 /* Print various statistics about Valgrind core, 0180 and optionally tool and memory statistics. */ 0181 extern void VG_(print_all_stats) (Bool memory_stats, Bool tool_stats); 0182 0183 #endif // __PUB_TOOL_GDBSERVER_H 0184 0185 /*--------------------------------------------------------------------*/ 0186 /*--- end ---*/ 0187 /*--------------------------------------------------------------------*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |