Decouple <cstddef>
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
#include "Crash.h"
|
||||
#include "ProductInfo.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <os/log.h>
|
||||
#include <sys/types.h>
|
||||
@@ -44,10 +47,10 @@ void CrashHandler::InformUserOfCrash( const RString& sPath )
|
||||
sPath.c_str(), REPORT_BUG_URL );
|
||||
CFOptionFlags response = kCFUserNotificationCancelResponse;
|
||||
CFTimeInterval timeout = 0.0; // Should we ever time out?
|
||||
|
||||
|
||||
CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, nullptr, nullptr, nullptr,
|
||||
sTitle, sBody, sDefault, sAlternate, sOther, &response );
|
||||
|
||||
|
||||
switch( response )
|
||||
{
|
||||
case kCFUserNotificationDefaultResponse:
|
||||
@@ -76,19 +79,19 @@ bool CrashHandler::IsDebuggerPresent()
|
||||
int ret;
|
||||
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
|
||||
struct kinfo_proc info;
|
||||
size_t size;
|
||||
|
||||
std::size_t size;
|
||||
|
||||
// Initialize the flags so that, if sysctl fails for some bizarre
|
||||
// reason, we get a predictable result.
|
||||
|
||||
|
||||
info.kp_proc.p_flag = 0;
|
||||
|
||||
|
||||
// Call sysctl.
|
||||
size = sizeof( info );
|
||||
ret = sysctl( mib, sizeof(mib)/sizeof(*mib), &info, &size, nullptr, 0 );
|
||||
|
||||
|
||||
// We're being debugged if the P_TRACED flag is set.
|
||||
|
||||
|
||||
return ret == 0 && (info.kp_proc.p_flag & P_TRACED) != 0;
|
||||
#else
|
||||
return false;
|
||||
@@ -113,7 +116,7 @@ void CrashHandler::DebugBreak()
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <IOKit/usb/USB.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_error.h>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <unordered_map>
|
||||
@@ -49,7 +50,7 @@ namespace __gnu_cxx
|
||||
template<>
|
||||
struct hash<IOHIDElementCookie> : private hash<uintptr_t>
|
||||
{
|
||||
size_t operator()( const IOHIDElementCookie& cookie ) const
|
||||
std::size_t operator()( const IOHIDElementCookie& cookie ) const
|
||||
{
|
||||
return hash<unsigned long>::operator()( uintptr_t(cookie) );
|
||||
}
|
||||
@@ -135,7 +136,7 @@ public:
|
||||
/*
|
||||
* (c) 2005-2006 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -145,7 +146,7 @@ public:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "KeyboardDevice.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
using namespace __gnu_cxx;
|
||||
|
||||
bool KeyboardDevice::AddLogicalDevice( int usagePage, int usage )
|
||||
@@ -477,7 +479,7 @@ bool KeyboardDevice::DeviceButtonToMacVirtualKey( DeviceButton button, UInt8 &iM
|
||||
for( int iUsbKey = 0; iUsbKey < 256; ++iUsbKey )
|
||||
{
|
||||
DeviceButton button2;
|
||||
if( UsbKeyToDeviceButton(iUsbKey, button2) && size_t(button2) < sizeof(g_iDeviceButtonToMacVirtualKey) )
|
||||
if( UsbKeyToDeviceButton(iUsbKey, button2) && std::size_t(button2) < sizeof(g_iDeviceButtonToMacVirtualKey) )
|
||||
g_iDeviceButtonToMacVirtualKey[button2] = g_iUsbKeyToMacVirtualKey[iUsbKey];
|
||||
}
|
||||
bInited = true;
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
#if defined(__VEC__)
|
||||
#include <vecLib/vecLib.h>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
bool Vector::CheckForVector()
|
||||
{
|
||||
int32_t result = 0;
|
||||
size_t size = 4;
|
||||
std::size_t size = 4;
|
||||
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, nullptr, 0 ) && result;
|
||||
}
|
||||
@@ -242,7 +244,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size )
|
||||
/*
|
||||
* (c) 2006-2007 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -252,7 +254,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -308,7 +309,7 @@ bool IsValidFrame( const StackFrame *frame )
|
||||
/* This x86 backtracer attempts to walk the stack frames. If we come to a
|
||||
* place that doesn't look like a valid frame, we'll look forward and try
|
||||
* to find one again. */
|
||||
static void do_backtrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
static void do_backtrace( const void **buf, std::size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
/* Read /proc/pid/maps to find the address range of the stack. */
|
||||
get_readable_ranges( g_ReadableBegin, g_ReadableEnd, 1024 );
|
||||
@@ -408,10 +409,10 @@ void GetSignalBacktraceContext( BacktraceContext *ctx, const ucontext_t *uc )
|
||||
#error
|
||||
#endif
|
||||
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
InitializeBacktrace();
|
||||
|
||||
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
@@ -448,7 +449,7 @@ static bool GetRegionInfo( mach_port_t self, const void *address, vm_address_t &
|
||||
vm_address_t start = vm_address_t( address );
|
||||
kern_return_t ret = vm_region_64( self, &start, &size, VM_REGION_BASIC_INFO_64,
|
||||
(vm_region_info_t)&info, &infoCnt, &unused );
|
||||
|
||||
|
||||
if( ret != KERN_SUCCESS ||
|
||||
start >= (vm_address_t)address ||
|
||||
(vm_address_t)address >= start + size )
|
||||
@@ -463,7 +464,7 @@ static bool GetRegionInfo( mach_port_t self, const void *address, vm_address_t &
|
||||
void InitializeBacktrace()
|
||||
{
|
||||
static bool bInitialized = false;
|
||||
|
||||
|
||||
if( bInitialized )
|
||||
return;
|
||||
vm_prot_t protection;
|
||||
@@ -484,7 +485,7 @@ void GetSignalBacktraceContext( BacktraceContext *ctx, const ucontext_t *uc )
|
||||
#elif defined(__i386__)
|
||||
ctx->ip = (void *) uc->uc_mcontext->__ss.__eip;
|
||||
ctx->bp = (void *) uc->uc_mcontext->__ss.__ebp;
|
||||
ctx->sp = (void *) uc->uc_mcontext->__ss.__esp;
|
||||
ctx->sp = (void *) uc->uc_mcontext->__ss.__esp;
|
||||
#elif defined(__x86_64__)
|
||||
ctx->ip = (void *) uc->uc_mcontext->__ss.__rip;
|
||||
ctx->bp = (void *) uc->uc_mcontext->__ss.__rbp;
|
||||
@@ -497,11 +498,11 @@ void GetSignalBacktraceContext( BacktraceContext *ctx, const ucontext_t *uc )
|
||||
static bool PointsToValidCall( vm_address_t start, const void *ptr )
|
||||
{
|
||||
const char *buf = (const char *) ptr;
|
||||
|
||||
|
||||
/* We're reading buf backwards, between buf[-7] and buf[-1]. Find out how
|
||||
* far we can read. */
|
||||
const int len = std::min<int>(intptr_t(ptr) - start, 7);
|
||||
|
||||
|
||||
// Permissible CALL sequences that we care about:
|
||||
//
|
||||
// E8 xx xx xx xx CALL near relative
|
||||
@@ -509,68 +510,68 @@ static bool PointsToValidCall( vm_address_t start, const void *ptr )
|
||||
//
|
||||
// Minimum sequence is 2 bytes (call eax).
|
||||
// Maximum sequence is 7 bytes (call dword ptr [eax+disp32]).
|
||||
|
||||
|
||||
if (len >= 5 && buf[-5] == '\xe8')
|
||||
return true;
|
||||
|
||||
|
||||
// FF 14 xx CALL [reg32+reg32*scale]
|
||||
if (len >= 3 && buf[-3] == '\xff' && buf[-2]=='\x14')
|
||||
return true;
|
||||
|
||||
|
||||
// FF 15 xx xx xx xx CALL disp32
|
||||
if (len >= 6 && buf[-6] == '\xff' && buf[-5]=='\x15')
|
||||
return true;
|
||||
|
||||
|
||||
// FF 00-3F(!14/15) CALL [reg32]
|
||||
if (len >= 2 && buf[-2] == '\xff' && (unsigned char)buf[-1] < '\x40')
|
||||
return true;
|
||||
|
||||
|
||||
// FF D0-D7 CALL reg32
|
||||
if (len >= 2 && buf[-2] == '\xff' && char(buf[-1]&0xF8) == '\xd0')
|
||||
return true;
|
||||
|
||||
|
||||
// FF 50-57 xx CALL [reg32+reg32*scale+disp8]
|
||||
if (len >= 3 && buf[-3] == '\xff' && char(buf[-2]&0xF8) == '\x50')
|
||||
return true;
|
||||
|
||||
|
||||
// FF 90-97 xx xx xx xx xx CALL [reg32+reg32*scale+disp32]
|
||||
if (len >= 7 && buf[-7] == '\xff' && char(buf[-6]&0xF8) == '\x90')
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
InitializeBacktrace();
|
||||
|
||||
|
||||
if( g_StackPointer == 0 )
|
||||
{
|
||||
buf[0] = BACKTRACE_METHOD_NOT_AVAILABLE;
|
||||
buf[1] = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
|
||||
CurrentCtx.ip = nullptr;
|
||||
CurrentCtx.bp = __builtin_frame_address(0);
|
||||
CurrentCtx.sp = __builtin_frame_address(0);
|
||||
}
|
||||
|
||||
|
||||
mach_port_t self = mach_task_self();
|
||||
vm_address_t stackPointer = 0;
|
||||
vm_prot_t protection = 0;
|
||||
vm_address_t start = 0;
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
std::size_t i = 0;
|
||||
if( i < size-1 && ctx->ip )
|
||||
buf[i++] = ctx->ip;
|
||||
|
||||
|
||||
if( GetRegionInfo(self, ctx->sp, stackPointer, protection) && protection == (VM_PROT_READ|VM_PROT_WRITE) )
|
||||
{
|
||||
const void *p = *(const void **)ctx->sp;
|
||||
@@ -581,7 +582,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
buf[i++] = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GetRegionInfo( self, ctx->sp, stackPointer, protection );
|
||||
if( protection != PROT_RW )
|
||||
{
|
||||
@@ -591,7 +592,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
return;
|
||||
}
|
||||
const Frame *frame = (Frame *)ctx->sp;
|
||||
|
||||
|
||||
while( i < size-1 )
|
||||
{
|
||||
// Make sure this is on the stack
|
||||
@@ -599,16 +600,16 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
break;
|
||||
if( (start != g_StackPointer && start != stackPointer) || uintptr_t(frame)-uintptr_t(start) < sizeof(Frame) )
|
||||
break;
|
||||
|
||||
|
||||
/* The stack pointer is always 16 byte aligned _before_ the call. Thus a valid frame
|
||||
* should look like the follwoing.
|
||||
* | |
|
||||
* | Caller's frame |
|
||||
* -------------------- 16 byte boundary
|
||||
* | Linkage | This is return_address
|
||||
* - - - - - - - - - -
|
||||
* - - - - - - - - - -
|
||||
* | Saved %ebp | This is link
|
||||
* - - - - - - - - - -
|
||||
* - - - - - - - - - -
|
||||
* | Rest of |
|
||||
* | Callee's frame |
|
||||
*
|
||||
@@ -645,7 +646,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
buf[i] = nullptr;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
#undef PROT_RW
|
||||
#undef PROT_EXE
|
||||
@@ -666,7 +667,7 @@ void GetSignalBacktraceContext( BacktraceContext *ctx, const ucontext_t *uc )
|
||||
|
||||
void InitializeBacktrace() { }
|
||||
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == nullptr )
|
||||
@@ -678,7 +679,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
CurrentCtx.FramePtr = (const Frame *) r1;
|
||||
CurrentCtx.PC = nullptr;
|
||||
}
|
||||
|
||||
|
||||
const Frame *frame = ctx->FramePtr;
|
||||
|
||||
unsigned i = 0;
|
||||
@@ -689,7 +690,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
if( frame->linkReg )
|
||||
buf[i++] = frame->linkReg;
|
||||
|
||||
|
||||
frame = frame->stackPointer;
|
||||
}
|
||||
|
||||
@@ -714,7 +715,7 @@ void GetSignalBacktraceContext( BacktraceContext *ctx, const ucontext_t *uc )
|
||||
|
||||
void InitializeBacktrace() { }
|
||||
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
BacktraceContext CurrentCtx;
|
||||
|
||||
@@ -751,7 +752,7 @@ void GetSignalBacktraceContext( BacktraceContext *ctx, const ucontext_t *uc )
|
||||
// NYI
|
||||
}
|
||||
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
buf[0] = BACKTRACE_METHOD_NOT_AVAILABLE;
|
||||
buf[1] = nullptr;
|
||||
@@ -762,7 +763,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
/*
|
||||
* (c) 2003-2007 Glenn Maynard, Steve Checkoway, Avery Lee
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -772,7 +773,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef BACKTRACE_H
|
||||
#define BACKTRACE_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
/* This API works like backtrace_pointers(), to retrieve a stack trace. */
|
||||
|
||||
#if defined(CPU_PPC)
|
||||
@@ -34,7 +36,7 @@ void InitializeBacktrace();
|
||||
* null-terminated. If ctx is nullptr, retrieve the current backtrace; otherwise
|
||||
* retrieve a backtrace for the given context. (Not all backtracers may
|
||||
* support contexts.) */
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx = nullptr );
|
||||
void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *ctx = nullptr );
|
||||
|
||||
/* Set up a BacktraceContext to get a backtrace for a thread. ThreadID may
|
||||
* not be the current thread. True is returned on success, false on failure. */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "global.h"
|
||||
#include "BacktraceNames.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
@@ -79,7 +80,7 @@ RString BacktraceNames::Format() const
|
||||
if( ShortenedPath != "" )
|
||||
{
|
||||
/* Abbreviate the module name. */
|
||||
size_t slash = ShortenedPath.rfind('/');
|
||||
std::size_t slash = ShortenedPath.rfind('/');
|
||||
if( slash != ShortenedPath.npos )
|
||||
ShortenedPath = ShortenedPath.substr(slash+1);
|
||||
ShortenedPath = RString("(") + ShortenedPath + ")";
|
||||
@@ -324,7 +325,7 @@ void BacktraceNames::FromString( RString s )
|
||||
|
||||
if( MangledAndOffset != "" )
|
||||
{
|
||||
size_t plus = MangledAndOffset.rfind('+');
|
||||
std::size_t plus = MangledAndOffset.rfind('+');
|
||||
|
||||
if(plus == MangledAndOffset.npos)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <limits.h>
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
@@ -38,7 +39,7 @@ static void safe_print( int fd, ... )
|
||||
{
|
||||
break;
|
||||
}
|
||||
size_t len = strlen( p );
|
||||
std::size_t len = strlen( p );
|
||||
while( len )
|
||||
{
|
||||
ssize_t result = write( fd, p, strlen(p) );
|
||||
@@ -100,7 +101,7 @@ static void spawn_child_process( int from_parent )
|
||||
}
|
||||
|
||||
/* write(), but retry a couple times on EINTR. */
|
||||
static int retried_write( int fd, const void *buf, size_t count )
|
||||
static int retried_write( int fd, const void *buf, std::size_t count )
|
||||
{
|
||||
int tries = 3, ret;
|
||||
do
|
||||
@@ -112,7 +113,7 @@ static int retried_write( int fd, const void *buf, size_t count )
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool parent_write( int to_child, const void *p, size_t size )
|
||||
static bool parent_write( int to_child, const void *p, std::size_t size )
|
||||
{
|
||||
int ret = retried_write( to_child, p, size );
|
||||
if( ret == -1 )
|
||||
@@ -121,7 +122,7 @@ static bool parent_write( int to_child, const void *p, size_t size )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( size_t(ret) != size )
|
||||
if( std::size_t(ret) != size )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", nullptr );
|
||||
return false;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// DO NOT USE stdio.h! printf() calls malloc()!
|
||||
//#include <stdio.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <windows.h>
|
||||
|
||||
#include "global.h"
|
||||
@@ -80,7 +81,7 @@ void CrashHandler::SetForegroundWindow( HWND hWnd )
|
||||
g_hForegroundWnd = hWnd;
|
||||
}
|
||||
|
||||
void WriteToChild( HANDLE hPipe, const void *pData, size_t iSize )
|
||||
void WriteToChild( HANDLE hPipe, const void *pData, std::size_t iSize )
|
||||
{
|
||||
while( iSize )
|
||||
{
|
||||
@@ -467,7 +468,7 @@ static bool PointsToValidCall( ULONG_PTR ptr )
|
||||
return IsValidCall(buf+7, len);
|
||||
}
|
||||
|
||||
void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
void CrashHandler::do_backtrace( const void **buf, std::size_t size,
|
||||
HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext )
|
||||
{
|
||||
const void **pLast = buf + size - 1;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#ifndef CRASH_H
|
||||
#define CRASH_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <windows.h>
|
||||
|
||||
/** @brief Win32 crash handling. */
|
||||
namespace CrashHandler
|
||||
{
|
||||
extern long __stdcall ExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo);
|
||||
|
||||
void do_backtrace( const void **buf, size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext );
|
||||
void do_backtrace( const void **buf, std::size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext );
|
||||
void SymLookup( const void *ptr, char *buf );
|
||||
void ForceCrash( const char *reason );
|
||||
void ForceDeadlock( RString reason, uint64_t iID );
|
||||
@@ -24,7 +27,7 @@ namespace CrashHandler
|
||||
* (c) 1998-2001 Avery Lee
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -34,7 +37,7 @@ namespace CrashHandler
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Crash.h"
|
||||
#include <errno.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include "archutils/Win32/ddk/dbghelp.h"
|
||||
@@ -103,10 +104,10 @@ namespace VDDebugInfo
|
||||
|
||||
src += 64;
|
||||
const int* pVer = reinterpret_cast<const int*>(src);
|
||||
const size_t* pRVASize = reinterpret_cast<const size_t*>(src + sizeof(int));
|
||||
const size_t* pFNamSize = reinterpret_cast<const size_t*>(src + sizeof(int) + sizeof(size_t));
|
||||
const int* pSegCnt = reinterpret_cast<const int*>(src + sizeof(int) + 2 * sizeof(size_t));
|
||||
src += 2 * (sizeof(int) + sizeof(size_t));
|
||||
const std::size_t* pRVASize = reinterpret_cast<const std::size_t*>(src + sizeof(int));
|
||||
const std::size_t* pFNamSize = reinterpret_cast<const std::size_t*>(src + sizeof(int) + sizeof(std::size_t));
|
||||
const int* pSegCnt = reinterpret_cast<const int*>(src + sizeof(int) + 2 * sizeof(std::size_t));
|
||||
src += 2 * (sizeof(int) + sizeof(std::size_t));
|
||||
|
||||
pctx->nBuildNumber = *pVer;
|
||||
pctx->pRVAHeap = reinterpret_cast<const unsigned char*>(src + sizeof(uintptr_t));
|
||||
@@ -146,7 +147,7 @@ namespace VDDebugInfo
|
||||
if( dwFileSize == INVALID_FILE_SIZE )
|
||||
break;
|
||||
|
||||
char *buffer = new char[static_cast<size_t>(dwFileSize) + 1];
|
||||
char *buffer = new char[static_cast<std::size_t>(dwFileSize) + 1];
|
||||
std::fill(buffer, buffer + dwFileSize + 1, '\0' );
|
||||
|
||||
DWORD dwActual;
|
||||
@@ -177,7 +178,7 @@ namespace VDDebugInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char *GetNameFromHeap(const char *heap, size_t idx)
|
||||
static const char *GetNameFromHeap(const char *heap, std::size_t idx)
|
||||
{
|
||||
while(idx--)
|
||||
while(*heap++);
|
||||
@@ -192,7 +193,7 @@ namespace VDDebugInfo
|
||||
|
||||
const unsigned char *pr = pctx->pRVAHeap;
|
||||
const unsigned char *pr_limit = (const unsigned char *)pctx->pFuncNameHeap;
|
||||
size_t idx = 0;
|
||||
std::size_t idx = 0;
|
||||
|
||||
// Linearly unpack RVA deltas and find lower_bound
|
||||
rva -= pctx->nFirstRVA;
|
||||
@@ -313,7 +314,7 @@ namespace SymbolLookup
|
||||
| UNDNAME_NO_CV_THISTYPE
|
||||
| UNDNAME_NO_ALLOCATION_MODEL
|
||||
| UNDNAME_NO_ACCESS_SPECIFIERS // no public:
|
||||
| UNDNAME_NO_MS_KEYWORDS // no __cdecl
|
||||
| UNDNAME_NO_MS_KEYWORDS // no __cdecl
|
||||
| UNDNAME_NO_MEMBER_TYPE // no virtual, static
|
||||
) )
|
||||
{
|
||||
@@ -340,7 +341,7 @@ namespace SymbolLookup
|
||||
return "???";
|
||||
}
|
||||
RString sName;
|
||||
char *buffer = new char[static_cast<size_t>(iSize) + 1];
|
||||
char *buffer = new char[static_cast<std::size_t>(iSize) + 1];
|
||||
std::fill(buffer, buffer + iSize + 1, '\0');
|
||||
if (!ReadFromParent(iFD, buffer, iSize))
|
||||
{
|
||||
@@ -392,7 +393,7 @@ namespace SymbolLookup
|
||||
}
|
||||
|
||||
wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s!%" ADDRESS_ZEROS "Ix",
|
||||
reinterpret_cast<uintptr_t>(ptr), sName.c_str(),
|
||||
reinterpret_cast<uintptr_t>(ptr), sName.c_str(),
|
||||
reinterpret_cast<uintptr_t>(meminfo.AllocationBase) );
|
||||
}
|
||||
}
|
||||
@@ -487,7 +488,7 @@ static void MakeCrashReport( const CompleteCrashData &Data, RString &sOut )
|
||||
sOut += ssprintf( "\n" );
|
||||
|
||||
sOut += ssprintf( "Partial log:\n" );
|
||||
for( size_t i = 0; i < Data.m_asRecent.size(); ++i )
|
||||
for( std::size_t i = 0; i < Data.m_asRecent.size(); ++i )
|
||||
sOut += ssprintf( "%s\n", Data.m_asRecent[i].c_str() );
|
||||
sOut += ssprintf( "\n" );
|
||||
|
||||
@@ -527,7 +528,7 @@ bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data )
|
||||
if( !ReadFromParent(iFD, &iSize, sizeof(iSize)) )
|
||||
return false;
|
||||
|
||||
char *buffer = new char[static_cast<size_t>(iSize) + 1];
|
||||
char *buffer = new char[static_cast<std::size_t>(iSize) + 1];
|
||||
std::fill(buffer, buffer + iSize + 1, '\0');
|
||||
bool wasReadSuccessful = ReadFromParent(iFD, buffer, iSize);
|
||||
RString tmp = buffer;
|
||||
@@ -708,7 +709,7 @@ INT_PTR CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
case IDC_STATIC_HEADER_TEXT:
|
||||
case IDC_STATIC_ICON:
|
||||
hbr = (HBRUSH)::GetStockObject(WHITE_BRUSH);
|
||||
hbr = (HBRUSH)::GetStockObject(WHITE_BRUSH);
|
||||
SetBkMode( hdc, OPAQUE );
|
||||
SetBkColor( hdc, RGB(255,255,255) );
|
||||
break;
|
||||
@@ -907,7 +908,7 @@ void CrashHandler::CrashHandlerHandleArgs( int argc, char* argv[] )
|
||||
/*
|
||||
* (c) 2003-2006 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -917,7 +918,7 @@ void CrashHandler::CrashHandlerHandleArgs( int argc, char* argv[] )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "RageTimer.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#include <windows.h>
|
||||
@@ -71,14 +72,14 @@ public:
|
||||
/* Read data. Block until any data is received, then return all data
|
||||
* available. Return the number of bytes read. The return value will always
|
||||
* be >= 0, unless an error or cancellation occured. */
|
||||
virtual int Read( void *pBuffer, size_t iSize ) = 0;
|
||||
virtual int Read( void *pBuffer, std::size_t iSize ) = 0;
|
||||
|
||||
/* Write data to the socket. (Design note: we always write all of the data
|
||||
* unless an error or cancellation occurs, and those states are checked
|
||||
* with GetState(). If that happens, the number of bytes written is
|
||||
* meaningless, since it may have simply been buffered and never sent.
|
||||
* So, this function returns no value.) */
|
||||
virtual void Write( const void *pBuffer, size_t iSize ) = 0;
|
||||
virtual void Write( const void *pBuffer, std::size_t iSize ) = 0;
|
||||
|
||||
/* Cancel the connection. This operation can clear an error state, aborts
|
||||
* any blocking calls, never fails, and will always result in the socket
|
||||
@@ -126,8 +127,8 @@ public:
|
||||
void Open( const RString &sHost, int iPort, ConnectionType ct = CONN_TCP );
|
||||
void Shutdown();
|
||||
void Close();
|
||||
int Read( void *pBuffer, size_t iSize );
|
||||
void Write( const void *pBuffer, size_t iSize );
|
||||
int Read( void *pBuffer, std::size_t iSize );
|
||||
void Write( const void *pBuffer, std::size_t iSize );
|
||||
|
||||
void Cancel();
|
||||
|
||||
@@ -439,7 +440,7 @@ void NetworkStream_Win32::Close()
|
||||
{
|
||||
if( m_State == STATE_IDLE )
|
||||
return;
|
||||
|
||||
|
||||
/* If we have an active, stable connection, make sure we flush any data
|
||||
* completely before closing. If you don't want to do this, call Cancel()
|
||||
* first. */
|
||||
@@ -490,7 +491,7 @@ void NetworkStream_Win32::Cancel()
|
||||
m_Mutex.Unlock();
|
||||
}
|
||||
|
||||
int NetworkStream_Win32::Read( void *pBuffer, size_t iSize )
|
||||
int NetworkStream_Win32::Read( void *pBuffer, std::size_t iSize )
|
||||
{
|
||||
if( m_State != STATE_CONNECTED )
|
||||
return 0;
|
||||
@@ -539,7 +540,7 @@ int NetworkStream_Win32::Read( void *pBuffer, size_t iSize )
|
||||
return iRead;
|
||||
}
|
||||
|
||||
void NetworkStream_Win32::Write( const void *pBuffer, size_t iSize )
|
||||
void NetworkStream_Win32::Write( const void *pBuffer, std::size_t iSize )
|
||||
{
|
||||
if( m_State != STATE_CONNECTED )
|
||||
return;
|
||||
@@ -747,7 +748,7 @@ void NetworkPostData::SetData( const RString &sKey, const RString &sData )
|
||||
/*
|
||||
* (c) 2006 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -757,7 +758,7 @@ void NetworkPostData::SetData( const RString &sKey, const RString &sData )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
#include "RageUtil.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <windows.h>
|
||||
|
||||
/* Given "HKEY_LOCAL_MACHINE\hardware\foo", return "hardware\foo", and place
|
||||
* the HKEY_LOCAL_MACHINE constant in key. */
|
||||
static bool GetRegKeyType( const RString &sIn, RString &sOut, HKEY &key )
|
||||
{
|
||||
size_t iBackslash = sIn.find( '\\' );
|
||||
std::size_t iBackslash = sIn.find( '\\' );
|
||||
if( iBackslash == sIn.npos )
|
||||
{
|
||||
LOG->Warn( "Invalid registry key: \"%s\" ", sIn.c_str() );
|
||||
@@ -94,9 +95,9 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, int
|
||||
DWORD iType;
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE) &iValue, &iSize );
|
||||
RegCloseKey( hKey );
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
return false;
|
||||
|
||||
|
||||
if( iType != REG_DWORD )
|
||||
return false; /* type mismatch */
|
||||
|
||||
@@ -160,14 +161,14 @@ bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, con
|
||||
|
||||
bool bSuccess = true;
|
||||
TCHAR sz[255];
|
||||
|
||||
|
||||
if( sVal.size() > 254 )
|
||||
return false;
|
||||
|
||||
strcpy( sz, sVal.c_str() );
|
||||
|
||||
|
||||
LONG lResult = ::RegSetValueEx(hKey, LPCTSTR(sName), 0, REG_SZ, (LPBYTE)sz, strlen(sz) + 1);
|
||||
if( lResult != ERROR_SUCCESS )
|
||||
if( lResult != ERROR_SUCCESS )
|
||||
bSuccess = false;
|
||||
|
||||
::RegCloseKey(hKey);
|
||||
@@ -181,10 +182,10 @@ bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, boo
|
||||
return false;
|
||||
|
||||
bool bSuccess = true;
|
||||
|
||||
|
||||
if (::RegSetValueEx(hKey, LPCTSTR(sName), 0,
|
||||
REG_BINARY, (LPBYTE)&bVal, sizeof(bVal))
|
||||
!= ERROR_SUCCESS)
|
||||
!= ERROR_SUCCESS)
|
||||
bSuccess = false;
|
||||
|
||||
::RegCloseKey(hKey);
|
||||
@@ -201,13 +202,13 @@ bool RegistryAccess::CreateKey( const RString &sKey )
|
||||
HKEY hKey;
|
||||
DWORD dwDisposition = 0;
|
||||
if( ::RegCreateKeyEx(
|
||||
hType,
|
||||
sSubkey,
|
||||
0,
|
||||
hType,
|
||||
sSubkey,
|
||||
0,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
&hKey,
|
||||
&dwDisposition ) != ERROR_SUCCESS )
|
||||
{
|
||||
@@ -220,7 +221,7 @@ bool RegistryAccess::CreateKey( const RString &sKey )
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -230,7 +231,7 @@ bool RegistryAccess::CreateKey( const RString &sKey )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstddef>
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAX_FNAMBUF (0x0FFFFFFF)
|
||||
@@ -95,7 +96,7 @@ void RemoveAnonymousNamespaces( char *p )
|
||||
|
||||
void parsename(uintptr_t rva, char *func_name) {
|
||||
RemoveAnonymousNamespaces( func_name );
|
||||
|
||||
|
||||
fnamptr = strtack(fnamptr, func_name, fnambuf+MAX_FNAMBUF);
|
||||
if(!fnamptr)
|
||||
throw "Too many func names; increase MAX_FNAMBUF.";
|
||||
@@ -223,7 +224,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
// printf("Processing RVA entries...\n");
|
||||
|
||||
for (size_t i = 0; i < rvabuf.size(); ++i) {
|
||||
for (std::size_t i = 0; i < rvabuf.size(); ++i) {
|
||||
uint16_t grp;
|
||||
uint32_t start;
|
||||
uintptr_t rva;
|
||||
@@ -236,17 +237,17 @@ int main(int argc, char **argv) {
|
||||
|
||||
parsename(rva, symname);
|
||||
}
|
||||
|
||||
|
||||
// printf("Processing segment entries...\n");
|
||||
|
||||
for (size_t i = 0; i < segcnt; i++) {
|
||||
for (std::size_t i = 0; i < segcnt; i++) {
|
||||
segbuf[i][0] += grpstart[seggrp[i]];
|
||||
// printf("\t#%-2zu %p-%p\n", i + 1, reinterpret_cast<void*>(segbuf[i][0]), reinterpret_cast<void*>(segbuf[i][0] + segbuf[i][1] - 1));
|
||||
}
|
||||
/*
|
||||
printf("Raw statistics:\n");
|
||||
printf("\tRVA bytes: %zu\n", rvabuf.size() * 4);
|
||||
printf("\tFunc name bytes: %" PRIdPTR "\n", static_cast<ptrdiff_t>(fnamptr - fnambuf));
|
||||
printf("\tFunc name bytes: %" PRIdPTR "\n", static_cast<std::ptrdiff_t>(fnamptr - fnambuf));
|
||||
|
||||
printf("\nPacking RVA data..."); fflush(stdout);
|
||||
*/
|
||||
@@ -256,7 +257,7 @@ int main(int argc, char **argv) {
|
||||
uintptr_t lastrva = firstrva;
|
||||
|
||||
for(; itRVA != itRVAEnd; ++itRVA) {
|
||||
ptrdiff_t rvadiff = (*itRVA).rva - lastrva;
|
||||
std::ptrdiff_t rvadiff = (*itRVA).rva - lastrva;
|
||||
|
||||
lastrva += rvadiff;
|
||||
|
||||
@@ -287,7 +288,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
fwrite(header, 64, 1, fo);
|
||||
|
||||
size_t t;
|
||||
std::size_t t;
|
||||
|
||||
fwrite(&ver, sizeof ver, 1, fo);
|
||||
|
||||
@@ -308,7 +309,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (fclose(fo))
|
||||
throw "output file close failed";
|
||||
|
||||
|
||||
} catch (const char *s) {
|
||||
fprintf(stderr, "%s: %s\n", argv[1], s);
|
||||
}
|
||||
@@ -321,7 +322,7 @@ int main(int argc, char **argv) {
|
||||
/*
|
||||
* (c) 2002 Avery Lee
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -331,7 +332,7 @@ int main(int argc, char **argv) {
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
Reference in New Issue
Block a user