[Lldb-commits] [PATCH] D151045: [lldb/crashlog] Remove tempfile prefix from inlined symbol object file

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 22 13:02:56 PDT 2023


bulbazord added inline comments.


================
Comment at: lldb/examples/python/crashlog.py:1165-1168
+        if os.path.isdir(obj_dir.name):
+            for file in os.listdir(obj_dir.name):
+                os.unlink(os.path.join(obj_dir.name, file))
+            os.rmdir(obj_dir.name)
----------------
JDevlieghere wrote:
> Can you call `obj_dir.cleanup()`, or better, can you wrap this in a `with tempfile.TemporaryDirectory() as obj_dir:`?
+1


================
Comment at: lldb/examples/python/symbolication.py:371
 
-    def add_module(self, target):
+    def add_module(self, target, obj_dir=tempfile.TemporaryDirectory()):
         '''Add the Image described in this object to "target" and load the sections if "load" is True.'''
----------------
JDevlieghere wrote:
> If the `obj_dir` is created this way, it will never be removed. Is anyone relying on the default argument? If not I would make it `None` and change the check on line 387 to `if obj_dir:`. 
+1 on this, we need to cleanup resources.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151045



More information about the lldb-commits mailing list