def get_symbolized_stack_bytes(crash_type, crash_address, symbolized_stack): """Get bytes for symbolized crash proto.""" # FIXME: For some tests, crash_address is literally 'address'. crash_address = stack_parser.format_address_to_dec(crash_address) if crash_address is None: # Instead of ignoring such reports, we pass 0xDEADBEEF address. # Crash address is not applicable to many crash types (e.g. CHECK failures, # MSan and UBSan crashes). crash_address = 0xDEADBEEF # TODO(jchinlee): Add os[_info] and cpu[_info] in form crash/ expects. process_state = process_state_pb2.ProcessStateProto( crash=process_state_pb2.ProcessStateProto.Crash( reason=crash_type, address=stack_parser.unsigned_to_signed(crash_address)), requesting_thread=0, ) try: for stack in symbolized_stack: thread = process_state.threads.add() thread.frames.extend( [stackframe.to_proto() for stackframe in stack]) return process_state.SerializeToString() except Exception as e: logs.log_error('Failed to get proto for crash:\n' 'Error: %s\n' 'Type: %s\n' 'Address: %s\n' 'Stack:\n%s\n' % (e, crash_type, crash_address, symbolized_stack)) return None
def test_parse_output_to_processed_report_big_addresses(self): """Tests that given output with big addresses prototizes.""" self.needs_file_delete = False actual_report_bytes = crash_uploader.get_symbolized_stack_bytes( 'reason', '0xfffffffffffffff4', []) actual_report_proto = process_state_pb2.ProcessStateProto() actual_report_proto.ParseFromString(actual_report_bytes) self.assertEqual(actual_report_proto.crash.address, -12)