DLLCC replacing argument with function's address

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DLLCC replacing argument with function's address

Thomas Gagné-2
I've attached a stacktrace showing how a method (mysql_num_rows) is
being called properly, and as far as I can tell from the trace it is
correct going into primCallC: correctly but inside the library, the
function's argument has been replaced with the function's address.

Is there a way to debug into primCallC()?

Break in TestMySQLQuery>>testQuery at 505
ExternalMethod
class>>primCallC:specifierCallFlags:arguments:argumentKinds:structArgSize:structReturnSize:datumClass:resultType:
ExternalMethod
class>>callFrom:external:specifierFlags:arguments:argumentKinds:structArgSize:structReturnSize:datumClass:resultType:
ExternalProcedure>>callFrom:specifierFlags:arguments:argumentKinds:structArgSize:structReturnSize:datumClass:resultType:
CProcedureType>>call:from:withArguments:
ExternalProcedure>>callFrom:withArguments:
[] in MySQLLinuxInterface(MySQLInterface)>>mysql_num_rows:
ExternalAccessFailed class(GenericException class)>>handle:do:
MySQLLinuxInterface(MySQLInterface)>>mysql_num_rows:
MySQLClient>>numRows:
MySQLResult>>numRows
[] in [] in XProgramming.SUnit.TestMySQLQuery>>testQuery
BlockClosure>>ensure:
[] in XProgramming.SUnit.TestMySQLQuery>>testQuery
BlockClosure>>ensure:
XProgramming.SUnit.TestMySQLQuery>>testQuery
XProgramming.SUnit.TestMySQLQuery(XProgramming.SUnit.TestCase)>>performTest
optimized [] in XProgramming.SUnit.TestCase>>runCase
BlockClosure>>ensure:
BlockClosure>>sunitEnsure:
XProgramming.SUnit.TestMySQLQuery(XProgramming.SUnit.TestCase)>>runCase
optimized [] in XProgramming.SUnit.TestCase>>debug
BlockClosure>>ensure:
BlockClosure>>sunitEnsure:
XProgramming.SUnit.TestMySQLQuery(XProgramming.SUnit.TestCase)>>debug
XProgramming.SUnit.TestRunner>>debugTest:
XProgramming.SUnit.TestRunner>>debugTest
MessageChannel>>value
UIDispatcher>>dispatch:for:
UIDispatcher>>valueChangeFor:
MenuButtonController(Controller)>>valueChange
MenuButtonController>>dispatchMenuSelection:
optimized [] in MenuButtonController>>pullDownAction
BlockClosure>>ensure:
MenuButtonController>>pullDownAction
MenuButtonController>>redButtonPressedEvent:
RedButtonPressedEvent>>dispatchTo:
MenuButtonController(Controller)>>handleEvent:
EventDispatcher>>dispatch:to:
EventDispatcher>>dispatchEvent:
RedButtonPressedEvent(Event)>>dispatch
RedButtonPressedEvent(Event)>>dispatchForWindowManager:
optimized [] in WindowManager>>safelyDispatchForWindowManager:
BlockClosure>>on:do:
WindowManager>>safelyDispatchForWindowManager:
WindowManager>>processNextEvent
optimized [] in [] in WindowManager>>newProcess
BlockClosure>>on:do:
optimized [] in WindowManager>>newProcess
BlockClosure>>on:do:
optimized [] in Process class>>forBlock:priority:

----------------------------------------------------------------------
ExternalMethod
class>>primCallC:specifierCallFlags:arguments:argumentKinds:structArgSize:structReturnSize:datumClass:resultType:
Receiver:
    an ExternalMethod class
