chromium/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc

// Copyright 2014 The Crashpad Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#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) {}

// For MINIDUMP_MISC_INFO_4::BuildString. dbghelp only places OS version
// information here, but if a machine description is also available, this is the
// only reasonable place in a minidump file to put it.
std::string BuildString(const SystemSnapshot* system_snapshot) {}

#if BUILDFLAG(IS_MAC)
// Converts the value of the __MAC_OS_X_VERSION_MIN_REQUIRED or
// __MAC_OS_X_VERSION_MAX_ALLOWED macro from <Availability.h> to a number
// identifying the macOS version that it represents, in the same format used by
// MacOSVersionNumber(). For example, with an argument of __MAC_10_15, this
// function will return 10'15'00, which is incidentally the same as __MAC_10_15.
// With an argument of __MAC_10_9, this function will return 10'09'00, different
// from __MAC_10_9, which is 10'9'0.
int AvailabilityVersionToMacOSVersionNumber(int availability) {
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_10
  DCHECK_GE(availability, 10'0'0);

  // Until __MAC_10_10, the format is major * 1'0'0 + minor * 1'0 + bugfix.
  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

  // Since __MAC_10_10, the format is major * 1'00'00 + minor * 1'00 + bugfix.
  DCHECK_GE(availability, 10'10'00);
  DCHECK_LE(availability, 99'99'99);

  return availability;
}
#endif  // BUILDFLAG(IS_MAC)

bool MaybeSetXStateData(const ProcessSnapshot* process_snapshot,
                        XSTATE_CONFIG_FEATURE_MSC_INFO* xstate) {}

}  // namespace

namespace internal {

// For MINIDUMP_MISC_INFO_4::DbgBldStr. dbghelp produces strings like
// “dbghelp.i386,6.3.9600.16520” and “dbghelp.amd64,6.3.9600.16520”. Mimic that
// format, and add the OS that wrote the minidump along with any relevant
// platform-specific data describing the compilation environment.
std::string MinidumpMiscInfoDebugBuildString() {}

}  // namespace internal

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 {}

}  // namespace crashpad