Skip to content

Commit

Permalink
Add an option, logServerCommands, that when enabled and running a deb…
Browse files Browse the repository at this point in the history
…ug or debugoptimized build of the bridge, logs the commands being processed by the bridge server to the bridge log.
  • Loading branch information
nv-ajaus committed Feb 8, 2024
1 parent 53a452f commit 8e1a65e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bridge.conf
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@

# logApiCalls = False

# Like logApiCalls, setting LogAllCalls to True will write each call
# Like logApiCalls, setting LogAllCalls to True while running a
# Debug or Debugoptimized build of the bridge will write each call
# to a D3D9 API function through the bridge client to to the the
# client log file ("d3d9.log"), except both the entry and exit of
# the call will be logged. This includes clientside internal calls to
Expand All @@ -256,6 +257,15 @@

# logAllCalls = False

# In a Debug or DebugOptimized build of the bridge, setting LogServerCommands
# to True will write each command sent to the server to the server log file
# ("NvRemixBridge.log")
# Default is false.
#
# Supported values: True, False

# logServerCommands = False


# The bridge client and server inter-process communication (IPC) relies
# on sending a lot of commands and data from the client to the server
Expand Down
5 changes: 5 additions & 0 deletions src/server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ void ProcessDeviceCommandQueue() {
ZoneName(commandStr.c_str(), commandStr.size());
}
PULL_U(currentUID);
#if defined(_DEBUG) || defined(DEBUGOPT)
if (GlobalOptions::getLogServerCommands()) {
Logger::info(toString(rpcHeader.command));
}
#endif
std::unique_lock<std::mutex> lock(gLock);
// The mother of all switch statements - every call in the D3D9 interface is mapped here...
switch (rpcHeader.command) {
Expand Down
5 changes: 5 additions & 0 deletions src/server/module_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ void processModuleCommandQueue(std::atomic<bool>* const pbSignalEnd) {
Commands::Bridge_Any, 0, pbSignalEnd))) {
const Header rpcHeader = ModuleBridge::pop_front();
PULL_U(currentUID);
#if defined(_DEBUG) || defined(DEBUGOPT)
if (GlobalOptions::getLogServerCommands()) {
Logger::info(toString(rpcHeader.command));
}
#endif
std::unique_lock<std::mutex> lock(gLock);
// The mother of all switch statements - every call in the D3D9 interface is mapped here...
switch (rpcHeader.command) {
Expand Down
11 changes: 11 additions & 0 deletions src/util/config/global_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class GlobalOptions {
return get().logApiCalls;
}

static bool getLogServerCommands() {
return get().logServerCommands;
}

static uint32_t getCommandTimeout() {
#ifdef _DEBUG
return (get().disableTimeouts || (IsDebuggerPresent() && get().disableTimeoutsWhenDebugging)) ? 0 : get().commandTimeout;
Expand Down Expand Up @@ -311,6 +315,12 @@ class GlobalOptions {
// public D3D9 API function will be offset by an additional tab.
logAllCalls = bridge_util::Config::getOption<bool>("logAllCalls", false);

// In a Debug or DebugOptimized build of the bridge, setting LogServerCommands
// to True will write each command sent to the server to the server log file
// ("NvRemixBridge.log")

logServerCommands = bridge_util::Config::getOption<bool>("logServerCommands", false);

// These values strike a good balance between not waiting too long during the
// handshake on startup, which we expect to be relatively quick, while still being
// resilient enough against blips that can cause intermittent timeouts during
Expand Down Expand Up @@ -416,6 +426,7 @@ class GlobalOptions {
bool sendCreateFunctionServerResponses;
bool logAllCalls;
bool logApiCalls;
bool logServerCommands;
uint32_t commandTimeout;
uint32_t startupTimeout;
uint32_t ackTimeout;
Expand Down

0 comments on commit 8e1a65e

Please sign in to comment.