Author: Med Ismail Bennani
Date: 2023-05-19T20:08:18-07:00
New Revision: aefa8f4460d12503d577c085069d632115e22ed4

URL: 
https://github.com/llvm/llvm-project/commit/aefa8f4460d12503d577c085069d632115e22ed4
DIFF: 
https://github.com/llvm/llvm-project/commit/aefa8f4460d12503d577c085069d632115e22ed4.diff

LOG: [lldb] Fix process pid parsing issue

This patch should fix an issue when parsing the process pid and setting
it in the scripted process.

It can happen that the `crashlog.process_id` attribute is sometimes
parsed as a string. That would cause the scripted process to pick the
default value (0).

To address that, this patch makes sure that the parsed attributed is
converted to the integer type before passing it to the scripted process.

Differential Revision: https://reviews.llvm.org/D151002

Signed-off-by: Med Ismail Bennani <ism...@bennani.ma>

Added: 
    

Modified: 
    lldb/examples/python/scripted_process/crashlog_scripted_process.py

Removed: 
    


################################################################################
diff  --git 
a/lldb/examples/python/scripted_process/crashlog_scripted_process.py 
b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index c913c86af11aa..46b2816032a59 100644
--- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -11,7 +11,13 @@
 class CrashLogScriptedProcess(ScriptedProcess):
     def set_crashlog(self, crashlog):
         self.crashlog = crashlog
-        self.pid = self.crashlog.process_id
+        if self.crashlog.process_id:
+            if type(self.crashlog.process_id) is int:
+                self.pid = self.crashlog.process_id
+            elif type(self.crashlog.process_id) is str:
+                self.pid = int(self.crashlog.process_id, 0)
+            else:
+                self.pid = super().get_process_id()
         self.addr_mask = self.crashlog.addr_mask
         self.crashed_thread_idx = self.crashlog.crashed_thread_idx
         self.loaded_images = []


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to