[Lldb-commits] [PATCH] D105389: [lldb] Add AllocateMemory/DeallocateMemory to the SBProcess API

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 6 14:07:27 PDT 2021


jingham added a comment.

Could you put a docstring describing the API's in the SBProcess.i file.  It is annoying to have to do this in two places but given the way SWIG works we don't have a better alternative.  This is where the help in the Python REPL comes from so it's useful to have it there.  There are other example of how to do this in the .i file.  Thanks!

It might also be good to test that the program can read from the newly allocated memory by, for instance, having a function in the program that returns the first character from a pointer passed in.  You could call that using expr and you should also get 'a'...  You could write another function that tries to write to that memory to test that setting the permissions to not writable works.



================
Comment at: lldb/test/API/python_api/process/TestProcessAPI.py:405-420
+        exe = self.getBuildArtifact("a.out")
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
+        self.assertTrue(breakpoint, VALID_BREAKPOINT)
----------------
This can all be done more compactly by using lldbutil.run_to_source_breakpoint.    The other tests in this test file are using the by-hand way of doing this, if you want to fix them as well, that would be great.  But at least, we're trying not to write new tests this way.


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

https://reviews.llvm.org/D105389



More information about the lldb-commits mailing list