tests/VDBVariableObjectTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 08 Jul 2019 13:31:11 +0100
changeset 178 5d1c3e5fab6b
permissions -rw-r--r--
Initial support for VDB python-based variable objects Due to a limitation of GDB itself, one cannot create variable object for "synthetic" argument/local created by custom frame decorator. Therefore one cannot "dig deeper" and inspect contents of such a variable in case it is a kind of composite - like an object on a heap referring to another objects. This is a problem when a debugee is does not have debug information and / or it's language is not C - such as when debugging JITed code. This (experimental) commit adds a parallel implementation of variable objects done completely in python. This new varobj MI interface is a super-set of GDB's builtin varobj MI interface.

"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
"{ Package: 'jv:vdb/tests' }"

"{ NameSpace: Smalltalk }"

GDBDebuggerTestCase subclass:#VDBVariableObjectTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-Core-Tests'
!

!VDBVariableObjectTests class methodsFor:'documentation'!

copyright
"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
! !

!VDBVariableObjectTests methodsFor:'running'!

setUp
    super setUp.
    debugger pythonImportVDB.

    "Created: / 06-07-2019 / 01:20:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 08-07-2019 / 13:15:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBVariableObjectTests methodsFor:'tests'!

test_variables_01a
    | stack varobj |

    debugger executable: GDBDebuggeesResource current binaryFactorial1.
    self assert: debugger breakpoints isEmpty.

    debugger send: 'source ', ((Smalltalk getPackageDirectoryForPackage:GDBDebuggeesResource package)
            / 'c' / 'py-framedecorator.py') pathName.
    debugger enableFrameFilters.
    debugger send: 'b factorial'.
    debugger send: 'r' andWaitFor: GDBStoppedEvent.
    stack := debugger selectedInferior threads first stack.

    varobj := VDBVariableObject evaluate: 'syntheticArg0'  in: stack first using: debugger. 

    self assert: varobj expression = 'syntheticArg0'.
    self assert: varobj value = '12'.
    self assert: varobj type = 'long long'.

    "
    VDBFrameApplication new
        debugger: debugger;
        frame: stack first;
        open.
    "
    debugger send: 'quit' andWait: false.

    "Created: / 06-07-2019 / 01:23:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 08-07-2019 / 13:29:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_variables_02a
    "
    Test #duplicate
    "
    | c1 c1_cdr c1_cdr_d  c1_cdr_d_cdr c1_cdr_d_cdr_d |

    debugger executable: GDBDebuggeesResource current binaryPyVarobj.
    self assert: debugger breakpoints isEmpty.

    debugger send: 'source ', ((Smalltalk getPackageDirectoryForPackage:GDBDebuggeesResource package)
            / 'c' / 'py-varobj.py') pathName.
    debugger enablePrettyPrinting.
    debugger send: 'b py-varobj.c:22'.
    debugger send: 'r' andWaitFor: GDBStoppedEvent.

    c1 := VDBVariableObject evaluate: '&c1'  in: debugger selectedInferior threads first stack first using: debugger.   
    self assert: c1 isDynamic.
    self assert: c1 path = '&c1'.

    c1_cdr := c1 children second.
    self assert: c1_cdr expression = 'cdr'.
    self assert: c1_cdr isDynamic.
    self assert: c1_cdr parent == c1.

    c1_cdr_d := c1_cdr duplicate.
    self assert: c1_cdr_d ~= c1_cdr.
    self assert: c1_cdr_d parent ~= c1_cdr parent.

    c1_cdr_d_cdr := c1_cdr_d children second.
    self assert: c1_cdr_d_cdr expression = 'cdr'.
    self assert: c1_cdr_d_cdr isDynamic.
    self assert: c1_cdr_d_cdr parent == c1_cdr_d
.
    c1_cdr_d_cdr_d := c1_cdr_d_cdr duplicate.
    self assert: c1_cdr_d_cdr_d ~= c1_cdr_d_cdr.
    self assert: c1_cdr_d_cdr_d parent ~= c1_cdr_d_cdr parent.

    debugger send: 'quit' andWait: false.

    "Created: / 08-07-2019 / 15:38:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 08-07-2019 / 16:53:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !