comments/cosmetics;
fix UNREACHABLE def on unix; string_s: use HAVE_STRING_S; wdbg_sym: fix option set code; explain why search path isn't needed WriteScreenshot: make sure there's enough mem; use Handle to free mem (more efficient+less error prone) This was SVN commit r2779.
This commit is contained in:
parent
0bda64f8e4
commit
609be94b8c
@ -295,6 +295,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// safe string functions: strcpy_s et al.
|
// safe string functions: strcpy_s et al.
|
||||||
|
// these are always available to users: if not provided by the CRT, we
|
||||||
|
// implement them ourselves. this flag is only used to skip our impl.
|
||||||
#if MSC_VERSION >= 1400
|
#if MSC_VERSION >= 1400
|
||||||
# define HAVE_STRING_S 1
|
# define HAVE_STRING_S 1
|
||||||
#else
|
#else
|
||||||
|
@ -294,12 +294,13 @@ enum LibError
|
|||||||
// .. wrapped around the parameter name, e.g. void f(int UNUSED(x))
|
// .. wrapped around the parameter name, e.g. void f(int UNUSED(x))
|
||||||
#define UNUSED(param)
|
#define UNUSED(param)
|
||||||
|
|
||||||
|
// indicates a piece of code cannot be reached (e.g. because all
|
||||||
|
// control paths before it end up returning). this is mostly for
|
||||||
|
// human benefit, but it may also help optimization.
|
||||||
#if MSC_VERSION
|
#if MSC_VERSION
|
||||||
# define UNREACHABLE __assume(0)
|
# define UNREACHABLE __assume(0)
|
||||||
#endif
|
#else
|
||||||
|
# define UNREACHABLE
|
||||||
#ifdef __GNUC__
|
|
||||||
#define UNREACHABLE 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARRAY_SIZE(name) (sizeof(name) / sizeof(name[0]))
|
#define ARRAY_SIZE(name) (sizeof(name) / sizeof(name[0]))
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef VFS_MOUNT_H__
|
#ifndef VFS_MOUNT_H__
|
||||||
#define VFS_MOUNT_H__
|
#define VFS_MOUNT_H__
|
||||||
|
|
||||||
|
#include "file.h"
|
||||||
|
#include "zip.h"
|
||||||
|
|
||||||
extern void mount_init();
|
extern void mount_init();
|
||||||
extern void mount_shutdown();
|
extern void mount_shutdown();
|
||||||
|
|
||||||
@ -21,10 +24,6 @@ enum MountType
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct TFile;
|
|
||||||
#include "file.h"
|
|
||||||
#include "zip.h"
|
|
||||||
|
|
||||||
struct XIo
|
struct XIo
|
||||||
{
|
{
|
||||||
enum MountType type; // internal use only
|
enum MountType type; // internal use only
|
||||||
@ -37,6 +36,8 @@ struct XIo
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TFile;
|
||||||
|
|
||||||
struct XFile
|
struct XFile
|
||||||
{
|
{
|
||||||
enum MountType type; // internal use only
|
enum MountType type; // internal use only
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#ifndef STRINGS_S_H__
|
#ifndef STRING_S_H__
|
||||||
#define STRINGS_S_H__
|
#define STRING_S_H__
|
||||||
|
|
||||||
#include "posix_types.h" // size_t
|
#include "posix_types.h" // size_t
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
// these are already shipped with VC2005
|
// only declare these functions if using our implementation
|
||||||
#if MSC_VERSION < 1400
|
// (otherwise, we risk incompatibilities)
|
||||||
|
#if !HAVE_STRING_S
|
||||||
|
|
||||||
// Conflicts with glibc definitions
|
// (conflicts with glibc definitions)
|
||||||
#if !OS_UNIX
|
#if !OS_UNIX
|
||||||
// return length [in characters] of a string, not including the trailing
|
// return length [in characters] of a string, not including the trailing
|
||||||
// null character. to protect against access violations, only the
|
// null character. to protect against access violations, only the
|
||||||
@ -52,7 +54,6 @@ extern int wcsncat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src, siz
|
|||||||
extern int strcat_s(char* dst, size_t max_dst_chars, const char* src);
|
extern int strcat_s(char* dst, size_t max_dst_chars, const char* src);
|
||||||
extern int wcscat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src);
|
extern int wcscat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src);
|
||||||
|
|
||||||
|
#endif // #if !HAVE_STRING_S
|
||||||
|
|
||||||
#endif // #if MSC_VERSION < 1400
|
#endif // #ifndef STRING_S_H__
|
||||||
|
|
||||||
#endif // #ifndef STRINGS_S_H__
|
|
||||||
|
@ -125,8 +125,6 @@ static ULONG64 mod_base;
|
|||||||
// for StackWalk64; taken from PE header by wdbg_init.
|
// for StackWalk64; taken from PE header by wdbg_init.
|
||||||
static WORD machine;
|
static WORD machine;
|
||||||
|
|
||||||
static const STACKFRAME64* current_stackframe64;
|
|
||||||
|
|
||||||
// call on-demand (allows handling exceptions raised before win.cpp
|
// call on-demand (allows handling exceptions raised before win.cpp
|
||||||
// init functions are called); no effect if already initialized.
|
// init functions are called); no effect if already initialized.
|
||||||
static int sym_init()
|
static int sym_init()
|
||||||
@ -138,10 +136,24 @@ static int sym_init()
|
|||||||
|
|
||||||
hProcess = GetCurrentProcess();
|
hProcess = GetCurrentProcess();
|
||||||
|
|
||||||
SymSetOptions(SYMOPT_DEFERRED_LOADS/*/*|SYMOPT_DEBUG*/);
|
// set options
|
||||||
// loads symbols for all active modules.
|
// notes:
|
||||||
BOOL ok = SymInitialize(hProcess, 0, TRUE);
|
// - can be done before SymInitialize; we do so in case
|
||||||
debug_assert(ok);
|
// any of the options affect it.
|
||||||
|
// - do not set directly - that would zero any existing flags.
|
||||||
|
DWORD opts = SymGetOptions();
|
||||||
|
opts |= SYMOPT_DEFERRED_LOADS; // the "fastest, most efficient way"
|
||||||
|
//opts |= SYMOPT_DEBUG; // lots of debug spew in output window
|
||||||
|
SymSetOptions(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.
|
||||||
|
const char* UserSearchPath = 0;
|
||||||
|
BOOL ok = SymInitialize(hProcess, UserSearchPath, fInvadeProcess);
|
||||||
|
WARN_IF_FALSE(ok);
|
||||||
|
|
||||||
mod_base = SymGetModuleBase64(hProcess, (u64)&sym_init);
|
mod_base = SymGetModuleBase64(hProcess, (u64)&sym_init);
|
||||||
IMAGE_NT_HEADERS* header = ImageNtHeader((void*)mod_base);
|
IMAGE_NT_HEADERS* header = ImageNtHeader((void*)mod_base);
|
||||||
@ -882,7 +894,7 @@ static int dump_array(const u8* p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const STACKFRAME64* current_stackframe64;
|
||||||
|
|
||||||
static int determine_symbol_address(DWORD id, DWORD UNUSED(type_id), const u8** pp)
|
static int determine_symbol_address(DWORD id, DWORD UNUSED(type_id), const u8** pp)
|
||||||
{
|
{
|
||||||
|
@ -305,7 +305,7 @@ static i64 ticks_lk()
|
|||||||
{
|
{
|
||||||
LARGE_INTEGER i;
|
LARGE_INTEGER i;
|
||||||
BOOL ok = QueryPerformanceCounter(&i);
|
BOOL ok = QueryPerformanceCounter(&i);
|
||||||
debug_assert(ok); // shouldn't fail if it was chosen above
|
WARN_IF_FALSE(ok); // shouldn't fail if it was chosen above
|
||||||
return i.QuadPart;
|
return i.QuadPart;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -191,7 +191,13 @@ void WriteScreenshot(const char* extension)
|
|||||||
|
|
||||||
const size_t img_size = w * h * bpp/8;
|
const size_t img_size = w * h * bpp/8;
|
||||||
const size_t hdr_size = tex_hdr_size(fn);
|
const size_t hdr_size = tex_hdr_size(fn);
|
||||||
void* data = mem_alloc(hdr_size+img_size, FILE_BLOCK_SIZE);
|
Handle img_hm;
|
||||||
|
void* data = mem_alloc(hdr_size+img_size, FILE_BLOCK_SIZE, 0, &img_hm);
|
||||||
|
if(!data)
|
||||||
|
{
|
||||||
|
debug_warn("not enough memory to write screenshot");
|
||||||
|
return;
|
||||||
|
}
|
||||||
GLvoid* img = (u8*)data + hdr_size;
|
GLvoid* img = (u8*)data + hdr_size;
|
||||||
|
|
||||||
|
|
||||||
@ -200,5 +206,5 @@ void WriteScreenshot(const char* extension)
|
|||||||
if(tex_write(fn, w, h, bpp, flags, img) < 0)
|
if(tex_write(fn, w, h, bpp, flags, img) < 0)
|
||||||
debug_warn("WriteScreenshot: tex_write failed");
|
debug_warn("WriteScreenshot: tex_write failed");
|
||||||
|
|
||||||
mem_free(img);
|
mem_free_h(img_hm);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user