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

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 22 08:28:40 PDT 2023

JDevlieghere 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)
Can you call `obj_dir.cleanup()`, or better, can you wrap this in a `with tempfile.TemporaryDirectory() as obj_dir:`?

Comment at: lldb/examples/python/scripted_process/crashlog_scripted_process.py:41
+        obj_dir = tempfile.TemporaryDirectory()
         for image in self.crashlog.images:
Same comment/question here.

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.'''
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:`. 

  rG LLVM Github Monorepo



More information about the lldb-commits mailing list