================ @@ -141,13 +141,56 @@ struct RecordReplayTy { if (Err) report_fatal_error("Error retrieving data for target pointer"); - StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize); std::error_code EC; raw_fd_ostream OS(Filename, EC); if (EC) report_fatal_error("Error dumping memory to file " + Filename + " :" + EC.message()); - OS << DeviceMemory; + + if (saveDiff) { + // Get the pre-record memory filename + SmallString<128> InputFilename = {Filename.split('.').first, ".memory"}; + // read the pre-record memorydump + auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename); + if (std::error_code EC = InputFileBuffer.getError()) + report_fatal_error("Error reading pre-record device memory"); + + StringRef InputBufferContents = (*InputFileBuffer)->getBuffer(); + if (InputBufferContents.size() != MemorySize) + report_fatal_error("Error: Pre-record device memory size mismatch"); + + // get current memory contents + StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(), + DeviceMemoryMB.get()->getBuffer().size()); + + // compare pre-record memorydump to current contents + size_t i = 0; + while (i < MemorySize) { + // if mismatch found, create a new diff line + // current format - location, size, differences ... + if (InputBufferContents[i] != DeviceMemoryContents[i]) { + OS << i << " "; // marks the start offset + SmallVector<uint8_t, 128> modified; ---------------- ggeorgakoudis wrote:
rename modified -> Modified https://github.com/llvm/llvm-project/pull/70667 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits