ipdbg: fix double free of virtual-ir data
[openocd.git] / src / helper / startup.tcl
blob5a0d479f5e9ed91450affd44957917111f3bf9b1
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Defines basic Tcl procs that must exist for OpenOCD scripts to work.
5 # Embedded into OpenOCD executable
8 # Try flipping / and \ to find file if the filename does not
9 # match the precise spelling
10 proc find {filename} {
11 if {[catch {ocd_find $filename} t]==0} {
12 return $t
14 if {[catch {ocd_find [string map {\ /} $filename} t]==0} {
15 return $t
17 if {[catch {ocd_find [string map {/ \\} $filename} t]==0} {
18 return $t
20 # make sure error message matches original input string
21 return -code error "Can't find $filename"
23 add_usage_text find "<file>"
24 add_help_text find "print full path to file according to OpenOCD search rules"
26 # Find and run a script
27 proc script {filename} {
28 uplevel #0 [list source [find $filename]]
30 add_help_text script "filename of OpenOCD script (tcl) to run"
31 add_usage_text script "<file>"
33 # Run a list of post-init commands
34 # Each command should be added with 'lappend post_init_commands command'
35 lappend _telnet_autocomplete_skip _run_post_init_commands
36 proc _run_post_init_commands {} {
37 if {[info exists ::post_init_commands]} {
38 foreach cmd $::post_init_commands {
39 eval $cmd
44 # Run a list of pre-shutdown commands
45 # Each command should be added with 'lappend pre_shutdown_commands command'
46 lappend _telnet_autocomplete_skip _run_pre_shutdown_commands
47 proc _run_pre_shutdown_commands {} {
48 if {[info exists ::pre_shutdown_commands]} {
49 foreach cmd $::pre_shutdown_commands {
50 eval $cmd
55 #########