add additional logging information

This commit is contained in:
nillerusr 2022-09-05 12:54:41 +03:00
parent f11087b83a
commit 3e19d26a72
8 changed files with 139 additions and 17 deletions

View File

@ -206,8 +206,6 @@ void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, vo
{
retval = _glGetProcAddress(fn);
Msg("_glGetProcAddress(%s) = %x\n", fn, retval);
if( !retval && l_gles )
retval = dlsym( l_gles, fn );
}

View File

@ -23,6 +23,7 @@ GNU General Public License for more details.
#include <SDL_version.h>
#include "tier0/dbg.h"
#include "tier0/threadtools.h"
#include <sys/system_properties.h>
char *LauncherArgv[512];
char java_args[4096];
@ -33,13 +34,13 @@ extern void InitCrashHandler();
DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setenv(JNIEnv *jenv, jclass *jclass, jstring env, jstring value, jint over)
{
Msg( "Java_com_valvesoftware_ValveActivity2_setenv %s=%s", jenv->GetStringUTFChars(env, NULL), jenv->GetStringUTFChars(value, NULL) );
Msg( "Java_com_valvesoftware_ValveActivity2_setenv %s=%s\n", jenv->GetStringUTFChars(env, NULL), jenv->GetStringUTFChars(value, NULL) );
return setenv( jenv->GetStringUTFChars(env, NULL), jenv->GetStringUTFChars(value, NULL), over );
}
DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_nativeOnActivityResult()
{
Msg( "Java_com_valvesoftware_ValveActivity_nativeOnActivityResult" );
// Msg( "Java_com_valvesoftware_ValveActivity_nativeOnActivityResult\n" );
}
DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_setArgs(JNIEnv *env, jclass *clazz, jstring str)
@ -55,7 +56,6 @@ void SetLauncherArgs()
static char binPath[2048];
snprintf(binPath, sizeof binPath, "%s/hl2_linux", getenv("APP_DATA_PATH") );
Msg(binPath);
D(binPath);
D("-nouserclip");
@ -77,12 +77,50 @@ void SetLauncherArgs()
#undef D
}
float GetTotalMemory()
{
int64_t mem = 0;
char meminfo[8196] = { 0 };
FILE *f = fopen("/proc/meminfo", "r");
if( !f )
return 0.f;
size_t size = fread(meminfo, 1, sizeof(meminfo), f);
if( !size )
return 0.f;
char *s = strstr(meminfo, "MemTotal:");
if( !s ) return 0.f;
sscanf(s+9, "%lld", &mem);
fclose(f);
return mem/1024/1024.f;
}
void android_property_print(const char *name)
{
char value[1024];
if( __system_property_get( name, value ) != 0 )
Msg("prop %s=%s\n", name, value);
}
DLL_EXPORT int LauncherMainAndroid( int argc, char **argv )
{
SDL_version ver;
SDL_GetVersion( &ver );
Msg("SDL version: %d.%d.%d rev: %s\n", (int)ver.major, (int)ver.minor, (int)ver.patch, SDL_GetRevision());
Msg("GetTotalMemory() = %.2f GiB\n", GetTotalMemory());
android_property_print("ro.build.version.sdk");
android_property_print("ro.product.system.device");
android_property_print("ro.product.system.manufacturer");
android_property_print("ro.product.system.model");
android_property_print("ro.product.system.name");
InitCrashHandler();
SetLauncherArgs();

View File

@ -767,6 +767,8 @@ bool CSourceAppSystemGroup::PreInit()
{
if ( !CommandLine()->FindParm( "-nolog" ) )
DebugLogger()->Init("engine.log");
else
DebugLogger()->Disable();
CreateInterfaceFn factory = GetFactory();
ConnectTier1Libraries( &factory, 1 );

View File

@ -53,6 +53,7 @@ class IDbgLogger
public:
virtual void Init(const char *logfile) = 0;
virtual void Write(const char *data) = 0;
virtual void Disable() = 0;
};
PLATFORM_INTERFACE IDbgLogger *DebugLogger();

View File

@ -365,6 +365,23 @@ const tchar* GetProcessorVendorId()
#endif
}
// Return the build's architecture
const tchar* GetProcessorArchName()
{
#if defined( __x86_64__) || defined(_M_X64)
return "amd64";
#elif defined(__i386__) || defined(_X86_) || defined(_M_IX86)
return "i386";
#elif defined __aarch64__
return "aarch64";
#elif defined __arm__ || defined _M_ARM
return "arm";
#else
#error "Unknown architecture"
#endif
}
// Returns non-zero if Hyper-Threading Technology is supported on the processors and zero if not. This does not mean that
// Hyper-Threading Technology is necessarily enabled.
static bool HTSupported(void)

View File

@ -50,6 +50,10 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
extern const tchar* GetProcessorArchName();
#define MAX_MSGS 4196
class CDbgLogger : public IDbgLogger
{
public:
@ -58,18 +62,35 @@ public:
void Init(const char *logfile);
void Write(const char *data);
void Disable();
private:
FILE *file;
float flStartTime;
bool bShouldLog;
char *pMsgs[MAX_MSGS];
size_t iMsg;
};
CDbgLogger::CDbgLogger()
{
bShouldLog = false;
bShouldLog = true;
flStartTime = Plat_FloatTime();
file = NULL;
iMsg = 0;
}
void CDbgLogger::Disable()
{
bShouldLog = false;
while( iMsg > 0 )
{
delete[] pMsgs[iMsg];
iMsg--;
}
}
void CDbgLogger::Init(const char *logfile)
@ -86,13 +107,33 @@ void CDbgLogger::Init(const char *logfile)
Plat_ctime( &timeCur, szTime, sizeof(szTime) );
file = fopen(logfile, "w+");
fprintf(file, ">>> Engine started at %s\n", szTime);
fflush(file);
if( file )
{
#ifdef GIT_COMMIT_HASH
fprintf(file, ">>> Engine(arch:%s commit:" GIT_COMMIT_HASH ") started at %s\n", GetProcessorArchName(), szTime);
#else
fprintf(file, ">>> Engine(arch:%s) started at %s\n", GetProcessorArchName(), szTime);
#endif
fflush(file);
for( int i = 0; i < iMsg; i++ )
{
Write(pMsgs[i]);
delete[] pMsgs[i];
}
iMsg = 0;
}
}
CDbgLogger::~CDbgLogger()
{
if( !bShouldLog )
while( iMsg > 0 )
{
delete[] pMsgs[iMsg];
iMsg--;
}
if( !file )
return;
time_t timeCur;
@ -113,9 +154,21 @@ void CDbgLogger::Write(const char *data)
if( !bShouldLog )
return;
fprintf(file, "[%.4f] ", Plat_FloatTime() - flStartTime);
fprintf(file, "%s", data);
fflush(file);
size_t len = strlen(data);
if( file )
{
fprintf(file, "[%.4f] ", Plat_FloatTime() - flStartTime);
fprintf(file, "%s", data);
fflush(file);
}
else if( iMsg < MAX_MSGS )
{
pMsgs[iMsg] = new char[len+8];
memcpy(pMsgs[iMsg], data, len);
pMsgs[iMsg][len] = 0;
iMsg++;
}
}
static CDbgLogger g_DbgLogger;

View File

@ -212,7 +212,16 @@ static void GetOpenGLVersion(int *major, int *minor, int *patch)
const char *version = (const char *) glGetString(GL_VERSION);
if (version)
{
sscanf( version, "%d.%d.%d", major, minor, patch );
const char *s = version;
while( *s )
{
if( *s >= '0' && *s <= '9' )
{
sscanf( s, "%d.%d", major, minor );
break;
}
s++;
}
}
}
}
@ -240,8 +249,8 @@ static int GetOpenGLVersionPatch()
static bool CheckBaseOpenGLVersion()
{
const int NEED_MAJOR = 2;
const int NEED_MINOR = 0;
const int NEED_MAJOR = 3;
const int NEED_MINOR = 2;
const int NEED_PATCH = 0;
int major, minor, patch;
@ -251,7 +260,7 @@ static bool CheckBaseOpenGLVersion()
const int have = GLVERNUM(major, minor, patch);
if (have < need)
{
fprintf(stderr, "PROBLEM: You appear to have OpenGL %d.%d.%d, but we need at least %d.%d.%d!\n",
Warning("PROBLEM: You appear to have OpenGL %d.%d.%d, but we need at least %d.%d.%d!\n",
major, minor, patch, NEED_MAJOR, NEED_MINOR, NEED_PATCH);
return false;
}
@ -381,9 +390,11 @@ COpenGLEntryPoints::COpenGLEntryPoints()
pszString = ( const char * )glGetString(GL_EXTENSIONS);
m_pGLDriverStrings[cGLExtensionsString] = strdup( pszString ? pszString : "" );
printf( "OpenGL: %s %s (%d.%d.%d)\n", m_pGLDriverStrings[ cGLRendererString ], m_pGLDriverStrings[ cGLVersionString ],
Msg( "GL_RENDERER=\"%s\" GL_VERSION=\"%s\" GL_VENDOR=\"%s\" (%d.%d.%d)\n", m_pGLDriverStrings[ cGLRendererString ], m_pGLDriverStrings[ cGLVersionString ], m_pGLDriverStrings[ cGLVendorString ],
m_nOpenGLVersionMajor, m_nOpenGLVersionMinor, m_nOpenGLVersionPatch );
Msg("GL_EXTENSIONS=\"%s\"\n", m_pGLDriverStrings[cGLExtensionsString]);
// !!! FIXME: Alfred says the original GL_APPLE_fence code only exists to
// !!! FIXME: hint Apple's drivers and not because we rely on the
// !!! FIXME: functionality. If so, just remove this check (and the

View File

@ -282,7 +282,9 @@ def configure(conf):
conf.load('subproject xcompile compiler_c compiler_cxx gitversion clang_compilation_database strip_on_install waf_unit_test enforce_pic')
if conf.env.DEST_OS == 'win32' and conf.env.DEST_CPU == 'amd64':
conf.load('masm')
define_platform(conf)
conf.define('GIT_COMMIT_HASH', conf.env.GIT_VERSION)
if conf.env.TOGLES:
projects['game'] += ['togles']