add: addSyntheticModule, removeSyntheticModule

This commit is contained in:
Aleksey R 2019-01-10 20:08:14 +03:00
parent 99b48ad0b4
commit 5f0d7125a4
5 changed files with 40 additions and 2 deletions

@ -1 +1 @@
Subproject commit 9126f4406b47281a331c3022c24eb5de73ca828c Subproject commit 7c3fcfbf80300cf100b6fe98d40662a1c56041b4

View File

@ -213,4 +213,20 @@ std::wstring printSyntheticSymbol(const kdlib::SyntheticSymbol& syntheticSymbol)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void addSyntheticModule(kdlib::MEMOFFSET_64 base, unsigned long size, const std::wstring &name, const std::wstring &path /*= std::wstring{}*/)
{
AutoRestorePyState pystate;
return kdlib::addSyntheticModule(base, size, name, path);
}
///////////////////////////////////////////////////////////////////////////////
void removeSyntheticModule(kdlib::MEMOFFSET_64 base)
{
AutoRestorePyState pystate;
return kdlib::removeSyntheticModule(base);
}
///////////////////////////////////////////////////////////////////////////////
} //end namespace pykd } //end namespace pykd

View File

@ -456,6 +456,9 @@ kdlib::SyntheticSymbol addSyntheticSymbol( kdlib::MEMOFFSET_64 offset, unsigned
void removeSyntheticSymbol(const kdlib::SyntheticSymbol& syntheticSymbol); void removeSyntheticSymbol(const kdlib::SyntheticSymbol& syntheticSymbol);
std::wstring printSyntheticSymbol(const kdlib::SyntheticSymbol& syntheticSymbol); std::wstring printSyntheticSymbol(const kdlib::SyntheticSymbol& syntheticSymbol);
void addSyntheticModule(kdlib::MEMOFFSET_64 base, unsigned long size, const std::wstring &name, const std::wstring &path = std::wstring{});
void removeSyntheticModule(kdlib::MEMOFFSET_64 base);
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
} //end namespace pykd } //end namespace pykd

View File

@ -106,6 +106,8 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromPdb_, pykd::getTypeInfoP
BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromSource_, pykd::getTypeInfoProviderFromSource, 1, 2); BOOST_PYTHON_FUNCTION_OVERLOADS( getTypeInfoProviderFromSource_, pykd::getTypeInfoProviderFromSource, 1, 2);
BOOST_PYTHON_FUNCTION_OVERLOADS(evalExpr_, pykd::evalExpr, 1, 3); BOOST_PYTHON_FUNCTION_OVERLOADS(evalExpr_, pykd::evalExpr, 1, 3);
BOOST_PYTHON_FUNCTION_OVERLOADS( addSyntheticModule_, pykd::addSyntheticModule, 3, 4 );
namespace pykd { namespace pykd {
void initialize() void initialize()
@ -599,7 +601,6 @@ void pykd_init()
python::def("appendSrcPath", pykd::appendSrcPath, python::def("appendSrcPath", pykd::appendSrcPath,
"Append current source path"); "Append current source path");
// synthetic symbol // synthetic symbol
python::def("addSyntheticSymbol", pykd::addSyntheticSymbol, python::def("addSyntheticSymbol", pykd::addSyntheticSymbol,
"The addSyntheticSymbol function adds a synthetic symbol to a module in the current process\n" "The addSyntheticSymbol function adds a synthetic symbol to a module in the current process\n"
@ -607,6 +608,12 @@ void pykd_init()
python::def( "removeSyntheticSymbol", pykd::removeSyntheticSymbol, python::def( "removeSyntheticSymbol", pykd::removeSyntheticSymbol,
"The removeSyntheticSymbol function removes a synthetic symbol from a module in the current proces" ); "The removeSyntheticSymbol function removes a synthetic symbol from a module in the current proces" );
// synthetic module
python::def("addSyntheticModule", pykd::addSyntheticModule, addSyntheticModule_(python::args("base", "size", "name", "path"),
"The addSyntheticModule function adds a synthetic module to the module list the debugger maintains for the current process"));
python::def("removeSyntheticModule", pykd::removeSyntheticModule,
"The removeSyntheticModule function removes a synthetic module from the module list the debugger maintains for the current process");
// secondary callback data // secondary callback data
python::def("enumTagged", pykd::enumTagged, python::def("enumTagged", pykd::enumTagged,
"Return the list of secondary callback data IDs (as a strings)" ); "Return the list of secondary callback data IDs (as a strings)" );

View File

@ -28,3 +28,15 @@ class SynSymTest(unittest.TestCase):
self.assertRaises( pykd.DbgException, target.module.offset, "synSym2" ) self.assertRaises( pykd.DbgException, target.module.offset, "synSym2" )
self.assertRaises( pykd.DbgException, pykd.removeSyntheticSymbol, _synsym ) self.assertRaises( pykd.DbgException, pykd.removeSyntheticSymbol, _synsym )
def testModule(self):
"""Add and remove synthetic module"""
base = 64 * 1024
pykd.addSyntheticModule(base, 1024, "artificial_module1")
pykd.addSyntheticModule(base + 1024, 1024, "artificial_module2", "artificial_module2_path")
pykd.removeSyntheticSymbol( pykd.addSyntheticSymbol(base, 1, "artificial_symbol") )
pykd.removeSyntheticModule(base + 1024)
pykd.removeSyntheticModule(base)