[pykd] fixed: issue 9555 ( dbgModuleClass.name() corrupts output )

git-svn-id: https://pykd.svn.codeplex.com/svn@70041 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-09-26 12:06:00 +00:00
parent 26c2b2d117
commit 4dc9bba048
3 changed files with 54 additions and 134 deletions

View File

@ -24,9 +24,8 @@ void dbgPrint::dprint( const boost::python::object& obj, bool dml )
void dbgPrint::dprintln( const boost::python::object& obj, bool dml ) void dbgPrint::dprintln( const boost::python::object& obj, bool dml )
{ {
std::wstring str = boost::python::extract<std::wstring>( obj ); std::wstring str = boost::python::extract<std::wstring>( obj );
str += L"\r\n";
dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, L"%ws", str.c_str() ); dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, L"%ws\r\n", str.c_str() );
std::wcout << str; std::wcout << str;
} }

View File

@ -68,6 +68,9 @@ void queryModuleParams(
NULL, NULL,
0, 0,
NULL ); NULL );
std::vector<char> nameBuf(moduleNameChars);
name.resize(moduleNameChars + 1); name.resize(moduleNameChars + 1);
hres = dbgExt->symbols->GetModuleNames( hres = dbgExt->symbols->GetModuleNames(
moduleIndex, moduleIndex,
@ -75,14 +78,16 @@ void queryModuleParams(
NULL, NULL,
0, 0,
NULL, NULL,
&name[0], &nameBuf[0],
(ULONG)name.size(), nameBuf.size(),
NULL, NULL,
NULL, NULL,
0, 0,
NULL ); NULL );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugSymbol::GetModuleNames failed" ); throw DbgException( "IDebugSymbol::GetModuleNames failed" );
name = std::string( &nameBuf[0] );
} }
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@ -106,7 +111,7 @@ dbgModuleClass::dbgModuleClass( const std::string &name, ULONG64 base, ULONG siz
m_base( addr64(base) ), m_base( addr64(base) ),
m_end( addr64(base) + size ) m_end( addr64(base) + size )
{ {
reloadSymbols(); //reloadSymbols();
std::string pattern = name + "!*"; std::string pattern = name + "!*";
ULONG64 enumHandle = 0; ULONG64 enumHandle = 0;

View File

@ -1,6 +1,5 @@
#include "stdafx.h" #include "stdafx.h"
#include <exception>
#include "dbgext.h" #include "dbgext.h"
#include "dbgexcept.h" #include "dbgexcept.h"
#include "dbgsystem.h" #include "dbgsystem.h"
@ -13,23 +12,11 @@ is64bitSystem()
{ {
HRESULT hres; HRESULT hres;
try { hres = dbgExt->control->IsPointer64Bit();
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::IsPointer64Bit failed" );
hres = dbgExt->control->IsPointer64Bit(); return hres == S_OK;
return hres == S_OK;
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return false;
} }
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
@ -48,29 +35,16 @@ dbgSymPath()
HRESULT hres; HRESULT hres;
std::string pathStr; std::string pathStr;
try { ULONG size;
dbgExt->symbols->GetSymbolPath( NULL, 0, &size );
ULONG size;
dbgExt->symbols->GetSymbolPath( NULL, 0, &size );
std::vector<char> path(size); std::vector<char> path(size);
hres = dbgExt->symbols->GetSymbolPath( &path[0], 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[0]; return std::string(&path[0]);
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return pathStr;
} }
@ -81,39 +55,29 @@ getPdbFile( ULONG64 moduleBase )
{ {
HRESULT hres; HRESULT hres;
try {
IMAGEHLP_MODULEW64 imageHelpInfo = { 0 }; IMAGEHLP_MODULEW64 imageHelpInfo = { 0 };
hres = hres =
dbgExt->advanced2->GetSymbolInformation( dbgExt->advanced2->GetSymbolInformation(
DEBUG_SYMINFO_IMAGEHLP_MODULEW64, DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
moduleBase, moduleBase,
0, 0,
&imageHelpInfo, &imageHelpInfo,
sizeof( imageHelpInfo ), sizeof( imageHelpInfo ),
NULL, NULL,
NULL, NULL,
0, 0,
NULL ); NULL );
char fileName[ 256 ]; if ( FAILED( hres ) )
WideCharToMultiByte( CP_ACP, 0, imageHelpInfo.LoadedPdbName, 256, fileName, 256, NULL, NULL ); throw DbgException( "IDebugAdvanced2::GetSymbolInformation failed" );
return std::string( fileName ); char fileName[ 256 ];
WideCharToMultiByte( CP_ACP, 0, imageHelpInfo.LoadedPdbName, 256, fileName, 256, NULL, NULL );
} return std::string( fileName );
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return std::string();
} }
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
@ -121,26 +85,10 @@ getPdbFile( ULONG64 moduleBase )
void void
reloadModule( const char * moduleName ) reloadModule( const char * moduleName )
{ {
HRESULT hres; // ïîäàâèòü âûâîä ñîîáùåíèé îá îòñóòñòâèè ñèìâîëîâ
OutputReader outputReader( dbgExt->client );
try { dbgExt->symbols->Reload( moduleName );
// ïîäàâèòü âûâîä ñîîáùåíèé îá îòñóòñòâèè ñèìâîëîâ
OutputReader outputReader( dbgExt->client );
hres = dbgExt->symbols->Reload( moduleName );
//if ( FAILED( hres ) )
// throw DbgException( "IDebugSymbol::Reload failed" );
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
} }
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
@ -148,31 +96,15 @@ reloadModule( const char * moduleName )
bool bool
isKernelDebugging() isKernelDebugging()
{ {
HRESULT hres; HRESULT hres;
bool result = false; ULONG debugClass, debugQualifier;
try { hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
ULONG debugClass, debugQualifier; if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier ); return debugClass == DEBUG_CLASS_KERNEL;
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
result = debugClass == DEBUG_CLASS_KERNEL;
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return result;
} }
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
@ -181,30 +113,14 @@ bool
isDumpAnalyzing() isDumpAnalyzing()
{ {
HRESULT hres; HRESULT hres;
bool result = false; ULONG debugClass, debugQualifier;
try { hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
ULONG debugClass, debugQualifier; if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier ); return debugQualifier >= DEBUG_DUMP_SMALL;
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
result = debugQualifier >= DEBUG_DUMP_SMALL;
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return result;
} }
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////