Commit e1bceada authored by ussrhero's avatar ussrhero
Browse files

Merge branch 'debugCommandMask' into 'dev-1.0'

added additional parameter mask for debugCommad function

See merge request !27
parents 3625e55d 9aa4b1ce
...@@ -35,7 +35,7 @@ PROCESS_DEBUG_ID attachKernel( const std::wstring &connectOptions = L"" ); ...@@ -35,7 +35,7 @@ PROCESS_DEBUG_ID attachKernel( const std::wstring &connectOptions = L"" );
bool isDumpAnalyzing(); bool isDumpAnalyzing();
bool isKernelDebugging(); bool isKernelDebugging();
std::wstring debugCommand(const std::wstring &command, bool suppressOutput=false); std::wstring debugCommand(const std::wstring &command, bool suppressOutput = false, const OutputFlagsSet& captureFlags = OutputFlag::Normal);
NumVariant evaluate( const std::wstring &expression, bool cplusplus=false ); NumVariant evaluate( const std::wstring &expression, bool cplusplus=false );
DebugOptionsSet getDebugOptions(); DebugOptionsSet getDebugOptions();
......
...@@ -39,6 +39,8 @@ bool initialize() ...@@ -39,6 +39,8 @@ bool initialize()
ClrDebugManager::init(); ClrDebugManager::init();
g_dbgMgr->control->ExecuteWide(DEBUG_OUTCTL_THIS_CLIENT, L".echo", 0);
return true; return true;
} }
...@@ -55,6 +57,8 @@ bool remote_initialize( const std::wstring& remoteOptions ) ...@@ -55,6 +57,8 @@ bool remote_initialize( const std::wstring& remoteOptions )
ClrDebugManager::init(); ClrDebugManager::init();
g_dbgMgr->control->ExecuteWide(DEBUG_OUTCTL_THIS_CLIENT, L".echo", 0);
return true; return true;
} }
...@@ -525,18 +529,18 @@ bool isKernelDebugging() ...@@ -525,18 +529,18 @@ bool isKernelDebugging()
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
std::wstring debugCommand( const std::wstring &command, bool suppressOutput ) std::wstring debugCommand( const std::wstring &command, bool suppressOutput, const OutputFlagsSet& captureFlags)
{ {
HRESULT hres; HRESULT hres;
if ( suppressOutput ) if ( suppressOutput )
{ {
OutputReader outReader( g_dbgMgr->client ); OutputReader outReader( g_dbgMgr->client, static_cast<ULONG>(captureFlags));
hres = g_dbgMgr->control->ExecuteWide( DEBUG_OUTCTL_THIS_CLIENT, command.c_str(), 0 ); hres = g_dbgMgr->control->ExecuteWide( DEBUG_OUTCTL_THIS_CLIENT, command.c_str(), 0 );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgEngException( L"IDebugControl::ExecuteWide", hres ); throw DbgEngException( L"IDebugControl::ExecuteWide", hres );
waitForEvent(); waitForEvent();
...@@ -546,7 +550,7 @@ std::wstring debugCommand( const std::wstring &command, bool suppressOutput ) ...@@ -546,7 +550,7 @@ std::wstring debugCommand( const std::wstring &command, bool suppressOutput )
hres = g_dbgMgr->control->ExecuteWide( DEBUG_OUTCTL_ALL_CLIENTS, command.c_str(), 0 ); hres = g_dbgMgr->control->ExecuteWide( DEBUG_OUTCTL_ALL_CLIENTS, command.c_str(), 0 );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgEngException( L"IDebugControl::ExecuteWide", hres ); throw DbgEngException( L"IDebugControl::ExecuteWide", hres );
waitForEvent(); waitForEvent();
......
...@@ -461,13 +461,12 @@ HRESULT STDMETHODCALLTYPE OutputReader::Output( ...@@ -461,13 +461,12 @@ HRESULT STDMETHODCALLTYPE OutputReader::Output(
__in ULONG Mask, __in ULONG Mask,
__in PCSTR Text ) __in PCSTR Text )
{ {
m_readLine += _bstr_t(Text); if ( ( Mask & m_mask ) != 0 )
m_readLine += _bstr_t(Text);
return S_OK; return S_OK;
} }
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
} //kdlib namespace end } //kdlib namespace end
...@@ -238,20 +238,23 @@ class OutputReader : public IDebugOutputCallbacks, private boost::noncopyable { ...@@ -238,20 +238,23 @@ class OutputReader : public IDebugOutputCallbacks, private boost::noncopyable {
public: public:
explicit OutputReader(IDebugClient5* client) explicit OutputReader(IDebugClient5* client, ULONG outputMask = DEBUG_OUTPUT_NORMAL)
{ {
HRESULT hres; HRESULT hres;
m_callbacks = NULL; m_callbacks = NULL;
m_client = client; m_client = client;
m_mask = outputMask;
hres = m_client->GetOutputCallbacks(&m_callbacks); hres = m_client->GetOutputCallbacks(&m_callbacks);
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgEngException( L"IDebugClient::GetOutputCallbacks", hres); throw DbgEngException( L"IDebugClient::GetOutputCallbacks", hres);
hres = m_client->SetOutputCallbacks(this ); hres = m_client->SetOutputCallbacks(this);
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgEngException( L"IDebugClient::SetOutputCallbacks", hres); throw DbgEngException( L"IDebugClient::SetOutputCallbacks", hres);
m_client->FlushCallbacks();
} }
~OutputReader() ~OutputReader()
...@@ -297,6 +300,8 @@ private: ...@@ -297,6 +300,8 @@ private:
CComPtr<IDebugClient5> m_client; CComPtr<IDebugClient5> m_client;
PDEBUG_OUTPUT_CALLBACKS m_callbacks; PDEBUG_OUTPUT_CALLBACKS m_callbacks;
ULONG m_mask;
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
#include <stdafx.h>
#include "procfixture.h"
#include "kdlib/dbgengine.h"
using namespace kdlib;
using namespace testing;
class DbgEngineTest : public ProcessFixture
{
};
TEST_F(DbgEngineTest, DbgCommandSuppress)
{
EXPECT_EQ(L"", kdlib::debugCommand(kdlib::debugCommand(L".printf /ow \"warning\""), true));
EXPECT_EQ(L"normal", kdlib::debugCommand(L".printf /on \"normal\"", true, OutputFlag::Normal));
EXPECT_EQ(L"", kdlib::debugCommand(L".printf /oe \"error\"", true, OutputFlag::Normal));
EXPECT_EQ(L"", kdlib::debugCommand(L".printf /on \"normal\"", true, OutputFlag::Error));
EXPECT_EQ(L"error", kdlib::debugCommand(L".printf /oe \"error\"", true, OutputFlag::Error));
EXPECT_EQ(L"", kdlib::debugCommand(L".printf /os \"symbols\"", true, OutputFlag::Normal | OutputFlag::Warning));
}
...@@ -222,4 +222,4 @@ TEST_F(EventHandlerTest, DebugOutput) ...@@ -222,4 +222,4 @@ TEST_F(EventHandlerTest, DebugOutput)
kdlib::debugCommand(L".printf /os \"symbols\""); kdlib::debugCommand(L".printf /os \"symbols\"");
kdlib::debugCommand(L".printf /ov \"verbose\""); kdlib::debugCommand(L".printf /ov \"verbose\"");
kdlib::debugCommand(L".printf /ow \"warning\""); kdlib::debugCommand(L".printf /ow \"warning\"");
} }
\ No newline at end of file
...@@ -196,6 +196,7 @@ ...@@ -196,6 +196,7 @@
<ClCompile Include="clangtest.cpp" /> <ClCompile Include="clangtest.cpp" />
<ClCompile Include="cputest.cpp" /> <ClCompile Include="cputest.cpp" />
<ClCompile Include="crttest.cpp" /> <ClCompile Include="crttest.cpp" />
<ClCompile Include="dbgenginetest.cpp" />
<ClCompile Include="disasmtest.cpp" /> <ClCompile Include="disasmtest.cpp" />
<ClCompile Include="eventhandlertest.cpp" /> <ClCompile Include="eventhandlertest.cpp" />
<ClCompile Include="exprevaltest.cpp" /> <ClCompile Include="exprevaltest.cpp" />
......
...@@ -80,6 +80,9 @@ ...@@ -80,6 +80,9 @@
<ClCompile Include="syntest.cpp"> <ClCompile Include="syntest.cpp">
<Filter>testcases</Filter> <Filter>testcases</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="dbgenginetest.cpp">
<Filter>testcases</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment