VDBStartup.st
author Jan Vrany <jan.vrany@labware.com>
Wed, 28 Oct 2020 10:49:52 +0000
changeset 198 1d26f35595b2
parent 180 a47acd6d73ca
child 203 6fd080fc5ee3
permissions -rw-r--r--
`import vdb` early on using `-ie` rather than after an inferior is loaded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     1
"
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     2
jv:vdb - Visual / VM Debugger
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     3
Copyright (C) 2015-now Jan Vrany
198
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
     4
Copyright (C) 2020 LabWare
49
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     5
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     6
This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     7
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     8
You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
     9
"
116
d0d6da74ead3 UI: add GDB executable configuration to settings dialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 107
diff changeset
    10
"{ Package: 'jv:vdb' }"
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
37
f417fe8685c5 Initial support for variables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18
diff changeset
    12
"{ NameSpace: Smalltalk }"
f417fe8685c5 Initial support for variables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18
diff changeset
    13
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
StandaloneStartup subclass:#VDBStartup
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
	instanceVariableNames:''
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
    16
	classVariableNames:'Standalone'
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
	poolDictionaries:''
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
	category:'VDB-UI'
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
!
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
49
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    21
!VDBStartup class methodsFor:'documentation'!
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    22
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    23
copyright
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    24
"
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    25
jv:vdb - Visual / VM Debugger
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    26
Copyright (C) 2015-now Jan Vrany
198
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
    27
Copyright (C) 2020 LabWare
49
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    28
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    29
This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    30
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    31
You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    32
"
180
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    33
!
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    34
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    35
documentation
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    36
"
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    37
    This is the entrypoint to start VDB.
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    38
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    39
    Examples: 
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    40
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    41
    *  start VDB with no command line options/parameters
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    42
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    43
        VDBStartup main: { }.   
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    44
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    45
    * start VDB with --no-pty command line option:
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    46
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    47
        VDBStartup main: { '--no-pty' }.  
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    48
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    49
    [author:]
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    50
        Jan Vrany <jan.vrany@fit.cvut.cz>
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    51
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    52
    [instance variables:]
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    53
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    54
    [class variables:]
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    55
        Standalone
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    56
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    57
    [see also:]
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    58
a47acd6d73ca Add `VDBStartupA` into `jv:vdb/application`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 131
diff changeset
    59
"
49
2ec7f7ed9242 License this package under 'Creative Commons Attribution-NonCommercial 4.0 International License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 47
diff changeset
    60
! !
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
!VDBStartup class methodsFor:'constants & defaults'!
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
applicationRegistryPath
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
    "the key under which this application stores its process ID in the registry
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
     as a collection of path-components.
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
     i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
     in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID.
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
     (would also be used as a relative path for a temporary lock file under unix).
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
     Used to detect if another instance of this application is already running."
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
    ^ #('vdb')
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
    "Modified: / 21-09-2014 / 01:29:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
!
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
applicationUUID
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    "answer an application-specific unique uuid.
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
     This is used as the name of some exclusive OS-resource, which is used to find out,
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
     if another instance of this application is already running.
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
     Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used.
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
     If redefined, please return a real UUID (i.e. UUID fromString:'.....') and not a string or
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
     similar possibly conflicting identifier.
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
     You can paste a fresh worldwide unique id via the editor's more-misc-paste UUID menuFunction."
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
    ^ UUID fromString:'57b09330-4126-11e4-a80f-606720e43e2c'
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
    "Modified: / 21-09-2014 / 01:29:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
! !
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
!VDBStartup class methodsFor:'defaults'!
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
allowDebugOption
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
    "enable/disable the --debug startup option.
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
     Can be redefined in subclasses to enable it"
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
    ^ true
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
    "Created: / 08-09-2014 / 19:30:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
! !
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   102
!VDBStartup class methodsFor:'private'!
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   103
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   104
loadPreferenceFile: file
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   105
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   106
    "Created: / 07-06-2017 / 09:49:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   107
! !
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   108
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   109
!VDBStartup class methodsFor:'queries'!
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   110
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   111
applicationName
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   112
    ^ 'vdb'
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   113
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   114
    "Created: / 06-06-2017 / 22:50:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   115
! !
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   116
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
!VDBStartup class methodsFor:'startup'!
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
main:argv
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   120
    "Application entry point. `argv` is the array of command arguments (as Array of Strings)"
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   121
198
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   122
    | optparser positional settingsFile settingsSuppressed cmd pySysDir1 noPTY replay
