VDBVirtualMemoryMap.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 13 Mar 2019 13:54:14 +0000
changeset 148 7d2d523173af
parent 49 2ec7f7ed9242
child 264 23960fcb9dac
permissions -rw-r--r--
Workaround: assume native target when issuing `run` or `attach` commands using simple console Background command execution is not supported by some targets, most notably by Windows native target. However, at the point we have to decided whether use background execution or not, we don't know which target will get connected and therefore we cannot check target features. So, make a guess and assime we gonna use native target. This is so bad, this *absolutely* has to be fixed somehow.

"
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' }"

"{ NameSpace: Smalltalk }"

Object subclass:#VDBVirtualMemoryMap
	instanceVariableNames:'regions'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-Tools'
!

!VDBVirtualMemoryMap 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/
"
! !

!VDBVirtualMemoryMap class methodsFor:'instance creation'!

fromSysInternalsVmmapDump: aStringOrFilenameOrStream
    | s |

    s := aStringOrFilenameOrStream readStream.
    ^ [
        self new initializeFromSysInternalsVmmapDump: s
    ] ensure:[ 
        s close.
    ].

    "Created: / 13-10-2017 / 12:11:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBVirtualMemoryMap methodsFor:'reading'!

initializeFromSysInternalsVmmapDump: aStream
    "
    Initializes regions from SysInterna's vmmap.exe dump (.mmp)
    "
    | dump snapshot |

    dump := XML::XMLParser parse: aStream.
    snapshot := (dump / 'root' / 'Snapshots' / 'Snapshot') last.
    regions := (snapshot / 'MemoryRegions' / 'Region') 
                select:[ :node | 
                    (node @ 'Commit') ~= '0'.
                ]
                thenCollect:[ :node |
                    | region |

                    region := VDBVirtualMemoryRegion new
                                address:     (node @ 'Address') asInteger;
                                size:        (node @ 'Size') asInteger;
                                protection:  (node @ 'Protection') asInteger;
                                comment:     (node @ 'Details');
                                yourself.
                ] as: OrderedCollection.

    regions sort:[ :a :b | a address  < b address ].

    "Created: / 13-10-2017 / 12:06:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !