extensions.st
author Jan Vrany <jan.vrany@labware.com>
Tue, 26 Jul 2022 15:01:33 +0100
changeset 265 f2470f0dd9cd
parent 221 e7ce99cd4375
permissions -rw-r--r--
Do not show address for (pseudo) instructions with no code While such instructions do not appear in GDB-produced disassembly, they may appear in some manually-generated instruction lists. One example of such (pseudo) instruction is label.

"{ Package: 'jv:vdb' }"!

!GDBDebugger methodsFor:'event handling'!

onRRExitEvent:anRRExitEvent
    | status |

    anRRExitEvent rr announcer unsubscribe: self.
    status := anRRExitEvent status.
    (status success or:[ status status == #signal and:[status code == OperatingSystem sigTERM ]]) ifFalse:[ 
        Dialog warn: (self class classResources string: 'Replay server terminated with error')
    ].

    "Created: / 31-07-2018 / 09:37:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBDebugger methodsFor:'commands - API'!

pythonImportVDB
    "Import VDB support"

    | pythonDir |

    pythonDir := (Smalltalk getPackageDirectoryForPackage: #jv:vdb) / 'python'.
    self assert: pythonDir isDirectory.

    self pythonSysPathAppend: pythonDir.
    self pythonImport: 'vdb'.
    self pythonImport: 'vdb.mi'.
    self send: 'python vdb.set_prompt()'.

    "Created: / 08-07-2019 / 11:44:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBDebugger methodsFor:'commands - API'!

targetConnectRR: rr
    "Connect to rr replay server"

    "/ rr suggest to connect as follows:
    "/ 
    "/     gdb '-l' '10000' '-ex' 'set sysroot /' '-ex' 'target extended-remote 127.0.0.1:9876' ...
    "/
    self send: (GDBMI_gdb_set arguments: #('sysroot' '/')).
    self targetConnect: 'extended-remote'  parameters: (Array with: '127.0.0.1:' with: rr port).
    rr announcer when: RRExitEvent send: #onRRExitEvent: to: self.

    "Created: / 26-07-2018 / 21:48:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 31-07-2018 / 09:38:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBFrame methodsFor:'printing & storing'!

dumpOn: aStream
    | vars srcFile |
    aStream nextPutAll: 'FRAME '.
    aStream nextPutAll: self displayString; cr; cr.

    vars := self variables.
    vars notEmptyOrNil ifTrue: [
        aStream nextPutAll: 'variables:'; cr.
        vars withIndexDo: [:var :idx |  
            aStream nextPutAll:'  '. 
            idx printOn: aStream leftPaddedTo:4.
            aStream space.
            var dumpOn: aStream.
            aStream cr.
        ]
    ].

    srcFile := self file.
    (line notNil and:[srcFile notNil and:[(srcFile := srcFile asFilename) exists]]) ifTrue: [
        | src srcFirstLineNr |    
        src := srcFile contents.

        srcFirstLineNr := 1.
        src size > 40 ifTrue:[ 
            | last |

            srcFirstLineNr := (line - 15) max: 1.
            last := (srcFirstLineNr + 29) min: src size.
            src := src copyFrom: srcFirstLineNr to: last.
        ].
        aStream cr.
        aStream nextPutAll: 'source: '; cr.
        src keysAndValuesDo:[:i :srcLine |
            | srcLineNo |

            srcLineNo := i + srcFirstLineNr - 1.

            aStream nextPutAll:'  '. 
            srcLineNo printOn: aStream leftPaddedTo:4.
            srcLineNo == line ifTrue:[
                aStream nextPutAll:' >> '.
            ] ifFalse:[
                aStream nextPutAll:'    '.
            ].
            aStream nextPutAll: srcLine; cr.
        ].
        aStream cr.  
    ].

    aStream cr; cr.

    "Created: / 07-08-2020 / 08:11:48 / Jan Vrany <jan.vrany@labware.com>"
    "Modified: / 09-08-2020 / 07:14:16 / Jan Vrany <jan.vrany@labware.com>"
! !

!GDBFrame methodsFor:'printing & storing'!

dumpString
    ^ String streamContents:[:s|self dumpOn: s].

    "Created: / 07-08-2020 / 08:14:40 / Jan Vrany <jan.vrany@labware.com>"
! !

!GDBVariable methodsFor:'printing & storing'!

dumpOn: aStream
    name printOn: aStream.
    name size < 15 ifTrue: [
        aStream next: 15 - name size put: Character space.
    ].
    aStream nextPutAll: ' : '.
    self value printOn: aStream.

    "Created: / 07-08-2020 / 08:14:09 / Jan Vrany <jan.vrany@labware.com>"
! !

!GDBVariableObject methodsFor:'inspecting'!

inspector2TabVariable
    <inspector2Tab>

    | varObjApp |

    varObjApp := Smalltalk at: #VDBVariableObjectListApplication ifAbsent:[ ^ nil ].
    ^ (self newInspector2Tab)
        label:'Variable';
        priority:95;
        "/ view: [ ... ];
        application: [ varObjApp new debugger: debugger; variableObjectList: (Array with: self); yourself ];
        "/ text: [ ... ];
        yourself

    "Modified: / 03-02-2018 / 09:58:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBVariableObject methodsFor:'accessing-private'!

varobj
    "Return self. This is here to make it polymorph with `GDBVariable` 
    (since `VDBVariableObjectListApplication` handles both, variables
    and varobjs."

    ^ self

    "Created: / 21-09-2019 / 01:28:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 24-09-2019 / 00:40:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!jv_vdb class methodsFor:'documentation'!

extensionsVersion_HG

    ^ '$Changeset: <not expanded> $'
! !