119
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   123
      programExecutable programArgs programPid attach
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   124
      debugger debuggerApp |
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   125
119
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   126
    "/ This is awkward. We HAVE TO load prefetences when VDB is compiled standalone
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   127
    "/ application or run from a command line (`--load jv:vdb` --run VDBStarup`.
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   128
    "/ We MUST NOT load preferences when `VDBStarup main` is run from running IDE.
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   129
    "/ for example while developing.
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   130
    "/
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   131
    "/ The trick is that there's no good and easy way to check this, so we have to
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   132
    "/ check whether this method is called from `Smalltalk >> start`. Bleh.
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   133
    Standalone := Smalltalk isStandAloneApp
119
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   134
                    or:[ thisContext sender method == (Smalltalk class compiledMethodAt: #start) ].
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   135
    settingsSuppressed := Standalone not.
119
be31a77e2d9c Fix (re)loading of preferences when calling `VDBStartup >> main:` from workspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   136
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   137
    noPTY := false.
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   138
    replay := false.
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   139
    attach := false.
198
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   140
    cmd := GDBProcess gdbCommand.
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   141
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   142
    "/ Parse options...
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   143
    optparser := CmdLineParser new
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   144
                    ignoreUnknownOptions: true;
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   145
                    on: #('--help') do:[
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   146
                        self usage
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   147
                    ];
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   148
                    on: #('--preferences') do:[:filename |
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   149
                        | file |
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   150
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   151
                        file := filename asFilename.
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   152
                        file isReadable ifFalse:[
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   153
                            self error: 'preference file does not exists or not readable: ' , filename.
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   154
                        ].
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   155
                        file isRegularFile ifFalse:[
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   156
                            self error: 'preference file is not a regular file: ' , filename.
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   157
                        ].
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   158
                        settingsFile := file.
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   159
                    ];
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   160
                    on: #('--no-preferences') do:[
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   161
                        settingsSuppressed := true
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   162
                    ];
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   163
                    on: #('--replay') do:[
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   164
                        replay := true
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   165
                    ];
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   166
                    on: #('-d' '--gdb') do:[ :str |
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   167
                        cmd := str
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   168
                    ];
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   169
                    on: #('--no-pty') do:[
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   170
                        noPTY := true
