[Lldb-commits] [PATCH] D130534: loading a binary at a slide multiple times leaves old entries in the SectionLoadList

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 21 13:51:57 PDT 2022


jasonmolenda updated this revision to Diff 462000.
jasonmolenda added a comment.

Getting back to this old patch.  When I lost track of it, @DavidSpickett was saying that the test case was still not clear -- I was loading a section at an address, checking that I could read values out of arrays, then setting the section to a different address and seeing that I could still read the value out of the arrays.  I added comments to these two key parts of the test file,

  # View the first element of `first` and `second` with
  # no slide applied, but with load address set.
  #
  # In memory, we have something like
  #    0x1000 - 0x17ff  first[]
  #    0x1800 - 0x1fff  second[]
  target.SetModuleLoadAddress(module, 0)
  self.expect("p/d ((int*)&first)[0]", substrs=['= 5'])
  self.expect("p/d ((int*)&second)[0]", substrs=['= 6'])
  self.assertEqual(first_sym.GetStartAddress().GetLoadAddress(target), 
                   first_sym.GetStartAddress().GetFileAddress())
  self.assertEqual(second_sym.GetStartAddress().GetLoadAddress(target),
                   second_sym.GetStartAddress().GetFileAddress())
  
  # Slide it a little bit less than the size of the first array.
  #
  # In memory, we have something like
  #    0xfc0 - 0x17bf  first[]
  #    0x17c0 - 0x1fbf second[]
  #
  # but if the original entries are still present in lldb, 
  # the beginning address of second[] will get a load address
  # of 0x1800, instead of 0x17c0 (0x1800-64) as we need to get.
  target.SetModuleLoadAddress(module, first_size - 64)
  self.expect("p/d ((int*)&first)[0]", substrs=['= 5'])
  self.expect("p/d ((int*)&second)[0]", substrs=['= 6'])
  self.assertNotEqual(first_sym.GetStartAddress().GetLoadAddress(target), 
                   first_sym.GetStartAddress().GetFileAddress())
  self.assertNotEqual(second_sym.GetStartAddress().GetLoadAddress(target),
                   second_sym.GetStartAddress().GetFileAddress())

The inferior is never actually run, so I can change the load addresses of the sections around and it ultimately should read the data out of the file on disk every time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130534/new/

https://reviews.llvm.org/D130534

Files:
  lldb/source/Target/SectionLoadList.cpp
  lldb/test/API/functionalities/multiple-slides/Makefile
  lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
  lldb/test/API/functionalities/multiple-slides/main.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130534.462000.patch
Type: text/x-patch
Size: 5579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220921/72bb8fc8/attachment.bin>


More information about the lldb-commits mailing list