mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 11:53:23 +08:00
[~] refactoring: RAII idiom is used instead of manual memory management
git-svn-id: https://pykd.svn.codeplex.com/svn@61917 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
a4993db623
commit
004a4067ea
@ -1,5 +1,7 @@
|
|||||||
#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"
|
||||||
@ -13,21 +15,19 @@ dbgLoadDump( const std::string &fileName )
|
|||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
wchar_t *fileNameW = NULL;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
fileNameW = new wchar_t [ fileName.size()+ 1 ];
|
std::vector<wchar_t> fileNameW( fileName.size()+ 1 );
|
||||||
|
|
||||||
MultiByteToWideChar(
|
MultiByteToWideChar(
|
||||||
CP_ACP,
|
CP_ACP,
|
||||||
0,
|
0,
|
||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
fileName.size() + 1,
|
fileName.size() + 1,
|
||||||
fileNameW,
|
&fileNameW[0],
|
||||||
fileName.size() + 1 );
|
fileName.size() + 1 );
|
||||||
|
|
||||||
hres = dbgExt->client4->OpenDumpFileWide( fileNameW, NULL );
|
hres = dbgExt->client4->OpenDumpFileWide( &fileNameW[0], NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
||||||
|
|
||||||
@ -37,9 +37,6 @@ dbgLoadDump( const std::string &fileName )
|
|||||||
|
|
||||||
dbgSessionStarted = true;
|
dbgSessionStarted = true;
|
||||||
|
|
||||||
if ( fileNameW )
|
|
||||||
delete[] fileNameW;
|
|
||||||
|
|
||||||
return "loaded ok";
|
return "loaded ok";
|
||||||
}
|
}
|
||||||
catch( std::exception& )
|
catch( std::exception& )
|
||||||
@ -54,9 +51,6 @@ dbgLoadDump( const std::string &fileName )
|
|||||||
std::string result = "failed to open dump ";
|
std::string result = "failed to open dump ";
|
||||||
result += fileName;
|
result += fileName;
|
||||||
|
|
||||||
if ( fileNameW )
|
|
||||||
delete[] fileNameW;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,9 +323,9 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
|
|||||||
{
|
{
|
||||||
DWORD oldCurDirLen = GetCurrentDirectoryA( 0, NULL );
|
DWORD oldCurDirLen = GetCurrentDirectoryA( 0, NULL );
|
||||||
|
|
||||||
char *oldCurDirCstr = new char[ oldCurDirLen ];
|
std::vector<char> oldCurDirCstr(oldCurDirLen);
|
||||||
|
|
||||||
GetCurrentDirectoryA( oldCurDirLen, oldCurDirCstr );
|
GetCurrentDirectoryA( oldCurDirLen, &oldCurDirCstr[0] );
|
||||||
|
|
||||||
SetCurrentDirectoryA( filePath.c_str() );
|
SetCurrentDirectoryA( filePath.c_str() );
|
||||||
|
|
||||||
@ -357,10 +357,7 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
|
|||||||
Py_XDECREF(traceback);
|
Py_XDECREF(traceback);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCurrentDirectoryA( oldCurDirCstr );
|
SetCurrentDirectoryA( &oldCurDirCstr[0] );
|
||||||
|
|
||||||
delete[] oldCurDirCstr;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <boost/scoped_array.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "dbgext.h"
|
#include "dbgext.h"
|
||||||
#include "dbgexcept.h"
|
#include "dbgexcept.h"
|
||||||
#include "dbgmem.h"
|
#include "dbgmem.h"
|
||||||
@ -68,34 +71,34 @@ compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr )
|
|||||||
addr1 = addr64( addr1 );
|
addr1 = addr64( addr1 );
|
||||||
addr2 = addr64( addr2 );
|
addr2 = addr64( addr2 );
|
||||||
|
|
||||||
char* m1 = new char[length];
|
boost::scoped_array<char> m1(new char[length]);
|
||||||
char* m2 = new char[length];
|
boost::scoped_array<char> m2(new char[length]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ( phyAddr == FALSE )
|
if ( phyAddr == FALSE )
|
||||||
{
|
{
|
||||||
|
|
||||||
hres = dbgExt->dataSpaces->ReadVirtual( addr1, m1, length, NULL );
|
hres = dbgExt->dataSpaces->ReadVirtual( addr1, m1.get(), length, NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
|
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
|
||||||
|
|
||||||
hres = dbgExt->dataSpaces->ReadVirtual( addr2, m2, length, NULL );
|
hres = dbgExt->dataSpaces->ReadVirtual( addr2, m2.get(), length, NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
|
throw DbgException( "IDebugDataSpace::ReadVirtual failed" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hres = dbgExt->dataSpaces->ReadPhysical( addr1, m1, length, NULL );
|
hres = dbgExt->dataSpaces->ReadPhysical( addr1, m1.get(), length, NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpace::ReadPhysical failed" );
|
throw DbgException( "IDebugDataSpace::ReadPhysical failed" );
|
||||||
|
|
||||||
hres = dbgExt->dataSpaces->ReadPhysical( addr2, m2, length, NULL );
|
hres = dbgExt->dataSpaces->ReadPhysical( addr2, m2.get(), length, NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpace::ReadPhysical failed" );
|
throw DbgException( "IDebugDataSpace::ReadPhysical failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
result = memcmp( m1, m2, length ) == 0;
|
result = memcmp( m1.get(), m2.get(), length ) == 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( std::exception &e )
|
catch( std::exception &e )
|
||||||
@ -107,9 +110,6 @@ compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr )
|
|||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] m1;
|
|
||||||
delete[] m2;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,42 +120,34 @@ loadPtrArray( ULONG64 address, ULONG number )
|
|||||||
{
|
{
|
||||||
if ( is64bitSystem() )
|
if ( is64bitSystem() )
|
||||||
{
|
{
|
||||||
ULONG64 *buffer = new ULONG64[ number ];
|
boost::scoped_array<ULONG64> buffer(new ULONG64[number]);
|
||||||
|
|
||||||
if ( loadMemory( address, buffer, number*sizeof(ULONG64) ) )
|
if ( loadMemory( address, buffer.get(), number*sizeof(ULONG64) ) )
|
||||||
{
|
{
|
||||||
boost::python::dict arr;
|
boost::python::dict arr;
|
||||||
|
|
||||||
for ( ULONG i = 0; i < number; ++i )
|
for ( ULONG i = 0; i < number; ++i )
|
||||||
arr[i] = buffer[i];
|
arr[i] = buffer[i];
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return boost::python::object();
|
return boost::python::object();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ULONG *buffer = new ULONG[ number ];
|
boost::scoped_array<ULONG> buffer(new ULONG[number]);
|
||||||
|
|
||||||
if ( loadMemory( address, buffer, number*sizeof(ULONG) ) )
|
if ( loadMemory( address, buffer.get(), number*sizeof(ULONG) ) )
|
||||||
{
|
{
|
||||||
boost::python::dict arr;
|
boost::python::dict arr;
|
||||||
|
|
||||||
for ( ULONG i = 0; i < number; ++i )
|
for ( ULONG i = 0; i < number; ++i )
|
||||||
arr[i] = addr64( buffer[i] );
|
arr[i] = addr64( buffer[i] );
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return boost::python::object();
|
return boost::python::object();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +224,6 @@ loadUnicodeStr( ULONG64 address )
|
|||||||
USHORT length;
|
USHORT length;
|
||||||
USHORT maximumLength;
|
USHORT maximumLength;
|
||||||
ULONG64 buffer = 0;
|
ULONG64 buffer = 0;
|
||||||
wchar_t *str = NULL;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
@ -270,22 +261,17 @@ loadUnicodeStr( ULONG64 address )
|
|||||||
address += 4;
|
address += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *str = new wchar_t[ length/2 ];
|
std::vector<wchar_t> str(length / 2);
|
||||||
|
|
||||||
if ( !loadMemory( buffer, str, length ) )
|
if ( !loadMemory( buffer, &str[0], length ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::wstring strValue(str, length/2);
|
std::wstring strValue(&str[0], length/2);
|
||||||
|
|
||||||
delete[] str;
|
|
||||||
|
|
||||||
return boost::python::object( strValue );
|
return boost::python::object( strValue );
|
||||||
|
|
||||||
} while( FALSE );
|
} while( FALSE );
|
||||||
|
|
||||||
if ( str )
|
|
||||||
delete[] str;
|
|
||||||
|
|
||||||
return boost::python::object( "" );
|
return boost::python::object( "" );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -298,7 +284,6 @@ loadAnsiStr( ULONG64 address )
|
|||||||
USHORT length;
|
USHORT length;
|
||||||
USHORT maximumLength;
|
USHORT maximumLength;
|
||||||
ULONG64 buffer = 0;
|
ULONG64 buffer = 0;
|
||||||
char *str = NULL;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
@ -337,22 +322,17 @@ loadAnsiStr( ULONG64 address )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
str = new char [ length ];
|
std::vector<char> str(length);
|
||||||
|
|
||||||
if ( !loadMemory( buffer, str, length ) )
|
if ( !loadMemory( buffer, &str[0], length ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::string strVal ( str, length );
|
std::string strVal ( &str[0], length );
|
||||||
|
|
||||||
delete[] str;
|
|
||||||
|
|
||||||
return boost::python::object( strVal );
|
return boost::python::object( strVal );
|
||||||
|
|
||||||
} while( FALSE );
|
} while( FALSE );
|
||||||
|
|
||||||
if ( str )
|
|
||||||
delete[] str;
|
|
||||||
|
|
||||||
return boost::python::object( "" );
|
return boost::python::object( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +416,7 @@ loadCStr( ULONG64 address )
|
|||||||
|
|
||||||
address = addr64( address );
|
address = addr64( address );
|
||||||
|
|
||||||
char* buffer = new char[maxLength];
|
boost::scoped_array<char> buffer(new char[maxLength]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -444,14 +424,14 @@ loadCStr( ULONG64 address )
|
|||||||
dbgExt->dataSpaces4->ReadMultiByteStringVirtual(
|
dbgExt->dataSpaces4->ReadMultiByteStringVirtual(
|
||||||
address,
|
address,
|
||||||
maxLength,
|
maxLength,
|
||||||
buffer,
|
buffer.get(),
|
||||||
maxLength,
|
maxLength,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpace4::ReadMultiByteStringVirtual failed" );
|
throw DbgException( "IDebugDataSpace4::ReadMultiByteStringVirtual failed" );
|
||||||
|
|
||||||
strObj = boost::python::object( std::string( buffer ) );
|
strObj = boost::python::object( std::string( buffer.get() ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( std::exception &e )
|
catch( std::exception &e )
|
||||||
@ -463,8 +443,6 @@ loadCStr( ULONG64 address )
|
|||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return strObj;
|
return strObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +456,7 @@ loadWStr( ULONG64 address )
|
|||||||
|
|
||||||
address = addr64( address );
|
address = addr64( address );
|
||||||
|
|
||||||
wchar_t* buffer = new wchar_t[maxLength];
|
boost::scoped_array<wchar_t> buffer(new wchar_t[maxLength]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -486,14 +464,14 @@ loadWStr( ULONG64 address )
|
|||||||
dbgExt->dataSpaces4->ReadUnicodeStringVirtualWide(
|
dbgExt->dataSpaces4->ReadUnicodeStringVirtualWide(
|
||||||
address,
|
address,
|
||||||
maxLength*sizeof(wchar_t),
|
maxLength*sizeof(wchar_t),
|
||||||
buffer,
|
buffer.get(),
|
||||||
maxLength,
|
maxLength,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpace4::ReadUnicodeStringVirtualWide failed" );
|
throw DbgException( "IDebugDataSpace4::ReadUnicodeStringVirtualWide failed" );
|
||||||
|
|
||||||
strObj = boost::python::object( std::wstring(buffer) );
|
strObj = boost::python::object( std::wstring(buffer.get()) );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( std::exception &e )
|
catch( std::exception &e )
|
||||||
@ -505,8 +483,6 @@ loadWStr( ULONG64 address )
|
|||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return strObj;
|
return strObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <boost/python.hpp>
|
#include <boost/python.hpp>
|
||||||
#include <boost/python/object.hpp>
|
#include <boost/python/object.hpp>
|
||||||
|
#include <boost/scoped_array.hpp>
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -23,23 +23,18 @@ template<typename T>
|
|||||||
boost::python::object
|
boost::python::object
|
||||||
loadArray( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE )
|
loadArray( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE )
|
||||||
{
|
{
|
||||||
T *buffer = new T[ number ];
|
boost::scoped_array<T> buffer(new T[number]);
|
||||||
|
|
||||||
if ( loadMemory( address, buffer, number*sizeof(T), phyAddr ) )
|
if ( loadMemory( address, buffer.get(), number*sizeof(T), phyAddr ) )
|
||||||
{
|
{
|
||||||
boost::python::list lst;
|
boost::python::list lst;
|
||||||
|
|
||||||
for ( ULONG i = 0; i < number; ++i )
|
for ( ULONG i = 0; i < number; ++i )
|
||||||
lst.append( buffer[i] );
|
lst.append( buffer[i] );
|
||||||
//arr[i] = buffer[i];
|
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
return boost::python::object();
|
return boost::python::object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "dbgext.h"
|
#include "dbgext.h"
|
||||||
#include "dbgmodule.h"
|
#include "dbgmodule.h"
|
||||||
@ -246,7 +247,6 @@ void
|
|||||||
dbgModuleClass::getImagePath()
|
dbgModuleClass::getImagePath()
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
PWSTR pathBuffer = NULL;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -255,13 +255,13 @@ dbgModuleClass::getImagePath()
|
|||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
||||||
|
|
||||||
pathBuffer = new WCHAR [ pathSize ];
|
std::vector<WCHAR> pathBuffer(pathSize);
|
||||||
|
|
||||||
hres = dbgExt->symbols3->GetSymbolPathWide( pathBuffer, pathSize, NULL );
|
hres = dbgExt->symbols3->GetSymbolPathWide( &pathBuffer[0], pathSize, NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
||||||
|
|
||||||
std::wstring symPath( pathBuffer, pathSize );
|
std::wstring symPath( &pathBuffer[0], pathSize );
|
||||||
|
|
||||||
std::wstring altName = m_debugInfo.CVData;
|
std::wstring altName = m_debugInfo.CVData;
|
||||||
altName = altName.substr( 0, altName.find_last_of(L".") );
|
altName = altName.substr( 0, altName.find_last_of(L".") );
|
||||||
@ -314,9 +314,6 @@ dbgModuleClass::getImagePath()
|
|||||||
{
|
{
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pathBuffer )
|
|
||||||
delete[] pathBuffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "dbgpath.h"
|
#include "dbgpath.h"
|
||||||
|
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
@ -15,24 +17,25 @@ DbgPythonPath::DbgPythonPath()
|
|||||||
|
|
||||||
enviromentSize = GetEnvironmentVariableA( "PYTHONPATH", NULL, enviromentSize );
|
enviromentSize = GetEnvironmentVariableA( "PYTHONPATH", NULL, enviromentSize );
|
||||||
|
|
||||||
char *enviromentBuffer = new char[ enviromentSize ];
|
std::vector<char> enviromentBuffer(enviromentSize);
|
||||||
|
|
||||||
GetEnvironmentVariableA( "PYTHONPATH", enviromentBuffer, enviromentSize );
|
|
||||||
|
|
||||||
typedef boost::escaped_list_separator<char> char_separator_t;
|
if (!enviromentBuffer.empty())
|
||||||
typedef boost::tokenizer< char_separator_t > char_tokenizer_t;
|
{
|
||||||
|
GetEnvironmentVariableA( "PYTHONPATH", &enviromentBuffer[0], enviromentSize );
|
||||||
std::string pytonPath( enviromentBuffer );
|
|
||||||
|
|
||||||
char_tokenizer_t token( pytonPath, char_separator_t( "", "; \t", "\"" ) );
|
|
||||||
|
|
||||||
for ( char_tokenizer_t::iterator it = token.begin(); it != token.end(); ++it )
|
typedef boost::escaped_list_separator<char> char_separator_t;
|
||||||
{
|
typedef boost::tokenizer< char_separator_t > char_tokenizer_t;
|
||||||
if ( *it != "" )
|
|
||||||
m_pathList.push_back( *it );
|
std::string pytonPath( &enviromentBuffer[0] );
|
||||||
}
|
|
||||||
|
char_tokenizer_t token( pytonPath, char_separator_t( "", "; \t", "\"" ) );
|
||||||
delete[] enviromentBuffer;
|
|
||||||
|
for ( char_tokenizer_t::iterator it = token.begin(); it != token.end(); ++it )
|
||||||
|
{
|
||||||
|
if ( *it != "" )
|
||||||
|
m_pathList.push_back( *it );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -84,7 +87,7 @@ DbgPythonPath::findPath(
|
|||||||
|
|
||||||
if ( bufSize > 0 )
|
if ( bufSize > 0 )
|
||||||
{
|
{
|
||||||
char *fullFileNameCStr = new char[ bufSize ];
|
std::vector<char> fullFileNameCStr(bufSize);
|
||||||
char *partFileNameCStr = NULL;
|
char *partFileNameCStr = NULL;
|
||||||
|
|
||||||
SearchPathA(
|
SearchPathA(
|
||||||
@ -92,13 +95,11 @@ DbgPythonPath::findPath(
|
|||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
pyExt ? NULL : ".py",
|
pyExt ? NULL : ".py",
|
||||||
bufSize,
|
bufSize,
|
||||||
fullFileNameCStr,
|
&fullFileNameCStr[0],
|
||||||
&partFileNameCStr );
|
&partFileNameCStr );
|
||||||
|
|
||||||
fullFileName = std::string( fullFileNameCStr );
|
fullFileName = std::string( &fullFileNameCStr[0] );
|
||||||
filePath = std::string( fullFileNameCStr, partFileNameCStr );
|
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
||||||
|
|
||||||
delete[] fullFileNameCStr;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -120,7 +121,7 @@ DbgPythonPath::findPath(
|
|||||||
|
|
||||||
if ( bufSize > 0 )
|
if ( bufSize > 0 )
|
||||||
{
|
{
|
||||||
char *fullFileNameCStr = new char[ bufSize ];
|
std::vector<char> fullFileNameCStr(bufSize);
|
||||||
char *partFileNameCStr = NULL;
|
char *partFileNameCStr = NULL;
|
||||||
|
|
||||||
SearchPathA(
|
SearchPathA(
|
||||||
@ -128,13 +129,11 @@ DbgPythonPath::findPath(
|
|||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
pyExt ? NULL : ".py",
|
pyExt ? NULL : ".py",
|
||||||
bufSize,
|
bufSize,
|
||||||
fullFileNameCStr,
|
&fullFileNameCStr[0],
|
||||||
&partFileNameCStr );
|
&partFileNameCStr );
|
||||||
|
|
||||||
fullFileName = std::string( fullFileNameCStr );
|
fullFileName = std::string( &fullFileNameCStr[0] );
|
||||||
filePath = std::string( fullFileNameCStr, partFileNameCStr );
|
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
||||||
|
|
||||||
delete[] fullFileNameCStr;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
#include <boost/scoped_array.hpp>
|
||||||
|
|
||||||
#include "dbgprocess.h"
|
#include "dbgprocess.h"
|
||||||
#include "dbgext.h"
|
#include "dbgext.h"
|
||||||
@ -13,7 +14,6 @@ boost::python::object
|
|||||||
getThreadList()
|
getThreadList()
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
PULONG ids = NULL;
|
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG oldThreadId = 0;
|
ULONG oldThreadId = 0;
|
||||||
|
|
||||||
@ -24,8 +24,8 @@ getThreadList()
|
|||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects::GetNumberThreads failed" );
|
throw DbgException( "IDebugSystemObjects::GetNumberThreads failed" );
|
||||||
|
|
||||||
ids = new ULONG[threadCount];
|
boost::scoped_array<ULONG> ids(new ULONG[threadCount]);
|
||||||
hres = dbgExt->system->GetThreadIdsByIndex( 0, threadCount, ids, NULL );
|
hres = dbgExt->system->GetThreadIdsByIndex( 0, threadCount, ids.get(), NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects::GetThreadIdsByIndex failed" );
|
throw DbgException( "IDebugSystemObjects::GetThreadIdsByIndex failed" );
|
||||||
|
|
||||||
@ -46,9 +46,6 @@ getThreadList()
|
|||||||
threadList.append( threadOffset );
|
threadList.append( threadOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ids )
|
|
||||||
delete[] ids;
|
|
||||||
|
|
||||||
return threadList;
|
return threadList;
|
||||||
}
|
}
|
||||||
catch( std::exception &e )
|
catch( std::exception &e )
|
||||||
@ -63,9 +60,6 @@ getThreadList()
|
|||||||
if ( oldThreadId )
|
if ( oldThreadId )
|
||||||
dbgExt->system->SetCurrentThreadId( oldThreadId );
|
dbgExt->system->SetCurrentThreadId( oldThreadId );
|
||||||
|
|
||||||
if ( ids )
|
|
||||||
delete[] ids;
|
|
||||||
|
|
||||||
return boost::python::list();
|
return boost::python::list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +129,6 @@ boost::python::object
|
|||||||
getCurrentStack()
|
getCurrentStack()
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
PDEBUG_STACK_FRAME frames = NULL;
|
|
||||||
ULONG currentScope = 0;
|
ULONG currentScope = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -144,10 +137,10 @@ getCurrentStack()
|
|||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol3::GetCurrentScopeFrameIndex failed" );
|
throw DbgException( "IDebugSymbol3::GetCurrentScopeFrameIndex failed" );
|
||||||
|
|
||||||
frames = new DEBUG_STACK_FRAME [ 1000 ];
|
boost::scoped_array<DEBUG_STACK_FRAME> frames(new DEBUG_STACK_FRAME [ 1000 ]);
|
||||||
|
|
||||||
ULONG filledFrames;
|
ULONG filledFrames;
|
||||||
hres = dbgExt->control->GetStackTrace( 0, 0, 0, frames, 1000, &filledFrames );
|
hres = dbgExt->control->GetStackTrace( 0, 0, 0, frames.get(), 1000, &filledFrames );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::GetStackTrace failed" );
|
throw DbgException( "IDebugControl::GetStackTrace failed" );
|
||||||
|
|
||||||
@ -166,9 +159,6 @@ getCurrentStack()
|
|||||||
frameList.append( frameObj );
|
frameList.append( frameObj );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( frames )
|
|
||||||
delete[] frames;
|
|
||||||
|
|
||||||
dbgExt->symbols3->SetScopeFrameByIndex( currentScope );
|
dbgExt->symbols3->SetScopeFrameByIndex( currentScope );
|
||||||
|
|
||||||
return frameList;
|
return frameList;
|
||||||
@ -183,9 +173,6 @@ getCurrentStack()
|
|||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( frames )
|
|
||||||
delete[] frames;
|
|
||||||
|
|
||||||
dbgExt->symbols3->SetScopeFrameByIndex( currentScope );
|
dbgExt->symbols3->SetScopeFrameByIndex( currentScope );
|
||||||
|
|
||||||
return boost::python::object();
|
return boost::python::object();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include "dbgext.h"
|
#include "dbgext.h"
|
||||||
#include "dbgexcept.h"
|
#include "dbgexcept.h"
|
||||||
@ -46,7 +48,6 @@ std::string
|
|||||||
dbgSymPath()
|
dbgSymPath()
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
char *path = NULL;
|
|
||||||
std::string pathStr;
|
std::string pathStr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -54,12 +55,12 @@ dbgSymPath()
|
|||||||
ULONG size;
|
ULONG size;
|
||||||
dbgExt->symbols->GetSymbolPath( NULL, 0, &size );
|
dbgExt->symbols->GetSymbolPath( NULL, 0, &size );
|
||||||
|
|
||||||
path = new char[ size ];
|
std::vector<char> path(size);
|
||||||
hres = dbgExt->symbols->GetSymbolPath( path, size, NULL );
|
hres = dbgExt->symbols->GetSymbolPath( &path[0], size, NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbols::GetSymbolPath failed" );
|
throw DbgException( "IDebugSymbols::GetSymbolPath failed" );
|
||||||
|
|
||||||
pathStr = path;
|
pathStr = &path[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( std::exception &e )
|
catch( std::exception &e )
|
||||||
@ -71,9 +72,6 @@ dbgSymPath()
|
|||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( path )
|
|
||||||
delete[] path;
|
|
||||||
|
|
||||||
return pathStr;
|
return pathStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user