1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-02-17 11:18:31 +01:00

feat(launcher): Integrate procmon as optional dependency

Integrate this as an optional dependency into launcher and
load it dynamically. Thus, these can be easily loaded/enabled
by developers and end-users.
This commit is contained in:
icex2 2024-02-25 09:36:53 +01:00
parent 024929e13c
commit 81821490bd
4 changed files with 58 additions and 5 deletions

View File

@ -14,6 +14,8 @@ libs_launcher := \
core \
hook \
util \
dwarfstack \
procmon-lib \
src_launcher := \
avs-config.c \

View File

@ -16,8 +16,14 @@
PSMAP_BEGIN(launcher_debug_psmap)
PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, remote_debugger,
"debug/remote_debugger", false)
PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, log_property_configs,
PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, log_property_configs,
"debug/log_property_configs", false)
PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, procmon_file,
"debug/procmon/file", false)
PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, procmon_module,
"debug/procmon/module", false)
PSMAP_OPTIONAL(PSMAP_TYPE_BOOL, struct launcher_debug_config, procmon_thread,
"debug/procmon/thread", false)
PSMAP_END
// clang-format on
@ -192,6 +198,9 @@ void launcher_config_init(struct launcher_config *config)
config->debug.remote_debugger = false;
config->debug.log_property_configs = false;
config->debug.procmon_file = false;
config->debug.procmon_module = false;
config->debug.procmon_thread = false;
}
void launcher_config_load(

View File

@ -36,6 +36,9 @@ struct launcher_config {
struct launcher_debug_config {
bool remote_debugger;
bool log_property_configs;
bool procmon_file;
bool procmon_module;
bool procmon_thread;
} debug;
};

View File

@ -33,6 +33,9 @@
#include "launcher/stubs.h"
#include "launcher/version.h"
#include "procmon-lib/procmon.h"
#include "util/debug.h"
#include "util/defs.h"
#include "util/fs.h"
#include "util/os.h"
@ -261,6 +264,32 @@ _launcher_remote_debugger_trap(const struct launcher_debug_config *config)
}
}
static void _launcher_procmon_init(
const struct launcher_debug_config *config,
struct procmon *procmon)
{
procmon_init(procmon);
if (procmon_available()) {
procmon_load(procmon);
procmon->set_loggers(log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
procmon->init();
if (config->procmon_file) {
procmon->file_mon_enable();
}
if (config->procmon_module) {
procmon->module_mon_enable();
}
if (config->procmon_thread) {
procmon->thread_mon_enable();
}
}
}
static void _launcher_bootstrap_config_load(
const struct launcher_bootstrap_config *launcher_bootstrap_config,
struct bootstrap_config *config)
@ -435,7 +464,8 @@ void _launcher_init(
const struct options *options,
struct launcher_config *launcher_config,
struct bootstrap_config *bootstrap_config,
struct ea3_ident_config *ea3_ident_config)
struct ea3_ident_config *ea3_ident_config,
struct procmon *procmon)
{
struct property *launcher_property;
@ -490,6 +520,8 @@ void _launcher_init(
_launcher_remote_debugger_trap(&launcher_config->debug);
_launcher_procmon_init(&launcher_config->debug, procmon);
_launcher_bootstrap_config_load(
&launcher_config->bootstrap, bootstrap_config);
_launcher_bootstrap_log_config_options_override(
@ -550,10 +582,12 @@ void _launcher_run(
void _launcher_fini(
struct launcher_config *launcher_config,
const struct bootstrap_config *bootstrap_config)
const struct bootstrap_config *bootstrap_config,
struct procmon *procmon)
{
log_assert(launcher_config);
log_assert(bootstrap_config);
log_assert(procmon);
bootstrap_eamuse_fini(&bootstrap_config->startup.eamuse);
@ -563,6 +597,10 @@ void _launcher_fini(
bootstrap_module_game_fini();
if (procmon->module != NULL) {
procmon_free(procmon);
}
launcher_config_fini(launcher_config);
log_info("Shutdown complete");
@ -575,13 +613,14 @@ void launcher_main(const struct options *options)
struct launcher_config launcher_config;
struct bootstrap_config bootstrap_config;
struct ea3_ident_config ea3_ident_config;
struct procmon procmon;
log_assert(options);
_launcher_init(
options, &launcher_config, &bootstrap_config, &ea3_ident_config);
options, &launcher_config, &bootstrap_config, &ea3_ident_config, &procmon);
_launcher_run(&launcher_config, &bootstrap_config, &ea3_ident_config);
_launcher_fini(&launcher_config, &bootstrap_config);
_launcher_fini(&launcher_config, &bootstrap_config, &procmon);
}