[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 28 08:16:50 PDT 2024
================
@@ -1,9 +1,76 @@
-#include <stdio.h>
-#include <stdint.h>
-
-int main (int argc, char const *argv[])
-{
- const char* stringdata = "hello world; I like to write text in const char pointers";
- uint8_t bytedata[] = {0xAA,0xBB,0xCC,0xDD,0xEE,0xFF,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99};
- return 0; // break here
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <initializer_list>
+#include <iostream>
+
+#ifdef _WIN32
+#include "Windows.h"
+
+int getpagesize() {
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+ return system_info.dwPageSize;
+}
+
+char *allocate_memory_with_holes() {
+ int pagesize = getpagesize();
+ void *mem = VirtualAlloc(nullptr, 5 * pagesize, MEM_RESERVE, PAGE_NOACCESS);
+ if (!mem) {
+ std::cerr << std::system_category().message(GetLastError()) << std::endl;
+ exit(1);
+ }
+ char *bytes = static_cast<char *>(mem);
+ for (int page : {0, 2, 4}) {
+ if (!VirtualAlloc(bytes + page * pagesize, pagesize, MEM_COMMIT,
----------------
DavidSpickett wrote:
This would be good as a comment maybe at the start of the function to illustrate what the end result should be.
https://github.com/llvm/llvm-project/pull/104193
More information about the lldb-commits
mailing list