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