xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/search.h (revision d16b7486a53dcb8072b60ec6fcb4373a2d0c27b7)
1 /* Copyright (C) 2020-2023 Free Software Foundation, Inc.
2 
3    This file is part of GDB.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17 
18 #ifndef COMMON_SEARCH_H
19 #define COMMON_SEARCH_H
20 
21 #include "gdbsupport/function-view.h"
22 
23 /* This is needed by the unit test, so appears here.  */
24 #define SEARCH_CHUNK_SIZE 16000
25 
26 /* The type of a callback function that can be used to read memory.
27    Note that target_read_memory is not used here, because gdbserver
28    wants to be able to examine trace data when searching, and
29    target_read_memory does not do this.  */
30 
31 typedef bool target_read_memory_ftype (CORE_ADDR, gdb_byte *, size_t);
32 
33 /* Utility implementation of searching memory.  */
34 extern int simple_search_memory
35   (gdb::function_view<target_read_memory_ftype> read_memory,
36    CORE_ADDR start_addr,
37    ULONGEST search_space_len,
38    const gdb_byte *pattern,
39    ULONGEST pattern_len,
40    CORE_ADDR *found_addrp);
41 
42 #endif /* COMMON_SEARCH_H */
43