xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/search.h (revision 5ba1f45f2a09259cc846f20c7c5501604d633c90)
1*5ba1f45fSchristos /* Copyright (C) 2020-2024 Free Software Foundation, Inc.
24b169a6bSchristos 
34b169a6bSchristos    This file is part of GDB.
44b169a6bSchristos 
54b169a6bSchristos    This program is free software; you can redistribute it and/or modify
64b169a6bSchristos    it under the terms of the GNU General Public License as published by
74b169a6bSchristos    the Free Software Foundation; either version 3 of the License, or
84b169a6bSchristos    (at your option) any later version.
94b169a6bSchristos 
104b169a6bSchristos    This program is distributed in the hope that it will be useful,
114b169a6bSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
124b169a6bSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
134b169a6bSchristos    GNU General Public License for more details.
144b169a6bSchristos 
154b169a6bSchristos    You should have received a copy of the GNU General Public License
164b169a6bSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
174b169a6bSchristos 
184b169a6bSchristos #ifndef COMMON_SEARCH_H
194b169a6bSchristos #define COMMON_SEARCH_H
204b169a6bSchristos 
214b169a6bSchristos #include "gdbsupport/function-view.h"
224b169a6bSchristos 
234b169a6bSchristos /* This is needed by the unit test, so appears here.  */
244b169a6bSchristos #define SEARCH_CHUNK_SIZE 16000
254b169a6bSchristos 
264b169a6bSchristos /* The type of a callback function that can be used to read memory.
274b169a6bSchristos    Note that target_read_memory is not used here, because gdbserver
284b169a6bSchristos    wants to be able to examine trace data when searching, and
294b169a6bSchristos    target_read_memory does not do this.  */
304b169a6bSchristos 
314b169a6bSchristos typedef bool target_read_memory_ftype (CORE_ADDR, gdb_byte *, size_t);
324b169a6bSchristos 
334b169a6bSchristos /* Utility implementation of searching memory.  */
344b169a6bSchristos extern int simple_search_memory
354b169a6bSchristos   (gdb::function_view<target_read_memory_ftype> read_memory,
364b169a6bSchristos    CORE_ADDR start_addr,
374b169a6bSchristos    ULONGEST search_space_len,
384b169a6bSchristos    const gdb_byte *pattern,
394b169a6bSchristos    ULONGEST pattern_len,
404b169a6bSchristos    CORE_ADDR *found_addrp);
414b169a6bSchristos 
424b169a6bSchristos #endif /* COMMON_SEARCH_H */
43