aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlldb/examples/python/crashlog.py14
-rw-r--r--lldb/examples/python/scripted_process/crashlog_scripted_process.py23
-rwxr-xr-xlldb/examples/python/symbolication.py9
3 files changed, 27 insertions, 19 deletions
diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py
index d207af1..7bfa402 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -40,6 +40,7 @@ import shlex
import string
import subprocess
import sys
+import tempfile
import threading
import time
import uuid
@@ -1154,12 +1155,17 @@ def SymbolicateCrashLog(crash_log, options):
futures = []
loaded_images = []
with concurrent.futures.ThreadPoolExecutor() as executor:
- def add_module(image, target):
- return image, image.add_module(target)
+ with tempfile.TemporaryDirectory() as obj_dir:
- for image in crash_log.images:
- futures.append(executor.submit(add_module, image=image, target=target))
+ def add_module(image, target, obj_dir):
+ return image, image.add_module(target, obj_dir)
+ for image in crash_log.images:
+ futures.append(
+ executor.submit(
+ add_module, image=image, target=target, obj_dir=obj_dir
+ )
+ )
for future in concurrent.futures.as_completed(futures):
image, err = future.result()
if err:
diff --git a/lldb/examples/python/scripted_process/crashlog_scripted_process.py b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index 46b2816..43e307b 100644
--- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -1,4 +1,4 @@
-import os,json,struct,signal,uuid
+import os, json, struct, signal, uuid, tempfile
from typing import Any, Dict
@@ -38,16 +38,17 @@ class CrashLogScriptedProcess(ScriptedProcess):
for image in self.crashlog.find_images_with_identifier(ident):
image.resolve = True
- for image in self.crashlog.images:
- if image not in self.loaded_images:
- if image.uuid == uuid.UUID(int=0):
- continue
- err = image.add_module(self.target)
- if err:
- # Append to SBCommandReturnObject
- print(err)
- else:
- self.loaded_images.append(image)
+ with tempfile.TemporaryDirectory() as obj_dir:
+ for image in self.crashlog.images:
+ if image not in self.loaded_images:
+ if image.uuid == uuid.UUID(int=0):
+ continue
+ err = image.add_module(self.target, obj_dir)
+ if err:
+ # Append to SBCommandReturnObject
+ print(err)
+ else:
+ self.loaded_images.append(image)
for thread in self.crashlog.threads:
if hasattr(thread, 'app_specific_backtrace') and thread.app_specific_backtrace:
diff --git a/lldb/examples/python/symbolication.py b/lldb/examples/python/symbolication.py
index 3a42f34..74de7dd 100755
--- a/lldb/examples/python/symbolication.py
+++ b/lldb/examples/python/symbolication.py
@@ -368,7 +368,7 @@ class Image:
else:
return 'error: no section infos'
- def add_module(self, target):
+ def add_module(self, target, obj_dir=None):
'''Add the Image described in this object to "target" and load the sections if "load" is True.'''
if target:
# Try and find using UUID only first so that paths need not match
@@ -384,7 +384,7 @@ class Image:
resolved_path, None, uuid_str, self.symfile)
if not self.module and self.section_infos:
name = os.path.basename(self.path)
- with tempfile.NamedTemporaryFile(suffix='.' + name) as tf:
+ if obj_dir and os.path.isdir(obj_dir):
data = {
'triple': target.triple,
'uuid': uuid_str,
@@ -398,9 +398,10 @@ class Image:
'size': section.end_addr - section.start_addr
})
data['symbols'] = list(self.symbols.values())
- with open(tf.name, 'w') as f:
+ obj_file = os.path.join(obj_dir, name)
+ with open(obj_file, "w") as f:
f.write(json.dumps(data, indent=4))
- self.module = target.AddModule(tf.name, None, uuid_str)
+ self.module = target.AddModule(obj_file, None, uuid_str)
if self.module:
# If we were able to add the module with inlined
# symbols, we should mark it as available so load_module