Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
utils.WindowsCoreDumpArchiver Class Reference
Inheritance diagram for utils.WindowsCoreDumpArchiver:
utils.BaseCoreDumpArchiver

Public Member Functions

 __init__ (self, output_directory)
 
 __exit__ (self, *args)
 
- Public Member Functions inherited from utils.BaseCoreDumpArchiver
 __enter__ (self)
 

Static Public Attributes

 CDBG_PROMPT_RE = re.compile(r'^\d+:\d+>')
 

Protected Member Functions

 _find_cdb (self)
 
 _dump_all_stacks (self)
 
 _cleanup (self)
 
 _find_all_coredumps (self)
 
 _find_coredump_file (self, crash)
 
 _report_missing_crashes (self, missing, throw=False)
 
- Protected Member Functions inherited from utils.BaseCoreDumpArchiver
 _safe_cleanup (self)
 
 _archive (self, crashes)
 
 _is_shard (self)
 
 _get_file_name (self, file)
 
 _move (self, files)
 
 _tar (self, file)
 
 _upload (self, files)
 
 _find_unexpected_crashes (self)
 

Protected Attributes

 _dumps_by_pid
 
 _search_dir
 
- Protected Attributes inherited from utils.BaseCoreDumpArchiver
 _bucket
 
 _binaries_dir
 
 _search_dir
 
 _output_directory
 

Additional Inherited Members

- Static Protected Attributes inherited from utils.BaseCoreDumpArchiver
str _UNEXPECTED_CRASHES_FILE = 'unexpected-crashes'
 

Detailed Description

Definition at line 846 of file utils.py.

Constructor & Destructor Documentation

◆ __init__()

utils.WindowsCoreDumpArchiver.__init__ (   self,
  output_directory 
)

Reimplemented from utils.BaseCoreDumpArchiver.

Definition at line 848 of file utils.py.

848 def __init__(self, output_directory):
849 super(WindowsCoreDumpArchiver, self).__init__(
850 WindowsCoreDumpEnabler.DUMPS_FOLDER, output_directory)
851 self._dumps_by_pid = None
852

Member Function Documentation

◆ __exit__()

utils.WindowsCoreDumpArchiver.__exit__ (   self,
args 
)

Reimplemented from utils.BaseCoreDumpArchiver.

Definition at line 908 of file utils.py.

908 def __exit__(self, *args):
909 try:
910 self._dump_all_stacks()
911 except Exception as error:
912 print('ERROR: Unable to dump stacks from dumps: {}'.format(error))
913
914 super(WindowsCoreDumpArchiver, self).__exit__(*args)
915
void print(void *str)
Definition bridge.cpp:126
uint32_t uint32_t * format

◆ _cleanup()

utils.WindowsCoreDumpArchiver._cleanup (   self)
protected

Reimplemented from utils.BaseCoreDumpArchiver.

Definition at line 916 of file utils.py.

916 def _cleanup(self):
917 found = super(WindowsCoreDumpArchiver, self)._cleanup()
918 for core in glob.glob(os.path.join(self._search_dir, '*')):
919 found = True
920 TryUnlink(core)
921 return found
922

◆ _dump_all_stacks()

utils.WindowsCoreDumpArchiver._dump_all_stacks (   self)
protected

Definition at line 875 of file utils.py.

875 def _dump_all_stacks(self):
876 # On Windows due to crashpad integration crashes do not produce any
877 # stacktraces. Dump stack traces from dumps Crashpad collected using
878 # CDB (if available).
879 cdb_path = self._find_cdb()
880 if cdb_path is None:
881 return
882
883 dumps = self._find_all_coredumps()
884 if not dumps:
885 return
886
887 print('### Collected {} crash dumps'.format(len(dumps)))
888 for dump in dumps:
889 print()
890 print('### Dumping stacks from {} using CDB'.format(dump))
891 cdb_output = subprocess.check_output(
892 '"{}" -z "{}" -kqm -c "!uniqstack -b -v -p;qd"'.format(
893 cdb_path, dump),
894 stderr=subprocess.STDOUT)
895 # Extract output of uniqstack from the whole output of CDB.
896 output = False
897 for line in cdb_output.split('\n'):
898 if re.match(WindowsCoreDumpArchiver.CDBG_PROMPT_RE, line):
899 output = True
900 elif line.startswith('quit:'):
901 break
902 elif output:
903 print(line)
904 print()
905 print('#############################################')
906 print()
907

