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 <vector>
#include "dbgext.h"
#include "dbgdump.h"
#include "dbgexcept.h"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -111,10 +111,10 @@ TypeInfo::TypeInfo( const std::string &moduleName, const std::string &typeName
}
}
} while( FALSE );
} while( FALSE );
m_arraySize = m_size;
g_typeInfoCache.insert( std::make_pair( std::make_pair( m_moduleName, m_typeName), *this) );
}
@ -167,10 +167,10 @@ TypeInfo::TypeInfo( const std::string &moduleName, ULONG64 moduleBase, ULONG typ
else
{
m_fields.push_back( TypeField( fieldName, TypeInfo( moduleName, fieldTypeName ), fieldSize, fieldOffset ) );
}
}
m_arraySize = m_size;
}
}
m_arraySize = m_size;
}
///////////////////////////////////////////////////////////////////////////////////
@ -206,7 +206,7 @@ TypeInfo::print() const
sstream << "unnamed";
if ( m_arraySize > m_size )
{
{
sstream << " size = " << dec << m_arraySize << "(0x" << hex << m_arraySize << ") " << dec << "[" << m_arraySize/m_size << "]";
}
else
@ -234,14 +234,14 @@ TypeInfo::getField( const std::string &fieldName ) const
if ( it->name == fieldName )
{
TypeInfo tinf = it->type;
tinf.m_parentOffset = m_parentOffset + it->offset;
tinf.m_arraySize = it->size;
return tinf;
}
}
}
}
throw TypeException();
}
@ -251,11 +251,11 @@ TypeInfo
TypeInfo::getFieldAt( size_t index ) const
{
TypeInfo tinf = m_fields[index].type;
tinf.m_parentOffset = m_parentOffset + m_fields[index].offset;
tinf.m_arraySize = m_fields[index].size;
return tinf;
return tinf;
}
///////////////////////////////////////////////////////////////////////////////////
@ -319,20 +319,20 @@ void
TypeInfo::appendField( const TypeInfo &typeInfo, const std::string &fieldName, ULONG count )
{
if ( m_isFreezed )
throw TypeException();
throw TypeException();
if ( count == 0 )
throw TypeException();
throw TypeException();
if ( count == 1 && typeInfo.m_typeName.find("[]") != std::string::npos )
throw TypeException();
throw TypeException();
TypeFieldList::const_iterator it = m_fields.begin();
for(;it != m_fields.end(); ++it )
{
if ( it->name == fieldName )
throw TypeException();
}
}
if ( count > 1 && typeInfo.m_typeName.find("[]") == std::string::npos )
{
@ -340,25 +340,19 @@ TypeInfo::appendField( const TypeInfo &typeInfo, const std::string &fieldName, U
arrayInfo.m_typeName += "[]";
appendField( arrayInfo, fieldName, count );
return;
}
ULONG offset = m_size;
}
ULONG offset = m_size;
if ( typeInfo.isBaseType() )
{
offset += offset % min( typeInfo.size(), m_align );
}
if ( count == 1 )
{
m_fields.push_back( TypeField( fieldName, typeInfo, typeInfo.size(), offset ) );
m_size = offset + typeInfo.size();
}
else
{
m_fields.push_back( TypeField( fieldName, typeInfo, typeInfo.size()*count, offset ) );
m_size = offset + typeInfo.size()*count;
}
const ULONG addSize = typeInfo.size() * count;
m_fields.push_back( TypeField( fieldName, typeInfo, addSize, offset ) );
m_size = offset + addSize;
m_arraySize = offset + addSize;
}
///////////////////////////////////////////////////////////////////////////////////
@ -489,7 +483,7 @@ valuePrinter( void* address, size_t size )
{
valType v = *(valType*)address;
sstr << v;
sstr << v << hex << " (0x" << v << ")";
}
else
{
@ -746,7 +740,7 @@ TypeInfo::printField( size_t index, void* buffer, size_t bufferLength ) const
sstr << hex << "+" << offset;
sstr << " " << field.name;
sstr << " " << fieldType.name();
sstr << " " << valuePrinter<void*>( (char*)buffer + offset, field.size );
sstr << " " << hex << valuePrinter<void*>( (char*)buffer + offset, field.size );
sstr << endl;
return sstr.str();
}
@ -812,16 +806,22 @@ TypedVar::getFieldWrap( PyObject* self, const std::string &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
TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName )
{
if ( m_buffer.size() == 0 )
{
m_buffer.resize( (size_t)m_typeInfo.fullSize() );
loadMemory( m_targetOffset, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() );
}
reallocBuffer();
TypeInfo typeInfo = m_typeInfo.getField( fieldName );
// îòíîñèòåëüíûé îôôñåò
@ -835,13 +835,16 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
{
if ( typeInfo.count() == 1 )
{
pyobj.attr(fieldName.c_str()) =
boost::python::object(
TypedVar(
typeInfo,
m_targetOffset + offset,
&m_buffer[0] + offset,
typeInfo.size() ) );
if (m_buffer.size())
{
pyobj.attr(fieldName.c_str()) =
boost::python::object(
TypedVar(
typeInfo,
m_targetOffset + offset,
&m_buffer[0] + offset,
typeInfo.size() ) );
}
}
else
{
@ -849,20 +852,23 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
for ( unsigned int i = 0; i < typeInfo.count(); ++i )
{
arr.append(
boost::python::object(
TypedVar(
typeInfo,
m_targetOffset + offset + i*typeInfo.size(),
&m_buffer[0] + offset + i*typeInfo.size(),
typeInfo.size() ) ) );
if (m_buffer.size())
{
arr.append(
boost::python::object(
TypedVar(
typeInfo,
m_targetOffset + offset + i*typeInfo.size(),
&m_buffer[0] + offset + i*typeInfo.size(),
typeInfo.size() ) ) );
}
}
pyobj.attr(fieldName.c_str()) = arr;
}
}
return pyobj.attr(fieldName.c_str());
return pyobj.attr(fieldName.c_str());
}
/////////////////////////////////////////////////////////////////////////////////////
@ -870,14 +876,8 @@ TypedVar::getField( boost::python::object &pyobj, const std::string &fieldName
std::string
TypedVar::data()
{
if ( m_buffer.size() == 0 )
{
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() );
reallocBuffer();
return std::string( getVectorBuffer(m_buffer), m_buffer.size() );
}
/////////////////////////////////////////////////////////////////////////////////////
@ -885,12 +885,7 @@ TypedVar::data()
std::string
TypedVar::print()
{
if ( m_buffer.size() == 0 )
{
m_buffer.resize( (size_t)m_typeInfo.fullSize() );
loadMemory( m_targetOffset, (PVOID)&m_buffer[0], (ULONG)m_buffer.size() );
}
reallocBuffer();
stringstream sstr;
@ -910,7 +905,7 @@ TypedVar::print()
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 );

View File

@ -2,7 +2,6 @@
#include <string>
#include <map>
#include <vector>
#include "dbgmem.h"
#include "dbgsystem.h"
@ -25,7 +24,9 @@ public:
m_arraySize( 0 ),
m_parentOffset( 0 ),
m_align( ptrSize() ),
m_isFreezed( false )
m_isFreezed( false ),
m_isBaseType( false ),
m_isPointer( false )
{}
TypeInfo( const std::string customName, ULONG align=0 ) :
@ -34,7 +35,9 @@ public:
m_arraySize( 0 ),
m_parentOffset( 0 ),
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 );
@ -52,7 +55,7 @@ public:
ULONG
count() const {
assert( m_size != 0 );
assert( m_size != 0 && m_arraySize >= m_size );
return m_arraySize / m_size;
}
@ -116,7 +119,7 @@ public:
loadVar( ULONG64 targetOffset, ULONG count = 1) const;
public:
typedef std::map< std::pair<std::string, std::string>, TypeInfo> TypeInfoMap;
template< typename TTypeInfo>
@ -141,11 +144,9 @@ public:
};
typedef TypeFieldT<TypeInfo> TypeField;
typedef std::vector<TypeField> TypeFieldList;
private:
typedef
@ -239,15 +240,17 @@ public:
private:
void reallocBuffer();
TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset, char* buffer, size_t bufferLength );
ULONG64 m_targetOffset;
TypeInfo m_typeInfo;
std::vector<char> m_buffer;
};
///////////////////////////////////////////////////////////////////////////////////
boost::python::object

View File

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

View File

@ -45,4 +45,17 @@
#include <boost/python/object.hpp>
#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

View File

@ -9,6 +9,18 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "targetapp", "test\targetapp\targetapp.vcproj", "{C6254E16-AB8E-41EE-887D-31458E93FC68}"
EndProject
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
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
@ -36,13 +48,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
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

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="targetapp"
ProjectGUID="{C6254E16-AB8E-41EE-887D-31458E93FC68}"
RootNamespace="targetapp"
SccProjectName="SAK"
SccAuxPath="SAK"
SccLocalPath="SAK"
SccProvider="SAK"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
@ -90,6 +94,78 @@
Name="VCPostBuildEventTool"
/>
</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
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
@ -164,78 +240,6 @@
Name="VCPostBuildEventTool"
/>
</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
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
@ -332,7 +336,7 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@ -340,7 +344,7 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"