116
d0d6da74ead3 UI: add GDB executable configuration to settings dialog
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 107
diff changeset
   171
                    ];
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   172
                    yourself.
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   173
    [
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   174
        positional := optparser parse:argv.
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   175
    ] on: CmdLineOptionError do:[:ex |
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   176
        self error: ex description.
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   177
    ].
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   178
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   179
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   180
    "/ Now validate and process options
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   181
    settingsSuppressed ifFalse:[
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   182
        | settings |
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   183
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   184
        settingsFile notNil ifTrue:[
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   185
            settingsFile exists ifFalse:[
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   186
                self error: 'preference file does not exist: ', settingsFile pathName
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   187
            ].
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   188
            settingsFile isDirectory ifTrue:[
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   189
                self error: 'preference file is not a regular file: ', settingsFile pathName
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   190
            ].
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   191
            settingsFile isReadable ifFalse:[
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   192
                self error: 'preference file is not a readable (check permissions): ', settingsFile pathName
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   193
            ].
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   194
            settings := UserPreferences loadSettingsFrom: settingsFile.
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   195
        ] ifFalse:[
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   196
            settings := UserPreferences loadSettings.
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   197
        ].
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   198
        UserPreferences setCurrent: settings.
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   199
    ].
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   200
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   201
    replay ifTrue:[ 
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   202
        OperatingSystem isLinuxLike ifFalse:[ 
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   203
            self error: 'replay not supported on this platform'.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   204
        ].
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   205
        RR available ifFalse:[ 
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   206
            self error: 'cannot replay because rr not available'
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   207
        ].
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   208
    ].
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   209
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   210
    "/ Parse positional arguments - there are two forms:
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   211
    "/
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   212
    "/   vdb [OPTIONS] [PROGRAM [ARGS]]
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   213
    "/   vdb [OPTIONS] [PID]
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   214
    "/
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   215
    "/ [OPTIONS] have already been processed, the rest is in `positional`
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   216
    "/ variable
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   217
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   218
    positional notEmpty ifTrue:[
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   219
        programExecutable := positional first.
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   220
        programExecutable asFilename exists ifFalse:[
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   221
            "Try to find the executable in PATH..."
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   222
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   223
            | path |
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   224
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   225
            path := OperatingSystem pathOfCommand: programExecutable.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   226
            path notNil ifTrue:[
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   227
                programExecutable := path.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   228
            ].
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   229
        ].
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   230
        programPid := Integer fromString: positional first onError: [ nil ].
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   231
        programArgs := positional copyFrom: 2.
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   232
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   233
        replay ifTrue:[ 
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   234
            programArgs notEmptyOrNil ifTrue:[ 
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   235
                self error: 'cannot specify program args when replaying'.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   236
            ].
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   237
        ] ifFalse:[
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   238
            "/ If * programExecutable does not exists
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   239
            "/    * AND programPid is not nil (i.e., first positional argument can be converted to an integer)
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   240
            "/    * AND programArguments are empty
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   241
            "/ then interpret positional argument as PID and attach to it.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   242
            "/ Otherwise, interpret positional arguments
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   243
            (programExecutable asFilename exists not and: [ programPid notNil and: [ programArgs isEmpty ]]) ifTrue:[
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   244
                attach := true.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   245
            ] ifFalse:[
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   246
                programExecutable asFilename exists ifFalse:[
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   247
                    self error: 'cannot find program executable: ', programExecutable.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   248
                ].
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   249
            ].
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   250
        ].
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   251
    ].
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   252
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   253
    Debugger := DebugView ? MiniDebugger.
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   254
    Inspector := InspectorView ? MiniInspector.
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   255
198
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   256
    pySysDir1 := (Smalltalk getPackageDirectoryForPackage: #jv:vdb) / 'python'.
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   257
    self assert: pySysDir1 isDirectory.        
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   258
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   259
    cmd := cmd , (' -iex ''python import sys; sys.path.append("%1"); import vdb''' 
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   260
                    bindWith: (GDBMIPrinter cescaped: pySysDir1 pathName)).
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   261
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   262
    noPTY ifTrue:[ 
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   263
        debugger := GDBDebugger newWithProcess: (GDBStXSimpleProcess newWithCommand: cmd).
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   264
    ] ifFalse:[ 
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   265
        debugger := GDBDebugger newWithProcess: (GDBLocalProcess newWithCommand: cmd).
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   266
    ].
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   267
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   268
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   269
    attach ifTrue:[
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   270
        debugger attach: programPid
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   271
    ] ifFalse:[
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   272
        programExecutable notNil ifTrue:[
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   273
            debugger executable: programExecutable arguments: programArgs.
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   274
        ].
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   275
    ].
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   276
    Smalltalk openDisplay.
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   277
    debuggerApp := VDBDebuggerApplication new.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   278
    debuggerApp debugger: debugger.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   279
    debuggerApp open.
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   280
    replay ifTrue:[ 
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   281
        debuggerApp doAttachToRR
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   282
    ]. 
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   283
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   284
    "
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   285
        VDBStartup main: #()
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   286
        VDBStartup main: #('ls')
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   287
        VDBStartup main: #('/bin/ls' '/tmp')
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   288
    "
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   289
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   290
    "Modified: / 13-12-2018 / 15:32:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
198
1d26f35595b2 `import vdb` early on using `-ie` rather than after an inferior is loaded
Jan Vrany <jan.vrany@labware.com>
parents: 180
diff changeset
   291
    "Modified: / 19-10-2020 / 11:52:33 / Jan Vrany <jan.vrany@labware.com>"
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   292
!
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   293
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   294
usage
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   295
    Transcript nextPutAll:'usage: '; nextPutAll: self applicationName; nextPutAll: ' [OPTIONS] [PROGRAM [ARGS]] '; cr.
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   296
    Transcript nextPutAll:'       '; nextPutAll: self applicationName; nextPutAll: ' [OPTIONS] [PID]'; cr.
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   297
                                                                          "|"
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   298
    Transcript nextPutLine:'
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   299
options:
83
101ff2210613 Initial support for Mozilla rr
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 49
diff changeset
   300
 --replay ..................... replay last rr record
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   301
 --no-pty ..................... do not use PTY-based GDB console even if current
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   302
                                platform supports it. 
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   303
 -d | --gdb CMD ............... use CMD to launch GDB (instead of platform
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   304
                                default).    
47
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   305
 --preference FILE ............ read user settings from FILE
25d82943a3cf Allow VDB to be launched without PID or program to debug
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 43
diff changeset
   306
 --no-preferences ............. do not read user settings at all
43
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   307
 --help ....................... output this message
c98aa29401f7 Initia support for running debugger as standalone application
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 37
diff changeset
   308
'.
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   309
    Standalone ifTrue:[
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   310
        Smalltalk exit: 0.
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   311
    ].
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   312
131
815f0bf03155 Improve `--gdb` command line option handling
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 119
diff changeset
   313
    "Modified: / 13-12-2018 / 15:29:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
18
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   314
! !
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   315
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   316
!VDBStartup class methodsFor:'documentation'!
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   317
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   318
version_HG
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   319
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   320
    ^ '$Changeset: <not expanded> $'
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   321
! !
0f44fe9848a0 Added standalone startup class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   322