VDBStartup.st
changeset 116 d0d6da74ead3
parent 107 d98c11f9a7f5
child 119 be31a77e2d9c
equal deleted inserted replaced
115:0dd989ce3ae7 116:d0d6da74ead3
     4 
     4 
     5 This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
     5 This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
     6 
     6 
     7 You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
     7 You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
     8 "
     8 "
     9 "{ Package: 'jv:vdb/application' }"
     9 "{ Package: 'jv:vdb' }"
    10 
    10 
    11 "{ NameSpace: Smalltalk }"
    11 "{ NameSpace: Smalltalk }"
    12 
    12 
    13 StandaloneStartup subclass:#VDBStartup
    13 StandaloneStartup subclass:#VDBStartup
    14 	instanceVariableNames:''
    14 	instanceVariableNames:''
    88 !VDBStartup class methodsFor:'startup'!
    88 !VDBStartup class methodsFor:'startup'!
    89 
    89 
    90 main:argv
    90 main:argv
    91     "Application entry point. `argv` is the array of command arguments (as Array of Strings)"
    91     "Application entry point. `argv` is the array of command arguments (as Array of Strings)"
    92 
    92 
    93     | optparser positional settingsFile settingsSuppressed replay 
    93     | optparser positional settingsFile settingsSuppressed gdb replay 
    94       programExecutable programArgs programPid attach 
    94       programExecutable programArgs programPid attach 
    95       debugger debuggerApp |
    95       debugger debuggerApp |
    96 
    96 
    97     settingsSuppressed := false.
    97     settingsSuppressed := false.
    98     replay := false.
    98     replay := false.
   120                         settingsSuppressed := true
   120                         settingsSuppressed := true
   121                     ];
   121                     ];
   122                     on: #('--replay') do:[
   122                     on: #('--replay') do:[
   123                         replay := true
   123                         replay := true
   124                     ];
   124                     ];
       
   125                     on: #('--gdb') do:[ :path |
       
   126                         gdb := path asFilename.
       
   127                         gdb exists ifFalse:[ 
       
   128                             self error: 'No such file: ', gdb pathName
       
   129                         ].
       
   130                         gdb isExecutable ifFalse:[ 
       
   131                             self error: 'Not an executable program: ', gdb pathName
       
   132                         ].
       
   133                     ];
   125                     yourself.
   134                     yourself.
   126     [
   135     [
   127         positional := optparser parse:argv.
   136         positional := optparser parse:argv.
   128     ] on: CmdLineOptionError do:[:ex |
   137     ] on: CmdLineOptionError do:[:ex |
   129         self error: ex description.
   138         self error: ex description.
   147             settings := UserPreferences loadSettingsFrom: settingsFile.
   156             settings := UserPreferences loadSettingsFrom: settingsFile.
   148         ] ifFalse:[
   157         ] ifFalse:[
   149             settings := UserPreferences loadSettings.
   158             settings := UserPreferences loadSettings.
   150         ].
   159         ].
   151         UserPreferences setCurrent: settings.
   160         UserPreferences setCurrent: settings.
       
   161     ].
       
   162 
       
   163     gdb notNil ifTrue:[
       
   164         GDBProcess gdbExecutable: gdb.
   152     ].
   165     ].
   153 
   166 
   154     replay ifTrue:[ 
   167     replay ifTrue:[ 
   155         OperatingSystem isLinuxLike ifFalse:[ 
   168         OperatingSystem isLinuxLike ifFalse:[ 
   156             self error: 'replay not supported on this platform'.
   169             self error: 'replay not supported on this platform'.
   226         VDBStartup main: #()
   239         VDBStartup main: #()
   227         VDBStartup main: #('ls')
   240         VDBStartup main: #('ls')
   228         VDBStartup main: #('/bin/ls' '/tmp')
   241         VDBStartup main: #('/bin/ls' '/tmp')
   229     "
   242     "
   230 
   243 
   231     "Modified: / 29-07-2018 / 08:51:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   244     "Modified: / 04-10-2018 / 15:40:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   232 !
   245 !
   233 
   246 
   234 usage
   247 usage
   235     Stdout nextPutAll:'usage: '; nextPutAll: self applicationName; nextPutAll: ' [OPTIONS] [PROGRAM [ARGS]] '; cr.
   248     Stdout nextPutAll:'usage: '; nextPutAll: self applicationName; nextPutAll: ' [OPTIONS] [PROGRAM [ARGS]] '; cr.
   236     Stdout nextPutAll:'       '; nextPutAll: self applicationName; nextPutAll: ' [OPTIONS] [PID]'; cr.
   249     Stdout nextPutAll:'       '; nextPutAll: self applicationName; nextPutAll: ' [OPTIONS] [PID]'; cr.
   237                                                                           "|"
   250                                                                           "|"
   238     Stdout nextPutLine:'
   251     Stdout nextPutLine:'
   239 options:
   252 options:
   240  --replay ..................... replay last rr record
   253  --replay ..................... replay last rr record
       
   254  --gdb GDB .................... use GDB instead if default one (overrides 
       
   255                                 preferences)
   241  --preference FILE ............ read user settings from FILE
   256  --preference FILE ............ read user settings from FILE
   242  --no-preferences ............. do not read user settings at all
   257  --no-preferences ............. do not read user settings at all
   243  --help ....................... output this message
   258  --help ....................... output this message
   244 '.
   259 '.
   245 
   260 
   246     Smalltalk exitIfStandalone: 0.
   261     Smalltalk exitIfStandalone: 0.
   247 
   262 
   248     "Modified: / 29-07-2018 / 08:55:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   263     "Modified: / 04-10-2018 / 15:14:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   249 ! !
   264 ! !
   250 
   265 
   251 !VDBStartup class methodsFor:'documentation'!
   266 !VDBStartup class methodsFor:'documentation'!
   252 
   267 
   253 version_HG
   268 version_HG