Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
m417z
kdlibcpp
Commits
7c3fcfbf
Commit
7c3fcfbf
authored
Jan 10, 2019
by
Aleksey R.
Browse files
add: addSyntheticModule
add: removeSyntheticModule add: test: of synthetic symbols and modules
parent
9126f440
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
6 deletions
+72
-6
kdlib/include/kdlib/dbgengine.h
kdlib/include/kdlib/dbgengine.h
+4
-0
kdlib/source/win/dbgeng.cpp
kdlib/source/win/dbgeng.cpp
+27
-4
kdlib/tests/kdlibtest/kdlibtest.vcxproj
kdlib/tests/kdlibtest/kdlibtest.vcxproj
+1
-0
kdlib/tests/kdlibtest/kdlibtest.vcxproj.filters
kdlib/tests/kdlibtest/kdlibtest.vcxproj.filters
+5
-2
kdlib/tests/kdlibtest/syntest.cpp
kdlib/tests/kdlibtest/syntest.cpp
+35
-0
No files found.
kdlib/include/kdlib/dbgengine.h
View file @
7c3fcfbf
...
...
@@ -199,6 +199,10 @@ void getSyntheticSymbolInformation(
SyntheticSymbol
addSyntheticSymbol
(
MEMOFFSET_64
offset
,
unsigned
long
size
,
const
std
::
wstring
&
name
);
void
removeSyntheticSymbol
(
const
SyntheticSymbol
&
syntheticSymbol
);
// synthetic modules
void
addSyntheticModule
(
MEMOFFSET_64
base
,
unsigned
long
size
,
const
std
::
wstring
&
name
,
const
std
::
wstring
&
path
=
std
::
wstring
{});
void
removeSyntheticModule
(
MEMOFFSET_64
base
);
std
::
wstring
loadSourceFileFromSrcSrv
(
MEMOFFSET_64
offset
,
const
std
::
wstring
&
fileName
);
// aux function
...
...
kdlib/source/win/dbgeng.cpp
View file @
7c3fcfbf
...
...
@@ -2650,7 +2650,7 @@ std::wstring loadSourceFileFromSrcSrv(MEMOFFSET_64 offset, const std::wstring& f
///////////////////////////////////////////////////////////////////////////////
kdlib
::
SyntheticSymbol
addSyntheticSymbol
(
kdlib
::
MEMOFFSET_64
offset
,
unsigned
long
size
,
const
std
::
wstring
&
name
)
kdlib
::
SyntheticSymbol
addSyntheticSymbol
(
kdlib
::
MEMOFFSET_64
offset
,
unsigned
long
size
,
const
std
::
wstring
&
name
)
{
offset
=
addr64
(
offset
);
...
...
@@ -2665,15 +2665,14 @@ kdlib::SyntheticSymbol addSyntheticSymbol( kdlib::MEMOFFSET_64 offset, unsigned
if
(
FAILED
(
hres
)
)
throw
DbgEngException
(
L"IDebugSymbols::AddSyntheticSymbolWide"
,
hres
);
SyntheticSymbol
syntheticSymbol
=
{
moduleAndId
.
ModuleBase
,
moduleAndId
.
Id
};
return
std
::
move
(
syntheticSymbol
);
return
SyntheticSymbol
{
moduleAndId
.
ModuleBase
,
moduleAndId
.
Id
};
}
///////////////////////////////////////////////////////////////////////////////
void
removeSyntheticSymbol
(
const
kdlib
::
SyntheticSymbol
&
syntheticSymbol
)
{
DEBUG_MODULE_AND_ID
moduleAndId
=
{
syntheticSymbol
.
moduleBase
,
syntheticSymbol
.
symbolId
};
DEBUG_MODULE_AND_ID
moduleAndId
{
syntheticSymbol
.
moduleBase
,
syntheticSymbol
.
symbolId
};
HRESULT
hres
=
g_dbgMgr
->
symbols
->
RemoveSyntheticSymbol
(
&
moduleAndId
);
if
(
FAILED
(
hres
)
)
...
...
@@ -2682,6 +2681,30 @@ void removeSyntheticSymbol(const kdlib::SyntheticSymbol& syntheticSymbol)
///////////////////////////////////////////////////////////////////////////////
void
addSyntheticModule
(
MEMOFFSET_64
base
,
unsigned
long
size
,
const
std
::
wstring
&
name
,
const
std
::
wstring
&
path
/* = std::wstring{} */
)
{
HRESULT
hres
=
g_dbgMgr
->
symbols
->
AddSyntheticModuleWide
(
addr64
(
base
),
size
,
path
.
empty
()
?
name
.
c_str
()
:
path
.
c_str
(),
name
.
c_str
(),
DEBUG_ADDSYNTHMOD_DEFAULT
);
if
(
FAILED
(
hres
)
)
throw
DbgEngException
(
L"IDebugSymbols::AddSyntheticModuleWide"
,
hres
);
}
///////////////////////////////////////////////////////////////////////////////
void
removeSyntheticModule
(
MEMOFFSET_64
base
)
{
HRESULT
hres
=
g_dbgMgr
->
symbols
->
RemoveSyntheticModule
(
addr64
(
base
));
if
(
FAILED
(
hres
))
throw
DbgEngException
(
L"IDebugSymbols::RemoveSyntheticModule"
,
hres
);
}
///////////////////////////////////////////////////////////////////////////////
void
dinput
(
const
std
::
wstring
&
str
)
{
g_dbgMgr
->
control
->
ReturnInputWide
(
str
.
c_str
());
...
...
kdlib/tests/kdlibtest/kdlibtest.vcxproj
View file @
7c3fcfbf
...
...
@@ -215,6 +215,7 @@
<ClCompile
Include=
"stdafx.cpp"
>
<PrecompiledHeader>
Create
</PrecompiledHeader>
</ClCompile>
<ClCompile
Include=
"syntest.cpp"
/>
<ClCompile
Include=
"taggedtest.cpp"
/>
<ClCompile
Include=
"targettest.cpp"
/>
<ClCompile
Include=
"typedvartest.cpp"
/>
...
...
kdlib/tests/kdlibtest/kdlibtest.vcxproj.filters
View file @
7c3fcfbf
...
...
@@ -69,14 +69,17 @@
<Filter>
testcases
</Filter>
</ClCompile>
<ClCompile
Include=
"typeevaltest.cpp"
>
<Filter>
testcases
</Filter>
</ClCompile>
<Filter>
testcases
</Filter>
</ClCompile>
<ClCompile
Include=
"arm64dumptest.cpp"
>
<Filter>
testcases
</Filter>
</ClCompile>
<ClCompile
Include=
"armdumptest.cpp"
>
<Filter>
testcases
</Filter>
</ClCompile>
<ClCompile
Include=
"syntest.cpp"
>
<Filter>
testcases
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"stdafx.h"
/>
...
...
kdlib/tests/kdlibtest/syntest.cpp
0 → 100644
View file @
7c3fcfbf
#include <stdafx.h>
#include "procfixture.h"
using
namespace
kdlib
;
class
SyntheticsTest
:
public
ProcessFixture
{
public:
SyntheticsTest
()
:
ProcessFixture
(
L"syntest"
)
{
}
};
TEST_F
(
SyntheticsTest
,
Symbol
)
{
SyntheticSymbol
synSym
{};
EXPECT_NO_THROW
(
synSym
=
addSyntheticSymbol
(
m_targetModule
->
getBase
()
+
1
,
1
,
L"artificial_symbol"
));
EXPECT_NO_THROW
(
removeSyntheticSymbol
(
synSym
));
// exception: symbol outside module
EXPECT_THROW
(
addSyntheticSymbol
(
32
*
1024
,
1
,
L"impossible_symbol"
),
DbgException
);
}
TEST_F
(
SyntheticsTest
,
Module
)
{
constexpr
MEMOFFSET_64
base
=
64
*
1024
;
EXPECT_NO_THROW
(
addSyntheticModule
(
base
,
1024
,
L"artificial_module"
));
SyntheticSymbol
synSym
{};
EXPECT_NO_THROW
(
synSym
=
addSyntheticSymbol
(
base
+
2
,
1
,
L"artificial_symbol"
));
EXPECT_NO_THROW
(
removeSyntheticSymbol
(
synSym
));
EXPECT_NO_THROW
(
removeSyntheticModule
(
base
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment