Commit 6a05363c authored by Aleksey R.'s avatar Aleksey R.

add: secondary callback data (issue #14)

parent 39bf8a49
......@@ -14,4 +14,4 @@
#include "kdlib/stack.h"
#include "kdlib/typeinfo.h"
#include "kdlib/typedvar.h"
#include "kdlib/tagged.h"
#pragma once
#include <vector>
#include <list>
#include <guiddef.h>
#include "kdlib/dbgtypedef.h"
namespace kdlib {
///////////////////////////////////////////////////////////////////////////////
using TaggedId = GUID;
using TaggedBuffer = std::vector<unsigned char>;
std::list<TaggedId> enumTagged();
TaggedBuffer loadTaggedBuffer(TaggedId id);
///////////////////////////////////////////////////////////////////////////////
} // kdlib namespace end
......@@ -79,6 +79,7 @@
<ClCompile Include="win\processimpl.cpp" />
<ClCompile Include="win\strconvert.cpp" />
<ClCompile Include="win\sympath.cpp" />
<ClCompile Include="win\tagged.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\kdlib\breakpoint.h" />
......@@ -100,6 +101,7 @@
<ClInclude Include="..\include\kdlib\scope.h" />
<ClInclude Include="..\include\kdlib\stack.h" />
<ClInclude Include="..\include\kdlib\symengine.h" />
<ClInclude Include="..\include\kdlib\tagged.h" />
<ClInclude Include="..\include\kdlib\typedvar.h" />
<ClInclude Include="..\include\kdlib\typeinfo.h" />
<ClInclude Include="..\include\kdlib\variant.h" />
......@@ -193,7 +195,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<LLVM_USE_CRT_RELEASE>MD</LLVM_USE_CRT_RELEASE>
<LLVM_USE_CRT_RELEASE>MD</LLVM_USE_CRT_RELEASE>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
......@@ -201,7 +203,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<LLVM_USE_CRT_RELEASE>MTd</LLVM_USE_CRT_RELEASE>
<LLVM_USE_CRT_RELEASE>MTd</LLVM_USE_CRT_RELEASE>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
......
......@@ -136,6 +136,9 @@
<Filter>net</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\lib\native\src\boost_chrono.chrono.cpp" />
<ClCompile Include="win\tagged.cpp">
<Filter>win</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
......@@ -275,6 +278,9 @@
<ClInclude Include="net\metadata.h">
<Filter>net</Filter>
</ClInclude>
<ClInclude Include="..\include\kdlib\tagged.h">
<Filter>kdlib/include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="kdlib/include">
......
#include "stdafx.h"
#include "kdlib/tagged.h"
#include "win/dbgmgr.h"
namespace kdlib {
///////////////////////////////////////////////////////////////////////////////
std::list<TaggedId> enumTagged()
{
ULONG64 handle{};
auto hres = g_dbgMgr->dataspace->StartEnumTagged(&handle);
if (S_OK != hres)
throw DbgEngException(L"IDebugDataSpaces3::StartEnumTagged", hres);
const auto enumDelete =
[](ULONG64 *handle)
{
const auto hres = g_dbgMgr->dataspace->EndEnumTagged(*handle);
if (S_OK != hres)
throw DbgEngException(L"IDebugDataSpaces3::EndEnumTagged", hres);
};
std::unique_ptr<ULONG64, decltype(enumDelete)> endGuard{&handle, enumDelete};
std::list<TaggedId> result;
for (; ; )
{
TaggedId id{};
ULONG tmp{};
hres = g_dbgMgr->dataspace->GetNextTagged(handle, &id, &tmp);
if (S_FALSE == hres)
break;
if (S_OK != hres)
throw DbgEngException(L"IDebugDataSpaces3::GetNextTagged", hres);
result.emplace_back( std::move(id) );
}
return std::move(result);
}
///////////////////////////////////////////////////////////////////////////////
TaggedBuffer loadTaggedBuffer(TaggedId id)
{
ULONG size{};
auto hres = g_dbgMgr->dataspace->ReadTagged(&id, 0, nullptr, 0, &size);
if (S_OK != hres)
throw DbgEngException(L"IDebugDataSpaces4::ReadTagged", hres);
if (!size)
return TaggedBuffer{};
TaggedBuffer result(size);
hres = g_dbgMgr->dataspace->ReadTagged(&id, 0, result.data(), size, &size);
if (S_OK != hres)
throw DbgEngException(L"IDebugDataSpaces4::ReadTagged", hres);
return std::move(result);
}
///////////////////////////////////////////////////////////////////////////////
} // kdlib namespace end
......@@ -20,7 +20,8 @@
#include "crttest.h"
#include "clangtest.h"
#include "nettest.h"
#include "taggedtest.h"
#ifdef _M_AMD64
#include "regtest_x64.h"
#endif
......
......@@ -201,6 +201,7 @@
<ClInclude Include="regtest_x64.h" />
<ClInclude Include="stacktest.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="taggedtest.h" />
<ClInclude Include="targettest.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="typedvartest.h" />
......
......@@ -80,6 +80,9 @@
<ClInclude Include="nettest.h">
<Filter>testcases</Filter>
</ClInclude>
<ClInclude Include="taggedtest.h">
<Filter>testcases</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.kdlibtest_vc120.config" />
......
......@@ -31,6 +31,11 @@ public:
{}
}
static std::wstring getKernelDumpName()
{
return L"..\\..\\..\\kdlib\\tests\\dumps\\win8_x64_mem.cab";
}
private:
std::wstring m_dumpName;
......
#pragma once
#include "memdumpfixture.h"
#include "kdlib/tagged.h"
using namespace kdlib;
class TaggedTest : public MemDumpFixture
{
public:
TaggedTest() : MemDumpFixture(MemDumpFixture::getKernelDumpName()) {}
};
struct __declspec(uuid("D03DC06F-D88E-44C5-BA2A-FAE035172D19")) ExistingId {};
struct __declspec(uuid("88597A32-1493-41CA-BF87-2A950DF4CEE0")) NonExistingId {};
TEST_F(TaggedTest, enum)
{
std::list<TaggedId> ids;
ASSERT_NO_THROW( ids = enumTagged() );
EXPECT_NE( std::find(ids.cbegin(), ids.cend(), __uuidof(ExistingId)), ids.cend() );
EXPECT_EQ( std::find(ids.cbegin(), ids.cend(), __uuidof(NonExistingId)), ids.cend() );
}
TEST_F(TaggedTest, load)
{
TaggedBuffer buff;
ASSERT_NO_THROW( buff = loadTaggedBuffer(__uuidof(ExistingId)) );
EXPECT_EQ( buff.size(), 0x410 );
EXPECT_THROW( loadTaggedBuffer(__uuidof(NonExistingId)), DbgException );
}
......@@ -17,12 +17,6 @@ public:
class KernelDumpTest : public BaseFixture
{
public:
std::wstring getKernelDumpName()
{
return L"..\\..\\..\\kdlib\\tests\\dumps\\win8_x64_mem.cab";
}
bool is64BitSystem() {
return true;
}
......@@ -31,7 +25,7 @@ public:
{
PROCESS_DEBUG_ID dumpId;
ASSERT_NO_THROW(dumpId = kdlib::loadDump(getKernelDumpName()));
ASSERT_NO_THROW(dumpId = kdlib::loadDump(MemDumpFixture::getKernelDumpName()));
m_dumpIds.push_back(dumpId);
}
......
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