Skip to content

Commit

Permalink
Fix debugger warnings in unit tests
Browse files Browse the repository at this point in the history
The sml client Agent destructor calls `KillDebugger` as a precautionary cleanup,
though the debugger process may never have been spawned. This lead to hundreds
of warnings in the unit tests, where agents are constantly created and
destroyed. Users are likely seeing this message in their applications as well.

Add an `ignoreNonExistent` parameter to `KillDebugger` that prevents a warning
from being printed when the debugger process is not present. Don't expose to
SWIG bindings for now, but use it in the Agent destructor, which takes care of
spurious warnings.

Thanks to Aaron Mininger for reporting.
  • Loading branch information
garfieldnate committed Sep 3, 2024
1 parent ca9cad7 commit 0518713
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Core/ClientSML/src/sml_ClientAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Agent::Agent(Kernel* pKernel, char const* pName)

Agent::~Agent()
{
KillDebugger();
KillDebugger(true);
}

Connection* Agent::GetConnection() const
Expand Down Expand Up @@ -1839,11 +1839,14 @@ bool Agent::SpawnDebugger(int port, const char* jarpath)
#endif // _WIN32
}

bool Agent::KillDebugger()
bool Agent::KillDebugger(bool ignoreNonExistent)
{
if (!m_pDPI)
{
std::cerr << "KillDebugger: No existing debugger process information" << std::endl;
if (!ignoreNonExistent)
{
std::cerr << "KillDebugger: No existing debugger process information" << std::endl;
}
return false;
}
bool successful = false;
Expand Down
10 changes: 8 additions & 2 deletions Core/ClientSML/src/sml_ClientAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,14 @@ namespace sml
* @brief Kills the previously spawned debugger. Returns false
* if the debugger was never spawned or an OS issue occurs
* while killing the process.
*************************************************************/
bool KillDebugger();
* @param ignoreNonExistent if true, do not print a warning if
* no debugger process exists to kill. This is useful, for example,
* when the client doesn't know if the debugger was ever actually
* opened, or whether the user may have closed the window, but wants
* to close it just in case for cleanup purposes. Not currently
* exposed via SWIG bindings.
*************************************************************/
bool KillDebugger(bool ignoreNonExistent = false);

/*************************************************************
* @brief Convert a client-side identifier string to kernel-side.
Expand Down

0 comments on commit 0518713

Please sign in to comment.