Commit 4dc9bba0 authored by SND\kernelnet_cp's avatar SND\kernelnet_cp
Browse files

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


git-svn-id: https://pykd.svn.codeplex.com/svn@70041 9b283d60-5439-405e-af05-b73fd8c4d996
parent 26c2b2d1
......@@ -24,9 +24,8 @@ void dbgPrint::dprint( 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 );
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;
}
......
......@@ -68,6 +68,9 @@ void queryModuleParams(
NULL,
0,
NULL );
std::vector<char> nameBuf(moduleNameChars);
name.resize(moduleNameChars + 1);
hres = dbgExt->symbols->GetModuleNames(
moduleIndex,
......@@ -75,14 +78,16 @@ void queryModuleParams(
NULL,
0,
NULL,
&name[0],
(ULONG)name.size(),
&nameBuf[0],
nameBuf.size(),
NULL,
NULL,
0,
NULL );
if ( FAILED( hres ) )
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_end( addr64(base) + size )
{
reloadSymbols();
//reloadSymbols();
std::string pattern = name + "!*";
ULONG64 enumHandle = 0;
......
#include "stdafx.h"
#include <exception>
#include "dbgext.h"
#include "dbgexcept.h"
#include "dbgsystem.h"
......@@ -13,23 +12,11 @@ is64bitSystem()
{
HRESULT hres;
try {
hres = dbgExt->control->IsPointer64Bit();
return hres == S_OK;
hres = dbgExt->control->IsPointer64Bit();
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::IsPointer64Bit 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" );
}
return false;
return hres == S_OK;
}
///////////////////////////////////////////////////////////////////////////////////
......@@ -48,29 +35,16 @@ dbgSymPath()
HRESULT hres;
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);
hres = dbgExt->symbols->GetSymbolPath( &path[0], size, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugSymbols::GetSymbolPath failed" );
pathStr = &path[0];
hres = dbgExt->symbols->GetSymbolPath( &path[0], size, NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugSymbols::GetSymbolPath 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" );
}
return pathStr;
return std::string(&path[0]);
}
......@@ -81,39 +55,29 @@ getPdbFile( ULONG64 moduleBase )
{
HRESULT hres;
try {
IMAGEHLP_MODULEW64 imageHelpInfo = { 0 };
hres =
dbgExt->advanced2->GetSymbolInformation(
DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
moduleBase,
0,
&imageHelpInfo,
sizeof( imageHelpInfo ),
NULL,
NULL,
0,
NULL );
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" );
}
IMAGEHLP_MODULEW64 imageHelpInfo = { 0 };
hres =
dbgExt->advanced2->GetSymbolInformation(
DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
moduleBase,
0,
&imageHelpInfo,
sizeof( imageHelpInfo ),
NULL,
NULL,
0,
NULL );
if ( FAILED( hres ) )
throw DbgException( "IDebugAdvanced2::GetSymbolInformation failed" );
char fileName[ 256 ];
WideCharToMultiByte( CP_ACP, 0, imageHelpInfo.LoadedPdbName, 256, fileName, 256, NULL, NULL );
return std::string();
return std::string( fileName );
}
///////////////////////////////////////////////////////////////////////////////////
......@@ -121,26 +85,10 @@ getPdbFile( ULONG64 moduleBase )
void
reloadModule( const char * moduleName )
{
HRESULT hres;
try {
//
OutputReader outputReader( dbgExt->client );
//
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" );
}
dbgExt->symbols->Reload( moduleName );
}
///////////////////////////////////////////////////////////////////////////////////
......@@ -148,31 +96,15 @@ reloadModule( const char * moduleName )
bool
isKernelDebugging()
{
HRESULT hres;
bool result = false;
try {
ULONG debugClass, debugQualifier;
HRESULT hres;
ULONG debugClass, debugQualifier;
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
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;
return debugClass == DEBUG_CLASS_KERNEL;
}
///////////////////////////////////////////////////////////////////////////////////
......@@ -181,30 +113,14 @@ bool
isDumpAnalyzing()
{
HRESULT hres;
bool result = false;
try {
ULONG debugClass, debugQualifier;
ULONG debugClass, debugQualifier;
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
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;
return debugQualifier >= DEBUG_DUMP_SMALL;
}
///////////////////////////////////////////////////////////////////////////////////
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment