git-svn-id: https://pykd.svn.codeplex.com/svn@66696 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2011-06-12 17:51:38 +00:00
parent 32f3428469
commit 6965f1bcee
14 changed files with 190 additions and 186 deletions

View File

@ -1,7 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include <vector>
#include "dbgext.h" #include "dbgext.h"
#include "dbgdump.h" #include "dbgdump.h"
#include "dbgexcept.h" #include "dbgexcept.h"

View File

@ -2,7 +2,6 @@
#include <wdbgexts.h> #include <wdbgexts.h>
#include <vector>
#include <string> #include <string>
#include <boost/python/module.hpp> #include <boost/python/module.hpp>

View File

@ -1,7 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
#include <vector>
#include "dbgext.h" #include "dbgext.h"
#include "dbgexcept.h" #include "dbgexcept.h"
@ -166,6 +165,7 @@ loadChars( ULONG64 address, ULONG number, BOOLEAN phyAddr )
{ {
std::vector<char> buffer(number); std::vector<char> buffer(number);
if (number)
loadMemory( address, &buffer[0], (ULONG)buffer.size(), phyAddr ); loadMemory( address, &buffer[0], (ULONG)buffer.size(), phyAddr );
return boost::python::object(std::string( buffer.begin(), buffer.end() ) ); return boost::python::object(std::string( buffer.begin(), buffer.end() ) );

View File

@ -1,7 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include <boost/format.hpp> #include <boost/format.hpp>
#include <vector>
#include "dbgext.h" #include "dbgext.h"
#include "dbgmem.h" #include "dbgmem.h"

View File

@ -1,7 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include <vector>
#include "dbgpath.h" #include "dbgpath.h"
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <string> #include <string>
#include <vector>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -3,7 +3,6 @@
#include <boost/interprocess/sync/scoped_lock.hpp> #include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp> #include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp> #include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <vector>
#include <list> #include <list>
#include "dbgext.h" #include "dbgext.h"

View File

@ -1,7 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include <vector>
#include <exception> #include <exception>
#include "dbgext.h" #include "dbgext.h"
#include "dbgexcept.h" #include "dbgexcept.h"

View File

@ -349,16 +349,10 @@ TypeInfo::appendField( const TypeInfo &typeInfo, const std::string &fieldName, U
offset += offset % min( typeInfo.size(), m_align ); offset += offset % min( typeInfo.size(), m_align );
} }
if ( count == 1 ) const ULONG addSize = typeInfo.size() * count;
{ m_fields.push_back( TypeField( fieldName, typeInfo, addSize, offset ) );
m_fields.push_back( TypeField( fieldName, typeInfo, typeInfo.size(), offset ) ); m_size = offset + addSize;
m_size = offset + typeInfo.size(); m_arraySize = offset + addSize;
}
else
{
m_fields.push_back( TypeField( fieldName, typeInfo, typeInfo.size()*count, offset ) );
m_size = offset + typeInfo.size()*count;
}
} }
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
@ -489,7 +483,7 @@ valuePrinter( void* address, size_t size )
{ {
valType v = *(valType*)address; valType v = *(valType*)address;
sstr << v; sstr << v << hex << " (0x" << v << ")";
} }
else else
{ {
@ -746,7 +740,7 @@ TypeInfo::printField( size_t index, void* buffer, size_t bufferLength ) const
sstr << hex << "+" << offset; sstr << hex << "+" << offset;
sstr << " " << field.name; sstr << " " << field.name;
sstr << " " << fieldType.name(); sstr << " " << fieldType.name();
sstr << " " << valuePrinter<void*>( (char*)buffer + offset, field.size ); sstr << " " << hex << valuePrinter<void*>( (char*)buffer + offset, field.size );
sstr << endl; sstr << endl;
return sstr.str(); return sstr.str();
} }
@ -812,15 +806,21 @@ TypedVar::getFieldWrap( PyObject* self, const std::string &fieldName )
return tv.getField( pyobj, fieldName ); return tv.getField( pyobj, fieldName );
} }
void TypedVar::reallocBuffer()
{
const size_t fullSize = m_typeInfo.fullSize();
if (m_buffer.size() < fullSize)
{
assert(fullSize);
m_buffer.resize( fullSize );
loadMemory( m_targetOffset, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() );
}
}
boost::python::object boost::python::object
TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName ) TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName )
{ {
if ( m_buffer.size() == 0 ) reallocBuffer();
{
m_buffer.resize( (size_t)m_typeInfo.fullSize() );
loadMemory( m_targetOffset, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() );
}
TypeInfo typeInfo = m_typeInfo.getField( fieldName ); TypeInfo typeInfo = m_typeInfo.getField( fieldName );
@ -834,6 +834,8 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
else else
{ {
if ( typeInfo.count() == 1 ) if ( typeInfo.count() == 1 )
{
if (m_buffer.size())
{ {
pyobj.attr(fieldName.c_str()) = pyobj.attr(fieldName.c_str()) =
boost::python::object( boost::python::object(
@ -843,11 +845,14 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
&m_buffer[0] + offset, &m_buffer[0] + offset,
typeInfo.size() ) ); typeInfo.size() ) );
} }
}
else else
{ {
boost::python::list arr; boost::python::list arr;
for ( unsigned int i = 0; i < typeInfo.count(); ++i ) for ( unsigned int i = 0; i < typeInfo.count(); ++i )
{
if (m_buffer.size())
{ {
arr.append( arr.append(
boost::python::object( boost::python::object(
@ -857,6 +862,7 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
&m_buffer[0] + offset + i*typeInfo.size(), &m_buffer[0] + offset + i*typeInfo.size(),
typeInfo.size() ) ) ); typeInfo.size() ) ) );
} }
}
pyobj.attr(fieldName.c_str()) = arr; pyobj.attr(fieldName.c_str()) = arr;
} }
@ -870,14 +876,8 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
std::string std::string
TypedVar::data() TypedVar::data()
{ {
if ( m_buffer.size() == 0 ) reallocBuffer();
{ return std::string( getVectorBuffer(m_buffer), m_buffer.size() );
m_buffer.resize( (size_t)m_typeInfo.fullSize() );
loadMemory( m_targetOffset, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() );
}
return std::string( &m_buffer[0], m_buffer.size() );
} }
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
@ -885,12 +885,7 @@ TypedVar::data()
std::string std::string
TypedVar::print() TypedVar::print()
{ {
if ( m_buffer.size() == 0 ) reallocBuffer();
{
m_buffer.resize( (size_t)m_typeInfo.fullSize() );
loadMemory( m_targetOffset, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() );
}
stringstream sstr; stringstream sstr;
@ -910,7 +905,7 @@ TypedVar::print()
for ( size_t i = 0; i < m_typeInfo.getFieldCount(); ++i ) for ( size_t i = 0; i < m_typeInfo.getFieldCount(); ++i )
{ {
sstr << m_typeInfo.printField( i, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() ); sstr << m_typeInfo.printField( i, (PVOID)getVectorBuffer(m_buffer), (ULONG)m_buffer.size() );
//TypeInfo fieldType = m_typeInfo.getFieldAt( i ); //TypeInfo fieldType = m_typeInfo.getFieldAt( i );

View File

@ -2,7 +2,6 @@
#include <string> #include <string>
#include <map> #include <map>
#include <vector>
#include "dbgmem.h" #include "dbgmem.h"
#include "dbgsystem.h" #include "dbgsystem.h"
@ -25,7 +24,9 @@ public:
m_arraySize( 0 ), m_arraySize( 0 ),
m_parentOffset( 0 ), m_parentOffset( 0 ),
m_align( ptrSize() ), m_align( ptrSize() ),
m_isFreezed( false ) m_isFreezed( false ),
m_isBaseType( false ),
m_isPointer( false )
{} {}
TypeInfo( const std::string customName, ULONG align=0 ) : TypeInfo( const std::string customName, ULONG align=0 ) :
@ -34,7 +35,9 @@ public:
m_arraySize( 0 ), m_arraySize( 0 ),
m_parentOffset( 0 ), m_parentOffset( 0 ),
m_isFreezed( false ), m_isFreezed( false ),
m_align( align == 0 ? ptrSize() : align ) m_align( align == 0 ? ptrSize() : align ),
m_isBaseType( false ),
m_isPointer( false )
{} {}
TypeInfo( const std::string &moduleName, const std::string &typeName ); TypeInfo( const std::string &moduleName, const std::string &typeName );
@ -52,7 +55,7 @@ public:
ULONG ULONG
count() const { count() const {
assert( m_size != 0 ); assert( m_size != 0 && m_arraySize >= m_size );
return m_arraySize / m_size; return m_arraySize / m_size;
} }
@ -144,8 +147,6 @@ public:
typedef std::vector<TypeField> TypeFieldList; typedef std::vector<TypeField> TypeFieldList;
private: private:
typedef typedef
@ -239,6 +240,8 @@ public:
private: private:
void reallocBuffer();
TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset, char* buffer, size_t bufferLength ); TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset, char* buffer, size_t bufferLength );
ULONG64 m_targetOffset; ULONG64 m_targetOffset;

View File

@ -558,10 +558,6 @@
> >
</File> </File>
</Filter> </Filter>
<File
RelativePath=".\pykd.vcproj"
>
</File>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>

View File

@ -45,4 +45,17 @@
#include <boost/python/object.hpp> #include <boost/python/object.hpp>
#pragma warning(pop) #pragma warning(pop)
#include <vector>
template <typename TElem>
TElem *getVectorBuffer(std::vector<TElem> &vec)
{
return vec.size() ? &vec[0] : NULL;
}
template <typename TElem>
const TElem *getVectorBuffer(const std::vector<TElem> &vec)
{
return vec.size() ? &vec[0] : NULL;
}
// TODO: reference additional headers your program requires here // TODO: reference additional headers your program requires here

View File

@ -9,6 +9,18 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "targetapp", "test\targetapp\targetapp.vcproj", "{C6254E16-AB8E-41EE-887D-31458E93FC68}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "targetapp", "test\targetapp\targetapp.vcproj", "{C6254E16-AB8E-41EE-887D-31458E93FC68}"
EndProject EndProject
Global Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 3
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/TFS08
SccLocalPath0 = .
SccProjectUniqueName1 = pykd\\pykd_2008.vcproj
SccProjectName1 = pykd
SccLocalPath1 = pykd
SccProjectUniqueName2 = test\\targetapp\\targetapp.vcproj
SccProjectName2 = test/targetapp
SccLocalPath2 = test\\targetapp
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -36,13 +48,4 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/TFS08
SccLocalPath0 = .
SccProjectUniqueName1 = pykd\\pykd_2008.vcproj
SccProjectName1 = pykd
SccLocalPath1 = pykd
EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9,00" Version="9.00"
Name="targetapp" Name="targetapp"
ProjectGUID="{C6254E16-AB8E-41EE-887D-31458E93FC68}" ProjectGUID="{C6254E16-AB8E-41EE-887D-31458E93FC68}"
RootNamespace="targetapp" RootNamespace="targetapp"
SccProjectName="SAK"
SccAuxPath="SAK"
SccLocalPath="SAK"
SccProvider="SAK"
Keyword="Win32Proj" Keyword="Win32Proj"
TargetFrameworkVersion="131072" TargetFrameworkVersion="131072"
> >
@ -90,6 +94,78 @@
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration <Configuration
Name="Release|Win32" Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)" OutputDirectory="$(SolutionDir)$(ConfigurationName)"
@ -164,78 +240,6 @@
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration <Configuration
Name="Release|x64" Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
@ -332,7 +336,7 @@
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration <FileConfiguration
Name="Release|Win32" Name="Debug|x64"
> >
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
@ -340,7 +344,7 @@
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration <FileConfiguration
Name="Debug|x64" Name="Release|Win32"
> >
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"