Instance Variables:
    superclass = CompiledMethod
    methodDict = a MethodDictionary[37]
    format = 20493
    subclasses = nil
    instanceVariables = an Array[10]
    organization = ('initialize-release' #for: #for:selector:
#releaseHandle #updateLayoutCache)
('address mapping' #mapAddress #mapAddressFor: #unlinkedCall:arguments:)
('accessing' #argumentKinds #datumClass #external #handle #libraries
#methodSelector #name #ordinal #ordinal: #owner #referentAddress
#resultType #specifierFlags #structArgSize #structReturnSize #virtuals)
('testing' #isLinkedFor: #isVirtual)
('copying' #postCopy)
('comparing' #=)
('tracing' #traceWalkFrom:)
('binary storage' #isCodeReaderEquivalentTo: #postLoad
#postReadGeneralStructureOn: #storeGeneralStructureOn:)
('private' #computeStructReturnSize #copyStateFromOldVersion:
#findVirtualHandleForClass: #referentAddress: #virtuals:)

    name = #ExternalMethod
    classPool = a NameSpaceOfClass[0]
    environment = a NameSpace[53]
Arguments:
    address = 3072889424
    specifierCallFlags = 48
    arguments = an Array[1]
    theArgumentKinds = a ByteArray[2]
    structArgSize = 0
    structReturnSize = 0
    datumClass = CDatum
    theResultType = my_ulonglong
Temporaries:
    errorCode = a SystemError(#'exception occured',#(11 3072889431))
Context PC = 8

----------------------------------------------------------------------
ExternalMethod
class>>callFrom:external:specifierFlags:arguments:argumentKinds:structArgSize:structReturnSize:datumClass:resultType:
Receiver:
    an ExternalMethod class
Instance Variables:
    superclass = CompiledMethod
    methodDict = a MethodDictionary[37]
    format = 20493
    subclasses = nil
    instanceVariables = an Array[10]
    organization = ('initialize-release' #for: #for:selector:
#releaseHandle #updateLayoutCache)
('address mapping' #mapAddress #mapAddressFor: #unlinkedCall:arguments:)
('accessing' #argumentKinds #datumClass #external #handle #libraries
#methodSelector #name #ordinal #ordinal: #owner #referentAddress
#resultType #specifierFlags #structArgSize #structReturnSize #virtuals)
('testing' #isLinkedFor: #isVirtual)
('copying' #postCopy)
('comparing' #=)
('tracing' #traceWalkFrom:)
('binary storage' #isCodeReaderEquivalentTo: #postLoad
#postReadGeneralStructureOn: #storeGeneralStructureOn:)
('private' #computeStructReturnSize #copyStateFromOldVersion:
#findVirtualHandleForClass: #referentAddress: #virtuals:)

    name = #ExternalMethod
    classPool = a NameSpaceOfClass[0]
    environment = a NameSpace[53]
Arguments:
    aClass = a MySQLLinuxInterface
    external = my_ulonglong __stdcall  mysql_num_rows(void * res)
    specifierCallFlags = 48
    args = an Array[1]
    kinds = a ByteArray[2]
    structArgumentSize = 0
    structReturnSize = 0
    datumClass = CDatum
    resultType = my_ulonglong
Temporaries:
    address = 3072889424
Context PC = 20

----------------------------------------------------------------------
ExternalProcedure>>callFrom:specifierFlags:arguments:argumentKinds:structArgSize:structReturnSize:datumClass:resultType:
Receiver:
    an ExternalProcedure
Instance Variables:
    name = #mysql_num_rows
    ordinal = nil
    handle = nil
    type = my_ulonglong __stdcall (void * res)
    virtuals = an Array[2]
    owner = MySQLInterface
Arguments:
    aClass = a MySQLLinuxInterface
    specifierCallFlags = 48
    args = an Array[1]
    kinds = a ByteArray[2]
    structArgumentSize = 0
    structReturnSize = 0
    datumClass = CDatum
    resultType = my_ulonglong
Context PC = 17

----------------------------------------------------------------------
CProcedureType>>call:from:withArguments:
Receiver:
    a CProcedureType
Instance Variables:
    specifierFlags = 64
    argumentNames = an Array[1]
Arguments:
    procedure = my_ulonglong __stdcall  mysql_num_rows(void * res)
    interfaceClass = a MySQLLinuxInterface
    args = an Array[1]
Temporaries:
    kinds = a ByteArray[2]
    numArgs = 1
    extraOverflow = 0
    structReturnSize = 0
    resultType = my_ulonglong
    index = 2
    index = nil
    defaultType = nil
    anArg = nil
Context PC = 187

----------------------------------------------------------------------
ExternalProcedure>>callFrom:withArguments:
Receiver:
    an ExternalProcedure
Instance Variables:
    name = #mysql_num_rows
    ordinal = nil
    handle = nil
    type = my_ulonglong __stdcall (void * res)
    virtuals = an Array[2]
    owner = MySQLInterface
Arguments:
    aClass = a MySQLLinuxInterface
    argumentArray = an Array[1]
Context PC = 8

----------------------------------------------------------------------
[] in MySQLLinuxInterface(MySQLInterface)>>mysql_num_rows:
Receiver:
    a MySQLLinuxInterface
Temporaries:
    __args = an Array[1]
    .res = a CPointer {0D071958} (void * )
    .self = a MySQLLinuxInterface
Context PC = 16

----------------------------------------------------------------------
ExternalAccessFailed class(GenericException class)>>handle:do:
Receiver:
    an ExternalAccessFailed class
Instance Variables:
    superclass = Error
    methodDict = a MethodDictionary[0]
    format = 16394
    subclasses = nil
    instanceVariables = nil
    organization =
    name = #ExternalAccessFailed
    classPool = nil
    environment = a NameSpace[53]
    notifierString = an UserMessage
Arguments:
    anExceptionBlock = BlockClosure [] in MySQLInterface>>mysql_num_rows:
    aProtectedBlock = BlockClosure [] in MySQLInterface>>mysql_num_rows:
Context PC = 3

----------------------------------------------------------------------
MySQLLinuxInterface(MySQLInterface)>>mysql_num_rows:
Receiver:
    a MySQLLinuxInterface
Arguments:
    res = a CPointer {0D071958} (void * )
Temporaries:
    _errorCode = nil
Context PC = 18


--
Visit <http://tggagne.blogspot.com/>,<http://gagne.homedns.org/> or
      <http://gagne.homedns.org/~tgagne/> for more great reading.

Reply | Threaded
Open this post in threaded view
|

Re: DLLCC replacing argument with function's address

Reinout Heeck
>
> Is there a way to debug into primCallC()?

 From the image you can try
   ObjectMemory invokeDebugger
just prior to the call.

I don't know the prerequisites, probably the VM needs to be executing  
under/attached to a debugger before you execute that code.


HTH,

Reinout
-------