◆ _find_all_coredumps()

utils.WindowsCoreDumpArchiver._find_all_coredumps (   self)
protected
Return coredumps that were recorded (if supported by the platform).
This method will be overridden by concrete platform specific implementations.

Reimplemented from utils.BaseCoreDumpArchiver.

Definition at line 923 of file utils.py.

923 def _find_all_coredumps(self):
924 pattern = os.path.join(self._search_dir, '*.dmp')
925 return [core_filename for core_filename in glob.glob(pattern)]
926

◆ _find_cdb()

utils.WindowsCoreDumpArchiver._find_cdb (   self)
protected

Definition at line 854 of file utils.py.

854 def _find_cdb(self):
855 win_toolchain_json_path = os.path.join(DART_DIR, 'build',
856 'win_toolchain.json')
857 if not os.path.exists(win_toolchain_json_path):
858 return None
859
860 with open(win_toolchain_json_path, 'r') as f:
861 win_toolchain_info = json.loads(f.read())
862
863 win_sdk_path = win_toolchain_info['win_sdk']
864
865 # We assume that we are running on 64-bit Windows.
866 # Note: x64 CDB can work with both X64 and IA32 dumps.
867 cdb_path = os.path.join(win_sdk_path, 'Debuggers', 'x64', 'cdb.exe')
868 if not os.path.exists(cdb_path):
869 return None
870
871 return cdb_path
872

◆ _find_coredump_file()

utils.WindowsCoreDumpArchiver._find_coredump_file (   self,
  crash 
)
protected

Definition at line 927 of file utils.py.

927 def _find_coredump_file(self, crash):
928 if self._dumps_by_pid is None:
929 # If this function is invoked the first time then look through the directory
930 # that contains crashes for all dump files and collect pid -> filename
931 # mapping.
932 self._dumps_by_pid = {}
933 minidump = GetMinidumpUtils()
934 pattern = os.path.join(self._search_dir, '*.dmp')
935 for core_filename in glob.glob(pattern):
936 pid = minidump.GetProcessIdFromDump(core_filename)
937 if pid != -1:
938 self._dumps_by_pid[str(pid)] = core_filename
939 if crash.pid in self._dumps_by_pid:
940 return self._dumps_by_pid[crash.pid]
941
GetProcessIdFromDump(path)
Definition minidump.py:179

◆ _report_missing_crashes()

utils.WindowsCoreDumpArchiver._report_missing_crashes (   self,
  missing,
  throw = False 
)
protected

Reimplemented from utils.BaseCoreDumpArchiver.

Definition at line 942 of file utils.py.

942 def _report_missing_crashes(self, missing, throw=False):
943 # Let's only print the debugging information and not throw. We'll do more
944 # validation for werfault.exe and throw afterwards.
945 super(WindowsCoreDumpArchiver, self)._report_missing_crashes(
946 missing, throw=False)
947
948 if throw:
949 missing_as_string = ', '.join([str(c) for c in missing])
950 raise Exception(
951 'Missing crash dumps for: {}'.format(missing_as_string))
952
953

Member Data Documentation

◆ _dumps_by_pid

utils.WindowsCoreDumpArchiver._dumps_by_pid
protected

Definition at line 851 of file utils.py.

◆ _search_dir

utils.WindowsCoreDumpArchiver._search_dir
protected

Definition at line 918 of file utils.py.

◆ CDBG_PROMPT_RE

utils.WindowsCoreDumpArchiver.CDBG_PROMPT_RE = re.compile(r'^\d+:\d+>')
static

Definition at line 873 of file utils.py.


The documentation for this class was generated from the following file: