1
0
forked from 0ad/0ad

remove dbghelp and directx libraries (not redistributable)

move dbghelp and powrprof-specific stuff into external_libraries
dbghelp: dynamically import functions to avoid needing the .lib

This was SVN commit r6912.
This commit is contained in:
janwas 2009-06-20 17:50:43 +00:00
parent 2019c12b0f
commit d9bb1a7447
9 changed files with 342 additions and 264 deletions

View File

@ -69,16 +69,9 @@ extern_lib_defs = {
dbg_suffix = "d",
no_delayload = 1
},
dbghelp = {
win_names = { "dbghelp" },
dbg_suffix = "",
},
devil = {
unix_names = { "IL", "ILU" },
},
directx = {
dbg_suffix = "",
},
-- rationale: see libraries_dir..enet/lib/rationale.txt
enet =
{

View File

@ -449,8 +449,6 @@ function setup_all_libs ()
"openal",
"vorbis",
"libjpg",
"dbghelp",
"directx",
"cryptopp",
"valgrind"
}
@ -507,9 +505,7 @@ used_extern_libs = {
"vorbis",
"boost",
"dbghelp",
"cxxtest",
"directx",
"comsuppw",
"enet",
}

View File

@ -0,0 +1,36 @@
/* Copyright (C) 2009 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#include "precompiled.h"
#include "dbghelp.h"
// define extension function pointers
extern "C"
{
#define FUNC(ret, name, params) ret (__stdcall *p##name) params;
#include "dbghelp_funcs.h"
#undef FUNC
}
void dbghelp_ImportFunctions()
{
HMODULE hDbghelp = LoadLibraryW(L"dbghelp.dll");
debug_assert(hDbghelp);
#define FUNC(ret, name, params) p##name = (ret (__stdcall*) params)GetProcAddress(hDbghelp, #name);
#include "dbghelp_funcs.h"
#undef FUNC
}

View File

@ -16,21 +16,113 @@
*/
/*
* bring in dbghelp library
* bring in dbghelp library.
*/
#ifndef INCLUDED_DBGHELP
#define INCLUDED_DBGHELP
#include "win.h"
#include "lib/sysdep/os/win/win.h"
#define _NO_CVCONST_H // request SymTagEnum be defined
#include <dbghelp.h> // must come after win.h
#include <OAIdl.h> // VARIANT
#if MSC_VERSION
# pragma comment(lib, "dbghelp.lib")
# pragma comment(lib, "oleaut32.lib") // VariantChangeType
#endif
//-----------------------------------------------------------------------------
// fix omissions in the VC PSDK's dbghelp.h
// the macros defined "for those without specstrings.h" are incorrect -
// parameter definition is missing.
#ifndef __specstrings
# define __specstrings // prevent dbghelp from changing these
# define __in
# define __out
# define __inout
# define __in_opt
# define __out_opt
# define __inout_opt
# define __in_ecount(s)
# define __out_ecount(s)
# define __inout_ecount(s)
# define __in_bcount(s)
# define __out_bcount(s)
# define __inout_bcount(s)
# define __deref_opt_out
# define __deref_out
#endif
// (VC2005 defines __specstrings, but doesn't define (or use) __out_xcount,
// so this is not inside the above #ifndef section)
//
// missing from dbghelp's list
#ifndef __out_xcount
# define __out_xcount(s)
#endif
//
// not defined by dbghelp; these values are taken from DIA cvconst.h
//
enum BasicType
{
btNoType = 0,
btVoid = 1,
btChar = 2,
btWChar = 3,
btInt = 6,
btUInt = 7,
btFloat = 8,
btBCD = 9,
btBool = 10,
btLong = 13,
btULong = 14,
btCurrency = 25,
btDate = 26,
btVariant = 27,
btComplex = 28,
btBit = 29,
btBSTR = 30,
btHresult = 31
};
enum DataKind
{
DataIsUnknown,
DataIsLocal,
DataIsStaticLocal,
DataIsParam,
DataIsObjectPtr,
DataIsFileStatic,
DataIsGlobal,
DataIsMember,
DataIsStaticMember,
DataIsConstant
};
//-----------------------------------------------------------------------------
#define _NO_CVCONST_H // request SymTagEnum be defined
#include <dbghelp.h> // must come after win.h and the above definitions
//-----------------------------------------------------------------------------
// rationale: Debugging Tools For Windows includes newer header/lib files,
// but they're not redistributable. since we don't want everyone to
// have to install that, it's preferable to link dynamically.
// declare function pointers
#define FUNC(ret, name, params) EXTERN_C ret (__stdcall *p##name) params;
#include "dbghelp_funcs.h"
#undef FUNC
extern void dbghelp_ImportFunctions();
#endif // #ifndef INCLUDED_DBGHELP

View File

@ -0,0 +1,13 @@
FUNC(BOOL, SymInitializeW, (__in HANDLE hProcess, __in_opt PCWSTR UserSearchPath, __in BOOL fInvadeProcess))
FUNC(DWORD, SymGetOptions, (VOID))
FUNC(DWORD, SymSetOptions, (__in DWORD SymOptions))
FUNC(DWORD64, SymGetModuleBase64, (__in HANDLE hProcess, __in DWORD64 qwAddr))
FUNC(BOOL, SymFromAddrW, (__in HANDLE hProcess, __in DWORD64 Address, __out_opt PDWORD64 Displacement, __inout PSYMBOL_INFOW Symbol))
FUNC(BOOL, SymGetLineFromAddr64, (__in HANDLE hProcess, __in DWORD64 qwAddr, __out PDWORD pdwDisplacement, __out PIMAGEHLP_LINE64 Line64))
FUNC(PVOID, SymFunctionTableAccess64, (__in HANDLE hProcess, __in DWORD64 AddrBase))
FUNC(BOOL, SymGetTypeInfo, (__in HANDLE hProcess, __in DWORD64 ModBase, __in ULONG TypeId, __in IMAGEHLP_SYMBOL_TYPE_INFO GetType, __out PVOID pInfo))
FUNC(BOOL, SymFromIndexW, (__in HANDLE hProcess, __in ULONG64 BaseOfDll, __in DWORD Index, __inout PSYMBOL_INFOW Symbol))
FUNC(BOOL, SymSetContext, (__in HANDLE hProcess, __in PIMAGEHLP_STACK_FRAME StackFrame, __in_opt PIMAGEHLP_CONTEXT Context))
FUNC(BOOL, SymEnumSymbolsW, (__in HANDLE hProcess, __in ULONG64 BaseOfDll, __in_opt PCWSTR Mask, __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, __in_opt PVOID UserContext))
FUNC(PIMAGE_NT_HEADERS, ImageNtHeader, (__in PVOID Base))
FUNC(BOOL, MiniDumpWriteDump, (IN HANDLE hProcess, IN DWORD ProcessId, IN HANDLE hFile, IN MINIDUMP_TYPE DumpType, IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL IN CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, OPTIONAL IN CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam OPTIONAL))

View File

@ -0,0 +1,155 @@
/* Copyright (C) 2009 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* bring in powrprof library.
*/
#ifndef INCLUDED_POWRPROF
#define INCLUDED_POWRPROF
#include "lib/sysdep/os/win/win.h"
#include <powrprof.h>
// the VC7 headers are missing some parts:
// MinGW headers are already correct; only change on VC
#if MSC_VERSION && MSC_VERSION < 1400
#ifndef NTSTATUS
#define NTSTATUS long
#endif
#ifndef STATUS_SUCCESS
#define STATUS_SUCCESS 0
#endif
#if WINVER < 0x500
typedef enum {
SystemPowerPolicyAc,
SystemPowerPolicyDc,
VerifySystemPolicyAc,
VerifySystemPolicyDc,
SystemPowerCapabilities,
SystemBatteryState,
SystemPowerStateHandler,
ProcessorStateHandler,
SystemPowerPolicyCurrent,
AdministratorPowerPolicy,
SystemReserveHiberFile,
ProcessorInformation,
SystemPowerInformation,
ProcessorStateHandler2,
LastWakeTime, // Compare with KeQueryInterruptTime()
LastSleepTime, // Compare with KeQueryInterruptTime()
SystemExecutionState,
SystemPowerStateNotifyHandler,
ProcessorPowerPolicyAc,
ProcessorPowerPolicyDc,
VerifyProcessorPowerPolicyAc,
VerifyProcessorPowerPolicyDc,
ProcessorPowerPolicyCurrent,
SystemPowerStateLogging,
SystemPowerLoggingEntry
} POWER_INFORMATION_LEVEL;
typedef struct {
DWORD Granularity;
DWORD Capacity;
} BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
typedef enum _SYSTEM_POWER_STATE {
PowerSystemUnspecified = 0,
PowerSystemWorking = 1,
PowerSystemSleeping1 = 2,
PowerSystemSleeping2 = 3,
PowerSystemSleeping3 = 4,
PowerSystemHibernate = 5,
PowerSystemShutdown = 6,
PowerSystemMaximum = 7
} SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
typedef struct {
// Misc supported system features
BOOLEAN PowerButtonPresent;
BOOLEAN SleepButtonPresent;
BOOLEAN LidPresent;
BOOLEAN SystemS1;
BOOLEAN SystemS2;
BOOLEAN SystemS3;
BOOLEAN SystemS4; // hibernate
BOOLEAN SystemS5; // off
BOOLEAN HiberFilePresent;
BOOLEAN FullWake;
BOOLEAN VideoDimPresent;
BOOLEAN ApmPresent;
BOOLEAN UpsPresent;
// Processors
BOOLEAN ThermalControl;
BOOLEAN ProcessorThrottle;
BYTE ProcessorMinThrottle;
BYTE ProcessorMaxThrottle;
BYTE spare2[4];
// Disk
BOOLEAN DiskSpinDown;
BYTE spare3[8];
// System Battery
BOOLEAN SystemBatteriesPresent;
BOOLEAN BatteriesAreShortTerm;
BATTERY_REPORTING_SCALE BatteryScale[3];
// Wake
SYSTEM_POWER_STATE AcOnLineWake;
SYSTEM_POWER_STATE SoftLidWake;
SYSTEM_POWER_STATE RtcWake;
SYSTEM_POWER_STATE MinDeviceWakeState; // note this may change on driver load
SYSTEM_POWER_STATE DefaultLowLatencyWake;
} SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
#endif // WINVER < 0x500
typedef struct _SYSTEM_POWER_INFORMATION
{
ULONG MaxIdlenessAllowed;
ULONG Idleness;
ULONG TimeRemaining;
UCHAR CoolingMode;
} SYSTEM_POWER_INFORMATION, *PSYSTEM_POWER_INFORMATION;
// SPI.CoolingMode
#define PO_TZ_INVALID_MODE 0 // The system does not support CPU throttling,
// or there is no thermal zone defined [..]
#endif // #if MSC_VERSION
// neither VC7.1 nor MinGW define this
typedef struct _PROCESSOR_POWER_INFORMATION
{
ULONG Number;
ULONG MaxMhz;
ULONG CurrentMhz;
ULONG MhzLimit;
ULONG MaxIdleState;
ULONG CurrentIdleState;
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
#endif // #ifndef INCLUDED_POWRPROF

View File

@ -21,7 +21,6 @@
#include "lib/sysdep/os/win/win.h"
#include <crtdbg.h>
#include <excpt.h>
#include <dbghelp.h>
#include "lib/sysdep/cpu.h" // cpu_AtomicAdd
#include "winit.h"

View File

@ -72,28 +72,30 @@ static LibError sym_init()
hProcess = GetCurrentProcess();
dbghelp_ImportFunctions();
// set options
// notes:
// - can be done before SymInitialize; we do so in case
// any of the options affect it.
// - do not set directly - that would zero any existing flags.
DWORD opts = SymGetOptions();
DWORD opts = pSymGetOptions();
opts |= SYMOPT_DEFERRED_LOADS; // the "fastest, most efficient way"
//opts |= SYMOPT_DEBUG; // lots of debug spew in output window
opts |= SYMOPT_UNDNAME;
SymSetOptions(opts);
pSymSetOptions(opts);
// initialize dbghelp.
// .. request symbols from all currently active modules be loaded.
const BOOL fInvadeProcess = TRUE;
// .. use default *symbol* search path. we don't use this to locate
// our PDB file because its absolute path is stored inside the EXE.
PCSTR UserSearchPath = 0;
BOOL ok = SymInitialize(hProcess, UserSearchPath, fInvadeProcess);
PWSTR UserSearchPath = 0;
BOOL ok = pSymInitializeW(hProcess, UserSearchPath, fInvadeProcess);
WARN_IF_FALSE(ok);
mod_base = (uintptr_t)SymGetModuleBase64(hProcess, (u64)&sym_init);
IMAGE_NT_HEADERS* header = ImageNtHeader((void*)(uintptr_t)mod_base);
mod_base = (uintptr_t)pSymGetModuleBase64(hProcess, (u64)&sym_init);
IMAGE_NT_HEADERS* header = pImageNtHeader((void*)(uintptr_t)mod_base);
machine = header->FileHeader.Machine;
return INFO::OK;
@ -145,7 +147,7 @@ static LibError ResolveSymbol_lk(void* ptr_of_interest, char* sym_name, char* fi
SYMBOL_INFO_PACKAGEW2 sp;
SYMBOL_INFOW* sym = &sp.si;
if(SymFromAddrW(hProcess, addr, 0, sym))
if(pSymFromAddrW(hProcess, addr, 0, sym))
{
wsprintfA(sym_name, "%ws", sym->Name);
successes++;
@ -159,8 +161,8 @@ static LibError ResolveSymbol_lk(void* ptr_of_interest, char* sym_name, char* fi
*line = 0;
IMAGEHLP_LINE64 line_info = { sizeof(IMAGEHLP_LINE64) };
DWORD displacement; // unused but required by SymGetLineFromAddr64!
if(SymGetLineFromAddr64(hProcess, addr, &displacement, &line_info))
DWORD displacement; // unused but required by pSymGetLineFromAddr64!
if(pSymGetLineFromAddr64(hProcess, addr, &displacement, &line_info))
{
if(file)
{
@ -387,7 +389,7 @@ LibError wdbg_sym_WalkStack(StackFrameCallback cb, uintptr_t cbData, const CONTE
// so we have to reset it and check for 0. *sigh*
SetLastError(0);
const HANDLE hThread = GetCurrentThread();
const BOOL ok = StackWalk64(machine, hProcess, hThread, &sf, (PVOID)pcontext, 0, SymFunctionTableAccess64, SymGetModuleBase64, 0);
const BOOL ok = StackWalk64(machine, hProcess, hThread, &sf, (PVOID)pcontext, 0, pSymFunctionTableAccess64, pSymGetModuleBase64, 0);
// note: don't use LibError_from_win32 because it raises a warning,
// and this "fails" commonly (when no stack frames are left).
err = ok? INFO::OK : ERR::FAIL;
@ -881,7 +883,7 @@ static LibError DetermineSymbolAddress(DWORD id, const SYMBOL_INFOW* sym, const
const _tagSTACKFRAME64* sf = current_stackframe64;
DWORD dataKind;
if(!SymGetTypeInfo(hProcess, mod_base, id, TI_GET_DATAKIND, &dataKind))
if(!pSymGetTypeInfo(hProcess, mod_base, id, TI_GET_DATAKIND, &dataKind))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
LibError ret = CanHandleDataKind(dataKind);
RETURN_ERR(ret);
@ -935,18 +937,18 @@ static LibError DetermineSymbolAddress(DWORD id, const SYMBOL_INFOW* sym, const
static LibError dump_sym_array(DWORD type_id, const u8* p, DumpState state)
{
ULONG64 size_ = 0;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
const size_t size = (size_t)size_;
// get element count and size
DWORD el_type_id = 0;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &el_type_id))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &el_type_id))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
// .. workaround: TI_GET_COUNT returns total struct size for
// arrays-of-struct. therefore, calculate as size / el_size.
ULONG64 el_size_;
if(!SymGetTypeInfo(hProcess, mod_base, el_type_id, TI_GET_LENGTH, &el_size_))
if(!pSymGetTypeInfo(hProcess, mod_base, el_type_id, TI_GET_LENGTH, &el_size_))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
const size_t el_size = (size_t)el_size_;
debug_assert(el_size != 0);
@ -976,10 +978,10 @@ static void AppendCharacterIfPrintable(u64 data)
static LibError dump_sym_base_type(DWORD type_id, const u8* p, DumpState state)
{
DWORD base_type;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_BASETYPE, &base_type))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_BASETYPE, &base_type))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
ULONG64 size_ = 0;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
const size_t size = (size_t)size_;
@ -1110,14 +1112,14 @@ display_as_hex:
static LibError dump_sym_base_class(DWORD type_id, const u8* p, DumpState state)
{
DWORD base_class_type_id;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &base_class_type_id))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &base_class_type_id))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
// this is a virtual base class. we can't display those because it'd
// require reading the VTbl, which is difficult given lack of documentation
// and just not worth it.
DWORD vptr_ofs;
if(SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_VIRTUALBASEPOINTEROFFSET, &vptr_ofs))
if(pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_VIRTUALBASEPOINTEROFFSET, &vptr_ofs))
return ERR::SYM_UNSUPPORTED; // NOWARN
return dump_sym(base_class_type_id, p, state);
@ -1130,7 +1132,7 @@ static LibError dump_sym_data(DWORD id, const u8* p, DumpState state)
{
SYMBOL_INFO_PACKAGEW2 sp;
SYMBOL_INFOW* sym = &sp.si;
if(!SymFromIndexW(hProcess, mod_base, id, sym))
if(!pSymFromIndexW(hProcess, mod_base, id, sym))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
out(L"%ws = ", sym->Name);
@ -1153,7 +1155,7 @@ static LibError dump_sym_data(DWORD id, const u8* p, DumpState state)
static LibError dump_sym_enum(DWORD type_id, const u8* p, DumpState UNUSED(state))
{
ULONG64 size_ = 0;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
const size_t size = (size_t)size_;
@ -1161,10 +1163,10 @@ static LibError dump_sym_enum(DWORD type_id, const u8* p, DumpState UNUSED(state
// get array of child symbols (enumerants).
DWORD num_children;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_CHILDRENCOUNT, &num_children))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_CHILDRENCOUNT, &num_children))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
TI_FINDCHILDREN_PARAMS2 fcp(num_children);
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_FINDCHILDREN, &fcp))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_FINDCHILDREN, &fcp))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
num_children = fcp.p.Count; // was truncated to MAX_CHILDREN
const DWORD* children = fcp.p.ChildId;
@ -1180,7 +1182,7 @@ static LibError dump_sym_enum(DWORD type_id, const u8* p, DumpState UNUSED(state
// it manually and guarantees we cover everything. the OLE DLL is
// already pulled in by e.g. OpenGL anyway.
VARIANT v;
if(!SymGetTypeInfo(hProcess, mod_base, child_data_id, TI_GET_VALUE, &v))
if(!pSymGetTypeInfo(hProcess, mod_base, child_data_id, TI_GET_VALUE, &v))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
if(VariantChangeType(&v, &v, 0, VT_I8) != S_OK)
continue;
@ -1189,7 +1191,7 @@ static LibError dump_sym_enum(DWORD type_id, const u8* p, DumpState UNUSED(state
if(enum_value == v.llVal)
{
const wchar_t* name;
if(!SymGetTypeInfo(hProcess, mod_base, child_data_id, TI_GET_SYMNAME, &name))
if(!pSymGetTypeInfo(hProcess, mod_base, child_data_id, TI_GET_SYMNAME, &name))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
out(L"%s", name);
LocalFree((HLOCAL)name);
@ -1287,7 +1289,7 @@ static bool ptr_already_visited(const u8* p)
static LibError dump_sym_pointer(DWORD type_id, const u8* p, DumpState state)
{
ULONG64 size_ = 0;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
const size_t size = (size_t)size_;
@ -1313,7 +1315,7 @@ static LibError dump_sym_pointer(DWORD type_id, const u8* p, DumpState state)
// if the pointed-to value turns out to uninteresting (e.g. void*),
// the responsible dump_sym* will erase "->", leaving only address.
out(L" -> ");
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &type_id))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &type_id))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
// prevent infinite recursion just to be safe (shouldn't happen)
@ -1329,7 +1331,7 @@ static LibError dump_sym_pointer(DWORD type_id, const u8* p, DumpState state)
static LibError dump_sym_typedef(DWORD type_id, const u8* p, DumpState state)
{
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &type_id))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_TYPEID, &type_id))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
return dump_sym(type_id, p, state);
}
@ -1354,7 +1356,7 @@ static LibError udt_get_child_type(const wchar_t* child_name, ULONG num_children
SYMBOL_INFO_PACKAGEW2 sp;
SYMBOL_INFOW* sym = &sp.si;
if(!SymFromIndexW(hProcess, mod_base, child_id, sym))
if(!pSymFromIndexW(hProcess, mod_base, child_id, sym))
{
// this happens for several UDTs; cause is unknown.
debug_assert(GetLastError() == ERROR_NOT_FOUND);
@ -1556,7 +1558,7 @@ static LibError udt_dump_normal(const wchar_t* type_name, const u8* p, size_t si
// get offset. if not available, skip this child
// (we only display data here, not e.g. typedefs)
DWORD ofs = 0;
if(!SymGetTypeInfo(hProcess, mod_base, child_id, TI_GET_OFFSET, &ofs))
if(!pSymGetTypeInfo(hProcess, mod_base, child_id, TI_GET_OFFSET, &ofs))
continue;
if(ofs >= size)
{
@ -1612,22 +1614,22 @@ static LibError udt_dump_normal(const wchar_t* type_name, const u8* p, size_t si
static LibError dump_sym_udt(DWORD type_id, const u8* p, DumpState state)
{
ULONG64 size_ = 0;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_LENGTH, &size_))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
const size_t size = (size_t)size_;
// get array of child symbols (members/functions/base classes).
DWORD num_children;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_CHILDRENCOUNT, &num_children))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_CHILDRENCOUNT, &num_children))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
TI_FINDCHILDREN_PARAMS2 fcp(num_children);
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_FINDCHILDREN, &fcp))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_FINDCHILDREN, &fcp))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
num_children = fcp.p.Count; // was truncated to MAX_CHILDREN
const DWORD* children = fcp.p.ChildId;
const wchar_t* type_name;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_SYMNAME, &type_name))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_SYMNAME, &type_name))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
LibError ret;
@ -1669,7 +1671,7 @@ static LibError dump_sym_unknown(DWORD type_id, const u8* UNUSED(p), DumpState U
{
// redundant (already done in dump_sym), but this is rare.
DWORD type_tag;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_SYMTAG, &type_tag))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_SYMTAG, &type_tag))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
debug_printf("SYM| unknown tag: %d\n", type_tag);
@ -1688,7 +1690,7 @@ static LibError dump_sym(DWORD type_id, const u8* p, DumpState state)
RETURN_ERR(out_check_limit());
DWORD type_tag;
if(!SymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_SYMTAG, &type_tag))
if(!pSymGetTypeInfo(hProcess, mod_base, type_id, TI_GET_SYMTAG, &type_tag))
WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE);
switch(type_tag)
{
@ -1808,10 +1810,10 @@ static LibError dump_frame_cb(const _tagSTACKFRAME64* sf, uintptr_t UNUSED(cbDat
// which isn't worth the trouble. since
IMAGEHLP_STACK_FRAME2 imghlp_frame(sf);
const PIMAGEHLP_CONTEXT context = 0; // ignored
SymSetContext(hProcess, &imghlp_frame, context);
pSymSetContext(hProcess, &imghlp_frame, context);
const ULONG64 base = 0; const wchar_t* const mask = 0; // use scope set by SymSetContext
SymEnumSymbolsW(hProcess, base, mask, dump_sym_cb, 0);
const ULONG64 base = 0; const wchar_t* const mask = 0; // use scope set by pSymSetContext
pSymEnumSymbolsW(hProcess, base, mask, dump_sym_cb, 0);
out(L"\r\n");
return INFO::CB_CONTINUE;
@ -1864,7 +1866,7 @@ void wdbg_sym_WriteMinidump(EXCEPTION_POINTERS* exception_pointers)
// non-Windows platforms. users will just have to send us both files.
HANDLE hProcess = GetCurrentProcess(); DWORD pid = GetCurrentProcessId();
if(!MiniDumpWriteDump(hProcess, pid, hFile, MiniDumpNormal, &mei, 0, 0))
if(!pMiniDumpWriteDump(hProcess, pid, hFile, MiniDumpNormal, &mei, 0, 0))
DEBUG_DISPLAY_ERROR(L"wdbg_sym_WriteMinidump: unable to generate minidump.");
CloseHandle(hFile);

View File

@ -89,214 +89,6 @@
#include <winreg.h>
//-----------------------------------------------------------------------------
// powrprof.h (missing some parts in VC7)
//-----------------------------------------------------------------------------
// MinGW headers are already correct; only change on VC
#if MSC_VERSION && MSC_VERSION < 1400
#ifndef NTSTATUS
#define NTSTATUS long
#endif
#ifndef STATUS_SUCCESS
#define STATUS_SUCCESS 0
#endif
#if WINVER < 0x500
typedef enum {
SystemPowerPolicyAc,
SystemPowerPolicyDc,
VerifySystemPolicyAc,
VerifySystemPolicyDc,
SystemPowerCapabilities,
SystemBatteryState,
SystemPowerStateHandler,
ProcessorStateHandler,
SystemPowerPolicyCurrent,
AdministratorPowerPolicy,
SystemReserveHiberFile,
ProcessorInformation,
SystemPowerInformation,
ProcessorStateHandler2,
LastWakeTime, // Compare with KeQueryInterruptTime()
LastSleepTime, // Compare with KeQueryInterruptTime()
SystemExecutionState,
SystemPowerStateNotifyHandler,
ProcessorPowerPolicyAc,
ProcessorPowerPolicyDc,
VerifyProcessorPowerPolicyAc,
VerifyProcessorPowerPolicyDc,
ProcessorPowerPolicyCurrent,
SystemPowerStateLogging,
SystemPowerLoggingEntry
} POWER_INFORMATION_LEVEL;
typedef struct {
DWORD Granularity;
DWORD Capacity;
} BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
typedef enum _SYSTEM_POWER_STATE {
PowerSystemUnspecified = 0,
PowerSystemWorking = 1,
PowerSystemSleeping1 = 2,
PowerSystemSleeping2 = 3,
PowerSystemSleeping3 = 4,
PowerSystemHibernate = 5,
PowerSystemShutdown = 6,
PowerSystemMaximum = 7
} SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
typedef struct {
// Misc supported system features
BOOLEAN PowerButtonPresent;
BOOLEAN SleepButtonPresent;
BOOLEAN LidPresent;
BOOLEAN SystemS1;
BOOLEAN SystemS2;
BOOLEAN SystemS3;
BOOLEAN SystemS4; // hibernate
BOOLEAN SystemS5; // off
BOOLEAN HiberFilePresent;
BOOLEAN FullWake;
BOOLEAN VideoDimPresent;
BOOLEAN ApmPresent;
BOOLEAN UpsPresent;
// Processors
BOOLEAN ThermalControl;
BOOLEAN ProcessorThrottle;
BYTE ProcessorMinThrottle;
BYTE ProcessorMaxThrottle;
BYTE spare2[4];
// Disk
BOOLEAN DiskSpinDown;
BYTE spare3[8];
// System Battery
BOOLEAN SystemBatteriesPresent;
BOOLEAN BatteriesAreShortTerm;
BATTERY_REPORTING_SCALE BatteryScale[3];
// Wake
SYSTEM_POWER_STATE AcOnLineWake;
SYSTEM_POWER_STATE SoftLidWake;
SYSTEM_POWER_STATE RtcWake;
SYSTEM_POWER_STATE MinDeviceWakeState; // note this may change on driver load
SYSTEM_POWER_STATE DefaultLowLatencyWake;
} SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
#endif // WINVER < 0x500
typedef struct _SYSTEM_POWER_INFORMATION
{
ULONG MaxIdlenessAllowed;
ULONG Idleness;
ULONG TimeRemaining;
UCHAR CoolingMode;
} SYSTEM_POWER_INFORMATION, *PSYSTEM_POWER_INFORMATION;
// SPI.CoolingMode
#define PO_TZ_INVALID_MODE 0 // The system does not support CPU throttling,
// or there is no thermal zone defined [..]
#endif // #if MSC_VERSION
// neither VC7.1 nor MinGW define this
typedef struct _PROCESSOR_POWER_INFORMATION
{
ULONG Number;
ULONG MaxMhz;
ULONG CurrentMhz;
ULONG MhzLimit;
ULONG MaxIdleState;
ULONG CurrentIdleState;
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
//-----------------------------------------------------------------------------
// fixes for dbghelp.h 6.4
//-----------------------------------------------------------------------------
// the macros defined "for those without specstrings.h" are incorrect -
// parameter definition is missing.
#ifndef __specstrings
# define __specstrings // prevent dbghelp from changing these
# define __in
# define __out
# define __inout
# define __in_opt
# define __out_opt
# define __inout_opt
# define __in_ecount(s)
# define __out_ecount(s)
# define __inout_ecount(s)
# define __in_bcount(s)
# define __out_bcount(s)
# define __inout_bcount(s)
# define __deref_opt_out
# define __deref_out
#endif
// (VC2005 defines __specstrings, but doesn't define (or use) __out_xcount,
// so this is not inside the above #ifndef section)
//
// missing from dbghelp's list
#ifndef __out_xcount
# define __out_xcount(s)
#endif
//
// not defined by dbghelp; these values are taken from DIA cvconst.h
//
enum BasicType
{
btNoType = 0,
btVoid = 1,
btChar = 2,
btWChar = 3,
btInt = 6,
btUInt = 7,
btFloat = 8,
btBCD = 9,
btBool = 10,
btLong = 13,
btULong = 14,
btCurrency = 25,
btDate = 26,
btVariant = 27,
btComplex = 28,
btBit = 29,
btBSTR = 30,
btHresult = 31
};
enum DataKind
{
DataIsUnknown,
DataIsLocal,
DataIsStaticLocal,
DataIsParam,
DataIsObjectPtr,
DataIsFileStatic,
DataIsGlobal,
DataIsMember,
DataIsStaticMember,
DataIsConstant
};
#if ARCH_IA32
// the official version causes pointer truncation warnings.
# undef InterlockedExchangePointer