[Lldb-commits] [PATCH] D47508: [lldb-test] Add a testing harness for the JIT's IRMemoryMap

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 30 02:16:30 PDT 2018


labath added a comment.

The idea that came to me while looking at this is testing this gdb-client style. This would allow you to mock the server responses to allocation and e.g. test handling of allocation failures. However, the problem is these tests sit on top of SBAPI and  there seems to be no way to  issue "raw" allocation requests through that (although maybe there is a case to be made for SBProcess.AllocateMemory as a generally useful API).

However, if this does the job you want, then I'm fine with that too.



================
Comment at: tools/lldb-test/lldb-test.cpp:503
+  uint8_t Alignment;
+  int Matches = sscanf(Line.data(), "malloc %lu %hhu", &Size, &Alignment);
+  if (Matches != 2)
----------------
is `Line` null-terminated here? Also a size_t arg should have a `%zu` modifier, but I am not sure if all msvc versions support that. It might be best to make the type uint64_t and then use SCNu64.


================
Comment at: tools/lldb-test/lldb-test.cpp:536-542
+  bool Overlaps = AllocatedIntervals.lookup(Addr, false);
+  if (Size && !Overlaps)
+    Overlaps = AllocatedIntervals.lookup(Addr + Size - 1, false);
+  if (Overlaps) {
+    outs() << "Malloc error: overlapping allocation detected\n";
+    exit(1);
+  }
----------------
It looks like this won't detect the case when a larger interval is placed on top of a smaller one (e.g. `0x1000-0x4000` and `0x2000-0x3000`).


https://reviews.llvm.org/D47508





More information about the lldb-commits mailing list