#include "minidump/minidump_misc_info_writer.h"
#include <iterator>
#include <limits>
#include "base/check_op.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "minidump/minidump_context_writer.h"
#include "minidump/minidump_writer_util.h"
#include "package.h"
#include "snapshot/cpu_context.h"
#include "snapshot/process_snapshot.h"
#include "snapshot/system_snapshot.h"
#include "snapshot/thread_snapshot.h"
#include "util/file/file_writer.h"
#include "util/numeric/in_range_cast.h"
#include "util/numeric/safe_assignment.h"
#if BUILDFLAG(IS_MAC)
#include <Availability.h>
#elif BUILDFLAG(IS_ANDROID)
#include <android/api-level.h>
#endif
namespace crashpad {
namespace {
uint32_t TimevalToRoundedSeconds(const timeval& tv) { … }
std::string BuildString(const SystemSnapshot* system_snapshot) { … }
#if BUILDFLAG(IS_MAC)
int AvailabilityVersionToMacOSVersionNumber(int availability) {
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_10
DCHECK_GE(availability, 10'0'0);
if (availability >= 10'0'0 && availability <= 10'9'9) {
int minor = (availability / 1'0) % 1'0;
int bugfix = availability % 1'0;
return 10'00'00 + minor * 1'00 + bugfix;
}
#endif
DCHECK_GE(availability, 10'10'00);
DCHECK_LE(availability, 99'99'99);
return availability;
}
#endif
bool MaybeSetXStateData(const ProcessSnapshot* process_snapshot,
XSTATE_CONFIG_FEATURE_MSC_INFO* xstate) { … }
}
namespace internal {
std::string MinidumpMiscInfoDebugBuildString() { … }
}
MinidumpMiscInfoWriter::MinidumpMiscInfoWriter()
: … { … }
MinidumpMiscInfoWriter::~MinidumpMiscInfoWriter() { … }
void MinidumpMiscInfoWriter::InitializeFromSnapshot(
const ProcessSnapshot* process_snapshot) { … }
void MinidumpMiscInfoWriter::SetProcessID(uint32_t process_id) { … }
void MinidumpMiscInfoWriter::SetProcessTimes(time_t process_create_time,
uint32_t process_user_time,
uint32_t process_kernel_time) { … }
void MinidumpMiscInfoWriter::SetProcessorPowerInfo(
uint32_t processor_max_mhz,
uint32_t processor_current_mhz,
uint32_t processor_mhz_limit,
uint32_t processor_max_idle_state,
uint32_t processor_current_idle_state) { … }
void MinidumpMiscInfoWriter::SetProcessIntegrityLevel(
uint32_t process_integrity_level) { … }
void MinidumpMiscInfoWriter::SetProcessExecuteFlags(
uint32_t process_execute_flags) { … }
void MinidumpMiscInfoWriter::SetProtectedProcess(uint32_t protected_process) { … }
void MinidumpMiscInfoWriter::SetTimeZone(uint32_t time_zone_id,
int32_t bias,
const std::string& standard_name,
const SYSTEMTIME& standard_date,
int32_t standard_bias,
const std::string& daylight_name,
const SYSTEMTIME& daylight_date,
int32_t daylight_bias) { … }
void MinidumpMiscInfoWriter::SetBuildString(
const std::string& build_string,
const std::string& debug_build_string) { … }
void MinidumpMiscInfoWriter::SetXStateData(
const XSTATE_CONFIG_FEATURE_MSC_INFO& xstate_data) { … }
bool MinidumpMiscInfoWriter::HasXStateData() const { … }
void MinidumpMiscInfoWriter::SetProcessCookie(uint32_t process_cookie) { … }
bool MinidumpMiscInfoWriter::Freeze() { … }
size_t MinidumpMiscInfoWriter::SizeOfObject() { … }
bool MinidumpMiscInfoWriter::WriteObject(FileWriterInterface* file_writer) { … }
MinidumpStreamType MinidumpMiscInfoWriter::StreamType() const { … }
size_t MinidumpMiscInfoWriter::CalculateSizeOfObjectFromFlags() const { … }
}