Commit 9aa4b1ce authored by ussrhero's avatar ussrhero

added additional parameter mask for debugCommad function

parent 3625e55d
......@@ -35,7 +35,7 @@ PROCESS_DEBUG_ID attachKernel( const std::wstring &connectOptions = L"" );
bool isDumpAnalyzing();
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 );
DebugOptionsSet getDebugOptions();
......
......@@ -39,6 +39,8 @@ bool initialize()
ClrDebugManager::init();
g_dbgMgr->control->ExecuteWide(DEBUG_OUTCTL_THIS_CLIENT, L".echo", 0);
return true;
}
......@@ -55,6 +57,8 @@ bool remote_initialize( const std::wstring& remoteOptions )
ClrDebugManager::init();
g_dbgMgr->control->ExecuteWide(DEBUG_OUTCTL_THIS_CLIENT, L".echo", 0);
return true;
}
......@@ -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;
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 ) )
throw DbgEngException( L"IDebugControl::ExecuteWide", hres );
throw DbgEngException( L"IDebugControl::ExecuteWide", hres );
waitForEvent();
......@@ -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 );
if ( FAILED( hres ) )
throw DbgEngException( L"IDebugControl::ExecuteWide", hres );
throw DbgEngException( L"IDebugControl::ExecuteWide", hres );
waitForEvent();
......
......@@ -461,13 +461,12 @@ HRESULT STDMETHODCALLTYPE OutputReader::Output(
__in ULONG Mask,
__in PCSTR Text )
{
m_readLine += _bstr_t(Text);
if ( ( Mask & m_mask ) != 0 )
m_readLine += _bstr_t(Text);
return S_OK;
}
///////////////////////////////////////////////////////////////////
} //kdlib namespace end
......@@ -238,20 +238,23 @@ class OutputReader : public IDebugOutputCallbacks, private boost::noncopyable {
public:
explicit OutputReader(IDebugClient5* client)
explicit OutputReader(IDebugClient5* client, ULONG outputMask = DEBUG_OUTPUT_NORMAL)
{
HRESULT hres;
m_callbacks = NULL;
m_client = client;
m_mask = outputMask;
hres = m_client->GetOutputCallbacks(&m_callbacks);
if ( FAILED( hres ) )
throw DbgEngException( L"IDebugClient::GetOutputCallbacks", hres);
hres = m_client->SetOutputCallbacks(this );
hres = m_client->SetOutputCallbacks(this);
if ( FAILED( hres ) )
throw DbgEngException( L"IDebugClient::SetOutputCallbacks", hres);
m_client->FlushCallbacks();
}
~OutputReader()
......@@ -297,6 +300,8 @@ private:
CComPtr<IDebugClient5> m_client;
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)
kdlib::debugCommand(L".printf /os \"symbols\"");
kdlib::debugCommand(L".printf /ov \"verbose\"");
kdlib::debugCommand(L".printf /ow \"warning\"");
}
\ No newline at end of file
}
......@@ -196,6 +196,7 @@
<ClCompile Include="clangtest.cpp" />
<ClCompile Include="cputest.cpp" />
<ClCompile Include="crttest.cpp" />
<ClCompile Include="dbgenginetest.cpp" />
<ClCompile Include="disasmtest.cpp" />
<ClCompile Include="eventhandlertest.cpp" />
<ClCompile Include="exprevaltest.cpp" />
......
......@@ -80,6 +80,9 @@
<ClCompile Include="syntest.cpp">
<Filter>testcases</Filter>
</ClCompile>
<ClCompile Include="dbgenginetest.cpp">
<Filter>testcases</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<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