mib updated this revision to Diff 488796.
mib marked 2 inline comments as done.
mib edited the summary of this revision.
mib added a comment.
Address @kastiglione & @JDevlieghere comments:
- rename the factory method to `create`
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139951/new/
https://reviews.llvm.org/D139951
Files:
lldb/examples/python/crashlog.py
lldb/examples/python/scripted_process/crashlog_scripted_process.py
Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===================================================================
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -10,7 +10,7 @@
class CrashLogScriptedProcess(ScriptedProcess):
def parse_crashlog(self):
- crashlog_parser = CrashLogParser(self.dbg, self.crashlog_path, False)
+ crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path,
False)
crash_log = crashlog_parser.parse()
self.pid = crash_log.process_id
Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -417,15 +417,15 @@
pass
class CrashLogParser:
- "CrashLog parser base class and factory."
- def __new__(cls, debugger, path, verbose):
+ @staticmethod
+ def create(debugger, path, verbose):
data = JSONCrashLogParser.is_valid_json(path)
if data:
- self = object.__new__(JSONCrashLogParser)
- self.data = data
- return self
+ parser = JSONCrashLogParser(debugger, path, verbose)
+ parser.data = data
+ return parser
else:
- return object.__new__(TextCrashLogParser)
+ return TextCrashLogParser(debugger, path, verbose)
def __init__(self, debugger, path, verbose):
self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@
if not os.path.exists(crashlog_path):
raise InteractiveCrashLogException("crashlog file %s does not exist" %
crashlog_path)
- crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
+ crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
target = lldb.SBTarget()
# 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@
except InteractiveCrashLogException as e:
result.SetError(str(e))
else:
- crash_log = CrashLogParser(debugger, crash_log_file,
options.verbose).parse()
+ crash_log = CrashLogParser.create(debugger, crash_log_file,
options.verbose).parse()
SymbolicateCrashLog(crash_log, options)
if __name__ == '__main__':
Index: lldb/examples/python/scripted_process/crashlog_scripted_process.py
===================================================================
--- lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -10,7 +10,7 @@
class CrashLogScriptedProcess(ScriptedProcess):
def parse_crashlog(self):
- crashlog_parser = CrashLogParser(self.dbg, self.crashlog_path, False)
+ crashlog_parser = CrashLogParser.create(self.dbg, self.crashlog_path, False)
crash_log = crashlog_parser.parse()
self.pid = crash_log.process_id
Index: lldb/examples/python/crashlog.py
===================================================================
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -417,15 +417,15 @@
pass
class CrashLogParser:
- "CrashLog parser base class and factory."
- def __new__(cls, debugger, path, verbose):
+ @staticmethod
+ def create(debugger, path, verbose):
data = JSONCrashLogParser.is_valid_json(path)
if data:
- self = object.__new__(JSONCrashLogParser)
- self.data = data
- return self
+ parser = JSONCrashLogParser(debugger, path, verbose)
+ parser.data = data
+ return parser
else:
- return object.__new__(TextCrashLogParser)
+ return TextCrashLogParser(debugger, path, verbose)
def __init__(self, debugger, path, verbose):
self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@
if not os.path.exists(crashlog_path):
raise InteractiveCrashLogException("crashlog file %s does not exist" % crashlog_path)
- crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
+ crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
target = lldb.SBTarget()
# 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@
except InteractiveCrashLogException as e:
result.SetError(str(e))
else:
- crash_log = CrashLogParser(debugger, crash_log_file, options.verbose).parse()
+ crash_log = CrashLogParser.create(debugger, crash_log_file, options.verbose).parse()
SymbolicateCrashLog(crash_log, options)
if __name__ == '__main__':
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits