This is an archive of the discontinued LLVM Phabricator instance.

[lldb/crashlog] Refactor CrashLogParser into a Factory pattern
ClosedPublic

Authored by mib on Dec 13 2022, 9:41 AM.

Details

Summary

This patch should fix an undefined behaviour that's happening when
parsing a crash report from an IDE. In the previous implementation, the
CrashLogParser base class would use the __new__ static class method to
create the right parser instance depending on the crash report type.

For some reasons, the derived parser initializer wouldn't be called when
running the command from an IDE, so this patch refactors the
CrashLogParser code to replace the use of the __new__ method with a
factory create static method.

rdar://100527640

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Diff Detail

Event Timeline

mib created this revision.Dec 13 2022, 9:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 9:41 AM
mib requested review of this revision.Dec 13 2022, 9:41 AM
JDevlieghere added inline comments.Dec 13 2022, 11:49 AM
lldb/examples/python/crashlog.py
419–426

This looks like a class now. The common patter for a factory is to create a static method (e.g. create) in the class you're instantiating.

kastiglione added inline comments.Dec 15 2022, 9:49 AM
lldb/examples/python/crashlog.py
419–426

+1

mib updated this revision to Diff 488796.Jan 12 2023, 3:26 PM
mib marked 2 inline comments as done.
mib edited the summary of this revision. (Show Details)

Address @kastiglione & @JDevlieghere comments:

  • rename the factory method to create
mib retitled this revision from [lldb/crashlog] Refactor CrashLogParser into a Factory patern to [lldb/crashlog] Refactor CrashLogParser into a Factory pattern.Jan 12 2023, 3:26 PM
This revision is now accepted and ready to land.Jan 12 2023, 5:15 PM