Commit 199df2e2 authored by ussrhero's avatar ussrhero

Merge branch 'debugOutputTest' into 'dev-1.0'

Fixed onDebugOutput method

See merge request !15
parents dae69fd5 acedc5a2
......@@ -23,7 +23,7 @@ struct DebugEventsCallback {
virtual void onChangeLocalScope() = 0;
virtual void onChangeSymbolPaths() = 0;
virtual void onChangeBreakpoints() = 0;
virtual void onDebugOutput(const std::wstring& text) = 0;
virtual void onDebugOutput(const std::wstring& text, OutputFlag flag) = 0;
virtual void onStartInput() = 0;
virtual void onStopInput() = 0;
......
......@@ -211,6 +211,22 @@ enum BreakpointAccess {
};
enum OutputFlag
{
Normal = 0x00000001,
Error = 0x00000002,
Warning = 0x00000004,
Verbose = 0x00000008,
Prompt = 0x00000010,
PromptRegister = 0x00000020,
ExtensionWarning = 0x00000040,
Debuggee = 0x00000080,
DebuggeePrompt = 0x00000100,
Symbols = 0x00000200,
Status = 0x00000400,
All = 0x000007FF
};
///////////////////////////////////////////////////////////////////////////////
} // kdlib namespace end
......
......@@ -57,7 +57,7 @@ public:
virtual void onChangeBreakpoints()
{}
virtual void onDebugOutput(const std::wstring& text)
virtual void onDebugOutput(const std::wstring& text, OutputFlag flag)
{}
virtual void onStartInput()
......
......@@ -79,7 +79,7 @@ public:
void changeSymbolPaths();
void breakpointsChange(PROCESS_DEBUG_ID id);
DebugCallbackResult exceptionHit(const ExceptionInfo& excinfo);
void debugOutput(const std::wstring& text);
void debugOutput(const std::wstring& text, OutputFlag flag);
void startInput();
void stopInput();
......@@ -298,9 +298,9 @@ DebugCallbackResult ProcessMonitor::exceptionHit(const ExceptionInfo& excinfo)
///////////////////////////////////////////////////////////////////////////////
void ProcessMonitor::debugOutput(const std::wstring& text)
void ProcessMonitor::debugOutput(const std::wstring& text, OutputFlag flag)
{
g_procmon->debugOutput(text);
g_procmon->debugOutput(text, flag);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -660,14 +660,14 @@ DebugCallbackResult ProcessMonitorImpl::exceptionHit(const ExceptionInfo& excin
///////////////////////////////////////////////////////////////////////////////
void ProcessMonitorImpl::debugOutput(const std::wstring& text)
void ProcessMonitorImpl::debugOutput(const std::wstring& text, OutputFlag flag)
{
boost::recursive_mutex::scoped_lock l(m_callbacksLock);
EventsCallbackList::iterator it;
for (it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
{
(*it)->onDebugOutput(text);
(*it)->onDebugOutput(text, flag);
}
}
......
......@@ -32,7 +32,7 @@ public: // notification
static void localScopeChange();
static void changeSymbolPaths();
static DebugCallbackResult exceptionHit(const ExceptionInfo& excinfo);
static void debugOutput(const std::wstring& text);
static void debugOutput(const std::wstring& text, OutputFlag flag);
static void startInput();
static void stopInput();
......
......@@ -40,7 +40,7 @@ DebugManager::DebugManager()
client->SetOutputCallbacksWide(this);
client->SetInputCallbacks(this);
client->SetOutputMask(DEBUG_OUTPUT_NORMAL);
client->SetOutputMask(0xFFFFFFFF); // DEBUG_OUTPUT_NORMAL);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -426,8 +426,7 @@ HRESULT STDMETHODCALLTYPE DebugManager::Output(
{
try {
if ( ( Mask & ( DEBUG_OUTPUT_NORMAL | DEBUG_OUTPUT_ERROR | DEBUG_OUTPUT_WARNING ) ) != 0 )
ProcessMonitor::debugOutput(std::wstring(Text));
ProcessMonitor::debugOutput(std::wstring(Text), OutputFlag(Mask));
}
catch (kdlib::DbgException&)
......
......@@ -17,5 +17,8 @@ public:
MOCK_METHOD0( onChangeSymbolPaths, void(void) );
MOCK_METHOD1(onProcessStart, kdlib::DebugCallbackResult(kdlib::PROCESS_DEBUG_ID processId));
MOCK_METHOD3(onProcessExit, kdlib::DebugCallbackResult(kdlib::PROCESS_DEBUG_ID processid, kdlib::ProcessExitReason reason, unsigned long exitCode));
MOCK_METHOD3(onProcessExit, kdlib::DebugCallbackResult(kdlib::PROCESS_DEBUG_ID processid,
kdlib::ProcessExitReason reason, unsigned long exitCode));
MOCK_METHOD2(onDebugOutput, void(const std::wstring& text, kdlib::OutputFlag flag));
};
......@@ -2,6 +2,7 @@
#include "basefixture.h"
#include "eventhandlermock.h"
#include "kdlib\dbgio.h"
using namespace kdlib;
using namespace testing;
......@@ -196,3 +197,22 @@ TEST_F(EventHandlerTest, SymbolPathChange)
EXPECT_NO_THROW(appendSymbolPath(L"C:\\temp2"));
EXPECT_NO_THROW(setSymbolPath(L"C:\\temp2"));
}
TEST_F(EventHandlerTest, DebugOutput)
{
ASSERT_NO_THROW(startProcess(L"targetapp.exe"));
NiceMock<EventHandlerMock> eventHandler;
EXPECT_CALL(eventHandler, onDebugOutput(_,_)).WillRepeatedly(Return());
kdlib::debugCommand(L".printf /od \"debugee\"");
kdlib::debugCommand(L".printf /oD \"debugee prompt\"");
kdlib::debugCommand(L".printf /oe \"error\"");
kdlib::debugCommand(L".printf /on \"normal\"");
kdlib::debugCommand(L".printf /op \"prompt\"");
kdlib::debugCommand(L".printf /oP \"prompt registers\"");
kdlib::debugCommand(L".printf /os \"symbols\"");
kdlib::debugCommand(L".printf /ov \"verbose\"");
kdlib::debugCommand(L".printf /ow \"warning\"");
}
\ No newline at end of file
......@@ -328,40 +328,43 @@ TEST(TypeEvalTest, TemplateNamespace2)
EXPECT_NO_THROW(evalType("testspace::TestStruct<int,testspace::TestStruct<int,int> >::field1", typeProvider));
}
TEST(TypeEvalTest, DISABLED_TemplateNamespace3)
TEST(TypeEvalTest, TemplateConstExpr)
{
static const char sourceCode[] = " \
namespace testspace { \
template<typename T1, typename T2> \
template<int> \
struct TestStruct { \
T1 field1; \
T2 field2; \
}; \
TestStruct<int,TestStruct<int,int>> testVal; \
} \
TestStruct<10> testVal1; \
TestStruct<-10> testVal2; \
TestStruct<0> testVal3; \
";
TypeInfoProviderPtr typeProvider = getTypeInfoProviderFromSource(sourceCode);
EXPECT_NO_THROW(evalType("testspace::TestStruct<int,testspace::TestStruct<int,int> >", typeProvider));
EXPECT_NO_THROW(evalType("testspace::TestStruct<int,testspace::TestStruct<int,int>>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<-10>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<+10>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<!1>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<~0xFFFFFFFF>", typeProvider));
}
TEST(TypeEvalTest, TemplateConstExpr)
TEST(TypeEvalTest, TemplateClose)
{
static const char sourceCode[] = " \
template<int> \
template<typename T1, typename T2> \
struct TestStruct { \
T1 field1; \
T2 field2; \
}; \
TestStruct<10> testVal1; \
TestStruct<-10> testVal2; \
TestStruct<0> testVal3; \
TestStruct<int,TestStruct<int,int>> testVal1; \
TestStruct<int,TestStruct<int, TestStruct<int,int>>> testVal2; \
";
TypeInfoProviderPtr typeProvider = getTypeInfoProviderFromSource(sourceCode);
EXPECT_NO_THROW(evalType("TestStruct<-10>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<+10>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<!1>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<~0xFFFFFFFF>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<int,TestStruct<int,int> >", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<int,TestStruct<int,int>>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<int,TestStruct<int,TestStruct<int,int> > >", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<int,TestStruct<int,TestStruct<int,int>>>", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<int,TestStruct<int,TestStruct<int,int>> >", typeProvider));
EXPECT_NO_THROW(evalType("TestStruct<int,TestStruct<int,TestStruct<int,int> >>", typeProvider));
}
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