search.h 1.5 KB

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